[gnome-love] Re:Canvas width



Try this (work for me, no other garanties):

Gonzalo.

gboolean
move_ok(GnomeCanvasItem *item,double* mov_x,double* mov_y)
{
 double x1, y1, x2, y2;
 gboolean ok = TRUE;

 gnome_canvas_item_get_bounds(item, &x1, &y1, &x2, &y2);
 gnome_canvas_world_to_window(item->canvas, x1, y1,&x1,&y1);
 gnome_canvas_world_to_window(item->canvas, x2, y2,&x2,&y2);

    if ((x1<= 0) && (*mov_x <= 0)) {
      *mov_x = 0;
      ok = FALSE;
 }
 if ((y1<= 0) && (*mov_y <= 0)){
     *mov_y = 0;
     ok = FALSE;
 }
 if ((x2>= GTK_LAYOUT(item->canvas)->width) && (*mov_x >= 0)) {
  *mov_x = 0;
     ok = FALSE;
 }
 if ((y2>= GTK_LAYOUT(item->canvas)->height) && (*mov_y >= 0)) {
  *mov_y = 0;
     ok = FALSE;
 }
 return ok;
}







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