};
-static void gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class);
-static void gnome_canvas_simplerect_init (GnomeCanvasSimpleRect *simplerect);
+static void gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class);
+
+static void gnome_canvas_simplerect_init (GnomeCanvasSimpleRect *simplerect);
+
+static void gnome_canvas_simplerect_destroy (GtkObject *object);
+
static void gnome_canvas_simplerect_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
+
static void gnome_canvas_simplerect_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void gnome_canvas_simplerect_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
-static void gnome_canvas_simplerect_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
-static double gnome_canvas_simplerect_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
-static void gnome_canvas_simplerect_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
-static void gnome_canvas_simplerect_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w, int h);
+
+static void gnome_canvas_simplerect_update (GnomeCanvasItem *item,
+ double *affine,
+ ArtSVP *clip_path,
+ int flags);
+
+static void gnome_canvas_simplerect_bounds (GnomeCanvasItem *item,
+ double *x1,
+ double *y1,
+ double *x2,
+ double *y2);
+
+static double gnome_canvas_simplerect_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item);
+
+static void gnome_canvas_simplerect_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
+
+static void gnome_canvas_simplerect_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w, int h);
static GnomeCanvasItemClass *parent_class;
-GtkType
+GType
gnome_canvas_simplerect_get_type (void)
{
- static GtkType simplerect_type = 0;
+ static GType simplerect_type;
if (!simplerect_type) {
- GtkTypeInfo simplerect_info = {
- "GnomeCanvasSimpleRect",
- sizeof (GnomeCanvasSimpleRect),
+ static const GTypeInfo object_info = {
sizeof (GnomeCanvasSimpleRectClass),
- (GtkClassInitFunc) gnome_canvas_simplerect_class_init,
- (GtkObjectInitFunc) gnome_canvas_simplerect_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gnome_canvas_simplerect_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GnomeCanvasSimpleRect),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnome_canvas_simplerect_init,
+ NULL /* value_table */
};
- simplerect_type = gtk_type_unique (gnome_canvas_item_get_type (), &simplerect_info);
+ simplerect_type = g_type_register_static (GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasSimpleRect",
+ &object_info, 0);
}
return simplerect_type;
static void
gnome_canvas_simplerect_class_init (GnomeCanvasSimpleRectClass *class)
{
- GObjectClass *object_class;
+ GObjectClass *gobject_class;
+ GtkObjectClass *object_class;
GnomeCanvasItemClass *item_class;
- object_class = G_OBJECT_CLASS (class);
+ gobject_class = (GObjectClass *) class;
+ object_class = (GtkObjectClass *) class;
item_class = (GnomeCanvasItemClass *) class;
+
+ parent_class = g_type_class_peek_parent (class);
- parent_class = gtk_type_class (gnome_canvas_item_get_type ());
-
- object_class->set_property = gnome_canvas_simplerect_set_property;
- object_class->get_property = gnome_canvas_simplerect_get_property;
+ gobject_class->set_property = gnome_canvas_simplerect_set_property;
+ gobject_class->get_property = gnome_canvas_simplerect_get_property;
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_X1,
g_param_spec_double ("x1",
_("x1"),
0.0,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_Y1,
g_param_spec_double ("y1",
_("y1"),
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_X2,
g_param_spec_double ("x2",
_("x2"),
0.0,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_Y2,
g_param_spec_double ("y2",
_("y2"),
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_OUTLINE_PIXELS,
g_param_spec_uint ("outline_pixels",
_("outline pixels"),
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_OUTLINE_WHAT,
g_param_spec_uint ("outline_what",
_("outline what"),
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_FILL,
g_param_spec_boolean ("fill",
_("fill"),
TRUE,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_DRAW,
g_param_spec_boolean ("draw",
_("draw"),
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_OUTLINE_COLOR_RGBA,
g_param_spec_uint ("outline_color_rgba",
_("outline color rgba"),
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
+ g_object_class_install_property (gobject_class,
PROP_FILL_COLOR_RGBA,
g_param_spec_uint ("fill_color_rgba",
_("fill color rgba"),
G_MAXUINT,
0,
G_PARAM_READWRITE));
-
+
+ object_class->destroy = gnome_canvas_simplerect_destroy;
+
item_class->update = gnome_canvas_simplerect_update;
+ item_class->draw = gnome_canvas_simplerect_draw;
item_class->bounds = gnome_canvas_simplerect_bounds;
item_class->point = gnome_canvas_simplerect_point;
item_class->render = gnome_canvas_simplerect_render;
- item_class->draw = gnome_canvas_simplerect_draw;
+
}
static void
simplerect->outline_color = 0;
simplerect->outline_pixels = 1;
simplerect->outline_what = 0xf;
+}
- // GTK2FIX
- // GNOME_CANVAS_ITEM(simplerect)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
+static void
+gnome_canvas_simplerect_destroy (GtkObject *object)
+{
+ GnomeCanvasSimpleRect *rect;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLERECT (object));
+
+ rect = GNOME_CANVAS_SIMPLERECT (object);
+
+ /* remember, destroy can be run multiple times! */
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
}
+
static void
gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item)
{
GnomeCanvasSimpleRect* simplerect;
double x1, x2, y1, y2;
double old_x1, old_x2, old_y1, old_y2;
- double a, b;
-
+ ArtDRect unionrect, old, new;
+
old_x1 = item->x1;
old_y1 = item->y1;
old_x2 = item->x2;
old_y2 = item->y2;
-
+
gnome_canvas_simplerect_bounds (item, &x1, &y1, &x2, &y2);
gnome_canvas_item_i2w (item, &x1, &y1);
gnome_canvas_item_i2w (item, &x2, &y2);
/* now queue redraws for changed areas */
- if (item->x1 != old_x1) {
-
- /* left edge changed. redraw the area that altered */
-
- a = MIN(item->x1, old_x1);
- b = MAX(item->x1, old_x1);
- gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2);
- }
-
- if (item->x2 != old_x2) {
-
- /* right edge changed. redraw the area that altered */
-
- a = MIN(item->x2, old_x2);
- b = MAX(item->x2, old_x2);
- gnome_canvas_request_redraw (item->canvas, a - 1, item->y1, b + 1, item->y2);
- }
-
- if (item->y1 != old_y1) {
-
- /* top edge changed. redraw the area that altered */
-
- a = MIN(item->y1, old_y1);
- b = MAX(item->y1, old_y1);
- gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1);
- }
-
- if (item->y2 != old_y2) {
-
- /* lower edge changed. redraw the area that altered */
-
- a = MIN(item->y2, old_y2);
- b = MAX(item->y2, old_y2);
- gnome_canvas_request_redraw (item->canvas, item->x1, a - 1, item->x2, b + 1);
- }
+ if (item->x1 == old_x1 && item->x2 == old_x2) {
+
+ /* no change in x-axis position */
+
+ if (item->y1 == old_y1) {
+ /* top didn't change, so just draw bottom */
+
+ double start_y = MIN (item->y2, old_y2);
+ double end_y = MAX (item->y2, old_y2);
+
+ gnome_canvas_request_redraw (item->canvas, item->x1, start_y - 0.5, item->x2, end_y + 1.5);
+ return;
+
+ } else if (item->y2 == old_y2) {
+
+ /* bottom didn't change, just draw top */
+
+ double start_y = MIN (item->y1, old_y1);
+ double end_y = MAX (item->y1, old_y1);
+
+ gnome_canvas_request_redraw (item->canvas, item->x1, start_y - 0.5, item->x2, end_y + 1.5);
+ return;
+
+ }
+
+ } else if (item->y1 == old_y1 && item->y2 == old_y2) {
+
+ /* no change in y-axis position */
+
+ if (item->x1 == old_x1) {
+ /* start didn't change, so just draw at the end */
+
+ double start_x = MIN (item->x2, old_x2);
+ double end_x = MAX (item->x2, old_x2);
+
+ gnome_canvas_request_redraw (item->canvas, start_x - 0.5, item->y1, end_x + 1.5, item->y2);
+ return;
+
+ } else if (item->x2 == old_x2) {
+
+ /* end didn't change, so just draw at the start */
+
+ double start_x = MIN (item->x1, old_x1);
+ double end_x = MAX (item->x1, old_x1);
+
+ gnome_canvas_request_redraw (item->canvas, start_x - 0.5, item->y1, end_x + 1.5, item->y2 + 0.5);
+ return;
+
+ }
+ }
+
+ new.x0 = x1;
+ new.y0 = y1;
+ new.x1 = x2;
+ new.y1 = y2;
+
+ old.x0 = old_x1;
+ old.y0 = old_y1;
+ old.x1 = old_x2;
+ old.y1 = old_y2;
+
+ art_drect_union (&unionrect, &old, &new);
+ gnome_canvas_request_redraw (item->canvas,
+ unionrect.x0 - 0.5,
+ unionrect.y0 - 0.5,
+ unionrect.x1 + 1.5,
+ unionrect.y1 + 1.5);
}
/*
GnomeCanvasSimpleRect *simplerect;
int update = FALSE;
int bounds_changed = FALSE;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLERECT (object));
simplerect = GNOME_CANVAS_SIMPLERECT (object);
{
GnomeCanvasSimpleRect *rect = GNOME_CANVAS_SIMPLERECT (object);
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLERECT (object));
+
switch (prop_id) {
case PROP_X1:
g_value_set_double (value, rect->x1);
gnome_canvas_request_redraw (item->canvas,
simplerect->bbox_ulx,
simplerect->bbox_uly,
- simplerect->bbox_lrx+1,
- simplerect->bbox_lry+1);
+ simplerect->bbox_lrx+0.5,
+ simplerect->bbox_lry+0.5);
simplerect->full_draw_on_update = FALSE;
}
UINT_TO_RGBA (simplerect->outline_color, &simplerect->outline_r, &simplerect->outline_g, &simplerect->outline_b, &foo);
}
-#define SIMPLERECT_FAST_RENDERER
+// this can be useful for debugging/understanding how the canvas redraws
+// stuff.
+
+#undef HARLEQUIN_DEBUGGING
+
+#undef SIMPLERECT_FAST_RENDERER
#ifdef SIMPLERECT_FAST_RENDERER
static void
if (parent_class->render) {
(*parent_class->render) (item, buf);
}
-
+
if (buf->is_bg) {
- // this can be useful for debugging/understanding how the canvas redraws
- // stuff.
-
- // gint randr, randg, randb;
- // randr = random() % 255;
- // randg = random() % 255;
- // randb = random() % 255;
- // PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
-
+#ifdef HARLEQUIN_DEBUGGING
+ gint randr, randg, randb;
+ randr = random() % 255;
+ randg = random() % 255;
+ randb = random() % 255;
+ PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
+#endif
gnome_canvas_buf_ensure_buf (buf);
buf->is_bg = FALSE;
}
// this can be useful for debugging/understanding how the canvas redraws
// stuff.
-
- // gint randr, randg, randb;
- // randr = random() % 255;
- // randg = random() % 255;
- // randb = random() % 255;
- // PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
-
- FAST_PAINT_BOX (buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a,
- intersection.x0, intersection.y0,
- intersection.x1, intersection.y1);
+
+#ifdef HARLEQUIN_DEBUGGING
+ gint randr, randg, randb;
+ randr = random() % 255;
+ randg = random() % 255;
+ randb = random() % 255;
+ PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
+#else
+ PAINT_BOX (buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a,
+ intersection.x0, intersection.y0,
+ intersection.x1, intersection.y1);
+#endif
}
if (buf->is_bg) {
- // this can be useful for debugging/understanding how the canvas redraws
- // stuff.
-
- // gint randr, randg, randb;
- // randr = random() % 255;
- // randg = random() % 255;
- // randb = random() % 255;
- // PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
-
+#ifdef HARLEQUIN_DEBUGGING
+ gint randr, randg, randb;
+ randr = random() % 255;
+ randg = random() % 255;
+ randb = random() % 255;
+ PAINT_BOX(buf, randr, randg, randb, 255, buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1);
+#endif
gnome_canvas_buf_ensure_buf (buf);
buf->is_bg = FALSE;
}
if (simplerect->fill) {
- // this can be useful for debugging/understanding how the canvas redraws
- // stuff.
-
- // gint randr, randg, randb;
- // randr = random() % 255;
- // randg = random() % 255;
- // randb = random() % 255;
- // PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
-
+#ifdef HARLEQUIN_DEBUGGING
+ gint randr, randg, randb;
+ randr = random() % 255;
+ randg = random() % 255;
+ randb = random() % 255;
+ PAINT_BOX(buf, randr, randg, randb, simplerect->fill_a, begin, sy, end, ey);
+#else
PAINT_BOX(buf, simplerect->fill_r, simplerect->fill_g, simplerect->fill_b, simplerect->fill_a, begin, sy, end, ey);
+#endif
}
for (i = 0; i < simplerect->outline_pixels; ++i) {