goocanvas.ItemSimple

goocanvas.ItemSimple — The base class for the standard canvas items.

Synopsis

class goocanvas.ItemSimple(gobject.GObject):
    def changed(recompute_bounds)
def check_in_path(x, y, cr, pointer_events)
def check_style()
def get_line_width()
def get_path_bounds(cr)
def paint_path(cr)
def set_model(model)
def user_bounds_to_device(cr, bounds)
def user_bounds_to_parent(cr, bounds)

Ancestry

+-- gobject.GObject
    +-- goocanvas.ItemSimple

goocanvas.ItemSimple Properties

"antialias"Read/WriteThe antialiasing mode to use. Default value: cairo.ANTIALIAS_DEFAULT
"clip-fill-rule"Read/WriteThe fill rule used to determine which parts of the item are clipped. Default value: cairo.FILL_RULE_WINDING
"clip-path"WriteThe sequence of commands describing the clip path of the item, specified as a string using the same syntax as in the Scalable Vector Graphics (SVG) path element. Default value: None
"fill-color"WriteThe color to use to paint the interior of the item. Default value: None
"fill-color-rgba"Read/WriteThe color to use to paint the interior of the item, specified as a 32-bit integer value. Default value: 0
"fill-pattern"Read/WriteThe pattern to use to paint the interior of the item.
"fill-pixbuf"WriteThe pixbuf to use to paint the interior of the item.
"fill-rule"Read/WriteThe fill rule used to determine which parts of the item are filled. Default value: cairo.FILL_RULE_WINDING
"font"Read/WriteThe base font to use for the text. Default value: None
"font-desc"Read/WriteThe attributes specifying which font to use.
"line-cap"Read/WriteThe line cap style to use. Default value: cairo.LINE_CAP_BUTT
"line-dash"Read/WriteThe dash pattern to use.
"line-join"Read/WriteThe line join style to use. Default value: cairo.LINE_JOIN_MITER
"line-join-miter-limit"Read/WriteThe smallest angle to use with miter joins, in degrees. Bevel joins will be used below this limit. Allowed values: >= 0 Default value: 10.
"line-width"Read/WriteThe line width to use for the item's perimeter. Allowed values: >= 0 Default value: 0
"operator"Read/WriteThe compositing operator to use. Default value: cairo.OPERATOR_OVER
"stroke-color"WriteThe color to use for the item's perimeter. Default value: None
"stroke-color-rgba"Read/WriteThe color to use for the item's perimeter, specified as a 32-bit integer value. Default value: 0
"stroke-pattern"Read/WriteThe pattern to use to paint the perimeter of the item.
"stroke-pixbuf"WriteThe pixbuf to use to draw the item's perimeter.

Known Implementation

goocanvas.ItemSimple is implementated by goocanvas.Rect goocanvas.Ellipse goocanvas.Path goocanvas.Polyline goocanvas.Text goocanvas.Image goocanvas.Group

Implemented Interfaces

goocanvas.ItemSimple implements goocanvas.Item

Description

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.)

Methods

goocanvas.ItemSimple.changed

    def changed(recompute_bounds)

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.

goocanvas.ItemSimple.check_in_path

    def check_in_path(x, y, cr, pointer_events)

x:

the x coordinate of the point.

y:

the y coordinate of the point.

cr:

a cairo context.

pointer_events:

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.

goocanvas.ItemSimple.check_style

    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.

goocanvas.ItemSimple.get_line_width

    def get_line_width()

Returns:

The item's line width.

Gets the item's line width.

goocanvas.ItemSimple.get_path_bounds

    def get_path_bounds(cr, bounds)

cr:

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

goocanvas.ItemSimple.paint_path

    def paint_path(cr)

cr:

A cairo context.

Paints the current path, using the item's style settings.

goocanvas.ItemSimple.set_model

    def set_model(model)

model:

The model that item will view.

This function should be called by subclasses of goocanvas.ItemSimple in their set_model() method.

goocanvas.ItemSimple.user_bounds_to_device

    def user_bounds_to_device(cr, bounds)

cr:

a cairo context.

bounds:

the bounds of the item, in the item's coordinate space.

Converts the item's bounds to a bounding box in device space.

goocanvas.ItemSimple.user_bounds_to_parent

    def user_bounds_to_parent(cr, bounds)

cr:

A cairo context.

bounds:

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.