summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkbinview.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/gtkbinview.c')
-rw-r--r--src/gtkext/gtkbinview.c112
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;
+
+}