goocanvas.CanvasView — The Canvas View
class goocanvas.CanvasView(gtk.Container): |
+-- gobject.GObject +-- gtk.Object +-- gtk.Widget +-- gtk.Container +-- goocanvas.CanvasView
gtk.Object Properties
gtk.Widget Properties
gtk.Container Properties
|
"item-view-created" | def callback( |
"set-scroll-adjustments" | def callback( |
def convert_from_item_space(item_view
, x
, y
)
item_view : | A goocanvas.CanvasItemView |
x : | The x coordinate to convert. |
y : | 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 view coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
def convert_from_pixel(x
, y
)
x : | The x coordinate to convert. |
y : | The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from pixels to the canvas view 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
.
def convert_to_item_space(item_view
, x
, y
)
item_view : | A goocanvas.CanvasItemView |
x : | The x coordinate to convert. |
y : | The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from the canvas view coordinate space to the given item's coordinate space, applying all transformation matrices including the item's own transformation matrix, if it has one.
def convert_to_pixel(x
, y
)
x : | The x coordinate to convert. |
y : | The y coordinate to convert. |
Returns: | The new x and y coordinates. |
Converts a coordinate from the canvas view coordinate space to pixels.
The canvas view 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
def create_item_view(item
, parent_view
)
item : | The the item to create a view for. |
parent_view : | The parent view of the new item. |
Returns: | A new item view. |
Creates a new item view for the given item, It emits the "item-view-created" signal after creating the view, so application code can connect signal handlers to the new view if desired.
def get_item_view_at(x
, y
, pointer_event
)
x : | The x coordinate of the point |
y : | The y coordinate of the point |
pointer_event : | True if the "pointer-events"
properties of items should be used to determine which parts
of the item are tested. |
Returns: | the item view found at the given point, or None if no item view was found. |
Gets the item view at the given point.
def get_model()
Returns: | the goocanvas.CanvasModel being displayed. |
Gets the model being displayed in the canvas.
def 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.
def grab_focus(item_view
)
item_view : | The item view to grab the focus. |
Returns: | A goocanvas.CanvasView |
Grabs the keyboard focus for the given item.
def keyboard_grab(item_view
, owner_events
, time
)
item_view : | The item view to grab the keyword for. |
owner_events : | 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 view. |
time : | 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.
def keyboard_grab(item_view
, time
)
item_view : | The item view that has the keyboard grab. |
time : | 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.
def pointer_grab(item_view
, event_mask
, cursor
, time
)
item_view : | The item view to grab the pointer for. |
event_mask : | The events to receive during the grab. |
cursor : | The cursor to display during the grab, or None .
|
time : | 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 view.
def pointer_ungrab(item_view
, time
)
item_view : | The item view that has the pointer grab. |
time : | 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.
def render(cr
, bounds
, scale
)
cr : | A cairo context. |
bounds : | The area to render, or None
to render the entire canvas. |
scale : | 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.
def request_redraw(bounds
)
bounds : | The bounds to redraw. |
Requests that the given bounds be redrawn.
def request_update()
Schedules an update of the
goocanvas.CanvasView
.
This will be performed in the idle loop, after all pending events have been handled,
but before the canvas has been repainted.
def scroll_to(left
, top
)
left : | The x coordinate to scroll to. |
top : | The y coordinate to scroll to. |
Scrolls the canvas, placing the given point as close to the top-left of the view as possible.
def set_bounds(left
, top
, right
, bottom
)
left : | The left edge. |
top : | The top edge. |
right : | The right edge. |
bottom : | The bottom edge. |
Sets the bounds of the
goocanvas.CanvasView
in device units. By default, device units are the same as pixels, though
set_scale
can be used to specify a different scale.
def set_model(model
)
model : |
A goocanvas.CanvasModel .
|
Sets the model to be displayed in the
goocanvas.CanvasView
.
A hierarchy of item views will be created, corresponding to the hierarchy of items in the model.
def set_scale(pixel_per_unit
)
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.
def update()
Updates any item views that need updating.
This is only intended to be used by subclasses of
goocanvas.CanvasView
or
goocanvas.CanvasItemView
implementation. If the bounds of items change, they will request a redraw of the old and
new bounds so the display is updated correctly.
def callback(canvas_view
, item_view
, item
, user_param
, ...
)
canvas_view : |
The goocanvas.CanvasView .
|
item_view : |
The new goocanvas.CanvasItemView .
|
item : |
The goocanvas.Item .
|
user_param : | the first user parameter (if any) specified
with the connect ()
method
|
... : | additional user parameters (if any) |
The 'item-view-created" signal is emitted when the a new item view is created. Applications can set up signal handlers for the new item views here.
def callback(canvas_view
, hadjustment
, vadjustment
, user_param
, ...
)
canvas_view : |
The goocanvas.CanvasView .
|
hadjustment : | The horizontal adjustment. |
vadjustment : | The vertical adjustment. |
user_param : | 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.