g.currentXXX = xxx.treeObject()
try:
page = self.pageCache[xxx.__class__]
+ page.box.SetLabel(xxx.panelName())
page.Reparent(self.page1)
except KeyError:
- page = PropPage(self.page1, xxx.className, xxx)
+ page = PropPage(self.page1, xxx.panelName(), xxx)
self.pageCache[xxx.__class__] = page
page.SetValues(xxx)
self.pages.append(page)
cacheID = (xxx.child.__class__, xxx.__class__)
try:
page = self.pageCache[cacheID]
+ page.box.SetLabel(xxx.child.panelName())
page.Reparent(self.page1)
except KeyError:
- page = PropPage(self.page1, xxx.child.className, xxx.child)
+ page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
self.pageCache[cacheID] = page
page.SetValues(xxx.child)
self.pages.append(page)
class PropPage(ParamPage):
def __init__(self, parent, label, xxx):
ParamPage.__init__(self, parent, xxx)
- box = wxStaticBox(self, -1, label)
- box.SetFont(labelFont)
- topSizer = wxStaticBoxSizer(box, wxVERTICAL)
+ self.box = wxStaticBox(self, -1, label)
+ self.box.SetFont(labelFont)
+ topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
sizer.AddGrowableCol(1)
if xxx.hasName:
ID_EXPAND = wxNewId()
ID_COLLAPSE = wxNewId()
ID_PASTE_SIBLING = wxNewId()
+ ID_SUBCLASS = wxNewId()
def __init__(self, parent):
self.ID_DELETE = parent.ID_DELETE
EVT_MENU(parent, self.ID_COLLAPSE, parent.OnCollapse)
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
EVT_MENU(parent, self.ID_PASTE_SIBLING, parent.OnPaste)
+ EVT_MENU(parent, self.ID_SUBCLASS, parent.OnSubclass)
# We connect to tree, but process in frame
EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
id = wxNewId()
menu.AppendMenu(id, 'Replace With', m)
if not m.GetMenuItemCount(): menu.Enable(id, False)
+ menu.Append(pullDownMenu.ID_SUBCLASS, 'Subclass...',
+ 'Set subclass property')
menu.AppendSeparator()
# Not using standart IDs because we don't want to show shortcuts
menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard')
self.modified = True
self.SetStatusText(status)
+ def OnSubclass(self, evt):
+ selected = tree.selection
+ xxx = tree.GetPyData(selected).treeObject()
+ elem = xxx.element
+ subclass = xxx.subclass
+ dlg = wxTextEntryDialog(self, 'Subclass:', defaultValue=subclass)
+ if dlg.ShowModal() == wxID_OK:
+ subclass = dlg.GetValue()
+ if subclass:
+ elem.setAttribute('subclass', subclass)
+ self.modified = True
+ elif elem.hasAttribute('subclass'):
+ elem.removeAttribute('subclass')
+ self.modified = True
+ xxx.subclass = elem.getAttribute('subclass')
+ tree.SetItemText(selected, xxx.treeName())
+ panel.pages[0].box.SetLabel(xxx.panelName())
+ dlg.Destroy()
+
def OnSelect(self, evt):
print >> sys.stderr, 'Xperimental function!'
wxYield()
self.undo = None
# Get attributes
self.className = element.getAttribute('class')
+ self.subclass = element.getAttribute('subclass')
if self.hasName: self.name = element.getAttribute('name')
# Set parameters (text element children)
self.params = {}
# Class name plus wx name
def treeName(self):
if self.hasChild: return self.child.treeName()
- if self.hasName and self.name: return self.className + ' "' + self.name + '"'
- return self.className
+ if self.subclass: className = self.subclass
+ else: className = self.className
+ if self.hasName and self.name: return className + ' "' + self.name + '"'
+ return className
+ # Class name or subclass
+ def panelName(self):
+ if self.subclass: return self.subclass + '(' + self.className + ')'
+ else: return self.className
################################################################################