added subclass attribute

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25012 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Roman Rolinsky
2003-12-25 23:28:17 +00:00
parent ae071f3106
commit 2481bf3cb6
4 changed files with 39 additions and 7 deletions

View File

@@ -89,9 +89,10 @@ class Panel(wxNotebook):
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)
@@ -101,9 +102,10 @@ class Panel(wxNotebook):
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)
@@ -253,9 +255,9 @@ class ParamPage(wxPanel):
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:

View File

@@ -95,6 +95,7 @@ class PullDownMenu:
ID_EXPAND = wxNewId()
ID_COLLAPSE = wxNewId()
ID_PASTE_SIBLING = wxNewId()
ID_SUBCLASS = wxNewId()
def __init__(self, parent):
self.ID_DELETE = parent.ID_DELETE
@@ -103,6 +104,7 @@ class PullDownMenu:
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)
@@ -903,6 +905,8 @@ class XML_Tree(wxTreeCtrl):
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')

View File

@@ -473,6 +473,25 @@ class Frame(wxFrame):
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()

View File

@@ -207,6 +207,7 @@ class xxxObject:
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 = {}
@@ -277,8 +278,14 @@ class xxxObject:
# 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
################################################################################