[evolution/foocanvas] Implement e-text / translate method.



commit 1031faf9465e0479c5e623fc6e81768b26e969d7
Author: H.Habighorst <h habighorst googlemail com>
Date:   Wed Apr 28 00:48:18 2010 +0200

    Implement e-text / translate method.
    
    foo_canvas_item_move, which replaced e_canvas_item_move_absolute, should work now.

 widgets/text/e-text.c |   37 ++++++++++++++++++++++++++++++++++---
 widgets/text/e-text.h |    1 +
 2 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 094aae0..0f1e07f 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -86,6 +86,8 @@ enum {
 	PROP_CLIP_HEIGHT,
 	PROP_CLIP,
 	PROP_FILL_CLIP_RECTANGLE,
+	PROP_X,
+	PROP_Y,
 	PROP_X_OFFSET,
 	PROP_Y_OFFSET,
 	PROP_FILL_COLOR,
@@ -501,8 +503,8 @@ get_bounds (EText *text, gdouble *px1, gdouble *py1, gdouble *px2, gdouble *py2)
 
 	/* Get canvas pixel coordinates for text position */
 
-	wx = 0;
-	wy = 0;
+	wx = text->x;
+	wy = text->y;
 	foo_canvas_item_i2w (item, &wx, &wy);
 	foo_canvas_w2c (item->canvas, wx, wy, &text->cx, &text->cy);
 	foo_canvas_w2c (item->canvas, wx, wy, &text->clip_cx, &text->clip_cy);
@@ -815,6 +817,14 @@ e_text_set_property (GObject *object,
 		needs_update = 1;
 		break;
 
+	case PROP_X:
+		text->x = g_value_get_double (value);
+		break;
+
+	case PROP_Y:
+		text->y = g_value_get_double (value);
+		break;
+
 	case PROP_X_OFFSET:
 		text->xofs = g_value_get_double (value);
 		text->needs_recalc_bounds = 1;
@@ -1065,6 +1075,14 @@ e_text_get_property (GObject *object,
 		g_value_set_boolean (value, text->fill_clip_rectangle);
 		break;
 
+	case PROP_X:
+		g_value_set_double (value, text->x);
+		break;
+
+	case PROP_Y:
+		g_value_set_double (value, text->y);
+		break;
+
 	case PROP_X_OFFSET:
 		g_value_set_double (value, text->xofs);
 		break;
@@ -1743,7 +1761,18 @@ e_text_point (FooCanvasItem *item, gdouble x, gdouble y,
 static void
 e_text_translate (FooCanvasItem *item, gdouble dx, gdouble dy)
 {
-	/* FIXME */
+	EText *text;
+
+	text = E_TEXT (item);
+
+	printf("Item coordinates before setting: %f, %f, %f, %f \n",
+		item->x1, item->y1, item->x2, item->y2);
+
+	text->x += dx;
+	text->y += dy;
+
+	printf("Item coordinates before setting: %f, %f, %f, %f \n",
+		item->x1, item->y1, item->x2, item->y2);
 }
 
 /* Bounds handler for the text item */
@@ -3583,6 +3612,8 @@ e_text_init (EText *text)
 	text->justification           = GTK_JUSTIFY_LEFT;
 	text->clip_width              = -1.0;
 	text->clip_height             = -1.0;
+	text->x			      = 0.0;
+	text->y			      = 0.0;
 	text->xofs                    = 0.0;
 	text->yofs                    = 0.0;
 
diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h
index 3716541..cd520be 100644
--- a/widgets/text/e-text.h
+++ b/widgets/text/e-text.h
@@ -120,6 +120,7 @@ struct _EText {
 	gdouble clip_width;		/* Width of optional clip rectangle */
 	gdouble clip_height;		/* Height of optional clip rectangle */
 
+	gdouble x, y;			/* Position at anchor */
 	gdouble xofs, yofs;		/* Text offset distance from anchor position */
 
 	GdkColor color;		/* Fill color */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]