summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-04-12 22:07:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-04-12 22:07:56 (GMT)
commit90923fccb863075722d2ed17360e2c330b262e04 (patch)
treeb7588517a6437efa2d4cd885984e0b87ef8307fe /src/gtkext
parent054d2d76f1951c20822286bce0128e60c26c4b9b (diff)
Highlighted the current segment on caret location changes.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@511 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/gtkblockview.c36
-rw-r--r--src/gtkext/gtkbufferview-int.h6
-rw-r--r--src/gtkext/gtkbufferview.c81
3 files changed, 114 insertions, 9 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c
index 2584405..1c7ba43 100644
--- a/src/gtkext/gtkblockview.c
+++ b/src/gtkext/gtkblockview.c
@@ -52,6 +52,9 @@ static void gtk_block_view_class_init(GtkBlockViewClass *);
/* Procède à l'initialisation de l'afficheur de bloc assembleur. */
static void gtk_block_view_init(GtkBlockView *);
+/* Réagit à un déplacement de curseur. */
+static bool gtk_block_view_notify_caret_relocation(GtkBlockView *, const GdkRectangle *, const vmpa2t *);
+
/* Assure la gestion des clics de souris sur le composant. */
static gboolean gtk_block_view_button_press_event(GtkBlockView *, GdkEventButton *, gpointer);
@@ -87,11 +90,15 @@ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BUFFER_VIEW)
static void gtk_block_view_class_init(GtkBlockViewClass *class)
{
GtkViewPanelClass *panel_class; /* Classe parente */
+ GtkBufferViewClass *buffer_class; /* Classe supérieure */
panel_class = GTK_VIEW_PANEL_CLASS(class);
+ buffer_class = GTK_BUFFER_VIEW_CLASS(class);
panel_class->attach = (attach_binary_fc)gtk_block_view_attach_binary;
+ buffer_class->notify_caret = (notify_caret_relocation_fc)gtk_block_view_notify_caret_relocation;
+
}
@@ -109,8 +116,35 @@ static void gtk_block_view_class_init(GtkBlockViewClass *class)
static void gtk_block_view_init(GtkBlockView *view)
{
+
+
+ /*
g_signal_connect(G_OBJECT(view), "button_press_event",
G_CALLBACK(gtk_block_view_button_press_event), NULL);
+ */
+
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = composant GTK à manipuler. *
+* area = emplacement pour le dessin d'un curseur. *
+* addr = position dans la mémoire représentée du curseur. *
+* *
+* Description : Réagit à un déplacement de curseur. *
+* *
+* Retour : true si un changement a été opéré. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool gtk_block_view_notify_caret_relocation(GtkBlockView *view, const GdkRectangle *area, const vmpa2t *addr)
+{
+ return g_buffer_view_highlight_segments(GTK_BUFFER_VIEW(view)->buffer_view, area->x, area->y,
+ GTK_VIEW_PANEL(view)->display);
}
@@ -174,7 +208,7 @@ static gboolean gtk_block_view_button_press_event(GtkBlockView *view, GdkEventBu
gtk_buffer_view_compute_real_coord(bview, &real_x, &real_y);
- g_buffer_view_highlight_segments(gtk_buffer_view_get_buffer(bview), real_x, real_y);
+ g_buffer_view_highlight_segments(gtk_buffer_view_get_buffer(bview), real_x, real_y, NULL);
diff --git a/src/gtkext/gtkbufferview-int.h b/src/gtkext/gtkbufferview-int.h
index a6d937b..e8e11a0 100644
--- a/src/gtkext/gtkbufferview-int.h
+++ b/src/gtkext/gtkbufferview-int.h
@@ -32,6 +32,10 @@
+/* Réagit à un déplacement de curseur. */
+typedef bool (* notify_caret_relocation_fc) (GtkBufferView *, const GdkRectangle *, const vmpa2t *);
+
+
/* Composant d'affichage de tampon de lignes (instance) */
struct _GtkBufferView
{
@@ -56,6 +60,8 @@ struct _GtkBufferViewClass
{
GtkViewPanelClass parent; /* A laisser en premier */
+ notify_caret_relocation_fc notify_caret;/* Accompagne un déplacement */
+
/* Signaux */
void (* caret_moved) (GtkBufferView *, const vmpa2t *);
diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c
index 1c2c7a9..1a1f6f1 100644
--- a/src/gtkext/gtkbufferview.c
+++ b/src/gtkext/gtkbufferview.c
@@ -41,6 +41,12 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *);
/* Procède à l'initialisation de l'afficheur de tampons. */
static void gtk_buffer_view_init(GtkBufferView *);
+/* Supprime toutes les références externes. */
+static void gtk_buffer_view_dispose(GtkBufferView *);
+
+/* Procède à la libération totale de la mémoire. */
+static void gtk_buffer_view_finalize(GtkBufferView *);
+
/* Intègre le focus dans le rendu du composant. */
static gboolean gtk_buffer_view_focus(GtkWidget *, GtkDirectionType);
@@ -110,12 +116,17 @@ G_DEFINE_TYPE(GtkBufferView, gtk_buffer_view, GTK_TYPE_VIEW_PANEL)
static void gtk_buffer_view_class_init(GtkBufferViewClass *class)
{
+ GObjectClass *object; /* Autre version de la classe */
GtkWidgetClass *widget_class; /* Classe version Widget */
GtkViewPanelClass *panel_class; /* Classe parente */
+ object = G_OBJECT_CLASS(class);
widget_class = GTK_WIDGET_CLASS(class);
panel_class = GTK_VIEW_PANEL_CLASS(class);
+ object->dispose = (GObjectFinalizeFunc/* ! */)gtk_buffer_view_dispose;
+ object->finalize = (GObjectFinalizeFunc)gtk_buffer_view_finalize;
+
widget_class->focus = gtk_buffer_view_focus;
widget_class->button_press_event = gtk_buffer_view_button_press;
widget_class->draw = gtk_buffer_view_draw;
@@ -163,6 +174,44 @@ static void gtk_buffer_view_init(GtkBufferView *view)
/******************************************************************************
* *
+* Paramètres : view = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_buffer_view_dispose(GtkBufferView *view)
+{
+ G_OBJECT_CLASS(gtk_buffer_view_parent_class)->dispose(G_OBJECT(view));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_buffer_view_finalize(GtkBufferView *view)
+{
+ G_OBJECT_CLASS(gtk_buffer_view_parent_class)->finalize(G_OBJECT(view));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : widget = composant GTK visé par l'opération. *
* dir = sens de l'opération : perte ou gain de focus. *
* *
@@ -826,21 +875,37 @@ void gtk_buffer_view_compute_relative_coords(GtkBufferView *view, gint *x, gint
static void gtk_buffer_view_relocate_caret(GtkBufferView *view, const GdkRectangle *area, const vmpa2t *addr)
{
+ bool clear_old; /* Effacement chirurgical */
+ GdkRectangle old_area; /* Mémorisation de l'ancien */
+ bool need_redraw; /* Besoin de rafraîchissement ?*/
+
if (view->caret_addr != NULL)
{
- gtk_buffer_view_compute_relative_coords(view, &view->caret.x, &view->caret.y);
+ clear_old = true;
+ old_area = view->caret;
+ }
+ else
+ clear_old = false;
+
+ view->caret = *area;
+ view->caret_addr = addr;
- /*
- gtk_widget_queue_draw_area(GTK_WIDGET(view), view->caret.x, view->caret.y,
- view->caret.width, view->caret.height);
- */
+ if (GTK_BUFFER_VIEW_GET_CLASS(view)->notify_caret != NULL)
+ need_redraw = GTK_BUFFER_VIEW_GET_CLASS(view)->notify_caret(view, area, addr);
+ else
+ need_redraw = false;
+ if (need_redraw)
gtk_widget_queue_draw(GTK_WIDGET(view));
- }
+ else if (clear_old)
+ {
+ gtk_buffer_view_compute_relative_coords(view, &old_area.x, &old_area.y);
- view->caret = *area;
- view->caret_addr = addr;
+ gtk_widget_queue_draw_area(GTK_WIDGET(view), old_area.x, old_area.y,
+ old_area.width, old_area.height);
+
+ }
restart_caret_blinking(view);