goocanvas.ItemSimple — The base class for the standard canvas items.
class goocanvas.ItemSimple(gobject.GObject): |
|
goocanvas.ItemSimple
is implementated by
goocanvas.Rect
goocanvas.Ellipse
goocanvas.Path
goocanvas.Polyline
goocanvas.Text
goocanvas.Image
goocanvas.Group
goocanvas.ItemSimple
is used as a base class for all of the standard canvas items.
It can also be used as the base class for new custom canvas items.
It provides default implementations for many of the
goocanvas.Item
methods.
For very simple items, all that is needed is to implement the create_path() method.
(GooCanvasEllipse, GooCanvasRect and GooCanvasPath do this.)
More complicated items need to implement the update(), paint() and get_item_at() methods.
(GooCanvasImage, GooCanvasPolyline, GooCanvasText and GooCanvasWidget do this.)
They may also need to override some of the other GooCanvasItem methods such as set_canvas(),
set_parent() or allocate_area() if special code is needed. (GooCanvasWidget does this to make
sure the GtkWidget is embedded in the GooCanvas widget correctly.)
def changed(recompute_bounds
)
| If the item's bounds need to be recomputed. |
This method is intended to be used by subclasses of
goocanvas.ItemSimple
.
It is used as a callback for the "changed" signal of the item models.
It requests an update or redraw of the item as appropriate.
def check_in_path(x
, y
, cr
, pointer_events
)
| the x coordinate of the point. |
| the y coordinate of the point. |
| a cairo context. |
| specifies which parts of the path to check. |
Returns: | True if the given point is in the current path. |
Checks if the given point is in the current path.
def check_style()
This method is intended to be used by subclasses of
goocanvas.ItemSimple
,
typically in their update() or get_requested_area() methods.
It ensures that the item's style is setup correctly. If the item has its own
goocanvas.Style
it makes sure the parent is set correctly.
If it doesn't have its own style it uses the parent item's style.
def get_line_width()
Returns: | The item's line width. |
Gets the item's line width.
def get_path_bounds(cr
, bounds
)
| A cairo context. |
Returns: | The goocanvas.Bounds holding the bounding box of the item in device space, converted to user space coordinates |
Calculates the bounds of the current path in device space, storing the results in a goocanvas.Bounds.
This method should be used only while implementing custom items
def paint_path(cr
)
| A cairo context. |
Paints the current path, using the item's style settings.
def set_model(model
)
| The model that item will view. |
This function should be called by subclasses of
goocanvas.ItemSimple
in their set_model() method.
def user_bounds_to_device(cr
, bounds
)
| a cairo context. |
| the bounds of the item, in the item's coordinate space. |
Converts the item's bounds to a bounding box in device space.
def user_bounds_to_parent(cr
, bounds
)
| A cairo context. |
| the bounds of the item, in the item's coordinate space. |
Converts the item's bounds to a bounding box in its parent's coordinate space.
If the item has no transformation matrix set then no conversion is needed.
This is typically needed when implementing the get_requested_area() method for subclasses of
goocanvas.ItemSimple
.