90 likes | 177 Views
The CanvasWidget. The Canvas Widget. A GnomeCanvas widget can be used to: draw figures display graphics position widgets gain detailed control over position and size of widgets. The Canvas Widget.
E N D
The Canvas Widget • A GnomeCanvas widget can be used to: • draw figures • display graphics • position widgets • gain detailed control over position and size of • widgets
The Canvas Widget A GnomeCanvas may be used to display a collection of graphic structures for use in the creation of interactive or dynamic graphic displays • Each graphic object: • is independent • can be moved, resized, modified • make use of available affine transforms • can receive events from the keyboard
The Canvas Widget • Canvas items can be organized into groups in a hierarchical tree structure • Groups of items: • can be moved, resized, modified • make use of available affine transforms • can receive events from the keyboard
The Canvas Widget Canvas Items are created with the following convenience function: gnome_canvas_item_new( rootGroup, gnome_canvas_rect_get_type(), "x1",(double)10, "y1",(double)10, "x2",(double)(WIDTH - 10), "y2",(double)(HEIGHT - 10), "fill_color","white", "outline_color","black", NULL);(arguments p.742)
The Canvas Widget Possible canvas Items include: gnome_canvas_rect_get_type() gnome_canvas_line_get_type() gnome_canvas_ellipse_get_type( gnome_canvas_image_get_type() gnome_canvas_text_get_type() gnome_canvas_polygon_get_type( gnome_canvas_widget_get_type()
The Canvas Widget Canvas items may respond to signals such as mouse events: gtk_signal_connect( GTK_OBJECT(item),"event", (GtkSignalFunc)itemEvent,NULL); static gint itemEvent(GnomeCanvasItem *item, GdkEvent *event, gpointer data) { if(event->type == GDK_ENTER_NOTIFY) gnome_canvas_item_raise_to_top(item); return(0); }
The Canvas Widget Canvas items may respond to signals such as mouse events: gtk_signal_connect( GTK_OBJECT(item),"event", (GtkSignalFunc)itemEvent,NULL); static gint itemEvent(GnomeCanvasItem *item, GdkEvent *event, gpointer data) { if(event->type == GDK_ENTER_NOTIFY) gnome_canvas_item_raise_to_top(item); return(0); }