diff options
Diffstat (limited to 'src/gtkext/gtkblockview.c')
-rw-r--r-- | src/gtkext/gtkblockview.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index 10941ab..b03bbff 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -45,7 +45,6 @@ struct _GtkBlockView bool show_code; /* Affichage du code brut ? */ PangoLayout *layout; /* Moteur de rendu du code ASM */ - GdkGC *gc; /* Contexte graphique du rendu */ int line_height; /* Hauteur maximale des lignes */ const exe_format *format; /* Format du contenu bianire */ @@ -64,6 +63,12 @@ struct _GtkBlockViewClass static void gtk_block_view_init(GtkBlockView *); + +/* Encadre la construction graphique initiale de la visualisation. */ +static void gtk_block_view_realize(GtkWidget *); + + + /* Définit les lignes du bloc de représentation. */ static void gtk_block_view_set_rendering_lines(GtkBlockView *, GRenderingLine *, GRenderingLine *); @@ -98,7 +103,6 @@ static void gtk_block_view_size_request(GtkWidget *widget, GtkRequisition *requisition); static void gtk_block_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation); -static void gtk_block_view_realize(GtkWidget *widget); static gboolean gtk_block_view_button_press(GtkWidget *, GdkEventButton *event); @@ -205,45 +209,28 @@ gtk_block_view_size_allocate(GtkWidget *widget, } -static void -gtk_block_view_realize(GtkWidget *widget) -{ - GdkWindowAttr attributes; - guint attributes_mask; - GdkColor white; /* Couleur de fond normale */ - - g_return_if_fail(widget != NULL); - g_return_if_fail(GTK_IS_BLOCK_VIEW(widget)); - - GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.event_mask = gtk_widget_get_events(widget) | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - widget->window = gdk_window_new( - gtk_widget_get_parent_window (widget), - & attributes, attributes_mask - ); - - gdk_window_set_user_data(widget->window, widget); - widget->style = gtk_style_attach(widget->style, widget->window); +/****************************************************************************** +* * +* Paramètres : widget = composant GTK à redessiner. * +* * +* Description : Encadre la construction graphique initiale de la visualisat°.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ +static void gtk_block_view_realize(GtkWidget *widget) +{ + GtkBinViewClass *parent_class; /* Version pure du parent */ - gdk_color_white(gtk_widget_get_colormap(widget), &white); - gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white); + parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget))); + GTK_WIDGET_CLASS(parent_class)->realize(widget); GTK_BLOCK_VIEW(widget)->layout = gtk_widget_create_pango_layout(widget, NULL); - GTK_BLOCK_VIEW(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window)); } @@ -329,6 +316,8 @@ void gtk_block_view_update_margin(GRenderingLine *line, GtkBlockView *view) static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event) { + GtkBinViewClass *parent_class; /* Version pure du parent */ + g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(GTK_IS_BLOCK_VIEW(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); @@ -353,8 +342,9 @@ void gdk_window_end_paint (GdkWindow *window); + parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget))); - + GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event); return TRUE; @@ -373,19 +363,19 @@ gtk_block_view_paint(GtkBlockView *view) GRenderingLine *iter; /* Boucle de parcours */ widget = GTK_WIDGET(view); - gdk_gc_get_values(view->gc, &values); + gdk_gc_get_values(GTK_BIN_VIEW(view)->gc, &values); gdk_color_white(gtk_widget_get_colormap(widget), &white); - gdk_gc_set_foreground(view->gc, &white); + gdk_gc_set_foreground(GTK_BIN_VIEW(view)->gc, &white); gtk_widget_get_size_request(widget, &width, &height); - gdk_draw_rectangle(GDK_DRAWABLE(widget->window), GTK_BLOCK_VIEW(widget)->gc, + gdk_draw_rectangle(GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(widget)->gc, TRUE, 0, 0, width, height); - gdk_gc_set_foreground(view->gc, &values.foreground); + gdk_gc_set_foreground(GTK_BIN_VIEW(view)->gc, &values.foreground); - gdk_draw_layout(GDK_DRAWABLE(widget->window), view->gc, + gdk_draw_layout(GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc, 2 * MARGIN_SPACE + view->line_height, 0, view->layout); @@ -395,7 +385,7 @@ gtk_block_view_paint(GtkBlockView *view) iter != NULL; iter = g_rendering_line_get_next_iter(GTK_BIN_VIEW(view)->lines, iter, GTK_BIN_VIEW(view)->last)) { - g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), view->gc, + g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc, MARGIN_SPACE, 2 * MARGIN_SPACE + view->line_height, y, view->line_height); @@ -403,6 +393,7 @@ gtk_block_view_paint(GtkBlockView *view) } + } |