Changeset 3859
- Timestamp:
- 01/12/08 05:26:07 (11 months ago)
- Files:
-
- trunk/ide/MenuBarPanel.py (modified) (4 diffs)
- trunk/ide/MenuDesignerComponents.py (modified) (11 diffs)
- trunk/ide/MenuDesignerForm.py (modified) (2 diffs)
- trunk/ide/MenuPanel.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ide/MenuBarPanel.py
r3515 r3859 30 30 31 31 def appendMenu(self, caption, useMRU=False): 32 mn = MenuPanel(self, Caption=caption, MRU=useMRU, Visible= self.Visible)32 mn = MenuPanel(self, Caption=caption, MRU=useMRU, Visible=True) 33 33 self.Sizer.append(mn) 34 dabo.ui.callAfterInterval(500, self._setNewMenu, mn)34 # dabo.ui.callAfterInterval(500, self._setNewMenu, mn) 35 35 self.fit() 36 36 self.Controller.updateLayout() 37 37 return mn 38 38 39 40 def _setNewMenu(self, mn):41 mn.PanelVisible = True42 dabo.ui.setAfterInterval(500, mn, "PanelVisible", False)43 44 39 45 40 def insertMenu(self, pos, caption, useMRU=False): … … 52 47 53 48 def menuClick(self, menu): 49 self.select(menu) 50 51 52 def select(self, menu): 54 53 self.Controller.Selection = menu 55 54 menu.PanelVisible = True 56 57 55 56 58 57 def fit(self): 59 58 self.layout(resetMin=True) … … 214 213 self.appendMenu(_("View"), False) 215 214 self.appendMenu(_("Help"), False) 215 216 for kid in self.Children: 217 kid.Visible = True 216 218 self.layout() 217 219 self.fitToSizer() 220 221 self.select(fm) 218 222 self.Form.unlockDisplay() 219 dabo.ui.callAfterInterval(100, self._cleanupQuickMenu, fm) 220 def _cleanupQuickMenu(self, itm): 221 self.Form.select(itm) 222 dabo.ui.callAfterInterval(100, self.Form.refresh) 223 self.Form.refresh() 224 225 226 # dabo.ui.callAfterInterval(100, self._cleanupQuickMenu, fm) 227 # def _cleanupQuickMenu(self, itm): 228 # self.Form.select(itm) 229 # dabo.ui.callAfterInterval(100, self.Form.refresh) 223 230 224 231 … … 267 274 Menus = property(_getMenus, None, None, 268 275 _("List of all menus in this menubar (list of MenuPanels)")) 269 270 trunk/ide/MenuDesignerComponents.py
r3515 r3859 5 5 from dabo.dLocalize import _ 6 6 import dabo.dEvents as dEvents 7 from dabo.ui import makeDynamicProperty 8 from dabo.ui import makeProxyProperty 7 9 8 10 … … 57 59 # Displayed name 58 60 _commonName = "Generic Item" 61 _kids = [] 59 62 60 63 def __init__(self, parent, *args, **kwargs): 61 64 self._caption = "" 62 65 self._MRU = False 66 self._selected = False 63 67 self._inUpdate = False 64 68 # The draw object representing the Caption … … 83 87 self.BorderColor = (222, 222, 222) 84 88 self.Height = 24 85 self. BackColor = self._unselectedBackColor = "white"89 self._unselectedBackColor = "white" 86 90 self._selectedBackColor = (255, 255, 192) 87 91 self._unselectedForeColor = "black" … … 89 93 # This is the background draw object 90 94 self._background = self.drawRectangle(0, 0, -1, -1, 91 penWidth=0, fillColor=self._unselectedBackColor) 92 self._selected = False 93 self._capText = self.drawText(self.Caption, 5, 5) 94 self._hotKeyText = self.drawText(self.AbbreviatedHotKey, 5, 5) 95 penWidth=0, fillColor=self._unselectedBackColor, visible=False) 96 self._capText = self.drawText(self.Caption, 5, 5, visible=False) 97 self._hotKeyText = self.drawText(self.AbbreviatedHotKey, 5, 5, visible=False) 98 self.DynamicBackColor = self.getBack #lambda: {True: self._selectedBackColor, False: self._unselectedBackColor}[self._selected] 99 self._background.DynamicFillColor = self._capText.DynamicFillColor = \ 100 self._hotKeyText.DynamicFillColor = self.getBack #lambda: {True: self._selectedBackColor, False: self._unselectedBackColor}[self._selected] 101 self._capText.DynamicForeColor = lambda: {True: self._selectedForeColor, False: self._unselectedForeColor}[self._selected] 95 102 # This will allow the hot key text position to stay right-aligned. 96 103 self._hotKeyText.DynamicXpos = self.positionHotKeyText … … 107 114 self.Buffered = True 108 115 109 116 self._kids = [self._background, self._hotKeyText, self._capText] 117 118 def getBack(self): 119 print "BACK", 120 try: 121 print self.Caption 122 except AttributeError: 123 print self.Shape, self 124 print "SELECTED:", self._selected 125 if self._selected: 126 ret = self._selectedBackColor 127 else: 128 ret = self._unselectedBackColor 129 print "RETURNING", ret 130 print 131 return ret 132 133 110 134 # These two methods will display the item's HelpText 111 135 # in the form's Status Bar when the mouse is over them. … … 150 174 addlwd += self._captionHotKeySpacing 151 175 calc = capwd + hkwd + addlwd 176 177 print "WID", self.Caption, calc 152 178 if curr < calc: 153 179 self.Width = calc … … 179 205 super(CaptionPanel, self).refresh() 180 206 self.setWidth() 207 print "PAR UP REF", self, self.Parent 181 208 self.Parent.update() 182 209 self.Parent.layout() … … 362 389 def _setSelected(self, val): 363 390 if self._constructed(): 391 print "SETSEL", self.Caption, val 364 392 self._selected = val 365 self.clear()366 self.lockDisplay()367 backcolor = {True: self._selectedBackColor,368 False: self._unselectedBackColor}[val]369 forecolor = {True: self._selectedForeColor,370 False: self._unselectedForeColor}[val]371 self._capText.ForeColor = self._capText.PenColor = forecolor372 self._capText.FontBold = val373 self.BackColor = self._background.FillColor = backcolor393 # self.clear() 394 # self.lockDisplay() 395 # backcolor = {True: self._selectedBackColor, 396 # False: self._unselectedBackColor}[val] 397 # forecolor = {True: self._selectedForeColor, 398 # False: self._unselectedForeColor}[val] 399 # self._capText.ForeColor = self._capText.PenColor = forecolor 400 # self._capText.FontBold = val 401 # self.BackColor = self._background.FillColor = backcolor 374 402 self.Parent.refresh() 375 self.unlockDisplay()403 # self.unlockDisplay() 376 404 else: 377 405 self._properties["Selected"] = val … … 429 457 430 458 459 _proxyDict = {} 460 Visible = makeProxyProperty(_proxyDict, "Visible", ("self", "_kids")) 431 461 432 462 … … 466 496 # Remove it. 467 497 self.removeDrawnObject(self._bmp) 498 self._kids.remove(self._bmp) 468 499 self._bmp = None 469 self._bmp = self.drawBitmap(bmp, 5, 5) 500 self._bmp = self.drawBitmap(bmp, 5, 5, visible=self.Parent.Visible) 501 502 self._kids.append(self._bmp) 503 470 504 wd = self._bmp.Width 471 505 # Move the text over to fit … … 520 554 self._line.DynamicPoints = self.setLineWidth 521 555 self._line.DynamicPenWidth = self.setLineThick 556 self._kids.append(self._line) 557 522 558 523 559 def onResize(self, evt): trunk/ide/MenuDesignerForm.py
r3662 r3859 86 86 def initialLayout(self): 87 87 # print "INITLAY" 88 #self.menubar.clear()89 #self.mainPanel.clear()88 self.menubar.clear() 89 self.mainPanel.clear() 90 90 self.menubar.quickMenu() 91 91 self.layout() … … 195 195 196 196 def select(self, obj): 197 #try: print "SELE", obj.Caption198 #except: print "SELE NONE"197 try: print "SELE", obj.Caption 198 except: print "SELE NONE" 199 199 if obj is self._selection: 200 #print "SAME"200 print "SAME" 201 201 return 202 202 self.lockDisplay() 203 203 if self._selection is not None: 204 #print "UNSEL", self._selection.Caption204 print "UNSEL", self._selection.Caption 205 205 self._selection.Selected = False 206 206 self._selection = obj 207 207 self.PropForm.select(obj) 208 #print "OBJ.SELECTED"208 print "OBJ.SELECTED" 209 209 obj.Selected = True 210 #try: print "ENSURE", obj.Caption211 #except: print "eENSEURE NONE"210 try: print "ENSURE", obj.Caption 211 except: print "eENSEURE NONE" 212 212 213 213 self.ensureVisible(obj) 214 214 dabo.ui.callAfterInterval(100, self._selectAfter) 215 215 def _selectAfter(self): 216 # try: print "SELE AFT", self._selection.Caption 217 # except: print "SELE AFT NONE" 216 try: print "SELE AFT", self._selection.Caption 217 except: print "SELE AFT NONE" 218 self.update() 218 219 self.refresh() 219 220 self.unlockDisplay() trunk/ide/MenuPanel.py
r3662 r3859 9 9 from MenuDesignerComponents import CaptionBitmapPanel 10 10 from MenuDesignerComponents import SeparatorPanel 11 from dabo.ui import makeDynamicProperty 12 from dabo.ui import makeProxyProperty 11 13 12 14 … … 26 28 self._controller = None 27 29 super(_ItemPanel, self).__init__(*args, **kwargs) 28 30 self.DynamicWidth = self._calcWidth 31 32 def _calcWidth(self): 33 kids = self.Children 34 if not kids: 35 return 0 36 else: 37 wd = max([kid.Width for kid in kids]) 38 dabo.ui.callAfter(self._resizeItems, wd) 39 return wd 40 41 def _resizeItems(self, wd): 42 if not self: 43 return 44 for kid in self.Children: 45 kid.Width = wd 46 self.layout() 47 self.refresh() 48 29 49 def processContextMenu(self, obj, evt): 30 50 self.Controller.processContextMenu(obj, evt) … … 38 58 Controller = property(_getController, _setController, None, 39 59 _("Object to which this panel is associated (MenuPanel)")) 60 40 61 41 62 # Add the panel that will hold the menu items. It needs to … … 64 85 65 86 66 def layout(self):67 dabo.ui.callAfterInterval(100, self.itemList.layout, resetMin=True)68 dabo.ui.callAfterInterval(100, self.itemList.fitToSizer)87 # def layout(self): 88 # dabo.ui.callAfterInterval(100, self.itemList.layout, resetMin=True) 89 # dabo.ui.callAfterInterval(100, self.itemList.fitToSizer) 69 90 70 91 … … 81 102 pos = len(self.itemList.Children) 82 103 if separator: 83 itm = SeparatorPanel(self.itemList, Controller=self )104 itm = SeparatorPanel(self.itemList, Controller=self, Visible=False) 84 105 else: 85 106 itm = CaptionBitmapPanel(self.itemList, Caption=caption, 86 Controller=self, Visible= self.Visible)107 Controller=self, Visible=False) 87 108 itm._className = "MenuItemPanel" 88 109 itm._commonName = "Menu Item" … … 94 115 itm.Picture = picture 95 116 117 itm.Visible = True 96 118 self.itemList.Height += itm.Height 97 119 self.itemList.Sizer.insert(pos, itm, "x") … … 223 245 224 246 def _getChildren(self): 225 return self.itemList.Children 247 try: 248 return self.itemList.Children 249 except AttributeError: 250 return [] 226 251 227 252 … … 230 255 231 256 def _setPanelVisible(self, val): 232 # print "SETVIS", self.Caption, val233 257 if val: 234 258 localPos = (self.Left, self.Bottom) … … 236 260 self.itemList.Position = formPos 237 261 self.Controller.onShowPanel(self) 262 # self.Visible = val 238 263 self.itemList.Visible = val 264 265 # itms = self._proxyDict.get("Visible", ()) 266 # for xx in itms: 267 # if xx == "Children": 268 # for xkid in self.Children: 269 # elif xx == "self": 270 # print "SELF ITEMLIST", self.itemList.Visible 271 # else: 272 # obj = getattr(self, xx) 273 # print xx, obj.Visible 274 275 self.itemList.update() 239 276 self.itemList.Parent.clear() 240 277 self.layout() 241 self.itemList.Parent.refresh()278 # self.itemList.Parent.refresh() 242 279 243 280 … … 247 284 PanelVisible = property(_getPanelVisible, _setPanelVisible, None, 248 285 _("Determines if the menu is currently 'open' (bool)")) 249 250 251 286 287 288 _proxyDict = {} 289 Visible = makeProxyProperty(_proxyDict, "Visible", ("self", "Children", "_capText"))
