[evolution/foocanvas] Do some more work to foocanvas migration.



commit 058cda4b86b7497f263cb4757e430048f3bb2510
Author: H.Habighorst <h habighorst googlemail com>
Date:   Sun Apr 25 22:54:17 2010 +0200

    Do some more work to foocanvas migration.
    
    -> fixup foo_canvas_group_update: it resets the bbox, so we need to save / restore it
    -> convert e-canvas/e-canvas-background/e-table-*-item to gdk/foocanvas
    -> add a nasty hack to foocanvas: foo_canvas_group_draw
    -> replace old gnome_canvas_* functions (which were only renamed) to foocanvas

 widgets/libfoocanvas/foo-canvas.c          |    5 +-
 widgets/libfoocanvas/libart-compat.c       |   11 +++
 widgets/libfoocanvas/libart-compat.h       |    2 +
 widgets/misc/e-calendar-item.c             |   13 +++
 widgets/misc/e-canvas-background.c         |  100 +++++++++++--------------
 widgets/misc/e-canvas.c                    |   39 +++-------
 widgets/table/e-table-field-chooser-item.c |   39 ++++++----
 widgets/table/e-table-header-item.c        |   39 ++++++----
 widgets/table/e-table-item.c               |  111 ++++++++++++----------------
 widgets/text/e-reflow.c                    |   57 ++++++++------
 widgets/text/e-text.c                      |   11 +++
 11 files changed, 220 insertions(+), 207 deletions(-)
---
diff --git a/widgets/libfoocanvas/foo-canvas.c b/widgets/libfoocanvas/foo-canvas.c
index 217f9ea..6e4e234 100644
--- a/widgets/libfoocanvas/foo-canvas.c
+++ b/widgets/libfoocanvas/foo-canvas.c
@@ -1499,7 +1499,10 @@ foo_canvas_group_draw (FooCanvasItem *item, GdkDrawable *drawable,
 			child_rect.width = child->x2 - child->x1 + 1;
 			child_rect.height = child->y2 - child->y1 + 1;
 
-			if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT)
+/*
+ *			XXX: This is a nasty hack...
+ *			if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT)
+ */
 				(* FOO_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose);
 		}
 	}
diff --git a/widgets/libfoocanvas/libart-compat.c b/widgets/libfoocanvas/libart-compat.c
index 061bf76..8bb4bb3 100644
--- a/widgets/libfoocanvas/libart-compat.c
+++ b/widgets/libfoocanvas/libart-compat.c
@@ -1,6 +1,17 @@
 #include "libart-compat.h"
 
 void
+art_affine_identity (double dst[6])
+{
+  dst[0] = 1;
+  dst[1] = 0;
+  dst[2] = 0;
+  dst[3] = 1;
+  dst[4] = 0;
+  dst[5] = 0;
+}
+
+void
 art_affine_point (ArtPoint *dst,
                   const ArtPoint *src,
                   const gdouble affine[6])
diff --git a/widgets/libfoocanvas/libart-compat.h b/widgets/libfoocanvas/libart-compat.h
index aa0dca3..c4126fe 100644
--- a/widgets/libfoocanvas/libart-compat.h
+++ b/widgets/libfoocanvas/libart-compat.h
@@ -19,6 +19,8 @@ struct _ArtDRect {
 	gdouble x0, y0, x1, y1;
 };
 
+void		art_affine_identity		(double dst[6]);
+
 void		art_affine_point		(ArtPoint *dst,
 						 const ArtPoint *src,
 						 const gdouble affine[6]);
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index b13483d..22a3169 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -891,14 +891,27 @@ e_calendar_item_update		(FooCanvasItem *item,
 	GtkStyle *style;
 	gint char_height, width, height, space, space_per_cal, space_per_cell;
 	gint rows, cols, xthickness, ythickness;
+	gdouble x_orig, y_orig, width_orig, height_orig;
 	PangoFontDescription *font_desc;
 	PangoContext *pango_context;
 	PangoFontMetrics *font_metrics;
 
 	item_class = FOO_CANVAS_ITEM_CLASS (e_calendar_item_parent_class);
+
+	// foo_canvas_group_update resets the bbox!
+	x_orig = item->x1;
+	y_orig = item->y1;
+	width_orig = item->x2;
+	height_orig = item->y2;
+
 	if (item_class->update != NULL)
 		item_class->update (item, i2w_dx, i2w_dy, flags);
 
+	item->x1 = x_orig;
+	item->y1 = y_orig;
+	item->x2 = width_orig;
+	item->y2 = height_orig;
+
 	calitem = E_CALENDAR_ITEM (item);
 	style = gtk_widget_get_style (GTK_WIDGET (item->canvas));
 	xthickness = style->xthickness;
diff --git a/widgets/misc/e-canvas-background.c b/widgets/misc/e-canvas-background.c
index 58f9cda..99a22e6 100644
--- a/widgets/misc/e-canvas-background.c
+++ b/widgets/misc/e-canvas-background.c
@@ -91,37 +91,31 @@ get_color(ECanvasBackground *ecb)
 static void
 ecb_bounds (FooCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2)
 {
-	gdouble   i2c [6];
-	ArtPoint c1, c2, i1, i2;
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
+	gdouble x, y, width, height;
 
 	/* Wrong BBox's are the source of redraw nightmares */
-
-	foo_canvas_item_i2c_affine (FOO_CANVAS_ITEM (ecb), i2c);
-
-	i1.x = ecb->priv->x1;
-	i1.y = ecb->priv->y1;
-	i2.x = ecb->priv->x2;
-	i2.y = ecb->priv->y2;
-	art_affine_point (&c1, &i1, i2c);
-	art_affine_point (&c2, &i2, i2c);
+	x = ecb->priv->x1;
+	y = ecb->priv->y1;
+	width = ecb->priv->x2;
+	height = ecb->priv->y2;
 
 	if (ecb->priv->x1 < 0)
-		c1.x = -(gdouble)UINT_MAX;
+		x = -(gdouble)UINT_MAX;
 
 	if (ecb->priv->y1 < 0)
-		c1.y = -(gdouble)UINT_MAX;
+		y = -(gdouble)UINT_MAX;
 
 	if (ecb->priv->x2 < 0)
-		c2.x = (gdouble)UINT_MAX;
+		width = (gdouble)UINT_MAX;
 
 	if (ecb->priv->y2 < 0)
-		c2.y = (gdouble)UINT_MAX;
+		height = (gdouble)UINT_MAX;
 
-	*x1 = c1.x;
-	*y1 = c1.y;
-	*x2 = c2.x + 1;
-	*y2 = c2.y + 1;
+	*x1 = x;
+	*y1 = y;
+	*x2 = width + 1;
+	*y2 = height + 1;
 }
 
 /*
@@ -130,29 +124,36 @@ ecb_bounds (FooCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble
 static void
 ecb_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 {
-	ArtPoint o1, o2;
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
+	gdouble x, y, width, height;
+
+	// foo_canvas_group_update wipes the bbox!
+	x = item->x1;
+	y = item->y1;
+	width  = item->x2;
+	height = item->y2;
 
 	if (FOO_CANVAS_ITEM_CLASS (ecb_parent_class)->update)
 		FOO_CANVAS_ITEM_CLASS (ecb_parent_class)->update (item, i2w_dx, i2w_dy, flags);
 
-	o1.x = item->x1;
-	o1.y = item->y1;
-	o2.x = item->x2;
-	o2.y = item->y2;
+	item->x1 = x;
+	item->y1 = y;
+	item->x2 = width;
+	item->y2 = height;
 
 	ecb_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
-	if (item->x1 != o1.x ||
-	    item->y1 != o1.y ||
-	    item->x2 != o2.x ||
-	    item->y2 != o2.y) {
-		foo_canvas_request_redraw (item->canvas, o1.x, o1.y, o2.x, o2.y);
+
+	if (item->x1 != x ||
+	    item->y1 != y ||
+	    item->x2 != width ||
+	    item->y2 != height) {
+		foo_canvas_request_redraw (item->canvas, x, y, width, height);
 		ecb->priv->needs_redraw = 1;
 	}
 
 	if (ecb->priv->needs_redraw) {
 		foo_canvas_request_redraw (item->canvas, item->x1, item->y1,
-					     item->x2, item->y2);
+					   item->x2, item->y2);
 		ecb->priv->needs_redraw = 0;
 	}
 }
@@ -371,41 +372,28 @@ ecb_draw (FooCanvasItem *item,
           GdkEventExpose *expose)
 {
 	ECanvasBackground *ecb = E_CANVAS_BACKGROUND (item);
-	gint x1, x2, y1, y2;
-	gint width, height;
-	gdouble i2c [6];
-	ArtPoint upper_left, lower_right, ecb_base_point;
+	gint x, y, width, height;
 
+	x = 0;
+	y = 0;
 	width = expose->area.width;
 	height = expose->area.height;
 
 	/*
 	 * Find out our real position after grouping
 	 */
-	foo_canvas_item_i2c_affine (item, i2c);
-	ecb_base_point.x = ecb->priv->x1;
-	ecb_base_point.y = ecb->priv->y1;
-	art_affine_point (&upper_left, &ecb_base_point, i2c);
-
-	ecb_base_point.x = ecb->priv->x2;
-	ecb_base_point.y = ecb->priv->y2;
-	art_affine_point (&lower_right, &ecb_base_point, i2c);
-
-	x1 = 0;
-	y1 = 0;
-	x2 = width;
-	y2 = height;
-	if (ecb->priv->x1 >= 0 && upper_left.x > x1)
-		x1 = upper_left.x;
-	if (ecb->priv->y1 >= 0 && upper_left.y > y1)
-		y1 = upper_left.y;
-	if (ecb->priv->x2 >= 0 && lower_right.x < x2)
-		x2 = lower_right.x;
-	if (ecb->priv->y2 >= 0 && lower_right.y < y2)
-		y2 = lower_right.y;
+
+	if (ecb->priv->x1 >= 0 && ecb->priv->x1 > x)
+		x = ecb->priv->x1;
+	if (ecb->priv->y1 >= 0 && ecb->priv->y1 > y)
+		y = ecb->priv->y1;
+	if (ecb->priv->x2 >= 0 && ecb->priv->x2 < width)
+		width = ecb->priv->x2;
+	if (ecb->priv->y2 >= 0 && ecb->priv->y2 < height)
+		height = ecb->priv->y2;
 
 	gdk_draw_rectangle (drawable, ecb->priv->gc, TRUE,
-			    x1, y1, x2 - x1, y2 - y1);
+			    x, y, width - x, height - y);
 }
 
 static double
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
index ef51d77..0d7a7d6 100644
--- a/widgets/misc/e-canvas.c
+++ b/widgets/misc/e-canvas.c
@@ -275,39 +275,20 @@ e_canvas_key (GtkWidget *widget, GdkEventKey *event)
 	return emit_event (canvas, &full_event);
 }
 
-/* This routine invokes the point method of the item.  The argument x, y should
- * be in the parent's item-relative coordinate system.  This routine applies the
- * inverse of the item's transform, maintaining the affine invariant.
+/*
+ * This routine invokes the point method of the item.
+ * The arguments x, y should be in the parent item local coordinates.
  */
-#define HACKISH_AFFINE
 
 static double
-foo_canvas_item_invoke_point (FooCanvasItem *item,
-                              gdouble x,
-                              gdouble y,
-                              gint cx,
-                              gint cy,
-                              FooCanvasItem **actual_item)
+foo_canvas_item_invoke_point (FooCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy, FooCanvasItem **actual_item)
 {
-#ifdef HACKISH_AFFINE
-	gdouble i2w[6], w2c[6], i2c[6], c2i[6];
-	ArtPoint c, i;
-#endif
-
-#ifdef HACKISH_AFFINE
-	foo_canvas_item_i2w_affine (item, i2w);
-	foo_canvas_w2c_affine (item->canvas, w2c);
-	art_affine_multiply (i2c, i2w, w2c);
-	art_affine_invert (c2i, i2c);
-	c.x = cx;
-	c.y = cy;
-	art_affine_point (&i, &c, c2i);
-	x = i.x;
-	y = i.y;
-#endif
-
-	return (* FOO_CANVAS_ITEM_CLASS (GTK_OBJECT_GET_CLASS (item))->point) (
-		item, x, y, cx, cy, actual_item);
+	/* Calculate x & y in item local coordinates */
+
+	if (FOO_CANVAS_ITEM_GET_CLASS (item)->point)
+		return FOO_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy, actual_item);
+
+	return 1e18;
 }
 
 /* Re-picks the current item in the canvas, based on the event's coordinates.
diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c
index 6114923..1f7e3bd 100644
--- a/widgets/table/e-table-field-chooser-item.c
+++ b/widgets/table/e-table-field-chooser-item.c
@@ -180,30 +180,37 @@ static void
 etfci_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 {
 	ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
-	gdouble   i2c [6];
-	ArtPoint c1, c2, i1, i2;
+	gdouble x_orig, y_orig, width_orig, height_orig;
+	gdouble x, y, width, height;
+
+	// foo_canvas_group_update wipes the bbox!
+	x_orig = item->x1;
+	y_orig = item->y1;
+	width_orig  = item->x2;
+	height_orig = item->y2;
 
 	if (FOO_CANVAS_ITEM_CLASS (etfci_parent_class)->update)
 		(*FOO_CANVAS_ITEM_CLASS (etfci_parent_class)->update)(item, i2w_dx, i2w_dy, flags);
 
-	i1.x = i1.y = 0;
-	i2.x = etfci->width;
-	i2.y = etfci->height;
+	item->x1 = x_orig;
+	item->y1 = y_orig;
+	item->x2 = width_orig;
+	item->y2 = height_orig;
 
-	foo_canvas_item_i2c_affine (item, i2c);
-	art_affine_point (&c1, &i1, i2c);
-	art_affine_point (&c2, &i2, i2c);
+	x = y = 0;
+	width = etfci->width;
+	height = etfci->height;
 
-	if (item->x1 != c1.x ||
-	     item->y1 != c1.y ||
-	     item->x2 != c2.x ||
-	     item->y2 != c2.y)
+	if (item->x1 != x ||
+	     item->y1 != y ||
+	     item->x2 != width ||
+	     item->y2 != height)
 		{
 			foo_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
-			item->x1 = c1.x;
-			item->y1 = c1.y;
-			item->x2 = c2.x;
-			item->y2 = c2.y;
+			item->x1 = x;
+			item->y1 = y;
+			item->x2 = width;
+			item->y2 = height;
 /* FIXME: Group Child bounds !? */
 #if 0
 			foo_canvas_group_child_bounds (FOO_CANVAS_GROUP (item->parent), item);
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index e4119d0..64137a4 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -190,13 +190,22 @@ ethi_update (FooCanvasItem *item,
              gint flags)
 {
 	ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
+	gdouble x, y, width, height;
 
-	gdouble   i2c [6];
-	ArtPoint c1, c2, i1, i2;
+	// foo_canvas_group_update wipes the bbox!
+	x = item->x1;
+	y = item->y1;
+	width = item->x2;
+	height = item->y2;
 
 	if (FOO_CANVAS_ITEM_CLASS (ethi_parent_class)->update)
 		(*FOO_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, i2w_dx, i2w_dy, flags);
 
+	item->x1 = x;
+	item->y1 = y;
+	item->x2 = width;
+	item->y2 = height;
+
 	if (ethi->sort_info)
 		ethi->group_indent_width =
 			e_table_sort_info_grouping_get_count (ethi->sort_info)
@@ -208,27 +217,23 @@ ethi_update (FooCanvasItem *item,
 		e_table_header_total_width (ethi->eth) +
 		ethi->group_indent_width;
 
-	i1.x = i1.y = 0;
-	i2.x = ethi->width;
-	i2.y = ethi->height;
-
-	foo_canvas_item_i2c_affine (item, i2c);
-	art_affine_point (&c1, &i1, i2c);
-	art_affine_point (&c2, &i2, i2c);
+	x = y = 0;
+	width = ethi->width;
+	height = ethi->height;
 
-	if (item->x1 != c1.x ||
-	    item->y1 != c1.y ||
-	    item->x2 != c2.x ||
-	    item->y2 != c2.y)
+	if (item->x1 != x ||
+	    item->y1 != y ||
+	    item->x2 != width ||
+	    item->y2 != height)
 		{
 			foo_canvas_request_redraw (
 				item->canvas,
 				item->x1, item->y1,
 				item->x2, item->y2);
-			item->x1 = c1.x;
-			item->y1 = c1.y;
-			item->x2 = c2.x;
-			item->y2 = c2.y;
+			item->x1 = x;
+			item->y1 = y;
+			item->x2 = width;
+			item->y2 = height;
 /* FIXME: Group Child bounds !? (FOO BAA) */
 #if 0
 			foo_canvas_group_child_bounds (FOO_CANVAS_GROUP (item->parent), item);
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index e4554ea..1fe9f47 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -430,25 +430,13 @@ eti_detach_cell_views (ETableItem *eti)
 static void
 eti_bounds (FooCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2)
 {
-	gdouble   i2c [6];
-	ArtPoint c1, c2, i1, i2;
 	ETableItem *eti = E_TABLE_ITEM (item);
 
 	/* Wrong BBox's are the source of redraw nightmares */
-
-	foo_canvas_item_i2c_affine (FOO_CANVAS_ITEM (eti), i2c);
-
-	i1.x = eti->x1;
-	i1.y = eti->y1;
-	i2.x = eti->x1 + eti->width;
-	i2.y = eti->y1 + eti->height;
-	art_affine_point (&c1, &i1, i2c);
-	art_affine_point (&c2, &i2, i2c);
-
-	*x1 = c1.x;
-	*y1 = c1.y;
-	*x2 = c2.x + 1;
-	*y2 = c2.y + 1;
+	*x1 = eti->x1;
+	*y1 = eti->y1;
+	*x2 = eti->x1 + eti->width + 1;
+	*y2 = eti->y1 + eti->height + 1;
 }
 
 static void
@@ -485,23 +473,30 @@ eti_reflow (FooCanvasItem *item, gint flags)
 static void
 eti_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 {
-	ArtPoint o1, o2;
 	ETableItem *eti = E_TABLE_ITEM (item);
+	gdouble x, y, width, height;
+
+	// foo_canvas_group_update wipes the bbox!
+	x = item->x1;
+	y = item->y1;
+	width = item->x2;
+	height = item->y2;
 
 	if (FOO_CANVAS_ITEM_CLASS (eti_parent_class)->update)
 		(*FOO_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, i2w_dx, i2w_dy, flags);
 
-	o1.x = item->x1;
-	o1.y = item->y1;
-	o2.x = item->x2;
-	o2.y = item->y2;
+	item->x1 = x;
+	item->y1 = y;
+	item->x2 = width;
+	item->y2 = height;
 
 	eti_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
-	if (item->x1 != o1.x ||
-	    item->y1 != o1.y ||
-	    item->x2 != o2.x ||
-	    item->y2 != o2.y) {
-		foo_canvas_request_redraw (item->canvas, o1.x, o1.y, o2.x, o2.y);
+
+	if (item->x1 != x ||
+	    item->y1 != y ||
+	    item->x2 != width ||
+	    item->y2 != height) {
+		foo_canvas_request_redraw (item->canvas, x, y, width, height);
 		eti->needs_redraw = 1;
 	}
 
@@ -790,18 +785,21 @@ static void
 eti_item_region_redraw (ETableItem *eti, gint x0, gint y0, gint x1, gint y1)
 {
 	FooCanvasItem *item = FOO_CANVAS_ITEM (eti);
-	ArtDRect rect;
-	gdouble i2c [6];
+	GdkRectangle rect, rect1, rect2;
+
+	rect.x = x0;
+	rect.y = y0;
+	rect.width = x1;
+	rect.height = y1;
 
-	rect.x0 = x0;
-	rect.y0 = y0;
-	rect.x1 = x1;
-	rect.y1 = y1;
+	rect1.x = item->x1;
+	rect1.y = item->y1;
+	rect1.width = item->x2;
+	rect1.height = item->y2;
 
-	foo_canvas_item_i2c_affine (item, i2c);
-	art_drect_affine_transform (&rect, &rect, i2c);
+	gdk_rectangle_union(&rect, &rect1, &rect2);
 
-	foo_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1);
+	foo_canvas_request_redraw (item->canvas, rect2.x, rect2.y, rect2.width, rect2.height);
 }
 
 /*
@@ -1741,8 +1739,6 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 	gint f_x1, f_x2, f_y1, f_y2;
 	gint x, y, width, height;
 	gboolean f_found;
-	gdouble i2c [6];
-	ArtPoint eti_base, eti_base_item, lower_right;
 	GtkWidget *canvas = GTK_WIDGET(item->canvas);
 	gint height_extra = eti->horizontal_draw_grid ? 1 : 0;
 	cairo_t *cr;
@@ -1755,23 +1751,11 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 	cr = gdk_cairo_create (drawable);
 
 	/*
-	 * Find out our real position after grouping
-	 */
-	foo_canvas_item_i2c_affine (item, i2c);
-	eti_base_item.x = eti->x1;
-	eti_base_item.y = eti->y1;
-	art_affine_point (&eti_base, &eti_base_item, i2c);
-
-	eti_base_item.x = eti->x1 + eti->width;
-	eti_base_item.y = eti->y1 + eti->height;
-	art_affine_point (&lower_right, &eti_base_item, i2c);
-
-	/*
 	 * First column to draw, last column to draw
 	 */
 	first_col = -1;
 	x_offset = 0;
-	x1 = floor (eti_base.x);
+	x1 = floor (eti->x1);
 	for (col = 0; col < cols; col++, x1 = x2) {
 		ETableCol *ecol = e_table_header_get_column (eti->header, col);
 
@@ -1781,6 +1765,7 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 			break;
 		if (x2 < x)
 			continue;
+		
 		if (first_col == -1) {
 			x_offset = x1 - x;
 			first_col = col;
@@ -1798,11 +1783,11 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 	 * Compute row span.
 	 */
 	if (eti->uniform_row_height) {
-		first_row = (y          - floor (eti_base.y) - height_extra) / (eti_row_height (eti, -1) + height_extra);
-		last_row  = (y + height - floor (eti_base.y)               ) / (eti_row_height (eti, -1) + height_extra) + 1;
+		first_row = (y          - floor (eti->y1) - height_extra) / (eti_row_height (eti, -1) + height_extra);
+		last_row  = (y + height - floor (eti->y1)               ) / (eti_row_height (eti, -1) + height_extra) + 1;
 		if (first_row > last_row)
 			goto exit;
-		y_offset = floor (eti_base.y) - y + height_extra + first_row * (eti_row_height (eti, -1) + height_extra);
+		y_offset = floor (eti->y1) - y + height_extra + first_row * (eti_row_height (eti, -1) + height_extra);
 		if (first_row < 0)
 			first_row = 0;
 		if (last_row > eti->rows)
@@ -1813,7 +1798,7 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 		y_offset = 0;
 		first_row = -1;
 
-		y1 = y2 = floor (eti_base.y) + height_extra;
+		y1 = y2 = floor (eti->y1) + height_extra;
 		for (row = 0; row < rows; row++, y1 = y2) {
 
 			y2 += ETI_ROW_HEIGHT (eti, row) + height_extra;
@@ -1848,7 +1833,7 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 	if (eti->horizontal_draw_grid && first_row == 0) {
 		gdk_draw_line (
 			drawable, eti->grid_gc,
-				eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
+				eti->x1 - x, yd, eti->x1 + eti->width - x, yd);
 	}
 
 	yd += height_extra;
@@ -1894,9 +1879,9 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 			}
 
 			x1 = xd;
-			y1 = yd+1;
-			x2 = x1 + ecol->width;
-			y2 = yd+height;
+			y1 = yd + 1;
+			x2 = xd + ecol->width;
+			y2 = yd + height;
 
 			background = eti_get_cell_background_color (eti, row, col, col_selected, &free_background);
 
@@ -1968,12 +1953,13 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 				switch (eti->cursor_mode) {
 				case E_CURSOR_LINE:
 					if (view_to_model_row(eti, row) == cursor_row) {
-						f_x1 = floor (eti_base.x) - x;
-						f_x2 = floor (lower_right.x) - x;
-						f_y1 = yd+1;
+						f_x1 = floor (eti->x1) - x;
+						f_x2 = floor ((eti->x1 + eti->width)) - x;
+						f_y1 = yd + 1;
 						f_y2 = yd + height;
 						f_found = TRUE;
 					}
+
 					break;
 				case E_CURSOR_SIMPLE:
 				case E_CURSOR_SPREADSHEET:
@@ -1995,8 +1981,7 @@ eti_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose)
 		if (eti->horizontal_draw_grid) {
 			gdk_draw_line (
 				drawable, eti->grid_gc,
-				eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
-
+				eti->x1 - x, yd, eti->x1 + eti->width - x, yd);
 			yd++;
 		}
 	}
diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c
index e86d12c..06f4900 100644
--- a/widgets/text/e-reflow.c
+++ b/widgets/text/e-reflow.c
@@ -1261,39 +1261,46 @@ static void
 e_reflow_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 {
 	EReflow *reflow;
-	gdouble x0, x1, y0, y1;
+	gdouble x, y, width, height;
 
 	reflow = E_REFLOW (item);
 
+	// foo_canvas_group_update wipes the bbox! 
+	x = item->x1;
+	y = item->y1;
+	width = item->x2;
+	height = item->y2;
+
 	if (FOO_CANVAS_ITEM_CLASS(e_reflow_parent_class)->update)
 		FOO_CANVAS_ITEM_CLASS(e_reflow_parent_class)->update (item, i2w_dx, i2w_dy, flags);
 
-	x0 = item->x1;
-	y0 = item->y1;
-	x1 = item->x2;
-	y1 = item->y2;
-	if (x1 < x0 + reflow->width)
-		x1 = x0 + reflow->width;
-	if (y1 < y0 + reflow->height)
-		y1 = y0 + reflow->height;
-	item->x2 = x1;
-	item->y2 = y1;
+	item->x1 = x;
+	item->y1 = y;
+	item->x2 = width;
+	item->y2 = height;
+
+	if (width < x + reflow->width)
+		width = x + reflow->width;
+	if (height < y + reflow->height)
+		height = y + reflow->height;
+	item->x2 = width;
+	item->y2 = height;
 
 	if (reflow->need_height_update) {
-		x0 = item->x1;
-		y0 = item->y1;
-		x1 = item->x2;
-		y1 = item->y2;
-		if (x0 > 0)
-			x0 = 0;
-		if (y0 > 0)
-			y0 = 0;
-		if (x1 < E_REFLOW(item)->width)
-			x1 = E_REFLOW(item)->width;
-		if (x1 < E_REFLOW(item)->height)
-			x1 = E_REFLOW(item)->height;
-
-		foo_canvas_request_redraw(item->canvas, x0, y0, x1, y1);
+		x = item->x1;
+		y = item->y1;
+		width = item->x2;
+		height = item->y2;
+		if (x > 0)
+			x = 0;
+		if (y > 0)
+			y = 0;
+		if (width < E_REFLOW(item)->width)
+			width = E_REFLOW(item)->width;
+		if (height < E_REFLOW(item)->height)
+			height = E_REFLOW(item)->height;
+
+		foo_canvas_request_redraw(item->canvas, x, y, width, height);
 		reflow->need_height_update = FALSE;
 	} else if (reflow->need_column_resize) {
 		GtkLayout *layout;
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 3fac25f..74e9409 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1198,9 +1198,20 @@ e_text_update (FooCanvasItem *item, gdouble i2w_dx, gdouble i2w_dy, gint flags)
 
 	text = E_TEXT (item);
 
+	// foo_canvas_group_update wipes the bbox!
+	x1 = item->x1;
+	y1 = item->y1;
+	x2 = item->x2;
+	y2 = item->y2;
+
 	if (FOO_CANVAS_ITEM_CLASS (e_text_parent_class)->update)
 		(* FOO_CANVAS_ITEM_CLASS (e_text_parent_class)->update) (item, i2w_dx, i2w_dy, flags);
 
+	item->x1 = x1;
+	item->y1 = y1;
+	item->x2 = x2;
+	item->y2 = y2;
+
 	if ( text->needs_recalc_bounds) {
 		set_text_gc_foreground (text);
 		set_stipple (text, text->stipple, TRUE);



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