root/gaphor/tags/gaphor-0.12.0/gaphor/diagram/elementitem.py

Revision 1747, 1.7 kB (checked in by arj..@yirdis.nl, 1 year ago)

renamed update() to post_update() for all diagram items.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Abstract classes for element-like Diagram items.
3 """
4
5 import gobject
6 import gaphas
7 from diagramitem import DiagramItem
8 from gaphor.diagram.style import get_text_point
9
10 __version__ = '$Revision$'
11
12 class ElementItem(gaphas.Element, DiagramItem):
13     __style__ = {
14         'min-size': (0, 0),
15         'stereotype-padding': (5, 10, 5, 10),
16     }
17
18     def __init__(self, id=None):
19         gaphas.Element.__init__(self)
20         DiagramItem.__init__(self, id)
21
22         self.min_width   = self.style.min_size[0]
23         self.min_height  = self.style.min_size[1]
24         self.auto_resize = 0
25
26     def save(self, save_func):
27         save_func('matrix', tuple(self.matrix))
28         for prop in ('width', 'height'):
29             self.save_property(save_func, prop)
30         DiagramItem.save(self, save_func)
31
32     def load(self, name, value):
33         if name == 'matrix':
34             self.matrix = eval(value)
35         else:
36             DiagramItem.load(self, name, value)
37
38     def pre_update(self, context):
39         #super(ElementItem, self).pre_update(context)
40         self.update_stereotype()
41         DiagramItem.pre_update(self, context)
42         gaphas.Element.pre_update(self, context)
43
44
45     def point(self, x, y):
46         d1 = gaphas.Element.point(self, x, y)
47         d2 = DiagramItem.point(self, x, y)
48         return min(d1, d2)
49
50
51     def post_update(self, context):
52         gaphas.Element.post_update(self, context)
53         DiagramItem.post_update(self, context)
54
55
56     def draw(self, context):
57         gaphas.Element.draw(self, context)
58         DiagramItem.draw(self, context)
59
60
61     def text_align(self, extents, align, padding, outside):
62         x, y = get_text_point(extents, self.width, self.height,
63                 align, padding, outside)
64
65         return x, y
66
67
68 # vim:sw=4
Note: See TracBrowser for help on using the browser.