StdDialogButtonSizer menu
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34854 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -72,7 +72,7 @@ class Panel(wxNotebook):
|
|||||||
# First page
|
# First page
|
||||||
# Remove current objects and sizer
|
# Remove current objects and sizer
|
||||||
sizer = self.ResetPage(self.page1)
|
sizer = self.ResetPage(self.page1)
|
||||||
if not xxx or (not xxx.allParams and not xxx.hasName):
|
if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
|
||||||
if g.tree.selection:
|
if g.tree.selection:
|
||||||
sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
|
sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
|
||||||
else: # nothing selected
|
else: # nothing selected
|
||||||
|
@@ -107,8 +107,20 @@ class ID_NEW:
|
|||||||
MENU = wxNewId()
|
MENU = wxNewId()
|
||||||
MENU_ITEM = wxNewId()
|
MENU_ITEM = wxNewId()
|
||||||
SEPARATOR = wxNewId()
|
SEPARATOR = wxNewId()
|
||||||
|
|
||||||
|
OK_BUTTON = wxNewId()
|
||||||
|
YES_BUTTON = wxNewId()
|
||||||
|
SAVE_BUTTON = wxNewId()
|
||||||
|
APPLY_BUTTON = wxNewId()
|
||||||
|
NO_BUTTON = wxNewId()
|
||||||
|
CANCEL_BUTTON = wxNewId()
|
||||||
|
HELP_BUTTON = wxNewId()
|
||||||
|
CONTEXT_HELP_BUTTON = wxNewId()
|
||||||
|
|
||||||
LAST = wxNewId()
|
LAST = wxNewId()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PullDownMenu:
|
class PullDownMenu:
|
||||||
ID_EXPAND = wxNewId()
|
ID_EXPAND = wxNewId()
|
||||||
ID_COLLAPSE = wxNewId()
|
ID_COLLAPSE = wxNewId()
|
||||||
@@ -182,6 +194,15 @@ class PullDownMenu:
|
|||||||
ID_NEW.STD_DIALOG_BUTTON_SIZER: 'wxStdDialogButtonSizer',
|
ID_NEW.STD_DIALOG_BUTTON_SIZER: 'wxStdDialogButtonSizer',
|
||||||
ID_NEW.SPACER: 'spacer',
|
ID_NEW.SPACER: 'spacer',
|
||||||
ID_NEW.UNKNOWN: 'unknown',
|
ID_NEW.UNKNOWN: 'unknown',
|
||||||
|
|
||||||
|
ID_NEW.OK_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.YES_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.SAVE_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.APPLY_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.NO_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.CANCEL_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.HELP_BUTTON: 'wxButton',
|
||||||
|
ID_NEW.CONTEXT_HELP_BUTTON: 'wxButton',
|
||||||
}
|
}
|
||||||
self.topLevel = [
|
self.topLevel = [
|
||||||
(ID_NEW.PANEL, 'Panel', 'Create panel'),
|
(ID_NEW.PANEL, 'Panel', 'Create panel'),
|
||||||
@@ -304,16 +325,41 @@ class PullDownMenu:
|
|||||||
(ID_NEW.LIST_BOX, 'ListBox', 'Create list box'),
|
(ID_NEW.LIST_BOX, 'ListBox', 'Create list box'),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
self.stdButtons = [
|
||||||
|
(ID_NEW.OK_BUTTON, 'OK Button', 'Create standard button'),
|
||||||
|
(ID_NEW.YES_BUTTON, 'YES Button', 'Create standard button'),
|
||||||
|
(ID_NEW.SAVE_BUTTON, 'SAVE Button', 'Create standard button'),
|
||||||
|
(ID_NEW.APPLY_BUTTON, 'APPLY Button', 'Create standard button'),
|
||||||
|
(ID_NEW.NO_BUTTON, 'NO Button', 'Create standard button'),
|
||||||
|
(ID_NEW.CANCEL_BUTTON, 'CANCEL Button', 'Create standard button'),
|
||||||
|
(ID_NEW.HELP_BUTTON, 'HELP Button', 'Create standard button'),
|
||||||
|
(ID_NEW.CONTEXT_HELP_BUTTON, 'CONTEXT HELP Button', 'Create standard button'),
|
||||||
|
]
|
||||||
|
self.stdButtonIDs = {
|
||||||
|
ID_NEW.OK_BUTTON: ('wxID_OK', '&Ok'),
|
||||||
|
ID_NEW.YES_BUTTON: ('wxID_YES', '&Yes'),
|
||||||
|
ID_NEW.SAVE_BUTTON: ('wxID_SAVE', '&Save'),
|
||||||
|
ID_NEW.APPLY_BUTTON: ('wxID_APPLY', '&Apply'),
|
||||||
|
ID_NEW.NO_BUTTON: ('wxID_NO', '&No'),
|
||||||
|
ID_NEW.CANCEL_BUTTON: ('wxID_CANCEL', '&Cancel'),
|
||||||
|
ID_NEW.HELP_BUTTON: ('wxID_HELP', '&Help'),
|
||||||
|
ID_NEW.CONTEXT_HELP_BUTTON: ('wxID_CONTEXT_HELP', '&Help'),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Set menu to list items.
|
# Set menu to list items.
|
||||||
# Each menu command is a tuple (id, label, help)
|
# Each menu command is a tuple (id, label, help)
|
||||||
# submenus are lists [id, label, help, submenu]
|
# submenus are lists [id, label, help, submenu]
|
||||||
# and separators are any other type
|
# and separators are any other type. Shift is for making
|
||||||
def SetMenu(m, list):
|
# alternative sets of IDs. (+1000).
|
||||||
|
def SetMenu(m, list, shift=False):
|
||||||
for l in list:
|
for l in list:
|
||||||
if type(l) == types.TupleType:
|
if type(l) == types.TupleType:
|
||||||
|
# Shift ID
|
||||||
|
if shift: l = (1000 + l[0],) + l[1:]
|
||||||
apply(m.Append, l)
|
apply(m.Append, l)
|
||||||
elif type(l) == types.ListType:
|
elif type(l) == types.ListType:
|
||||||
subMenu = wxMenu()
|
subMenu = wxMenu()
|
||||||
@@ -321,19 +367,6 @@ def SetMenu(m, list):
|
|||||||
m.AppendMenu(wxNewId(), l[0], subMenu, l[1])
|
m.AppendMenu(wxNewId(), l[0], subMenu, l[1])
|
||||||
else: # separator
|
else: # separator
|
||||||
m.AppendSeparator()
|
m.AppendSeparator()
|
||||||
# Same, but adds 1000 to all IDs
|
|
||||||
def SetMenu2(m, list):
|
|
||||||
for l in list:
|
|
||||||
if type(l) == types.TupleType:
|
|
||||||
# Shift ID
|
|
||||||
l = (1000 + l[0],) + l[1:]
|
|
||||||
apply(m.Append, l)
|
|
||||||
elif type(l) == types.ListType:
|
|
||||||
subMenu = wxMenu()
|
|
||||||
SetMenu2(subMenu, l[2:])
|
|
||||||
m.AppendMenu(wxNewId(), l[0], subMenu, l[1])
|
|
||||||
else: # separator
|
|
||||||
m.AppendSeparator()
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@@ -542,12 +575,12 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.selection = None
|
self.selection = None
|
||||||
return node
|
return node
|
||||||
# Find position relative to the top-level window
|
# Find position relative to the top-level window
|
||||||
def FindNodePos(self, item):
|
def FindNodePos(self, item, obj=None):
|
||||||
# Root at (0,0)
|
# Root at (0,0)
|
||||||
if item == g.testWin.item: return wxPoint(0, 0)
|
if item == g.testWin.item: return wxPoint(0, 0)
|
||||||
itemParent = self.GetItemParent(item)
|
itemParent = self.GetItemParent(item)
|
||||||
# Select NB page
|
# Select NB page
|
||||||
obj = self.FindNodeObject(item)
|
if not obj: obj = self.FindNodeObject(item)
|
||||||
if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
|
if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
|
||||||
notebook = self.FindNodeObject(itemParent)
|
notebook = self.FindNodeObject(itemParent)
|
||||||
# Find position
|
# Find position
|
||||||
@@ -587,6 +620,12 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
elif isinstance(xxx.parent, xxxToolBar):
|
elif isinstance(xxx.parent, xxxToolBar):
|
||||||
# How to get tool from toolbar?
|
# How to get tool from toolbar?
|
||||||
return parentWin.GetChildren()[0]
|
return parentWin.GetChildren()[0]
|
||||||
|
elif isinstance(xxx.parent, xxxStdDialogButtonSizer):
|
||||||
|
# This sizer returns non-existing children
|
||||||
|
for ch in parentWin.GetChildren():
|
||||||
|
if ch.GetWindow() and ch.GetWindow().GetName() == xxx.name:
|
||||||
|
return ch.GetWindow()
|
||||||
|
return None
|
||||||
# Otherwise get parent's object and it's child
|
# Otherwise get parent's object and it's child
|
||||||
child = parentWin.GetChildren()[self.ItemIndex(item)]
|
child = parentWin.GetChildren()[self.ItemIndex(item)]
|
||||||
# Return window or sizer for sizer items
|
# Return window or sizer for sizer items
|
||||||
@@ -653,7 +692,9 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
if g.testWin.highLight: g.testWin.highLight.Remove()
|
if g.testWin.highLight: g.testWin.highLight.Remove()
|
||||||
return
|
return
|
||||||
# Get window/sizer object
|
# Get window/sizer object
|
||||||
obj, pos = self.FindNodeObject(item), self.FindNodePos(item)
|
obj = self.FindNodeObject(item)
|
||||||
|
if not obj: return
|
||||||
|
pos = self.FindNodePos(item, obj)
|
||||||
size = obj.GetSize()
|
size = obj.GetSize()
|
||||||
# Highlight
|
# Highlight
|
||||||
# Negative positions are not working quite well
|
# Negative positions are not working quite well
|
||||||
@@ -968,6 +1009,8 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
SetMenu(m, pullDownMenu.toolBarControls)
|
SetMenu(m, pullDownMenu.toolBarControls)
|
||||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
||||||
SetMenu(m, pullDownMenu.menuControls)
|
SetMenu(m, pullDownMenu.menuControls)
|
||||||
|
elif xxx.__class__ == xxxStdDialogButtonSizer:
|
||||||
|
SetMenu(m, pullDownMenu.stdButtons)
|
||||||
else:
|
else:
|
||||||
SetMenu(m, pullDownMenu.controls)
|
SetMenu(m, pullDownMenu.controls)
|
||||||
if xxx.__class__ == xxxNotebook:
|
if xxx.__class__ == xxxNotebook:
|
||||||
@@ -996,19 +1039,19 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
if xxx.__class__ == xxxMenuBar:
|
if xxx.__class__ == xxxMenuBar:
|
||||||
m.Append(1000 + ID_NEW.MENU, 'Menu', 'Create menu')
|
m.Append(1000 + ID_NEW.MENU, 'Menu', 'Create menu')
|
||||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
||||||
SetMenu2(m, pullDownMenu.menuControls)
|
SetMenu(m, pullDownMenu.menuControls, shift=True)
|
||||||
elif xxx.__class__ == xxxToolBar and \
|
elif xxx.__class__ == xxxToolBar and \
|
||||||
self.GetItemParent(item) == self.root:
|
self.GetItemParent(item) == self.root:
|
||||||
SetMenu2(m, [])
|
SetMenu(m, [], shift=True)
|
||||||
elif xxx.__class__ in [xxxFrame, xxxDialog, xxxPanel]:
|
elif xxx.__class__ in [xxxFrame, xxxDialog, xxxPanel]:
|
||||||
SetMenu2(m, [
|
SetMenu(m, [
|
||||||
(ID_NEW.PANEL, 'Panel', 'Create panel'),
|
(ID_NEW.PANEL, 'Panel', 'Create panel'),
|
||||||
(ID_NEW.DIALOG, 'Dialog', 'Create dialog'),
|
(ID_NEW.DIALOG, 'Dialog', 'Create dialog'),
|
||||||
(ID_NEW.FRAME, 'Frame', 'Create frame')])
|
(ID_NEW.FRAME, 'Frame', 'Create frame')], shift=True)
|
||||||
elif xxx.isSizer:
|
elif xxx.isSizer:
|
||||||
SetMenu2(m, pullDownMenu.sizers)
|
SetMenu(m, pullDownMenu.sizers, shift=True)
|
||||||
else:
|
else:
|
||||||
SetMenu2(m, pullDownMenu.controls)
|
SetMenu(m, pullDownMenu.controls, shift=True)
|
||||||
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)
|
||||||
|
@@ -498,7 +498,7 @@ class Frame(wxFrame):
|
|||||||
# Parent is sizer or notebook, child is not child container
|
# Parent is sizer or notebook, child is not child container
|
||||||
if parent.isSizer and not isChildContainer and not isinstance(xxx, xxxSpacer):
|
if parent.isSizer and not isChildContainer and not isinstance(xxx, xxxSpacer):
|
||||||
# Create sizer item element
|
# Create sizer item element
|
||||||
sizerItemElem = MakeEmptyDOM('sizeritem')
|
sizerItemElem = MakeEmptyDOM(parent.itemTag)
|
||||||
sizerItemElem.appendChild(elem)
|
sizerItemElem.appendChild(elem)
|
||||||
elem = sizerItemElem
|
elem = sizerItemElem
|
||||||
elif isinstance(parent, xxxNotebook) and not isChildContainer:
|
elif isinstance(parent, xxxNotebook) and not isChildContainer:
|
||||||
@@ -764,8 +764,16 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
if parent.__class__ == xxxMainNode:
|
if parent.__class__ == xxxMainNode:
|
||||||
cl = xxx.treeObject().__class__
|
cl = xxx.treeObject().__class__
|
||||||
frame.maxIDs[cl] += 1
|
frame.maxIDs[cl] += 1
|
||||||
xxx.treeObject().name = '%s%d' % (defaultIDs[cl], frame.maxIDs[cl])
|
xxx.setTreeName('%s%d' % (defaultIDs[cl], frame.maxIDs[cl]))
|
||||||
xxx.treeObject().element.setAttribute('name', xxx.treeObject().name)
|
# And for some other standard controls
|
||||||
|
elif parent.__class__ == xxxStdDialogButtonSizer:
|
||||||
|
xxx.setTreeName(pullDownMenu.stdButtonIDs[evt.GetId()][0])
|
||||||
|
# We can even set label
|
||||||
|
obj = xxx.treeObject()
|
||||||
|
elem = g.tree.dom.createElement('label')
|
||||||
|
elem.appendChild(g.tree.dom.createTextNode(pullDownMenu.stdButtonIDs[evt.GetId()][1]))
|
||||||
|
obj.params['label'] = xxxParam(elem)
|
||||||
|
xxx.treeObject().element.appendChild(elem)
|
||||||
|
|
||||||
# Insert new node, register undo
|
# Insert new node, register undo
|
||||||
elem = xxx.element
|
elem = xxx.element
|
||||||
@@ -855,8 +863,7 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
if parent.__class__ == xxxMainNode:
|
if parent.__class__ == xxxMainNode:
|
||||||
cl = xxx.treeObject().__class__
|
cl = xxx.treeObject().__class__
|
||||||
frame.maxIDs[cl] += 1
|
frame.maxIDs[cl] += 1
|
||||||
xxx.treeObject().name = '%s%d' % (defaultIDs[cl], frame.maxIDs[cl])
|
xxx.setTreeName('%s%d' % (defaultIDs[cl], frame.maxIDs[cl]))
|
||||||
xxx.treeObject().element.setAttribute('name', xxx.treeObject().name)
|
|
||||||
|
|
||||||
# Update panel
|
# Update panel
|
||||||
g.panel.SetData(xxx)
|
g.panel.SetData(xxx)
|
||||||
|
@@ -294,6 +294,12 @@ class xxxObject:
|
|||||||
def panelName(self):
|
def panelName(self):
|
||||||
if self.subclass: return self.subclass + '(' + self.className + ')'
|
if self.subclass: return self.subclass + '(' + self.className + ')'
|
||||||
else: return self.className
|
else: return self.className
|
||||||
|
# Sets name of tree object
|
||||||
|
def setTreeName(self, name):
|
||||||
|
if self.hasChild: obj = self.child
|
||||||
|
else: obj = self
|
||||||
|
obj.name = name
|
||||||
|
obj.element.setAttribute('name', name)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@@ -623,6 +629,7 @@ class xxxSizer(xxxContainer):
|
|||||||
hasName = hasStyle = False
|
hasName = hasStyle = False
|
||||||
paramDict = {'orient': ParamOrient}
|
paramDict = {'orient': ParamOrient}
|
||||||
isSizer = True
|
isSizer = True
|
||||||
|
itemTag = 'sizeritem' # different for some sizers
|
||||||
|
|
||||||
class xxxBoxSizer(xxxSizer):
|
class xxxBoxSizer(xxxSizer):
|
||||||
allParams = ['orient']
|
allParams = ['orient']
|
||||||
@@ -644,6 +651,7 @@ class xxxGridSizer(xxxSizer):
|
|||||||
|
|
||||||
class xxxStdDialogButtonSizer(xxxSizer):
|
class xxxStdDialogButtonSizer(xxxSizer):
|
||||||
allParams = []
|
allParams = []
|
||||||
|
itemTag = 'button'
|
||||||
|
|
||||||
# For repeated parameters
|
# For repeated parameters
|
||||||
class xxxParamMulti:
|
class xxxParamMulti:
|
||||||
@@ -742,6 +750,16 @@ class xxxSizerItem(xxxChildContainer):
|
|||||||
self.child.allParams = self.child.allParams[:]
|
self.child.allParams = self.child.allParams[:]
|
||||||
self.child.allParams.remove('pos')
|
self.child.allParams.remove('pos')
|
||||||
|
|
||||||
|
class xxxSizerItemButton(xxxSizerItem):
|
||||||
|
allParams = []
|
||||||
|
paramDict = {}
|
||||||
|
def __init__(self, parent, element):
|
||||||
|
xxxChildContainer.__init__(self, parent, element)
|
||||||
|
# Remove pos parameter - not needed for sizeritems
|
||||||
|
if 'pos' in self.child.allParams:
|
||||||
|
self.child.allParams = self.child.allParams[:]
|
||||||
|
self.child.allParams.remove('pos')
|
||||||
|
|
||||||
class xxxNotebookPage(xxxChildContainer):
|
class xxxNotebookPage(xxxChildContainer):
|
||||||
allParams = ['label', 'selected']
|
allParams = ['label', 'selected']
|
||||||
paramDict = {'selected': ParamBool}
|
paramDict = {'selected': ParamBool}
|
||||||
@@ -842,7 +860,7 @@ xxxDict = {
|
|||||||
'wxFlexGridSizer': xxxFlexGridSizer,
|
'wxFlexGridSizer': xxxFlexGridSizer,
|
||||||
'wxGridBagSizer': xxxGridBagSizer,
|
'wxGridBagSizer': xxxGridBagSizer,
|
||||||
'wxStdDialogButtonSizer': xxxStdDialogButtonSizer,
|
'wxStdDialogButtonSizer': xxxStdDialogButtonSizer,
|
||||||
'sizeritem': xxxSizerItem,
|
'sizeritem': xxxSizerItem, 'button': xxxSizerItemButton,
|
||||||
'spacer': xxxSpacer,
|
'spacer': xxxSpacer,
|
||||||
|
|
||||||
'wxMenuBar': xxxMenuBar,
|
'wxMenuBar': xxxMenuBar,
|
||||||
@@ -907,7 +925,7 @@ def MakeEmptyXXX(parent, className):
|
|||||||
# If parent is a sizer, we should create sizeritem object, except for spacers
|
# If parent is a sizer, we should create sizeritem object, except for spacers
|
||||||
if parent:
|
if parent:
|
||||||
if parent.isSizer and className != 'spacer':
|
if parent.isSizer and className != 'spacer':
|
||||||
sizerItemElem = MakeEmptyDOM('sizeritem')
|
sizerItemElem = MakeEmptyDOM(parent.itemTag)
|
||||||
sizerItemElem.appendChild(elem)
|
sizerItemElem.appendChild(elem)
|
||||||
elem = sizerItemElem
|
elem = sizerItemElem
|
||||||
elif isinstance(parent, xxxNotebook):
|
elif isinstance(parent, xxxNotebook):
|
||||||
|
Reference in New Issue
Block a user