Changeset 3842
- Timestamp:
- 02/16/12 16:42:28 (15 months ago)
- Location:
- trunk/engine/python/fife/extensions/pychan/widgets
- Files:
-
- 3 edited
-
containers.py (modified) (7 diffs)
-
scrollarea.py (modified) (1 diff)
-
widget.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/engine/python/fife/extensions/pychan/widgets/containers.py
r3841 r3842 118 118 119 119 def addChild(self, widget): 120 """ 121 Adds a child widget to the container. 122 123 This makes the childs widgets visible state the same as the containers. 124 i.e. if the containter is visible the child will be as well and if the 125 container widget is hidden so will the child. The child however WILL 126 be shown when you show the container widget. If you want the child to 127 be hidden when you show the container widget you must call child.hide(). 128 """ 120 129 widget.parent = self 121 130 widget._visible = self._visible … … 123 132 self.children_position_cache.append(widget) 124 133 self.real_widget.add(widget.real_widget) 125 134 135 #update the states of the child widgets. This does not actually call 136 #the show() or hide() functions of the widget. 137 if self._visible: 138 def _show(shown_widget): 139 shown_widget._visible = True 140 141 self.deepApply(_show, shown_only=True) 142 else: 143 def _hide(hidden_widget): 144 hidden_widget._visible = False 145 146 self.deepApply(_hide) 147 126 148 def insertChild(self, widget, position): 127 149 if position > len(self.children) or 0-position > len(self.children): … … 135 157 children = self.children[0:position]+[widget]+self.children[position:] 136 158 #assert len(children) == len(self.children) + 1 137 self.removeAllChildren() 159 160 for widget in self.children: 161 self.removeChild(widget) 162 138 163 for child in children: 139 164 self.addChild(child) … … 145 170 146 171 def removeChild(self,widget): 147 if not widget in self.children :172 if not widget in self.children and not widget in self.hidden_children: 148 173 raise RuntimeError("%s does not have %s as direct child widget." % (str(self),str(widget))) 149 self.children.remove(widget) 150 self.children_position_cache.remove(widget) 151 self.real_widget.remove(widget.real_widget) 152 174 175 if widget in self.children: 176 self.children.remove(widget) 177 self.children_position_cache.remove(widget) 178 self.real_widget.remove(widget.real_widget) 179 153 180 if widget in self.hidden_children: 154 181 self.hidden_children.remove(widget) 155 182 156 183 widget.parent = None 157 184 … … 168 195 def showChild(self, child): 169 196 if not child in self.hidden_children: 170 r eturn171 197 raise RuntimeError("%s does not have %s as hidden child widget." % (str(self), str(child))) 198 172 199 self.hidden_children.remove(child) 173 200 … … 176 203 hidden_children = self.hidden_children[:] 177 204 178 self.removeAllChildren() 205 for widget in children: 206 self.removeChild(widget) 179 207 180 208 for child_widget in children_position_cache: … … 197 225 return max(widget.height for widget in self.children) 198 226 199 def deepApply(self,visitorFunc, leaves_first = True): 200 children = [] 201 children.extend(self.children) 202 children.extend(self.hidden_children) 227 def deepApply(self,visitorFunc, leaves_first = True, shown_only = False): 228 229 if not shown_only: 230 children = self.children + self.hidden_children 231 else: 232 children = self.children 203 233 204 234 if leaves_first: 205 235 for child in children: 206 child.deepApply(visitorFunc, leaves_first = leaves_first )236 child.deepApply(visitorFunc, leaves_first = leaves_first, shown_only = shown_only) 207 237 visitorFunc(self) 208 238 if not leaves_first: 209 239 for child in children: 210 child.deepApply(visitorFunc, leaves_first = leaves_first )240 child.deepApply(visitorFunc, leaves_first = leaves_first, shown_only = shown_only) 211 241 212 242 def beforeShow(self): -
trunk/engine/python/fife/extensions/pychan/widgets/scrollarea.py
r3786 r3842 104 104 content = property(_getContent,_setContent) 105 105 106 def deepApply(self,visitorFunc, leaves_first = True ):106 def deepApply(self,visitorFunc, leaves_first = True, shown_only = False): 107 107 if leaves_first: 108 if self._content: self._content.deepApply(visitorFunc, leaves_first = leaves_first )108 if self._content: self._content.deepApply(visitorFunc, leaves_first = leaves_first, shown_only = shown_only) 109 109 visitorFunc(self) 110 110 if not leaves_first: 111 if self._content: self._content.deepApply(visitorFunc, leaves_first = leaves_first )111 if self._content: self._content.deepApply(visitorFunc, leaves_first = leaves_first, shown_only = shown_only) 112 112 113 113 def resizeToContent(self,recurse=True): -
trunk/engine/python/fife/extensions/pychan/widgets/widget.py
r3786 r3842 311 311 widget._visible = True 312 312 313 self.deepApply(_show )313 self.deepApply(_show, shown_only=True) 314 314 315 315 def hide(self): … … 331 331 widget._visible = False 332 332 333 self.deepApply(_hide )333 self.deepApply(_hide, shown_only=True) 334 334 335 335 def isVisible(self): … … 766 766 self.deepApply(_callExpandContent, leaves_first=False) 767 767 768 def deepApply(self,visitorFunc, leaves_first = True ):768 def deepApply(self,visitorFunc, leaves_first = True, shown_only = False): 769 769 """ 770 770 Recursively apply a callable to all contained widgets and then the widget itself.
Note: See TracChangeset
for help on using the changeset viewer.
