13 'The x coordinate of a SVG image',
17 gobject.PARAM_READWRITE),
21 'The y coordinate of a SVG image',
25 gobject.PARAM_READWRITE),
29 'The width of the SVG Image',
33 gobject.PARAM_READWRITE),
37 'The width of the SVG Image',
41 gobject.PARAM_READWRITE),
44 def __init__(self, x, y, rsvg_handle, **kwargs):
45 super(SvgItem, self).__init__(**kwargs)
46 assert isinstance(rsvg_handle, rsvg.Handle)
52 self.
width = self.handle.props.width
53 self.
height = self.handle.props.height
57 def do_set_property(self, pspec, value):
64 elif pspec.name ==
'y':
70 elif pspec.name ==
'width':
77 elif pspec.name ==
'height':
85 raise AttributeError,
'unknown property %s' % pspec.name
87 def _size_changed(self):
89 self.
width = self.handle.props.width
90 self.
height = self.handle.props.height
97 self.
height = self.handle.props.height*self.
sy
102 self.
width = self.handle.props.width*self.
sx
109 def do_get_property(self, pspec):
110 if pspec.name ==
'x':
113 elif pspec.name ==
'y':
116 elif pspec.name ==
'width':
117 self.
width = self.handle.props.width
118 self.
height = self.handle.props.height
122 elif pspec.name ==
'height':
126 raise AttributeError,
'unknown property %s' % pspec.name
128 def do_simple_paint(self, cr, bounds):
129 cr.translate(self.
x, self.
y)
130 cr.scale(self.
sx, self.
sy)
131 self.handle.render_cairo(cr)
133 def do_simple_update(self, cr):
139 def do_simple_is_item_at(self, x, y, cr, is_pointer_event):
140 if ((x < self.
x)
or (x > self.
x + self.
width))
or ((y < self.
y)
or (y > self.
y + self.
height)):
148 def rsvg_handle_factory(base_file_name):
150 return _rsvg_cache[base_file_name]
152 full_path = os.path.join(os.path.dirname(__file__),
'resource', base_file_name)
153 rsvg_handle = rsvg.Handle(full_path)
154 _rsvg_cache[base_file_name] = rsvg_handle