The bounds method
computes the approximate bounding box of a canvas item.
In Gnome 1.0, this method is only used in gnome_canvas_item_get_bounds(), a
user-visible function to return the bounds of a canvas
item. The canvas does not use it at all internally, and
most likely you could get away without implementing it,
though all the stock items do.
The function should return an item's bounding box in item
coordinates; here is the
GnomeCanvasRE version:
static void
gnome_canvas_re_bounds (GnomeCanvasItem *item,
double *x1, double *y1,
double *x2, double *y2)
{
GnomeCanvasRE *re;
double hwidth;
re = GNOME_CANVAS_RE (item);
if (re->width_pixels)
hwidth = (re->width / item->canvas->pixels_per_unit) / 2.0;
else
hwidth = re->width / 2.0;
*x1 = re->x1 - hwidth;
*y1 = re->y1 - hwidth;
*x2 = re->x2 + hwidth;
*y2 = re->y2 + hwidth;
}
|