summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkgraphview.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/gtkgraphview.c')
-rw-r--r--src/gtkext/gtkgraphview.c201
1 files changed, 42 insertions, 159 deletions
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index 1f8d51c..cde919c 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -69,16 +69,15 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *);
/* Initialise une instance d'afficheur de code en graphique. */
static void gtk_graph_view_init(GtkGraphView *);
-/* S'adapte à la surface concédée par le composant parent. */
-static void gtk_graph_view_size_allocate(GtkWidget *, GtkAllocation *);
+/* Indique les dimensions de travail du composant d'affichage. */
+static void gtk_graph_view_compute_requested_size(GtkGraphView *, gint *, gint *);
+
+/* Réagit à un défilement chez une barre associée au composant. */
+static void gtk_graph_view_adjust_scroll_value(GtkGraphView *, GtkAdjustment *, GtkOrientation);
/* Met à jour l'affichage de la vue sous forme graphique. */
static gboolean gtk_graph_view_draw(GtkWidget *, cairo_t *, GtkGraphView *);
-
-/* Indique les dimensions de travail du composant d'affichage. */
-static void gtk_graph_view_compute_requested_size(GtkGraphView *, gint *, gint *);
-
/* Actualise les besoins internes avant un redimensionnement. */
static void gtk_graph_view_prepare_resize(GtkGraphView *);
@@ -126,9 +125,8 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *class)
widget_class = GTK_WIDGET_CLASS(class);
panel_class = GTK_VIEW_PANEL_CLASS(class);
- widget_class->size_allocate = gtk_graph_view_size_allocate;
-
- panel_class->compute_size = (compute_requested_size)gtk_graph_view_compute_requested_size;
+ panel_class->compute_size = (compute_requested_size_fc)gtk_graph_view_compute_requested_size;
+ panel_class->adjust = (adjust_scroll_value_fc)gtk_graph_view_adjust_scroll_value;
panel_class->define = (define_address_fc)gtk_graph_view_define_main_address;
panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates;
@@ -146,7 +144,7 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *class)
* Remarques : - *
* *
******************************************************************************/
-#include "easygtk.h"////////////
+
static void gtk_graph_view_init(GtkGraphView *view)
{
GtkViewPanel *viewpanel; /* Instance parente #1 */
@@ -174,161 +172,14 @@ static void gtk_graph_view_init(GtkGraphView *view)
gtk_widget_show(GTK_WIDGET(view->support));
- /*
- gdk_color_white(gtk_widget_get_colormap(GTK_WIDGET(view->support)), &white);
- gtk_widget_modify_bg(GTK_WIDGET(view->support), GTK_STATE_NORMAL, &white);
- */
-
gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->support), 0, 0);
- //gtk_widget_size_allocate(view->support, (GtkAllocation []){ { 200, 200, 500, 500 } });
-
-#if 0
- do
- {
- GtkWidget *btn;
-
- btn = qck_create_button(NULL, NULL, "caption 0", NULL, NULL);
- gtk_fixed_put(GTK_FIXED(view), btn, 10, 10);
-
-
- btn = qck_create_button(NULL, NULL, "caption 1", NULL, NULL);
- gtk_fixed_put(GTK_FIXED(view->support), btn, 100, 100);
-
-
-
- }
- while (0);
-#endif
-
//view->mutex = g_mutex_new();
//view->cond = g_cond_new();
}
-
-
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* allocation = étendue accordée à la vue. *
-* *
-* Description : S'adapte à la surface concédée par le composant parent. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- gpointer fixed_class; /* Classe parente */
- GtkViewPanel *panel; /* Autre version du composant */
- GtkAllocation valloc; /* Surface utilisable */
- GtkRequisition req; /* Taille demandée */
- GtkGraphView *view; /* Autre vision du composant */
- GdkWindow *window; /* Fenêtre associée au support */
- gboolean changed; /* Changement de valeur ? */
-
-
- printf("GRAPH SIZE ALLOC :: (%d ; %d) - (%d ; %d)\n",
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
-
- GTK_WIDGET_CLASS(gtk_graph_view_parent_class)->size_allocate(widget, allocation);
-
-
- /* Mise à jour GTK */
-
- /*
- fixed_class = g_type_class_peek_parent(GTK_GRAPH_VIEW_GET_CLASS(widget));
- fixed_class = g_type_class_peek_parent(fixed_class);
-
- GTK_WIDGET_CLASS(fixed_class)->size_allocate(widget, allocation);
- */
-
-
-
- panel = GTK_VIEW_PANEL(widget);
-
- /*
- if (panel->hadjustment == NULL || panel->vadjustment == NULL)
- return;
- */
-
- // !!!! moved !!! gtk_view_panel_compute_allocation(panel, &valloc);
-
- gtk_widget_get_preferred_size(widget, NULL, &req);
-
- /* Correction de la taille du support */
-
- view = GTK_GRAPH_VIEW(widget);
- window = gtk_widget_get_window(GTK_WIDGET(view->support));
-
-
-
- gtk_widget_size_allocate(view->support, (GtkAllocation []){ { 0, 0, 1500, 1500 } });
-
- //gdk_window_resize(window, 500, 500);
-
- /*
- printf(" --> cmp :: (%d ; %d) vs (%d ; %d)\n",
- gdk_window_get_width(window), gdk_window_get_height(window),
- req.width, req.height);
- */
- /*
- if (gdk_window_get_width(window) != req.width || gdk_window_get_height(window) != req.height)
- gdk_window_resize(window, req.width, req.height);
- */
-
- return;
-
-
- /* Défilement horizontal */
-
- gtk_adjustment_set_page_size(panel->hadjustment, valloc.width);
- gtk_adjustment_set_step_increment(panel->hadjustment, valloc.width * 0.1);
- gtk_adjustment_set_page_increment(panel->hadjustment, valloc.width * 0.9);
-
- gtk_adjustment_set_upper(panel->hadjustment, MAX(req.width, valloc.width));
-
- // !!!! moved !!! gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed);
-
- gtk_adjustment_changed(panel->hadjustment);
-
- if (changed)
- gtk_adjustment_value_changed(panel->hadjustment);
-
- /* Défilement vertical */
-
- gtk_adjustment_set_page_size(panel->vadjustment, valloc.width);
- gtk_adjustment_set_step_increment(panel->vadjustment, valloc.width * 0.1);
- gtk_adjustment_set_page_increment(panel->vadjustment, valloc.width * 0.9);
-
- gtk_adjustment_set_upper(panel->vadjustment, MAX(req.height, valloc.height));
-
- // !!!! moved !!! gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed);
-
- gtk_adjustment_changed(panel->vadjustment);
-
- if (changed)
- gtk_adjustment_value_changed(panel->vadjustment);
-
-}
-
-
-
-
-
-
/******************************************************************************
* *
* Paramètres : view = composant GTK à consulter. *
@@ -362,6 +213,34 @@ static void gtk_graph_view_compute_requested_size(GtkGraphView *view, gint *widt
}
+/******************************************************************************
+* *
+* Paramètres : view = panneau d'affichage concerné. *
+* adj = défilement dont une valeur a changé. *
+* orientation = indication sur le défilement à traiter. *
+* *
+* Description : Réagit à un défilement chez une barre associée au composant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_graph_view_adjust_scroll_value(GtkGraphView *view, GtkAdjustment *adj, GtkOrientation orientation)
+{
+ gint fake_x; /* Abscisse virtuelle */
+ gint fake_y; /* Ordonnée virtuelle */
+
+ fake_x = 0;
+ fake_y = 0;
+ gtk_buffer_view_compute_fake_coord(view, &fake_x, &fake_y);
+
+ printf("fake :: (%d ; %d)\n", fake_x, fake_y);
+
+ gtk_fixed_move(GTK_FIXED(view), GTK_WIDGET(view->support), fake_x, -fake_y);
+
+}
/******************************************************************************
@@ -445,6 +324,8 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t
GBinRoutine **routines; /* Liste des routines trouvées */
size_t routines_count; /* Nombre de ces routines */
size_t i; /* Boucle de parcours */
+ gint width; /* Largeur idéale du composant */
+ gint height; /* Hauteur idéale du composant */
if (view->routine == NULL)
need_update = true;
@@ -493,6 +374,9 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t
}
+ gtk_graph_view_compute_requested_size(view, &width, &height);
+ gtk_widget_size_allocate(view->support, (GtkAllocation []){ { 0, 0, width, height } });
+
change_editor_items_current_view_content(GTK_VIEW_PANEL(view));
}
@@ -619,8 +503,7 @@ void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocati
gtk_container_remove(GTK_CONTAINER(parent), widget);
}
- //gtk_fixed_put(view->support, widget, alloc->x, alloc->y);
- gtk_fixed_put(view->support, widget, i * 200, i * 150);
+ gtk_fixed_put(view->support, widget, alloc->x, alloc->y);
if (parent != NULL)
g_object_unref(G_OBJECT(widget));