goocanvas.Canvas — The Canvas
goocanvas.Canvas extends, gtk.Container {goocanvas.Canvas();convert_bounds_to_item_space(item,
bounds);convert_from_item_space(item,
x,
y);convert_to_item_space(item,
x,
y);convert_from_pixel(x,
y);convert_to_pixel(x,
y);create_cairo_context();create_item(model);get_bounds();get_default_line_width();get_item(model);get_item_at(x,
y,
is_pointer_event);get_items_at(x,
y,
is_pointer_event);get_items_in_area(area,
inside_area,
allow_overlaps,
including_containers);get_root_item();get_root_item_model();get_scale();get_static_root_item();get_static_root_item_model();grab_focus(item);keyboard_grab(item,
owner_events,
time);keyboard_ungrab(item,
time);pointer_grab(item,
event_mask,
cursor,
time);pointer_ungrab(item,
time);register_widget_item(witem);render(cr,
bounds,
scale);request_item_redraw(bounds,
is_static);request_redraw(bounds);request_update();scroll_to(left,
top);set_bounds(left,
top,
right,
bottom);set_root_item(item);set_root_item_model(model);set_scale(scale);set_static_root_item(item);set_static_root_item_model(model);unregister_item(model);unregister_widget_item(witem);update();
}
"anchor" Read/Write Where to place the canvas when it is smaller than the widget's allocated area. Default value: gtk.ANCHOR_NORTH_WEST "automatic-bounds" Read/Write If the bounds are automatically calculated based on the bounds of all the items in the canvas. "bounds-from-origin" Read/Write If the automatic bounds are calculated from the origin. "bounds-padding" Read/Write The padding added to the automatic bounds. "clear-background" Read/Write If the background is cleared before the canvas is painted. Default value: True"integer-layout" Read/Write If all item layout is done to the nearest integer. "redraw-when-scrolled" Read/Write If the canvas is completely redrawn when scrolled, to reduce the flicker of static items. Default value: False."resolution-x" Read/Write The horizontal resolution of the display, in dots per inch. Allowed values: >= 0 Default value: 96 "resolution-y" Read/Write The vertical resolution of the display, in dots per inch. Allowed values: >= 0 Default value: 96 "scale" Read/Write The number of pixels to use for each device unit. Allowed values: >= 0 Default value: 1 "scale-x" Read/Write The horizontal magnification factor of the canvas. "scale-y" Read/Write The vertical magnification factor of the canvas. "x1" Read/Write The x coordinate of the left edge of the canvas bounds, in device units. Default value: 0. "x2" Read/Write The x coordinate of the right edge of the canvas bounds, in device units. Default value: 1000. "y1" Read/Write The y coordinate at the top edge of the canvas bounds, in device units. Default value: 0. "y2" Read/Write The y coordinate at the bottom edge of the canvas bounds, in device units. Default value: 1000.
callback(canvas,
| |
callback(canvas_view,
|
convert_bounds_to_item_space(item,
bounds);
| A goocanvas.Item |
| the bounds in device space. |
Converts the bound in device space to a bounding box in item space. This is useful in the item paint() methods to convert the bounds to be painted to the item's coordinate space.
convert_from_item_space(item,
x,
y);
| A goocanvas.Item |
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns : | The new x and y coordinates. |
Converts a coordinate from the given item's coordinate space to the canvas coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
convert_from_pixel(x,
y);
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns : | The new x and y coordinates. |
Converts a coordinate from pixels to the canvas coordinate space.
The pixel coordinate space specifies pixels from the top-left of the entire canvas window,
according to the current scale setting. See
set_scale().
The canvas view coordinate space is specified in the call to
set_bounds().
convert_to_item_space(item,
x,
y);
| A goocanvas.Item |
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns : | The new x and y coordinates. |
Converts a coordinate from the canvas coordinate space to the given item's coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
convert_to_pixel(x,
y);
| The x coordinate to convert. |
| The y coordinate to convert. |
Returns : | The new x and y coordinates. |
Converts a coordinate from the canvas coordinate space to pixels.
The canvas coordinate space is specified in the call to
set_bounds
The pixel coordinate space specifies pixels from the top-left of the entire canvas window,
according to the current scale setting. See
set_scale
create_cairo_context();
Returns : | a new cairo context. |
Creates a cairo context, initialized with the default canvas settings.
create_item(model);
| The item model to create a canvas item for. |
Returns : | A new canvas item. |
Creates a new canvas item for the given item model, and recursively creates items for any children. It uses the create_item virtual method if it has been set. Subclasses of GooCanvas can define this method if they want to use custom views for items. It emits the "item-created" signal after creating the view, so application code can connect signal handlers to the new view if desired.
get_bounds();
Returns : | A tuple with the four coordinates. |
Gets the bounds of the canvas, in canvas units. By default, canvas units are pixels, though the GooCanvas:units property can be used to change the units to points, inches or millimeters.
get_default_line_width();
Returns : | The default line width of the canvas. |
Gets the default line width, which depends on the current units setting.
get_item(model);
| A
goocanvas.ItemModel
|
Returns : | The canvas item corresponding to the given
goocanvas.ItemModel
or None if no canvas item has been created for it yet.
|
Gets the canvas item associated with the given
goocanvas.ItemModel.
This is only useful when set_root_item_model
has been used to set a model for the canvas.
For simple applications you can use get_item to set up signal handlers for your items, e.g.
item = canvas.get_item (my_item)
item.connect ("button_press_event", on_my_item_button_press)
More complex applications may want to use the GooCanvas::item-created signal to hook up their signal handlers.
get_item_at(x,
y,
is_pointer_event);
| The x coordinate of the point. |
| The y coordinate of the point. |
| True if the "pointer-events" property of items should be used to determine which parts of the item are tested. |
Returns : | The item found at the given point, or None if no item was found. |
Gets the item at the given point.
get_items_at(x,
y,
is_pointer_event);
| The x coordinate of the point. |
| The y coordinate of the point. |
| True if the "pointer-events" property of items should be used to determine which parts of the item are tested. |
Returns : | A list of items found at the given point, with the top item at the start of the list, or None if no items were found. |
Gets all items at the given point.
get_items_in_area(area,
inside_area,
allow_overlaps,
include_containers);
| The area to compare with each item's bounds. |
| True if items inside area should be returned, or False if items outside area should be returned. |
| True if items which are partly inside and partly outside should be returned. |
| True if containers should be checked as well as normal items. |
Returns : | A list of items in the given area, or None if no items are found. |
Gets a list of items inside or outside a given area.
get_root_item();
Returns : | The root item, or None if there is no root item. |
Gets the root item of the canvas, usually a
goocanvas.Group.
get_root_item_model();
Returns : | The root item model, or None if there is no root item. |
Gets the root item model of the canvas, usually a
goocanvas.GroupModel.
get_scale();
Returns : | The current scale setting. |
Gets the current scale of the canvas, i.e. the number of pixels to use for each device unit.
get_static_root_item();
Returns : | the static root item, or None. |
Gets the static root item of the canvas.
get_static_root_item_model();
Returns : | the static root item model, or None. |
Gets the static root item model of the canvas.
grab_focus(item);
| The item to grab the focus. |
Grabs the keyboard focus for the given item.
keyboard_grab(item,
owner_events,
time);
| The item to grab the keyword for. |
| True if keyboard events for this application
will be reported normally, or False if all keyboard events will
be reported with respect to the grab item. |
| The time of the event that lead to the keyboard grab.
This should come from the relevant
gtk.gdk.Event
|
Returns : | gtk.gdk.GRAB_SUCCESS if the grab succeeded. |
Grabs the keyboard focus for the given item.
keyboard_grab(item,
time);
| The item that has the keyboard grab. |
| The time of the event that lead to the keyboard ungrab.
This should come from the relevant
gtk.gdk.Event
|
Ungrabs the pointer, if the given item view has the pointer grab.
pointer_grab(item,
event_mask,
cursor,
time);
| The item to grab the pointer for. |
| The events to receive during the grab. |
| The cursor to display during the grab, or None.
|
| The time of the event that lead to the pointer grab.
This should come from the relevant
gtk.gdk.Event.
|
Returns : | gtk.gdk.GRAB_SUCCESS if the grab succeeded. |
Attempts to grab the pointer for the given item.
pointer_ungrab(item,
time);
| The item that has the pointer grab. |
| The time of the event that lead to the pointer ungrab.
This should come from the relevant
gtk.gdk.Event
|
Ungrabs the pointer, if the given item view has the pointer grab.
register_widget_item(witem);
| A goocanvas.Widget.
|
Registers a widget item with the canvas, so that the canvas can do the necessary actions to move and resize the widget as needed.
This function should only be used by
goocanvas.Widget
and subclass implementations.
render(cr,
bounds,
scale);
| A cairo context. |
| The area to render, or None
to render the entire canvas. |
| The scale to compare with each item's visibility threshold to see if they should be rendered. This only affects items that have their visibility set to goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD. |
Renders all or part of a canvas to the given cairo context.
request_item_redraw(bounds,
is_static);
| the bounds of the item to redraw. |
| if the item is static. |
Requests that the given bounds be redrawn.
request_redraw(bounds);
| The bounds to redraw. |
Requests that the given bounds be redrawn.
request_update();
Schedules an update of the
goocanvas.Canvas.
This will be performed in the idle loop, after all pending events have been handled,
but before the canvas has been repainted.
scroll_to(left,
top);
| The x coordinate to scroll to. |
| The y coordinate to scroll to. |
Scrolls the canvas, placing the given point as close to the top-left of the view as possible.
set_bounds(left,
top,
right,
bottom);
| The left edge. |
| The top edge. |
| The right edge. |
| The bottom edge. |
Sets the bounds of the
goocanvas.Canvas
in device units. By default, device units are the same as pixels, though
set_scale
can be used to specify a different scale.
set_root_item(item);
| The root canvas item. |
Sets the root item of the canvas. Any existing canvas items are removed.
set_root_item_model(model);
| The root canvas item model. |
Sets the root item of the canvas. A hierarchy of canvas items will be created, corresponding to the hierarchy of items in the model. Any current canvas items will be removed.
set_scale(pixel_per_unit);
| The new scale setting. |
Sets the current scale of the canvas, i.e. the number of pixels to use for each device unit.
set_static_root_item(item);
| the static root item. |
Sets the static root item. Any existing static items are removed.
set_static_root_item_model(model);
| the static root item model. |
Sets the static root item model. Any existing static items are removed.
unregister_item(model);
| The item model whose canvas item is being finalized. |
This function should be called in the finalize method of
goocanvas.Item
objects, to remove the canvas item from the GooCanvas's hash table.
unregister_widget_item(witem);
| A
goocanvas.Widget item.
|
Unregisters a widget item from the canvas, when the item is no longer in the canvas.
This function should only be used by
goocanvas.Widget
and ubclass implementations.
update();
Updates any items that need updating.
This is only intended to be used by subclasses of
goocanvas.Canvas or
goocanvas.Item
implementation.
callback(canvas,
item,
model,
user_param,
...);
|
The goocanvas.Canvas.
|
|
The new goocanvas.Item.
|
|
The goocanvas.ItemModel.
|
| the first user parameter (if any) specified
with the connect()
method
|
| additional user parameters (if any) |
The 'item-created" signal is emitted when the a new canvas item is created. Applications can set up signal handlers for the new items here.
callback(canvas,
hadjustment,
vadjustment,
user_param,
...);
|
The goocanvas.Canvas.
|
| The horizontal adjustment. |
| The vertical adjustment. |
| the first user parameter (if any) specified
with the connect()
method
|
| additional user parameters (if any) |
The 'set-scroll-adjustments" signal is emitted when the GooCanvas is placed inside a
gtk.ScrolledWindow,
to connect up the adjustments so scrolling works properly.
It isn't useful for applications.