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.c143
1 files changed, 138 insertions, 5 deletions
diff --git a/src/gtkext/gtkbinview.c b/src/gtkext/gtkbinview.c
index 147a59c..0a9ce6e 100644
--- a/src/gtkext/gtkbinview.c
+++ b/src/gtkext/gtkbinview.c
@@ -25,9 +25,12 @@
#include "gtkbinview-int.h"
+#include "iodamarshal.h"
+/* Enregistrement les défilements à associer au composant GTK. */
+static void gtk_binview_set_scroll_adjustments(GtkBinView *, GtkAdjustment *, GtkAdjustment *);
/* Encadre la construction graphique initiale de la visualisation. */
static void gtk_bin_view_realize(GtkWidget *);
@@ -35,6 +38,8 @@ 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 *);
+/* Prend acte d'un nouveau défilement. */
+static void gtk_bin_view_adj_value_changed(GtkAdjustment *, GtkBinView *);
@@ -68,6 +73,19 @@ static void gtk_binview_class_init(GtkBinViewClass *class)
widget_class->realize = gtk_bin_view_realize;
widget_class->expose_event = gtk_bin_view_expose;
+ class->set_scroll_adjustments = gtk_binview_set_scroll_adjustments;
+
+ widget_class->set_scroll_adjustments_signal =
+ g_signal_new(("set_scroll_adjustments"),
+ GTK_TYPE_BIN_VIEW,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(GtkBinViewClass, set_scroll_adjustments),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ADJUSTMENT,
+ GTK_TYPE_ADJUSTMENT);
+
g_signal_new("lines-set",
GTK_TYPE_BIN_VIEW,
G_SIGNAL_RUN_LAST,
@@ -81,6 +99,34 @@ static void gtk_binview_class_init(GtkBinViewClass *class)
/******************************************************************************
* *
+* Paramètres : view = vue à compléter. *
+* hadjustment = nouveau défilement horizontal à intégrer. *
+* vadjustment = nouveau défilement vertical à intégrer. *
+* *
+* Description : Enregistrement les défilements à associer au composant GTK. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_binview_set_scroll_adjustments(GtkBinView *view, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment)
+{
+ view->hadjustment = hadjustment;
+ view->vadjustment = vadjustment;
+
+ g_signal_connect(hadjustment, "value_changed",
+ G_CALLBACK(gtk_bin_view_adj_value_changed), view);
+
+ g_signal_connect(vadjustment, "value_changed",
+ G_CALLBACK(gtk_bin_view_adj_value_changed), view);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : view = composant GTK à initialiser. *
* *
* Description : Procède à l'initialisation de l'afficheur de morceaux. *
@@ -205,6 +251,96 @@ static gboolean gtk_bin_view_expose(GtkBinView *view, GdkEventExpose *event)
}
+/******************************************************************************
+* *
+* Paramètres : view = composant GTK à consulter. *
+* alloc = étendue à accorder à la vue. *
+* *
+* Description : Calcule la surface pleine utilisable pour la vue. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_bin_view_compute_allocation(GtkBinView *view, GtkAllocation *alloc)
+{
+ GtkWidget *widget; /* Autre version de la vue */
+ GtkAllocation *allocation; /* Raccourci d'utilisation #1 */
+ gint border_width; /* Raccourci d'utilisation #2 */
+
+ widget = GTK_WIDGET(view);
+ allocation = &widget->allocation;
+ border_width = GTK_CONTAINER(view)->border_width;
+
+ alloc->x = 0;
+ alloc->y = 0;
+
+ /*
+ if (viewport->shadow_type != GTK_SHADOW_NONE)
+ {
+ alloc->x = widget->style->xthickness;
+ alloc->y = widget->style->ythickness;
+ }
+ */
+
+ alloc->width = MAX(1, allocation->width - alloc->x * 2 - border_width * 2);
+ alloc->height = MAX(1, allocation->height - alloc->y * 2 - border_width * 2);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : adj = valeurs de défilement à consulter. *
+* changed = note une mise à jour de valeur. [OUT] *
+* *
+* Description : S'assure que la valeur de défilement actuelle est valable. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_bin_view_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed)
+{
+ gdouble value; /* Valeur actuelle */
+
+ value = adj->value;
+
+ value = CLAMP(value, 0, adj->upper - adj->page_size);
+
+ if (value != adj->value)
+ {
+ adj->value = value;
+ *changed = TRUE;
+ }
+ else *changed = FALSE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : adj = défilement à l'origine de l'action. *
+* view = composant GTK à redessiner. *
+* *
+* Description : Prend acte d'un nouveau défilement. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_bin_view_adj_value_changed(GtkAdjustment *adj, GtkBinView *view)
+{
+ view->scroll(view);
+
+}
+
/******************************************************************************
* *
@@ -432,7 +568,6 @@ void gtk_bin_view_scroll_to_address(GtkBinView *view, vmpa_t addr)
{
gint x; /* Abscisse à garantir */
gint y; /* Ordonnée à garantir */
- GtkViewport *support; /* Support avec défilements */
GtkAdjustment *adj; /* Défilement à mettre à jour */
if (view->define_address != NULL)
@@ -440,16 +575,14 @@ void gtk_bin_view_scroll_to_address(GtkBinView *view, vmpa_t addr)
if (view->get_coordinates(view, addr, &x, &y))
{
- support = GTK_VIEWPORT(gtk_widget_get_parent(GTK_WIDGET(view)));
-
- adj = gtk_viewport_get_hadjustment(support);
+ adj = view->hadjustment;
if (x > (adj->upper - adj->page_size))
x = adj->upper - adj->page_size;
gtk_adjustment_set_value(adj, x);
- adj = gtk_viewport_get_vadjustment(support);
+ adj = view->vadjustment;
if (y > (adj->upper - adj->page_size))
y = adj->upper - adj->page_size;