X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..3d2d9036037d9ee51f47d878c3dcef4af4a6ef41:/wxPython/wx/tools/XRCed/xxx.py diff --git a/wxPython/wx/tools/XRCed/xxx.py b/wxPython/wx/tools/XRCed/xxx.py index 6da593b359..32636a5565 100644 --- a/wxPython/wx/tools/XRCed/xxx.py +++ b/wxPython/wx/tools/XRCed/xxx.py @@ -47,9 +47,16 @@ class xxxParam(xxxNode): self.textNode.data = value else: def value(self): - return self.textNode.data.encode(g.currentEncoding) + try: + return self.textNode.data.encode(g.currentEncoding) + except LookupError: + return self.textNode.data.encode() 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: + self.textNode.data = unicode(value) + #wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") # Integer parameter class xxxParamInt(xxxParam): @@ -207,6 +214,7 @@ class xxxObject: self.undo = None # Get attributes self.className = element.getAttribute('class') + self.subclass = element.getAttribute('subclass') if self.hasName: self.name = element.getAttribute('name') # Set parameters (text element children) self.params = {} @@ -222,7 +230,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) @@ -234,9 +242,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): @@ -244,7 +254,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) @@ -277,14 +287,20 @@ class xxxObject: # Class name plus wx name def treeName(self): if self.hasChild: return self.child.treeName() - if self.hasName and self.name: return self.className + ' "' + self.name + '"' - return self.className + if self.subclass: className = self.subclass + 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 ################################################################################ # This is a little special: it is both xxxObject and xxxNode class xxxParamFont(xxxObject, xxxNode): - allParams = ['size', 'style', 'weight', 'family', 'underlined', + allParams = ['size', 'family', 'style', 'weight', 'underlined', 'face', 'encoding'] def __init__(self, parent, element): xxxObject.__init__(self, parent, element) @@ -323,15 +339,14 @@ class xxxParamFont(xxxObject, xxxNode): class xxxContainer(xxxObject): hasChildren = True + exStyles = [] # 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): @@ -343,7 +358,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 @@ -352,40 +367,37 @@ class xxxPanel(xxxContainer): allParams = ['pos', 'size', 'style'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip'] - winStyles = ['wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] - exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY'] class xxxDialog(xxxContainer): allParams = ['title', 'centered', 'pos', 'size', 'style'] paramDict = {'centered': ParamBool} required = ['title'] default = {'title': ''} - winStyles = ['wxDEFAULT_DIALOG_STYLE', 'wxSTAY_ON_TOP', - 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', - 'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxRESIZE_BOX', + winStyles = ['wxDEFAULT_DIALOG_STYLE', + 'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX', + 'wxSTAY_ON_TOP', 'wxTHICK_FRAME', - 'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] + 'wxNO_3D', 'wxDIALOG_NO_PARENT'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip'] - exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY'] class xxxFrame(xxxContainer): allParams = ['title', 'centered', 'pos', 'size', 'style'] paramDict = {'centered': ParamBool} required = ['title'] default = {'title': ''} - winStyles = ['wxDEFAULT_FRAME_STYLE', 'wxDEFAULT_DIALOG_STYLE', + winStyles = ['wxDEFAULT_FRAME_STYLE', + 'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX', 'wxSTAY_ON_TOP', - 'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', - 'wxRESIZE_BOX', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', - 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW', - 'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] + 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', + 'wxFRAME_TOOL_WINDOW', 'wxFRAME_NO_TASKBAR', + 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_SHAPED' + ] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip'] - exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY'] class xxxTool(xxxObject): - allParams = ['bitmap', 'bitmap2', 'toggle', 'tooltip', 'longhelp'] + allParams = ['bitmap', 'bitmap2', 'toggle', 'tooltip', 'longhelp', 'label'] required = ['bitmap'] paramDict = {'bitmap2': ParamBitmap, 'toggle': ParamBool} hasStyle = False @@ -397,7 +409,24 @@ class xxxToolBar(xxxContainer): paramDict = {'bitmapsize': ParamPosSize, 'margins': ParamPosSize, 'packing': ParamInt, 'separation': ParamInt, 'style': ParamNonGenericStyle} - winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL'] + winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL', 'wxTB_TEXT'] + +class xxxWizard(xxxContainer): + allParams = ['title', 'bitmap', 'pos'] + required = ['title'] + default = {'title': ''} + winStyles = [] + exStyles = ['wxWIZARD_EX_HELPBUTTON'] + +class xxxWizardPage(xxxContainer): + allParams = ['bitmap'] + winStyles = [] + exStyles = [] + +class xxxWizardPageSimple(xxxContainer): + allParams = ['bitmap'] + winStyles = [] + exStyles = [] ################################################################################ # Bitmap, Icon @@ -408,8 +437,7 @@ class xxxBitmap(xxxObject): # Just like bitmap class xxxIcon(xxxObject): - allParams = ['icon'] - required = ['icon'] + allParams = [] ################################################################################ # Controls @@ -489,6 +517,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} @@ -531,6 +566,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 @@ -548,6 +588,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): @@ -599,6 +641,9 @@ class xxxGridSizer(xxxSizer): required = ['cols'] default = {'cols': '2', 'rows': '2'} +class xxxStdDialogButtonSizer(xxxSizer): + allParams = [] + # For repeated parameters class xxxParamMulti: def __init__(self, node): @@ -636,6 +681,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): @@ -661,9 +728,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: @@ -725,6 +796,9 @@ xxxDict = { 'wxFrame': xxxFrame, 'tool': xxxTool, 'wxToolBar': xxxToolBar, + 'wxWizard': xxxWizard, + 'wxWizardPage': xxxWizardPage, + 'wxWizardPageSimple': xxxWizardPageSimple, 'wxBitmap': xxxBitmap, 'wxIcon': xxxIcon, @@ -733,6 +807,7 @@ xxxDict = { 'wxBitmapButton': xxxBitmapButton, 'wxRadioButton': xxxRadioButton, 'wxSpinButton': xxxSpinButton, + 'wxToggleButton' : xxxToggleButton, 'wxStaticBox': xxxStaticBox, 'wxStaticBitmap': xxxStaticBitmap, @@ -750,8 +825,9 @@ xxxDict = { 'wxScrollBar': xxxScrollBar, 'wxTreeCtrl': xxxTreeCtrl, 'wxListCtrl': xxxListCtrl, - 'wxCheckList': xxxCheckList, + 'wxCheckListBox': xxxCheckList, 'wxNotebook': xxxNotebook, + 'wxSplitterWindow': xxxSplitterWindow, 'notebookpage': xxxNotebookPage, 'wxHtmlWindow': xxxHtmlWindow, 'wxCalendarCtrl': xxxCalendarCtrl, @@ -763,6 +839,8 @@ xxxDict = { 'wxStaticBoxSizer': xxxStaticBoxSizer, 'wxGridSizer': xxxGridSizer, 'wxFlexGridSizer': xxxFlexGridSizer, + 'wxGridBagSizer': xxxGridBagSizer, + 'wxStdDialogButtonSizer': xxxStdDialogButtonSizer, 'sizeritem': xxxSizerItem, 'spacer': xxxSpacer, @@ -777,7 +855,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: