diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-06-28 22:35:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-06-28 22:35:31 (GMT) |
commit | 33c1281b6a4e46e94daa3d165e32024f7d85d856 (patch) | |
tree | c3b2c4e23e05c547beb59671adf2b80b30b18c9e /src/gtkext/gtkbinview.c | |
parent | 549dd203344a2f95f4bc596f963a854af004cba2 (diff) |
Drawn a border around the views when needed.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@82 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/gtkbinview.c')
-rw-r--r-- | src/gtkext/gtkbinview.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/gtkext/gtkbinview.c b/src/gtkext/gtkbinview.c index 2cb046f..ccb533f 100644 --- a/src/gtkext/gtkbinview.c +++ b/src/gtkext/gtkbinview.c @@ -29,7 +29,11 @@ +/* Encadre la construction graphique initiale de la visualisation. */ +static void gtk_bin_view_realize(GtkWidget *); +/* Met à jour l'affichage de la visualisation de code binaire. */ +static gboolean gtk_bin_view_expose(GtkBinView *, GdkEventExpose *); @@ -61,6 +65,9 @@ static void gtk_binview_class_init(GtkBinviewClass *class) widget_class = GTK_WIDGET_CLASS(class); + widget_class->realize = gtk_bin_view_realize; + widget_class->expose_event = gtk_bin_view_expose; + } @@ -102,8 +109,113 @@ GtkWidget* gtk_binview_new(void) } +/****************************************************************************** +* * +* Paramètres : widget = composant GTK à redessiner. * +* * +* Description : Encadre la construction graphique initiale de la visualisat°.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_bin_view_realize(GtkWidget *widget) +{ + GdkWindowAttr attributes; /* Propriétés du composant */ + guint attributes_mask; /* Masque de prise en compte */ + GdkColor white; /* Couleur de fond normale */ + + 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); + + gdk_color_white(gtk_widget_get_colormap(widget), &white); + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white); + + GTK_BIN_VIEW(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window)); + +} + + +/****************************************************************************** +* * +* Paramètres : view = composant GTK à redessiner. * +* event = informations liées à l'événement. * +* * +* Description : Met à jour l'affichage de la visualisation de code binaire. * +* * +* Retour : FALSE pour poursuivre la propagation de l'événement. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_bin_view_expose(GtkBinView *view, GdkEventExpose *event) +{ + GdkGCValues values; /* Propriétés du contexte */ + GtkStyle *style; /* Style associé au composant */ + int width; /* Largeur de l'élément */ + int height; /* Hauteur de l'élément */ + + if (view->show_border) + { + gdk_gc_get_values(view->gc, &values); + style = gtk_widget_get_style(GTK_WIDGET(view)); + + gtk_widget_get_size_request(GTK_WIDGET(view), &width, &height); + + gdk_gc_set_foreground(view->gc, &style->black); + + gdk_draw_rectangle(GDK_DRAWABLE(GTK_WIDGET(view)->window), view->gc, + FALSE, 0, 0, width - 1, height - 1); + + gdk_gc_set_foreground(view->gc, &values.foreground); + + } + + return FALSE; + +} + + +/****************************************************************************** +* * +* Paramètres : view = composant GTK à mettre à jour. * +* show = état de l'affichage auquel parvenir. * +* * +* Description : Définit si une bordure est à afficher. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ +void gtk_bin_view_show_border(GtkBinview *view, bool show) +{ + view->show_border = show; + +} |