diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-12-12 21:25:32 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-12-12 21:25:32 (GMT) |
commit | dae8c208e24d03c7bf5314a86cb366a4e84a53c2 (patch) | |
tree | ed0544d501d6ad8819e4abc18c7382199666bba3 /src/gtkext | |
parent | e86f211252a66d6c1b4abec350217f5241b6ef66 (diff) |
Updated display of graphical views on option change and fixed size bugs.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@301 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/gtkgraphview.c | 66 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel-int.h | 4 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 18 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.h | 4 |
4 files changed, 77 insertions, 15 deletions
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 1a48680..88210f5 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -38,8 +38,6 @@ struct _GtkGraphView GtkViewPanel parent; /* A laisser en premier */ GtkFixed *support; /* Support des vues en bloc */ - GtkRequisition requisition; /* Espace requis d'affichage */ /* A garder ?? */ - vmpa_t start; /* Début de la portion vue */ vmpa_t end; /* Fin de la portion affichée */ @@ -79,6 +77,9 @@ static gboolean gtk_graph_view_expose(GtkWidget *, GdkEventExpose *, GtkGraphVie /* Réagit à la sélection externe d'une adresse. */ static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); +/* Actualise les besoins internes avant un redimensionnement. */ +static void gtk_graph_view_prepare_resize(GtkGraphView *); + /* Indique la position d'affichage d'une adresse donnée. */ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, gint *, gint *); @@ -145,6 +146,7 @@ static void gtk_graph_view_init(GtkGraphView *view) viewpanel = GTK_VIEW_PANEL(view); viewpanel->define = (define_address_fc)gtk_graph_view_define_main_address; + viewpanel->resize = (prepare_resize_fc)gtk_graph_view_prepare_resize; viewpanel->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; viewpanel->scroll = (scroll_fc)gtk_graph_view_scroll; viewpanel->cache_glance = (cache_glance_fc)gtk_graph_view_cache_glance; @@ -213,8 +215,8 @@ static void gtk_graph_view_size_request(GtkWidget *widget, GtkRequisition *requi if (left_corner != G_MAXINT) requisition->width += left_corner; if (top_corner != G_MAXINT) requisition->height += top_corner; - if (view->requisition.width == 0 && view->requisition.height == 0) - view->requisition = *requisition; + requisition->width += GTK_VIEW_PANEL(widget)->hadjustment->value; + requisition->height += GTK_VIEW_PANEL(widget)->vadjustment->value; } @@ -237,6 +239,7 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc gpointer fixed_class; /* Classe parente */ GtkViewPanel *panel; /* Autre version du composant */ GtkAllocation valloc; /* Surface utilisable */ + GtkRequisition req; /* Taille demandée */ gboolean changed; /* Changement de valeur ? */ /* Mise à jour GTK */ @@ -253,13 +256,15 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc gtk_view_panel_compute_allocation(panel, &valloc); + gtk_widget_size_request(widget, &req); + /* Défilement horizontal */ panel->hadjustment->page_size = valloc.width; panel->hadjustment->step_increment = valloc.width * 0.1; panel->hadjustment->page_increment = valloc.width * 0.9; - panel->hadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.width, valloc.width); + panel->hadjustment->upper = MAX(req.width, valloc.width); gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed); @@ -274,7 +279,7 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc panel->vadjustment->step_increment = valloc.width * 0.1; panel->vadjustment->page_increment = valloc.width * 0.9; - panel->vadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.height, valloc.height); + panel->vadjustment->upper = MAX(req.height, valloc.height); gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed); @@ -376,6 +381,36 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) /****************************************************************************** * * +* Paramètres : view = composant GTK à mettre à jour. * +* * +* Description : Actualise les besoins internes avant un redimensionnement. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_graph_view_prepare_resize(GtkGraphView *view) +{ + size_t i; /* Boucle de parcours */ + + if (view->children_count > 0) + { + for (i = 0; i < view->children_count; i++) + gtk_widget_queue_resize(GTK_WIDGET(view->children[i])); + + build_graph_view(view, view->children, view->children_count); + + change_editor_items_current_view_content(GTK_VIEW_PANEL(view)); + + } + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à consulter. * * addr = adresse à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * @@ -496,6 +531,7 @@ GtkWidget *gtk_graph_view_new(void) void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocation *alloc) { size_t i; /* Boucle de parcours */ + GtkWidget *parent; /* Parent en cas de réajustemt.*/ for (i = 0; i < view->children_count; i++) if (GTK_WIDGET(view->children[i]) == widget) @@ -504,8 +540,19 @@ void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocati break; } + parent = gtk_widget_get_parent(widget); + + if (parent != NULL) + { + g_object_ref(G_OBJECT(widget)); + gtk_container_remove(GTK_CONTAINER(parent), widget); + } + gtk_fixed_put(view->support, widget, alloc->x, alloc->y); + if (parent != NULL) + g_object_unref(G_OBJECT(widget)); + } @@ -547,9 +594,6 @@ static void gtk_graph_view_reset(GtkGraphView *view) { size_t i; /* Boucle de parcours */ - view->requisition.width = 0; - view->requisition.height = 0; - view->start = VMPA_MAX; view->end = VMPA_MAX; @@ -618,8 +662,8 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinar list = g_loaded_binary_get_instructions(binary); buffer = g_loaded_binary_get_disassembled_buffer(binary); - addr = g_loaded_binary_display_addresses_in_text(binary, BDT_GRAPH); - code = g_loaded_binary_display_code_in_text(binary, BDT_GRAPH); + addr = GTK_VIEW_PANEL(view)->display_addr; + code = GTK_VIEW_PANEL(view)->display_code; first = start; last = first; diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index ee14067..b859f99 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -39,6 +39,9 @@ typedef void (* attach_binary_fc) (GtkViewPanel *, GLoadedBinary *, bool *, bool /* Réagit à la sélection externe d'une adresse. */ typedef void (* define_address_fc) (GtkViewPanel *, vmpa_t); +/* Actualise les besoins internes avant un redimensionnement. */ +typedef void (* prepare_resize_fc) (GtkViewPanel *); + /* Indique la position d'affichage d'une adresse donnée. */ typedef bool (* get_addr_coordinates_fc) (const GtkViewPanel *, vmpa_t, gint *, gint *); @@ -65,6 +68,7 @@ struct _GtkViewPanel attach_binary_fc attach; /* Association avec un binaire */ define_address_fc define; /* Centrage sur une partie */ + prepare_resize_fc resize; /* Prépare une nouvelle taille */ get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ scroll_fc scroll; /* Défilement du contenu */ cache_glance_fc cache_glance; /* Cache de la mignature */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index a3bf747..ab0f237 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -410,12 +410,19 @@ bool gtk_view_panel_get_addresses_display(const GtkViewPanel *panel) * * ******************************************************************************/ -void gtk_view_panel_set_addresses_display(const GtkViewPanel *panel, bool state) +void gtk_view_panel_set_addresses_display(GtkViewPanel *panel, bool state) { if (*panel->display_addr != state) { *panel->display_addr = state; + + if (panel->resize != NULL) + panel->resize(panel); + + gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(panel))); + gtk_widget_queue_resize(GTK_WIDGET(panel)); gtk_widget_queue_draw(GTK_WIDGET(panel)); + } } @@ -453,12 +460,19 @@ bool gtk_view_panel_get_code_display(const GtkViewPanel *panel) * * ******************************************************************************/ -void gtk_view_panel_set_code_display(const GtkViewPanel *panel, bool state) +void gtk_view_panel_set_code_display(GtkViewPanel *panel, bool state) { if (*panel->display_code != state) { *panel->display_code = state; + + if (panel->resize != NULL) + panel->resize(panel); + + gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(panel))); + gtk_widget_queue_resize(GTK_WIDGET(panel)); gtk_widget_queue_draw(GTK_WIDGET(panel)); + } } diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h index 3de5fab..61df60f 100644 --- a/src/gtkext/gtkviewpanel.h +++ b/src/gtkext/gtkviewpanel.h @@ -60,13 +60,13 @@ void gtk_view_panel_attach_binary(GtkViewPanel *, GLoadedBinary *, bool *, bool bool gtk_view_panel_get_addresses_display(const GtkViewPanel *); /* Définit si les adresses doivent apparaître dans le rendu. */ -void gtk_view_panel_set_addresses_display(const GtkViewPanel *, bool); +void gtk_view_panel_set_addresses_display(GtkViewPanel *, bool); /* Indique si le code doit apparaître dans le rendu. */ bool gtk_view_panel_get_code_display(const GtkViewPanel *); /* Définit si le code doit apparaître dans le rendu. */ -void gtk_view_panel_set_code_display(const GtkViewPanel *, bool); +void gtk_view_panel_set_code_display(GtkViewPanel *, bool); /* Fournit le binaire associé à la représentation. */ GLoadedBinary *gtk_view_panel_get_binary(const GtkViewPanel *); |