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:
@@ -89,9 +89,10 @@ class Panel(wxNotebook):
|
|||||||
g.currentXXX = xxx.treeObject()
|
g.currentXXX = xxx.treeObject()
|
||||||
try:
|
try:
|
||||||
page = self.pageCache[xxx.__class__]
|
page = self.pageCache[xxx.__class__]
|
||||||
|
page.box.SetLabel(xxx.panelName())
|
||||||
page.Reparent(self.page1)
|
page.Reparent(self.page1)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
page = PropPage(self.page1, xxx.className, xxx)
|
page = PropPage(self.page1, xxx.panelName(), xxx)
|
||||||
self.pageCache[xxx.__class__] = page
|
self.pageCache[xxx.__class__] = page
|
||||||
page.SetValues(xxx)
|
page.SetValues(xxx)
|
||||||
self.pages.append(page)
|
self.pages.append(page)
|
||||||
@@ -101,9 +102,10 @@ class Panel(wxNotebook):
|
|||||||
cacheID = (xxx.child.__class__, xxx.__class__)
|
cacheID = (xxx.child.__class__, xxx.__class__)
|
||||||
try:
|
try:
|
||||||
page = self.pageCache[cacheID]
|
page = self.pageCache[cacheID]
|
||||||
|
page.box.SetLabel(xxx.child.panelName())
|
||||||
page.Reparent(self.page1)
|
page.Reparent(self.page1)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
page = PropPage(self.page1, xxx.child.className, xxx.child)
|
page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
|
||||||
self.pageCache[cacheID] = page
|
self.pageCache[cacheID] = page
|
||||||
page.SetValues(xxx.child)
|
page.SetValues(xxx.child)
|
||||||
self.pages.append(page)
|
self.pages.append(page)
|
||||||
@@ -253,9 +255,9 @@ class ParamPage(wxPanel):
|
|||||||
class PropPage(ParamPage):
|
class PropPage(ParamPage):
|
||||||
def __init__(self, parent, label, xxx):
|
def __init__(self, parent, label, xxx):
|
||||||
ParamPage.__init__(self, parent, xxx)
|
ParamPage.__init__(self, parent, xxx)
|
||||||
box = wxStaticBox(self, -1, label)
|
self.box = wxStaticBox(self, -1, label)
|
||||||
box.SetFont(labelFont)
|
self.box.SetFont(labelFont)
|
||||||
topSizer = wxStaticBoxSizer(box, wxVERTICAL)
|
topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
|
||||||
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
|
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 1, 1)
|
||||||
sizer.AddGrowableCol(1)
|
sizer.AddGrowableCol(1)
|
||||||
if xxx.hasName:
|
if xxx.hasName:
|
||||||
|
@@ -95,6 +95,7 @@ class PullDownMenu:
|
|||||||
ID_EXPAND = wxNewId()
|
ID_EXPAND = wxNewId()
|
||||||
ID_COLLAPSE = wxNewId()
|
ID_COLLAPSE = wxNewId()
|
||||||
ID_PASTE_SIBLING = wxNewId()
|
ID_PASTE_SIBLING = wxNewId()
|
||||||
|
ID_SUBCLASS = wxNewId()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.ID_DELETE = parent.ID_DELETE
|
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_COLLAPSE, parent.OnCollapse)
|
||||||
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
|
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
|
||||||
EVT_MENU(parent, self.ID_PASTE_SIBLING, parent.OnPaste)
|
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
|
# We connect to tree, but process in frame
|
||||||
EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
|
EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
|
||||||
|
|
||||||
@@ -903,6 +905,8 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
id = wxNewId()
|
id = wxNewId()
|
||||||
menu.AppendMenu(id, 'Replace With', m)
|
menu.AppendMenu(id, 'Replace With', m)
|
||||||
if not m.GetMenuItemCount(): menu.Enable(id, False)
|
if not m.GetMenuItemCount(): menu.Enable(id, False)
|
||||||
|
menu.Append(pullDownMenu.ID_SUBCLASS, 'Subclass...',
|
||||||
|
'Set subclass property')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
# Not using standart IDs because we don't want to show shortcuts
|
# Not using standart IDs because we don't want to show shortcuts
|
||||||
menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard')
|
menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard')
|
||||||
|
@@ -473,6 +473,25 @@ class Frame(wxFrame):
|
|||||||
self.modified = True
|
self.modified = True
|
||||||
self.SetStatusText(status)
|
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):
|
def OnSelect(self, evt):
|
||||||
print >> sys.stderr, 'Xperimental function!'
|
print >> sys.stderr, 'Xperimental function!'
|
||||||
wxYield()
|
wxYield()
|
||||||
|
@@ -207,6 +207,7 @@ class xxxObject:
|
|||||||
self.undo = None
|
self.undo = None
|
||||||
# Get attributes
|
# Get attributes
|
||||||
self.className = element.getAttribute('class')
|
self.className = element.getAttribute('class')
|
||||||
|
self.subclass = element.getAttribute('subclass')
|
||||||
if self.hasName: self.name = element.getAttribute('name')
|
if self.hasName: self.name = element.getAttribute('name')
|
||||||
# Set parameters (text element children)
|
# Set parameters (text element children)
|
||||||
self.params = {}
|
self.params = {}
|
||||||
@@ -277,8 +278,14 @@ class xxxObject:
|
|||||||
# Class name plus wx name
|
# Class name plus wx name
|
||||||
def treeName(self):
|
def treeName(self):
|
||||||
if self.hasChild: return self.child.treeName()
|
if self.hasChild: return self.child.treeName()
|
||||||
if self.hasName and self.name: return self.className + ' "' + self.name + '"'
|
if self.subclass: className = self.subclass
|
||||||
return self.className
|
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
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user