X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2481bf3cb684141768951d987a5adce365735051..f6d43eda3e8bc5c17cd3c55f037abcc4a4e043be:/wxPython/wx/tools/XRCed/xxx.py diff --git a/wxPython/wx/tools/XRCed/xxx.py b/wxPython/wx/tools/XRCed/xxx.py index e564f70873..1fb1c81ebe 100644 --- a/wxPython/wx/tools/XRCed/xxx.py +++ b/wxPython/wx/tools/XRCed/xxx.py @@ -49,7 +49,10 @@ class xxxParam(xxxNode): def value(self): return self.textNode.data.encode(g.currentEncoding) def update(self, value): - self.textNode.data = unicode(value, g.currentEncoding) + try: # handle exception if encoding is wrong + self.textNode.data = unicode(value, g.currentEncoding) + except UnicodeDecodeError: + wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") # Integer parameter class xxxParamInt(xxxParam): @@ -223,7 +226,7 @@ class xxxObject: elif tag in self.specials: self.special(tag, node) elif tag == 'content': - if self.className == 'wxCheckList': + if self.className == 'wxCheckListBox': self.params[tag] = xxxParamContentCheckList(node) else: self.params[tag] = xxxParamContent(node) @@ -235,9 +238,11 @@ class xxxObject: else: # simple parameter self.params[tag] = xxxParam(node) else: + pass # Remove all other nodes - element.removeChild(node) - node.unlink() +# element.removeChild(node) +# node.unlink() + # Check that all required params are set for param in self.required: if not self.params.has_key(param): @@ -245,7 +250,7 @@ class xxxObject: if self.default.has_key(param): elem = g.tree.dom.createElement(param) if param == 'content': - if self.className == 'wxCheckList': + if self.className == 'wxCheckListBox': self.params[param] = xxxParamContentCheckList(elem) else: self.params[param] = xxxParamContent(elem) @@ -333,12 +338,10 @@ class xxxContainer(xxxObject): # Simulate normal parameter for encoding class xxxEncoding: - def __init__(self, val): - self.encd = val def value(self): - return self.encd + return g.currentEncoding def update(self, val): - self.encd = val + g.currentEncoding = val # Special class for root node class xxxMainNode(xxxContainer): @@ -350,7 +353,7 @@ class xxxMainNode(xxxContainer): # Reset required parameters after processing XML, because encoding is # a little special self.required = ['encoding'] - self.params['encoding'] = xxxEncoding(dom.encoding) + self.params['encoding'] = xxxEncoding() ################################################################################ # Top-level windwows @@ -368,7 +371,7 @@ class xxxDialog(xxxContainer): required = ['title'] default = {'title': ''} winStyles = ['wxDEFAULT_DIALOG_STYLE', 'wxSTAY_ON_TOP', - 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', +## 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', 'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 'wxTHICK_FRAME', 'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] @@ -415,8 +418,7 @@ class xxxBitmap(xxxObject): # Just like bitmap class xxxIcon(xxxObject): - allParams = ['icon'] - required = ['icon'] + allParams = [] ################################################################################ # Controls @@ -496,6 +498,13 @@ class xxxNotebook(xxxContainer): paramDict = {'usenotebooksizer': ParamBool} winStyles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM'] +class xxxSplitterWindow(xxxContainer): + allParams = ['orientation', 'sashpos', 'minsize', 'pos', 'size', 'style'] + paramDict = {'orientation': ParamOrientation, 'sashpos': ParamUnit, 'minsize': ParamUnit } + winStyles = ['wxSP_3D', 'wxSP_3DSASH', 'wxSP_3DBORDER', 'wxSP_BORDER', + 'wxSP_NOBORDER', 'wxSP_PERMIT_UNSPLIT', 'wxSP_LIVE_UPDATE', + 'wxSP_NO_XP_THEME' ] + class xxxGenericDirCtrl(xxxObject): allParams = ['defaultfolder', 'filter', 'defaultfilter', 'pos', 'size', 'style'] paramDict = {'defaultfilter': ParamInt} @@ -538,6 +547,11 @@ class xxxSpinCtrl(xxxObject): paramDict = {'value': ParamInt} winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP'] +class xxxToggleButton(xxxObject): + allParams = ['label', 'checked', 'pos', 'size', 'style'] + paramDict = {'checked': ParamBool} + required = ['label'] + ################################################################################ # Boxes @@ -555,6 +569,8 @@ class xxxRadioBox(xxxObject): class xxxCheckBox(xxxObject): allParams = ['label', 'checked', 'pos', 'size', 'style'] paramDict = {'checked': ParamBool} + winStyles = ['wxCHK_2STATE', 'wxCHK_3STATE', 'wxCHK_ALLOW_3RD_STATE_FOR_USER', + 'wxALIGN_RIGHT'] required = ['label'] class xxxComboBox(xxxObject): @@ -643,6 +659,28 @@ class xxxFlexGridSizer(xxxGridSizer): 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) + # Container with only one child. # Not shown in tree. class xxxChildContainer(xxxObject): @@ -668,9 +706,13 @@ class xxxChildContainer(xxxObject): assert 0, 'no child found' class xxxSizerItem(xxxChildContainer): - allParams = ['option', 'flag', 'border', 'minsize'] - paramDict = {'option': ParamInt, 'minsize': ParamPosSize} + allParams = ['option', 'flag', 'border', 'minsize', 'ratio'] + paramDict = {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize} + #default = {'cellspan': '1,1'} def __init__(self, parent, element): + # For GridBag sizer items, extra parameters added + if isinstance(parent, xxxGridBagSizer): + self.allParams = self.allParams + ['cellpos', 'cellspan'] xxxChildContainer.__init__(self, parent, element) # Remove pos parameter - not needed for sizeritems if 'pos' in self.child.allParams: @@ -740,6 +782,7 @@ xxxDict = { 'wxBitmapButton': xxxBitmapButton, 'wxRadioButton': xxxRadioButton, 'wxSpinButton': xxxSpinButton, + 'wxToggleButton' : xxxToggleButton, 'wxStaticBox': xxxStaticBox, 'wxStaticBitmap': xxxStaticBitmap, @@ -757,8 +800,9 @@ xxxDict = { 'wxScrollBar': xxxScrollBar, 'wxTreeCtrl': xxxTreeCtrl, 'wxListCtrl': xxxListCtrl, - 'wxCheckList': xxxCheckList, + 'wxCheckListBox': xxxCheckList, 'wxNotebook': xxxNotebook, + 'wxSplitterWindow': xxxSplitterWindow, 'notebookpage': xxxNotebookPage, 'wxHtmlWindow': xxxHtmlWindow, 'wxCalendarCtrl': xxxCalendarCtrl, @@ -770,6 +814,7 @@ xxxDict = { 'wxStaticBoxSizer': xxxStaticBoxSizer, 'wxGridSizer': xxxGridSizer, 'wxFlexGridSizer': xxxFlexGridSizer, + 'wxGridBagSizer': xxxGridBagSizer, 'sizeritem': xxxSizerItem, 'spacer': xxxSpacer, @@ -784,7 +829,8 @@ 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() + 'tooltip': wxNewId(), 'encoding': wxNewId(), + 'cellpos': wxNewId(), 'cellspan': wxNewId() } for cl in xxxDict.values(): if cl.allParams: