summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-05 00:02:49 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-05 00:02:49 +0100
commitfefcd04cde32b38a304c860d38df73336777c93c (patch)
tree9fb973cca6231ede7cb06d38e0c290c33e858a82
parent2bb732bf05d9695155d4cecf70a2d3be2a0faaff (diff)
downloadgmathlib-fefcd04cde32b38a304c860d38df73336777c93c.tar.gz
gmathlib-fefcd04cde32b38a304c860d38df73336777c93c.tar.bz2
* Outline currently selected symbol in gMathView
-rw-r--r--gmathview/gmathview.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/gmathview/gmathview.c b/gmathview/gmathview.c
index 60ad216..df81995 100644
--- a/gmathview/gmathview.c
+++ b/gmathview/gmathview.c
@@ -35,8 +35,14 @@ struct _GMathViewPrivate
GMathFormula *formula;
GMathContext *context;
GMathCairoContext *cairo_context;
+
+ GMathBoxed *current_boxed;
+ cairo_surface_t *work_surface;
};
+static void
+g_math_view_update_surface (GMathView *mathview);
+
G_DEFINE_TYPE (GMathView, g_math_view, GTK_TYPE_DRAWING_AREA)
static gboolean
@@ -133,6 +139,9 @@ g_math_view_on_button_press (GtkWidget *widget, GdkEventButton *event)
if (container->symbol)
g_message ("*CLICK* on symbol of type %s", container->symbol->type);
+ priv->current_boxed = container;
+ g_math_view_update_surface (G_MATH_VIEW (widget));
+
return FALSE;
}
@@ -166,10 +175,10 @@ g_math_view_do_expose (GtkWidget *widget, GdkEventExpose *event)
event->area.width, event->area.height);
cairo_clip (cr);
- if (priv->boxed && priv->boxed->surface)
+ if (priv->work_surface)
{
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_source_surface (cr, priv->boxed->surface, 0, 0);
+ cairo_set_source_surface (cr, priv->work_surface, 0, 0);
cairo_paint (cr);
}
@@ -179,6 +188,29 @@ g_math_view_do_expose (GtkWidget *widget, GdkEventExpose *event)
}
void
+g_math_view_update_surface (GMathView *mathview)
+{
+ GMathViewPrivate *priv;
+
+ priv = G_MATH_VIEW_GET_PRIVATE (mathview);
+
+ if (priv->work_surface)
+ {
+ cairo_surface_destroy (priv->work_surface);
+ priv->work_surface = NULL;
+ }
+
+ if (priv->boxed && priv->boxed->surface)
+ {
+ priv->work_surface = g_math_view_copy_surface (priv->boxed->surface);
+ if (priv->current_boxed)
+ g_math_view_outline_boxed (priv->work_surface, priv->current_boxed);
+ }
+
+ g_math_view_force_redraw (mathview);
+}
+
+void
g_math_view_update (GMathView *mathview)
{
GMathViewPrivate *priv;
@@ -193,9 +225,13 @@ g_math_view_update (GMathView *mathview)
gmathboxed_rec_offset (priv->boxed, 0, 0);
width = priv->boxed->box.width;
height = priv->boxed->box.height;
+ priv->work_surface = g_math_view_copy_surface (priv->boxed->surface);
}
else
+ {
width = height = 0;
+ priv->work_surface = NULL;
+ }
gtk_widget_set_size_request (GTK_WIDGET (mathview), width, height);