]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/xxx.py
Ctrl-H must not be used on Mac...
[wxWidgets.git] / wxPython / wx / tools / XRCed / xxx.py
index 92df22cfe6b70c7bd8e0766d4c10c09dd76e942c..7226d26d9104e464b62bcf703442cdcb8378e9b9 100644 (file)
@@ -40,7 +40,7 @@ class xxxParam(xxxNode):
         # Use convertion from unicode to current encoding
         self.textNode = text
     # Value returns string
-    if wxUSE_UNICODE:   # no conversion is needed
+    if wx.USE_UNICODE:   # no conversion is needed
         def value(self):
             return self.textNode.data
         def update(self, value):
@@ -56,7 +56,7 @@ class xxxParam(xxxNode):
                 self.textNode.data = unicode(value, g.currentEncoding)
             except UnicodeDecodeError:
                 self.textNode.data = unicode(value)
-                #wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
+                #wx.LogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
 
 # Integer parameter
 class xxxParamInt(xxxParam):
@@ -90,7 +90,7 @@ class xxxParamContent(xxxNode):
                     text = n.childNodes[0] # first child must be text node
                     assert text.nodeType == minidom.Node.TEXT_NODE
                 l.append(text)
-                data.append(str(text.data))
+                data.append(text.data)
             else:                       # remove other
                 node.removeChild(n)
                 n.unlink()
@@ -285,7 +285,7 @@ class xxxObject:
                     else:
                         self.element.appendChild(elem)
                 else:
-                    wxLogWarning('Required parameter %s of %s missing' %
+                    wx.LogWarning('Required parameter %s of %s missing' %
                                  (param, self.className))
     # Returns real tree object
     def treeObject(self):
@@ -314,6 +314,23 @@ class xxxObject:
         else: obj = self
         obj.name = name
         obj.element.setAttribute('name', name)
+    # Special processing for growablecols-like parameters
+    # represented by several nodes
+    def special(self, tag, node):
+        if not self.params.has_key(tag):
+            # Create new multi-group
+            self.params[tag] = xxxParamMulti(node)
+        self.params[tag].append(xxxParamInt(node))
+    def setSpecial(self, param, value):
+        # Straightforward implementation: remove, add again
+        self.params[param].remove()
+        del self.params[param]
+        for i in value:
+            node = g.tree.dom.createElement(param)
+            text = g.tree.dom.createTextNode(str(i))
+            node.appendChild(text)
+            self.element.appendChild(node)
+            self.special(param, node)
 
 # Imitation of FindResource/DoFindResource from xmlres.cpp
 def DoFindResource(parent, name, classname, recursive):
@@ -338,7 +355,7 @@ def DoFindResource(parent, name, classname, recursive):
 def FindResource(name, classname='', recursive=True):
     found = DoFindResource(g.tree.mainNode, name, classname, recursive)
     if found:  return found
-    wxLogError('XRC resource "%s" not found!' % name)
+    wx.LogError('XRC resource "%s" not found!' % name)
                 
 
 ################################################################################
@@ -475,6 +492,7 @@ class xxxWizard(xxxContainer):
     default = {'title': ''}
     winStyles = []
     exStyles = ['wxWIZARD_EX_HELPBUTTON']
+    styles = ['fg', 'bg', 'font', 'exstyle']
 
 class xxxWizardPage(xxxContainer):
     allParams = ['bitmap']
@@ -604,8 +622,8 @@ class xxxCalendarCtrl(xxxObject):
 
 class xxxNotebook(xxxContainer):
     allParams = ['pos', 'size', 'style']
-    winStyles = ['wxNB_DEFAULT', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM',
-                 'wxNB_FIXEDWIDTH', 'wxNB_MULTILINE', 'wxNB_NOPAGETHEME']
+    winStyles = ['wxNB_TOP', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM',
+                 'wxNB_FIXEDWIDTH', 'wxNB_MULTILINE', 'wxNB_NOPAGETHEME', 'wxNB_FLAT']
 
 class xxxChoicebook(xxxContainer):
     allParams = ['pos', 'size', 'style']
@@ -644,14 +662,17 @@ class xxxButton(xxxObject):
     allParams = ['label', 'default', 'pos', 'size', 'style']
     paramDict = {'default': ParamBool}
     required = ['label']
-    winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM', 'wxBU_EXACTFIT']
+    winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM', 'wxBU_EXACTFIT',
+                 'wxNO_BORDER']
 
 class xxxBitmapButton(xxxObject):
     allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default',
                  'pos', 'size', 'style']
+    paramDict = {'selected': ParamBitmap, 'focus': ParamBitmap, 'disabled': ParamBitmap,
+                 'default': ParamBool}
     required = ['bitmap']
     winStyles = ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_RIGHT',
-                 'wxBU_TOP', 'wxBU_BOTTOM', 'wxBU_EXACTFIT']
+                 'wxBU_TOP', 'wxBU_BOTTOM']
 
 class xxxRadioButton(xxxObject):
     allParams = ['label', 'value', 'pos', 'size', 'style']
@@ -767,45 +788,11 @@ class xxxFlexGridSizer(xxxGridSizer):
     specials = ['growablecols', 'growablerows']
     allParams = ['cols', 'rows', 'vgap', 'hgap'] + specials
     paramDict = {'growablecols': ParamIntList, 'growablerows': ParamIntList}
-    # Special processing for growable* parameters
-    # (they are represented by several nodes)
-    def special(self, tag, node):
-        if not self.params.has_key(tag):
-            # Create new multi-group
-            self.params[tag] = xxxParamMulti(node)
-        self.params[tag].append(xxxParamInt(node))
-    def setSpecial(self, param, value):
-        # Straightforward implementation: remove, add again
-        self.params[param].remove()
-        del self.params[param]
-        for i in value:
-            node = g.tree.dom.createElement(param)
-            text = g.tree.dom.createTextNode(str(i))
-            node.appendChild(text)
-            self.element.appendChild(node)
-            self.special(param, node)
 
 class xxxGridBagSizer(xxxSizer):
     specials = ['growablecols', 'growablerows']
     allParams = ['vgap', 'hgap'] + specials
-    paramDict = {'growablecols':ParamIntList, 'growablerows':ParamIntList}
-    # Special processing for growable* parameters
-    # (they are represented by several nodes)
-    def special(self, tag, node):
-        if not self.params.has_key(tag):
-            # Create new multi-group
-            self.params[tag] = xxxParamMulti(node)
-        self.params[tag].append(xxxParamInt(node))
-    def setSpecial(self, param, value):
-        # Straightforward implementation: remove, add again
-        self.params[param].remove()
-        del self.params[param]
-        for i in value:
-            node = g.tree.dom.createElement(param)
-            text = g.tree.dom.createTextNode(str(i))
-            node.appendChild(text)
-            self.element.appendChild(node)
-            self.special(param, node)
+    paramDict = {'growablecols': ParamIntList, 'growablerows': ParamIntList}
 
 # Container with only one child.
 # Not shown in tree.
@@ -830,6 +817,11 @@ class xxxChildContainer(xxxObject):
                 element.removeChild(node)
                 node.unlink()
         assert 0, 'no child found'
+    def resetChild(self, xxx):
+        '''Reset child info (for replacing with another class).'''
+        self.child = xxx
+        self.hasChildren = xxx.hasChildren
+        self.isSizer = xxx.isSizer        
 
 class xxxSizerItem(xxxChildContainer):
     allParams = ['option', 'flag', 'border', 'minsize', 'ratio']
@@ -844,6 +836,12 @@ class xxxSizerItem(xxxChildContainer):
         if 'pos' in self.child.allParams:
             self.child.allParams = self.child.allParams[:]
             self.child.allParams.remove('pos')
+    def resetChild(self, xxx):
+        xxxChildContainer.resetChild(self, xxx)
+        # 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 xxxSizerItemButton(xxxSizerItem):
     allParams = []
@@ -874,6 +872,11 @@ class xxxSpacer(xxxObject):
     allParams = ['size', 'option', 'flag', 'border']
     paramDict = {'option': ParamInt}
     default = {'size': '0,0'}
+    def __init__(self, parent, element, refElem=None):
+        # For GridBag sizer items, extra parameters added
+        if isinstance(parent, xxxGridBagSizer):
+            self.allParams = self.allParams + ['cellpos', 'cellspan']
+        xxxObject.__init__(self, parent, element, refElem)
 
 class xxxMenuBar(xxxContainer):
     allParams = ['style']
@@ -973,16 +976,16 @@ xxxDict = {
     }
 
 # Create IDs for all parameters of all classes
-paramIDs = {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNewId(),
-            'enabled': wxNewId(), 'focused': wxNewId(), 'hidden': wxNewId(),
-            'tooltip': wxNewId(), 'encoding': wxNewId(),
-            'cellpos': wxNewId(), 'cellspan': wxNewId()
+paramIDs = {'fg': wx.NewId(), 'bg': wx.NewId(), 'exstyle': wx.NewId(), 'font': wx.NewId(),
+            'enabled': wx.NewId(), 'focused': wx.NewId(), 'hidden': wx.NewId(),
+            'tooltip': wx.NewId(), 'encoding': wx.NewId(),
+            'cellpos': wx.NewId(), 'cellspan': wx.NewId()
             }
 for cl in xxxDict.values():
     if cl.allParams:
         for param in cl.allParams + cl.paramDict.keys():
             if not paramIDs.has_key(param):
-                paramIDs[param] = wxNewId()
+                paramIDs[param] = wx.NewId()
 
 ################################################################################
 # Helper functions
@@ -1081,5 +1084,9 @@ def MakeEmptyRefXXX(parent, ref):
             pageElem.appendChild(elem)
             elem = pageElem
     # Now just make object
-    return MakeXXXFromDOM(parent, elem)
+    xxx = MakeXXXFromDOM(parent, elem)
+    # Label is not used for references
+    xxx.allParams = xxx.allParams[:]
+    #xxx.allParams.remove('label')
+    return xxx