annotate engine/extensions/pychan/layout.py @ 253:6ab09eb765a1

* Added patch by MadMonk that exposes the guichan focus functions to pychan * Thanks for contributing
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 08 May 2009 08:45:27 +0000
parents 54bfd1015b35
children
rev   line source
205
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # coding: utf-8
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 from attrs import IntAttr
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 AlignTop, AlignBottom, AlignLeft, AlignRight, AlignCenter = range(5)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 def isLayouted(widget):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 return isinstance(widget,LayoutBase)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 class LayoutBase(object):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 This class is at the core of the layout engine. The two MixIn classes L{VBoxLayoutMixin}
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 and L{HBoxLayoutMixin} specialise on this by reimplementing the C{resizeToContent} and
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 the C{expandContent} methods.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 Dynamic Layouting
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 -----------------
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 The layout is calculated in the L{Widget.show} method. Thus if you modify the layout,
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 by adding or removing child widgets for example, you have to call L{widgets.Widget.adaptLayout}
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 so that the changes ripple through the widget hierachy.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 Internals
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 ---------
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 At the core the layout engine works in two passes:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 Before a root widget loaded by the XML code is shown, its resizeToContent method
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 is called recursively (walking the widget containment relation in post order).
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 This shrinks all HBoxes and VBoxes to their minimum heigt and width.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 After that the expandContent method is called recursively in the same order,
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 which will re-align the widgets if there is space left AND if a Spacer is contained.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 Inside bare Container instances (without a Layout MixIn) absolute positioning
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 can be used.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 def __init__(self,align = (AlignLeft,AlignTop), **kwargs):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 self.align = align
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 self.spacer = []
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 super(LayoutBase,self).__init__(**kwargs)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 def addSpacer(self,spacer):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 self.spacer.append(spacer)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 spacer.index = len(self.children)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 def xdelta(self,widget):return 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 def ydelta(self,widget):return 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 def _applyHeight(self, spacers = []):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 y = self.border_size + self.margins[1]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 ydelta = map(self.ydelta,self.children)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 for index, child in enumerate(self.children):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 while spacers and spacers[0].index == index:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 y += spacers.pop(0).size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 child.y = y
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 y += ydelta.pop(0)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 def _adjustHeightWithSpacer(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 pass
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 def _applyWidth(self, spacers = []):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 x = self.border_size + self.margins[0]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 xdelta = map(self.xdelta,self.children)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 for index, child in enumerate(self.children):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 while spacers and spacers[0].index == index:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 x += spacers.pop(0).size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 child.x = x
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 x += xdelta.pop(0)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 def _expandWidthSpacer(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 xdelta = map(self.xdelta,self.children)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 xdelta += [spacer.min_size for spacer in self.spacer]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 available_space = self.width - 2*self.margins[0] - 2*self.border_size - self._extra_border[0]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 used_space = sum(xdelta)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 if self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 used_space -= self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 if used_space >= available_space:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 return
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 expandable_items = self._getExpanders(vertical=False)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 #print "AS/US - before",self,[o.width for o in expandable_items]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 #print "SPACERS",self.spacer
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 index = 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 while used_space < available_space and expandable_items:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 index = index % len(expandable_items)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 expander = expandable_items[index]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 old_width = expander.width
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 expander.width += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 if old_width == expander.width:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 expandable_items.pop(index)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 else:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 used_space += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 index += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 #print "AS/US - after",self,[o.width for o in expandable_items]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 #print "SPACERS",self.spacer
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 self._applyWidth(spacers = self.spacer[:])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 def _expandHeightSpacer(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 ydelta = map(self.ydelta,self.children)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 ydelta += [spacer.min_size for spacer in self.spacer]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 available_space = self.height - 2*self.margins[1] - 2*self.border_size - self._extra_border[1]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 used_space = sum(ydelta)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 if self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 used_space -= self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 if used_space >= available_space:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 return
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 expandable_items = self._getExpanders(vertical=True)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 #print "AS/US - before",self,[o.height for o in expandable_items]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 index = 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 while used_space < available_space and expandable_items:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 index = index % len(expandable_items)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 expander = expandable_items[index]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 old_width = expander.height
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 expander.height += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 if old_width == expander.height:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 expandable_items.pop(index)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 else:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 used_space += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 index += 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 #print "AS/US - after",self,[o.height for o in expandable_items]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 self._applyHeight(spacers = self.spacer[:])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 def _getExpanders(self,vertical=True):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 expanders = []
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 spacers = self.spacer[:]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 for index, child in enumerate(self.children):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 if spacers and spacers[0].index == index:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 expanders.append( spacers.pop(0) )
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 #print self,child,child.expanding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 if child.vexpanding and vertical:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 expanders.append( child )
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 if child.hexpanding and not vertical:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 expanders.append( child )
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 return expanders + spacers
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 def _resetSpacers(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 for spacer in self.spacer:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 spacer.size = 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 class VBoxLayoutMixin(LayoutBase):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 A mixin class for a vertical layout. Do not use directly.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 def __init__(self,**kwargs):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 super(VBoxLayoutMixin,self).__init__(**kwargs)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 def resizeToContent(self, recurse = True):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 self._resetSpacers()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 max_w = self.getMaxChildrenWidth()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 x = self.margins[0] + self.border_size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 y = self.margins[1] + self.border_size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 for widget in self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 widget.width = max_w
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 y += widget.height + self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 if self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 y -= self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 y += sum([spacer.min_size for spacer in self.spacer])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 self.height = y + self.margins[1] + self.border_size + self._extra_border[1]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 self.width = max_w + 2*x + self._extra_border[0]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 self._applyHeight(spacers = self.spacer[:])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 self._applyWidth()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 def expandContent(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 self._expandHeightSpacer()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 if not self.hexpanding:return
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 for widget in self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 widget.width = self.width - 2*self.margins[0] - 2*self.border_size - self._extra_border[0]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 def ydelta(self,widget):return widget.height + self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 class HBoxLayoutMixin(LayoutBase):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 A mixin class for a horizontal layout. Do not use directly.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 def __init__(self,**kwargs):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 super(HBoxLayoutMixin,self).__init__(**kwargs)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 def resizeToContent(self, recurse = True):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 self._resetSpacers()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 max_h = self.getMaxChildrenHeight()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 x = self.margins[0] + self.border_size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 y = self.margins[1] + self.border_size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 for widget in self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 widget.height = max_h
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 x += widget.width + self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 if self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 x -= self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 x += sum([spacer.min_size for spacer in self.spacer])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 self.width = x + self.margins[0] + self._extra_border[0]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 self.height = max_h + 2*y + self._extra_border[1]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 self._applyHeight()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 self._applyWidth(spacers = self.spacer[:])
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 def expandContent(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 self._expandWidthSpacer()
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 if not self.vexpanding:return
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 for widget in self.children:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 widget.height = self.height - 2*self.margins[1] - 2*self.border_size - self._extra_border[1]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 def xdelta(self,widget):return widget.width + self.padding
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 class Spacer(object):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 """ A spacer represents expandable or fixed 'whitespace' in the GUI.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 In a XML file you can get this by adding a <Spacer /> inside a VBox or
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 HBox element (Windows implicitly are VBox elements).
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 Attributes
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 ----------
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 As with widgets a number of attributes can be set on a spacer (inside the XML definition).
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 - min_size: Int: The minimal size this Spacer is allowed to have.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 - max_size: Int: The maximal size this Spacer is allowed to have.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 - fixed_size: Int: Set min_size and max_size to the same vale - effectively a Fixed size spacer.
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 """
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 ATTRIBUTES = [
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 IntAttr('min_size'), IntAttr('size'), IntAttr('max_size'),
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 IntAttr('fixed_size'),
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 ]
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 def __init__(self,parent=None,**kwargs):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
246 self._parent = parent
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 self.min_size = 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 self.max_size = 1000
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 self.size = 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 def __str__(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 return "Spacer(parent.name='%s')" % getattr(self._parent,'name','None')
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 def __repr__(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 return "<Spacer(parent.name='%s') at %x>" % (getattr(self._parent,'name','None'),id(self))
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 def _getSize(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 self.size = self._size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 return self._size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 def _setSize(self,size):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 self._size = max(self.min_size, min(self.max_size,size))
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 size = property(_getSize,_setSize)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 # Alias for size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 width = property(_getSize,_setSize)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 height = property(_getSize,_setSize)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 def _setFixedSize(self,size):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 self.min_size = self.max_size = size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 self.size = size
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 fixed_size = property(fset=_setFixedSize)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 def _isExpanding(self):
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 if self.min_size < self.max_size:
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 return 1
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 return 0
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 vexpanding = property(_isExpanding)
54bfd1015b35 * PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 hexpanding = property(_isExpanding)