defaults for unset required parameters, ParamUnit for border and {v,h}gap
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@19413 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -230,6 +230,29 @@ class xxxObject:
|
|||||||
# Remove all other nodes
|
# Remove all other nodes
|
||||||
element.removeChild(node)
|
element.removeChild(node)
|
||||||
node.unlink()
|
node.unlink()
|
||||||
|
# Check that all required params are set
|
||||||
|
for param in self.required:
|
||||||
|
if not self.params.has_key(param):
|
||||||
|
# If default is specified, set it
|
||||||
|
if self.default.has_key(param):
|
||||||
|
elem = g.tree.dom.createElement(param)
|
||||||
|
self.params[param] = xxxParam(elem)
|
||||||
|
# Find place to put new element: first present element after param
|
||||||
|
found = False
|
||||||
|
paramStyles = self.allParams + self.styles
|
||||||
|
for p in paramStyles[paramStyles.index(param) + 1:]:
|
||||||
|
# Content params don't have same type
|
||||||
|
if self.params.has_key(p) and p != 'content':
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
if found:
|
||||||
|
nextTextElem = self.params[p].node
|
||||||
|
self.element.insertBefore(elem, nextTextElem)
|
||||||
|
else:
|
||||||
|
self.element.appendChild(elem)
|
||||||
|
else:
|
||||||
|
wxLogWarning('Required parameter %s of %s missing' %
|
||||||
|
(param, self.className))
|
||||||
# Returns real tree object
|
# Returns real tree object
|
||||||
def treeObject(self):
|
def treeObject(self):
|
||||||
if self.hasChild: return self.child
|
if self.hasChild: return self.child
|
||||||
@@ -301,6 +324,7 @@ class xxxEncoding:
|
|||||||
class xxxMainNode(xxxContainer):
|
class xxxMainNode(xxxContainer):
|
||||||
allParams = ['encoding']
|
allParams = ['encoding']
|
||||||
required = ['encoding']
|
required = ['encoding']
|
||||||
|
default = {'encoding': ''}
|
||||||
hasStyle = hasName = False
|
hasStyle = hasName = False
|
||||||
def __init__(self, dom):
|
def __init__(self, dom):
|
||||||
xxxContainer.__init__(self, None, dom.documentElement)
|
xxxContainer.__init__(self, None, dom.documentElement)
|
||||||
@@ -377,6 +401,7 @@ class xxxIcon(xxxObject):
|
|||||||
class xxxStaticText(xxxObject):
|
class xxxStaticText(xxxObject):
|
||||||
allParams = ['label', 'pos', 'size', 'style']
|
allParams = ['label', 'pos', 'size', 'style']
|
||||||
required = ['label']
|
required = ['label']
|
||||||
|
default = {'label': ''}
|
||||||
winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']
|
winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']
|
||||||
|
|
||||||
class xxxStaticLine(xxxObject):
|
class xxxStaticLine(xxxObject):
|
||||||
@@ -542,7 +567,6 @@ class xxxBoxSizer(xxxSizer):
|
|||||||
class xxxStaticBoxSizer(xxxBoxSizer):
|
class xxxStaticBoxSizer(xxxBoxSizer):
|
||||||
allParams = ['label', 'orient']
|
allParams = ['label', 'orient']
|
||||||
required = ['label', 'orient']
|
required = ['label', 'orient']
|
||||||
default = {'orient': 'wxVERTICAL'}
|
|
||||||
|
|
||||||
class xxxGridSizer(xxxSizer):
|
class xxxGridSizer(xxxSizer):
|
||||||
allParams = ['cols', 'rows', 'vgap', 'hgap']
|
allParams = ['cols', 'rows', 'vgap', 'hgap']
|
||||||
@@ -611,8 +635,8 @@ class xxxChildContainer(xxxObject):
|
|||||||
assert 0, 'no child found'
|
assert 0, 'no child found'
|
||||||
|
|
||||||
class xxxSizerItem(xxxChildContainer):
|
class xxxSizerItem(xxxChildContainer):
|
||||||
allParams = ['option', 'flag', 'border']
|
allParams = ['option', 'flag', 'border', 'minsize']
|
||||||
paramDict = {'option': ParamInt}
|
paramDict = {'option': ParamInt, 'minsize': ParamPosSize}
|
||||||
def __init__(self, parent, element):
|
def __init__(self, parent, element):
|
||||||
xxxChildContainer.__init__(self, parent, element)
|
xxxChildContainer.__init__(self, parent, element)
|
||||||
# Remove pos parameter - not needed for sizeritems
|
# Remove pos parameter - not needed for sizeritems
|
||||||
|
Reference in New Issue
Block a user