From: Robin Dunn Date: Fri, 2 Nov 2001 01:59:05 +0000 (+0000) Subject: Updated XRCed X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a40b5e8474e7c8d3be805c83e54c5e016c11decc?hp=b6ea61a58979a763c9427f7b1ad2091067d3b458 Updated XRCed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/MANIFEST.in b/wxPython/MANIFEST.in index 3b5fb84398..dfe692137a 100644 --- a/wxPython/MANIFEST.in +++ b/wxPython/MANIFEST.in @@ -80,12 +80,11 @@ include src/gtk/*.h include src/gtk/*.py include tools/*.py -tools/XRCed/CHANGES -tools/XRCed/TODO -tools/XRCed/README -tools/XRCed/*.py -tools/XRCed/*.xrc - +include tools/XRCed/CHANGES +include tools/XRCed/TODO +include tools/XRCed/README +include tools/XRCed/*.py +include tools/XRCed/*.xrc include contrib/glcanvas/*.i include contrib/glcanvas/*.py diff --git a/wxPython/tools/XRCed/CHANGES b/wxPython/tools/XRCed/CHANGES index 7b15733c1e..2b2dbef1e5 100644 --- a/wxPython/tools/XRCed/CHANGES +++ b/wxPython/tools/XRCed/CHANGES @@ -1,3 +1,14 @@ +0.0.5 +----- + +Added notebook with properties page and style page. Fixed some problems +on Windows. + +0.0.4 +----- + +Some fixes suggested by RD + 0.0.3 ----- diff --git a/wxPython/tools/XRCed/TODO b/wxPython/tools/XRCed/TODO index dc6e7b2047..da2aaf4be5 100644 --- a/wxPython/tools/XRCed/TODO +++ b/wxPython/tools/XRCed/TODO @@ -26,3 +26,8 @@ TODO for XRCed * import XRC/WXR files +* disable some window creation when it's not valid + +* check for memory leaks from wx objects + +* style defaults for `hidde' and `focused' should be false diff --git a/wxPython/tools/XRCed/images.py b/wxPython/tools/XRCed/images.py index 3cb6d15471..668186f52c 100644 --- a/wxPython/tools/XRCed/images.py +++ b/wxPython/tools/XRCed/images.py @@ -5,6 +5,26 @@ from wxPython.wx import wxBitmapFromXPMData, wxImageFromBitmap import cPickle, zlib +def getIconData(): + return cPickle.loads(zlib.decompress( +'x\xda\x9d\x90\xbb\x0e\xc20\x0cEw\xbe\xc2\x12C\x91"Y-\xa2\x82\xd1\x80\xd45C\ +\x97\xac\x88\x11\xa4\xf0\xff\x13\xd7Nh\xa0\xcd\x00\xb8y\xf4\xe6\xf8\x95l\xee\ +\x8fn56\xdb\x1da\xec\xa9kV\x97\xb1\tt\xa5\xd3\xfdr\xbd\x99b\xa8\xf5\xf1\xa0\ +\x9fi\xa7\xba\x85\rI\xcb\x8bg\x1dU\xf7m\xbf\xeb[\xd3\xfe\xa53\'\xd5\xc3a8O\ +\xban_@\x0eL10\x07X\xc4iL[\x8e\x8c\x81 \xe1\xc3\xea\x17\xd4/NPct\x85{0N\xcc\ +\xa5f\xb4\x83\x94\xd6|\xde\x1b\xb2"\x9a\x16\x05\xe6\x10\x81\x08\xe5\x9cZ\x1d\ +K\xcd\xd4\xed\x04-}\xb9\n\n\x12\xdb\xb0\x99\x0e\xe8\x8f\x17\xf2N~\x81\xe2}"^\ +\x16\xd0;\x18\xce\x9c\xcb?oP\x9c\xc7t\xf0\xb1\xfd\x13Z&,9z\x0eS:\x04/\x1bB:\ +\x81Q\x15jM4Z\xaf\x99\xba\xf4\xf5n\xed\x9e\x92\xef)B\x7f\xbem\x81\xfc\x04\ +\x8f\xd5\x99\xcc' )) + +def getIconBitmap(): + return wxBitmapFromXPMData(getIconData()) + +def getIconImage(): + return wxImageFromBitmap(getIconBitmap()) + +#---------------------------------------------------------------------- def getNewData(): return cPickle.loads(zlib.decompress( "x\xda\xd3\xc8)0\xe4\nV72Q02V0Q0T\xe7J\x0cV\xd7SHVp\xcaIL\xce\x06\xf3\xf2\ @@ -133,6 +153,34 @@ def getAutoRefreshBitmap(): def getAutoRefreshImage(): return wxImageFromBitmap(getAutoRefreshBitmap()) +#---------------------------------------------------------------------- +def getTreeDefaultData(): + return cPickle.loads(zlib.decompress( +"x\xda\xd3\xc8)0\xe4\nV74S04Q0U0T\xe7J\x0cV\x8fPHVp\xcaIL\xce\x06\xf3\xfc\ +\x81\ +\x88\xefb\xe0b\xe2\x02S\x8c\n\xc8\x10\xd4\x83\x80\x08T\xc1|\x10\xf0\xa7\xae\ +\xa0?\x18\xa0\nF@\x01\x99\x8e'FP\x0f\x00\xdc\x1bL7" )) + +def getTreeDefaultBitmap(): + return wxBitmapFromXPMData(getTreeDefaultData()) + +def getTreeDefaultImage(): + return wxImageFromBitmap(getTreeDefaultBitmap()) + +#---------------------------------------------------------------------- +def getTreeRootData(): + return cPickle.loads(zlib.decompress( +'x\xda\xd3\xc8)0\xe4\nV74S04Q0V0T\xe7J\x0cV\xd7SHVp\xcaIL\xce\x06\xf3"\x80 # Created: 22.08.2001 +# RCS-ID: $Id$ from wxPython.wx import * from wxPython.xrc import * @@ -13,25 +14,23 @@ def SetCurrentXXX(xxx): global currentXXX currentXXX = xxx -# Register objects in the view -registered = {} -def Register(param, obj): - registered[param] = obj -def GetRegistered(param): - return registered[param] -def ClearRegister(): - registered.clear() - genericStyles = ['wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxRAISED_BORDER', 'wxTAB_TRAVERSAL', 'wxWANTS_CHARS', 'wxVSCROLL', 'wxHSCROLL'] -class ParamBinaryOr(wxPanel): - ID_TEXT_CTRL = wxNewId() - ID_BUTTON_CHOICES = wxNewId() - def __init__(self, parent, id, value, size, name, param): +# Class that can properly disable children +class PPanel(wxPanel): + def __init__(self, parent, id, name): wxPanel.__init__(self, parent, id, name=name) + def Enable(self, value): + for w in self.GetChildren(): + w.Enable(value) + +class ParamBinaryOr(PPanel): + def __init__(self, parent, id, value, size, name): + PPanel.__init__(self, parent, id, name) + self.ID_TEXT_CTRL = wxNewId() + self.ID_BUTTON_CHOICES = wxNewId() self.SetBackgroundColour(panel.GetBackgroundColour()) - Register(param, self) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, value, size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT, 10) @@ -50,9 +49,9 @@ class ParamBinaryOr(wxPanel): def SetValue(self, value): self.text.SetValue(value) def OnButtonChoices(self, evt): - dlg = wxDialog(self, -1, 'Choices', size=wxSize(250,300)) + dlg = wxDialog(self, -1, 'Choices') topSizer = wxBoxSizer(wxVERTICAL) - listBox = wxCheckListBox(dlg, -1, choices=self.values) + listBox = wxCheckListBox(dlg, -1, choices=self.values, size=(250,200)) value = map(string.strip, string.split(self.text.GetValue(), '|')) if value == ['']: value = [] ignored = [] @@ -76,6 +75,7 @@ class ParamBinaryOr(wxPanel): topSizer.Add(sizer, 0, wxALL | wxEXPAND, 10) dlg.SetAutoLayout(true) dlg.SetSizer(topSizer) + topSizer.Fit(dlg) dlg.Center() if dlg.ShowModal() != wxID_OK: return value = [] @@ -95,19 +95,153 @@ class ParamFlag(ParamBinaryOr): equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE', 'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL', 'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'} - def __init__(self, parent, id, value, size, name, param): - ParamBinaryOr.__init__(self, parent, id, value, size, name, param) + def __init__(self, parent, id, value, size, name): + ParamBinaryOr.__init__(self, parent, id, value, size, name) class ParamStyle(ParamBinaryOr): equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'} - def __init__(self, parent, id, value, size, name, param): - self.values = currentXXX.styles + genericStyles - ParamBinaryOr.__init__(self, parent, id, value, size, name, param) + def __init__(self, parent, id, value, size, name): + self.values = currentXXX.winStyles + genericStyles + ParamBinaryOr.__init__(self, parent, id, value, size, name) -class ParamInt(wxPanel): - ID_SPIN_CTRL = wxNewId() - def __init__(self, parent, id, value, size, name, param): - wxPanel.__init__(self, parent, id, name=name) +class ParamExStyle(ParamBinaryOr): + def __init__(self, parent, id, value, size, name): + if currentXXX: + self.values = currentXXX.exStyles # constant at the moment + else: + self.values = [] + ParamBinaryOr.__init__(self, parent, id, value, size, name) + +class ParamColour(PPanel): + def __init__(self, parent, id, value, size, name): + PPanel.__init__(self, parent, id, name) + self.ID_TEXT_CTRL = wxNewId() + self.ID_BUTTON = wxNewId() + self.SetBackgroundColour(panel.GetBackgroundColour()) + sizer = wxBoxSizer() + self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(60,-1)) + sizer.Add(self.text, 0, wxGROW | wxRIGHT, 10) + self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(40, -1)) + sizer.Add(self.button, 0, wxGROW) + self.SetAutoLayout(true) + self.SetSizer(sizer) + sizer.Fit(self) + self.textModified = false + self.SetValue(value) + EVT_PAINT(self.button, self.OnPaintButton) + EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + EVT_LEFT_DOWN(self.button, self.OnLeftDown) + def GetValue(self): + return self.value + def SetValue(self, value): + if not value: value = '#FFFFFF' + self.value = value + self.text.SetValue(str(value)) # update text ctrl + self.button.SetBackgroundColour(wxNamedColour(value)) + self.button.Refresh() + def OnChange(self, evt): + panel.SetModified(true) + self.textModified = true + evt.Skip() + def OnPaintButton(self, evt): + dc = wxPaintDC(self.button) + dc.SetBrush(wxTRANSPARENT_BRUSH) + if panel.page2.IsEnabled() and self.IsEnabled(): dc.SetPen(wxBLACK_PEN) + else: dc.SetPen(wxGREY_PEN) + size = self.button.GetSize() + dc.DrawRectangle(0, 0, size.x, size.y) + def OnLeftDown(self, evt): + dlg = wxColourDialog(self) + if dlg.ShowModal() == wxID_OK: + self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get()) + panel.SetModified(true) + +################################################################################ + +# Mapping from wx constants ro XML strings +fontFamiliesWx2Xml = {wxDEFAULT: 'default', wxDECORATIVE: 'decorative', + wxROMAN: 'roman', wxSCRIPT: 'script', wxSWISS: 'swiss', + wxMODERN: 'modern'} +fontStylesWx2Xml = {wxNORMAL: 'normal', wxSLANT: 'slant', wxITALIC: 'italic'} +fontWeightsWx2Xml = {wxNORMAL: 'normal', wxLIGHT: 'light', wxBOLD: 'bold'} +def ReverseMap(m): + rm = {} + for k,v in m.items(): rm[v] = k + return rm +fontFamiliesXml2wx = ReverseMap(fontFamiliesWx2Xml) +fontStylesXml2wx = ReverseMap(fontStylesWx2Xml) +fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml) + +class ParamFont(PPanel): + def __init__(self, parent, id, value, size, name): + PPanel.__init__(self, parent, id, name) + self.ID_TEXT_CTRL = wxNewId() + self.ID_BUTTON_SELECT = wxNewId() + self.SetBackgroundColour(panel.GetBackgroundColour()) + sizer = wxBoxSizer() + self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(200,-1)) + sizer.Add(self.text, 0, wxRIGHT, 10) + self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...') + sizer.Add(self.button) + self.SetAutoLayout(true) + self.SetSizer(sizer) + sizer.Fit(self) + self.textModified = false + EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect) + EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + def OnChange(self, evt): + panel.SetModified(true) + self.textModified = true + evt.Skip() + def GetValue(self): + if self.textModified: # text has newer value + return eval(self.text.GetValue()) + return self.value + def SetValue(self, value): + if not value: value = [''] * 7 + self.value = value + self.text.SetValue(str(value)) # update text ctrl + def OnButtonSelect(self, evt): + if self.textModified: # text has newer value + self.value = eval(self.text.GetValue()) + # Make initial font + try: size = int(self.value[0]) + except ValueError: size = 12 + try: family = fontFamiliesXml2wx[self.value[1]] + except KeyError: family = wxDEFAULT + try: style = fontStylesXml2wx[self.value[2]] + except KeyError: style = wxNORMAL + try: weight = fontWeightsXml2wx[self.value[3]] + except KeyError: weight = wxNORMAL + try: underlined = int(self.value[4]) + except ValueError: underlined = 0 + face = self.value[5] + mapper = wxFontMapper() + enc = wxFONTENCODING_DEFAULT + if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6]) + if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM + font = wxFont(size, family, style, weight, underlined, face, enc) + data = wxFontData() + data.SetInitialFont(font) + dlg = wxFontDialog(self, data) + if dlg.ShowModal() != wxID_OK: return + font = dlg.GetFontData().GetChosenFont() + value = [str(font.GetPointSize()), fontFamiliesWx2Xml[font.GetFamily()], + fontStylesWx2Xml[font.GetStyle()], + fontWeightsWx2Xml[font.GetWeight()], + str(font.GetUnderlined()), font.GetFaceName(), + wxFontMapper_GetEncodingName(font.GetEncoding())] + # Add ignored flags + self.SetValue(value) + panel.SetModified(true) + self.textModified = false + +################################################################################ + +class ParamInt(PPanel): + def __init__(self, parent, id, value, size, name): + PPanel.__init__(self, parent, id, name) + self.ID_SPIN_CTRL = wxNewId() sizer = wxBoxSizer() self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, value, size=wxSize(50,-1)) self.SetBackgroundColour(panel.GetBackgroundColour()) @@ -115,7 +249,6 @@ class ParamInt(wxPanel): self.SetAutoLayout(true) self.SetSizer(sizer) sizer.Fit(self) - Register(param, self) EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) def GetValue(self): return str(self.spin.GetValue()) @@ -127,27 +260,24 @@ class ParamInt(wxPanel): evt.Skip() class ParamText(wxTextCtrl): - def __init__(self, parent, id, value, size, name, param): + def __init__(self, parent, id, value, size, name): wxTextCtrl.__init__(self, parent, id, value, size=wxSize(200,-1), name=name) - Register(param, self) EVT_TEXT(self, id, self.OnChange) def OnChange(self, evt): panel.SetModified(true) evt.Skip() class ParamAccel(wxTextCtrl): - def __init__(self, parent, id, value, size, name, param): + def __init__(self, parent, id, value, size, name): wxTextCtrl.__init__(self, parent, id, value, size=wxSize(50,-1), name=name) - Register(param, self) EVT_TEXT(self, id, self.OnChange) def OnChange(self, evt): panel.SetModified(true) evt.Skip() class ParamPosSize(wxTextCtrl): - def __init__(self, parent, id, value, size, name, param): + def __init__(self, parent, id, value, size, name): wxTextCtrl.__init__(self, parent, id, value, size=wxSize(80,-1), name=name) - Register(param, self) EVT_TEXT(self, id, self.OnChange) def OnChange(self, evt): panel.SetModified(true) @@ -155,6 +285,7 @@ class ParamPosSize(wxTextCtrl): class ContentDialog(wxDialog): def __init__(self, parent, value): + #wxPreDialog(self) # Use another constructor w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT') self.this = w.this @@ -166,8 +297,9 @@ class ContentDialog(wxDialog): # Set list items for v in value: self.list.Append(v) - # !!! Bug in XRC or wxWin listbox select random items - self.FindWindowByName('wxID_OK').SetFocus() + self.SetAutoLayout(true) + # !!! self.SetSizer(sizer) + self.GetSizer().Fit(self) # Callbacks self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND') self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE') @@ -203,15 +335,15 @@ class ContentDialog(wxDialog): elif evt.GetId() == self.ID_BUTTON_UP: evt.Enable(self.list.GetSelection() > 0) elif evt.GetId() == self.ID_BUTTON_DOWN: - evt.Enable(self.list.GetSelection() < self.list.Number() - 1) + evt.Enable(self.list.GetSelection() != -1 and \ + self.list.GetSelection() < self.list.Number() - 1) -class ParamContent(wxPanel): - ID_TEXT_CTRL = wxNewId() - ID_BUTTON_EDIT = wxNewId() - def __init__(self, parent, id, value, size, name, param): - wxPanel.__init__(self, parent, id, name=name) +class ParamContent(PPanel): + def __init__(self, parent, id, value, size, name): + PPanel.__init__(self, parent, id, name) + self.ID_TEXT_CTRL = wxNewId() + self.ID_BUTTON_EDIT = wxNewId() self.SetBackgroundColour(panel.GetBackgroundColour()) - Register(param, self) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, str(value), size=wxSize(200,-1)) sizer.Add(self.text, 0, wxRIGHT, 10) @@ -248,11 +380,11 @@ class ParamContent(wxPanel): self.textModified = false # Boxless radiobox -class RadioBox(wxPanel): - ID_RADIO_CHOICE = wxNewId() # economize on IDs, use names +class RadioBox(PPanel): def __init__(self, parent, id, choices, pos=wxDefaultPosition, size=wxDefaultSize, name='radiobox'): - wxPanel.__init__(self, parent, id, pos, size, name=name) + PPanel.__init__(self, parent, id, name) + self.ID_RADIO_CHOICE = wxNewId() # economize on IDs, use names self.SetBackgroundColour(panel.GetBackgroundColour()) self.choices = choices topSizer = wxBoxSizer() @@ -281,9 +413,8 @@ class RadioBox(wxPanel): class ParamBool(RadioBox): values = {'yes': '1', 'no': '0'} seulav = {'1': 'yes', '0': 'no'} - def __init__(self, parent, id, value, size, name, param): + def __init__(self, parent, id, value, size, name): RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) - Register(param, self) self.SetValue(value) def GetValue(self): return self.values[self.GetStringSelection()] @@ -294,9 +425,8 @@ class ParamBool(RadioBox): class ParamOrient(RadioBox): values = {'horizontal': 'wxHORIZONTAL', 'vertical': 'wxVERTICAL'} seulav = {'wxHORIZONTAL': 'horizontal', 'wxVERTICAL': 'vertical'} - def __init__(self, parent, id, value, size, name, param): + def __init__(self, parent, id, value, size, name): RadioBox.__init__(self, parent, id, choices = self.values.keys(), name=name) - Register(param, self) self.SetValue(value) def GetValue(self): return self.values[self.GetStringSelection()] @@ -306,7 +436,7 @@ class ParamOrient(RadioBox): paramDict = { 'flag': ParamFlag, - 'style': ParamStyle, + 'style': ParamStyle, 'exstyle': ParamExStyle, 'pos': ParamPosSize, 'size': ParamPosSize, 'border': ParamInt, 'cols': ParamInt, 'rows': ParamInt, 'vgap': ParamInt, 'hgap': ParamInt, @@ -314,4 +444,8 @@ paramDict = { 'label': ParamText, 'title': ParamText, 'value': ParamText, 'content': ParamContent, 'selection': ParamInt, 'min': ParamInt, 'max': ParamInt, + 'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont, + 'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool, + 'tooltip': ParamText } + diff --git a/wxPython/tools/XRCed/xrced.py b/wxPython/tools/XRCed/xrced.py index 6d19390d8b..2378d1661b 100644 --- a/wxPython/tools/XRCed/xrced.py +++ b/wxPython/tools/XRCed/xrced.py @@ -2,6 +2,7 @@ # Purpose: XRC editor, main module # Author: Roman Rolinsky # Created: 20.08.2001 +# RCS-ID: $Id$ from wxPython.wx import * from wxPython.xrc import * @@ -14,10 +15,14 @@ import tempfile import images # String constants -htmlHeader = '\n' + +faceColour = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DFACE) +# Stange wxHtmlWindow behavior: when bgcolor is exact, it turns white +bgcolor = (faceColour.Red()-1, faceColour.Green()-1, faceColour.Blue()-1) +htmlHeader = '\n' % bgcolor htmlFooter = '\n' progname = 'XRCed' -version = '0.0.3' +version = '0.0.5' # Local modules from xxx import * @@ -48,40 +53,85 @@ def SetMenu(m, list): else: # separator m.AppendSeparator() -# Properties panel -class Panel(wxHtmlWindow): - def __init__(self, parent, id): - wxHtmlWindow.__init__(self, parent, id) - self.SetBorders(5) - self.SetFonts('', '', [8, 10, 12, 14, 16, 19, 24]) - EVT_CHECKBOX(self, xxxObject.ID_CHECK_PARAMS, self.OnCheckParams) - EVT_CHECKBOX(self, xxxChildContainer.ID_CHECK_PARAMS, self.OnCheckParams) - self.modified = false - +################################################################################ + +# Properties panel containing notebook +class Panel(wxNotebook): + def __init__(self, parent, id = -1): + wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM) + #self.SetBackgroundColour(wxColour(bgcolor)) + sys.modules['params'].panel = self + self.page1 = HtmlPage(self) + self.AddPage(self.page1, 'Properties') + self.page2 = None + def SetData(self, xxx): + self.page1.SetPageData(xxx) + # Replace/remove style page + if self.page2: + self.RemovePage(1) + self.page2.Destroy() + if xxx and xxx.treeObject().hasStyle: + self.page2 = StylePage(self, xxx.treeObject()) + self.AddPage(self.page2, 'Style') + else: + self.page2 = None def Clear(self): - self.SetPage(htmlHeader + 'select a tree item on the left' + htmlFooter) - + self.page1.Clear() + if self.page2: + self.RemovePage(1) + self.page2.Destroy() + self.page2 = None + # If some parameter on some page has changed + def IsModified(self): + return self.page1.IsModified() or self.page2 and self.page2.IsModified() + def SetModified(self, value): + self.page1.SetModified(value) + if self.page2: + self.page2.SetModified(value) + +################################################################################ + +# General class for notebook pages +class ParamPage: + def __init__(self): + # Register event handlers + for id in paramIDs.values(): + EVT_CHECKBOX(self, id, self.OnCheckParams) def OnCheckParams(self, evt): selected = tree.GetSelection() xxx = tree.GetPyData(selected) - if xxx.hasChild and evt.GetId() != xxxChildContainer.ID_CHECK_PARAMS: - xxx = xxx.child + winName = evt.GetEventObject().GetName() + sizerParam = false + if winName[0] == '_': + param = winName[7:] + sizerParam = true + else: + if xxx.hasChild: xxx = xxx.child + param = winName[6:] # Set current object - param = evt.GetEventObject().GetName()[6:] - if xxx.hasChild: - w = GetRegistered('_'+param) + if sizerParam: + w = self.FindWindowByName('_data_' + param) else: - w = GetRegistered(param) + w = self.FindWindowByName('data_' + param) elem = xxx.element if evt.IsChecked(): # Ad new text node in order of allParams - w.SetValue('') - textElem = tree.dom.createElement(param) - textNode = tree.dom.createTextNode('') - textElem.appendChild(textNode) + w.SetValue('') # set empty (default) value + # For font element, we have to create another object + if param == 'font': + # Make XXX object + textElem = tree.dom.createElement('font') + font = xxxFont(xxx, textElem) + xxx.params['font'] = font + else: + textElem = tree.dom.createElement(param) + textNode = tree.dom.createTextNode('') + textElem.appendChild(textNode) + xxx.params[param] = textNode # Find place to put new element: first present element after param found = false - for p in xxx.allParams[xxx.allParams.index(param) + 1:]: + paramStyles = xxx.allParams + xxx.styles + for p in paramStyles[paramStyles.index(param) + 1:]: # Content params don't have same type if xxx.params.has_key(p) and p != 'content': found = true @@ -91,7 +141,6 @@ class Panel(wxHtmlWindow): elem.insertBefore(textElem, nextTextElem) else: elem.appendChild(textElem) - xxx.params[param] = textNode else: # Remove parameter element and following text node textElem = xxx.params[param].parentNode @@ -105,12 +154,108 @@ class Panel(wxHtmlWindow): # Set modified flas self.SetModified(true) - # If some parameter was changed + +################################################################################ + +# Properties panel notebook page +class HtmlPage(wxHtmlWindow, ParamPage): + def __init__(self, parent, id = -1): + wxHtmlWindow.__init__(self, parent, id) + ParamPage.__init__(self) + self.SetBorders(5) + if wxGetOsVersion()[1] == 1: + self.SetFonts('', '', [8, 10, 12, 14, 16, 19, 24]) + else: + self.SetFonts("", "", [7, 8, 10, 12, 16, 22, 30]) + self.modified = false + def Clear(self): + self.SetPage(htmlHeader + 'select a tree item on the left' + htmlFooter) + def SetPageData(self, xxx): + if not xxx: + self.SetPage(htmlHeader + 'this item has no properties' + htmlFooter) + return + self.SetPage(htmlHeader + xxx.generateHtml() + htmlFooter) + # Set values, checkboxes to false, disable defaults + if xxx.hasChild: prefix = '_' + else: prefix = '' + for param in xxx.allParams: + if xxx.params.has_key(param): + if param == 'content': + value = [] + for text in xxx.params[param]: + value.append(str(text.data)) # convert from unicode + else: + value = xxx.params[param].data + self.FindWindowByName(prefix + 'data_' + param).SetValue(value) + if not param in xxx.required: + self.FindWindowByName(prefix + 'check_' + param).SetValue(true) + else: + self.FindWindowByName(prefix + 'data_' + param).Enable(false) + # Same for the child of sizeritem + if xxx.hasChild: + xxx = xxx.child + for param in xxx.allParams: + if xxx.params.has_key(param): + if param == 'content': + value = [] + for text in xxx.params[param]: + value.append(str(text.data)) # convert from unicode + else: + value = xxx.params[param].data + self.FindWindowByName('data_' + param).SetValue(value) + if not param in xxx.required: + self.FindWindowByName('check_' + param).SetValue(true) + else: + self.FindWindowByName('data_' + param).Enable(false) + # If some parameter has changed def IsModified(self): return self.modified def SetModified(self, value): self.modified = value +################################################################################ + +# Style notebook page +class StylePage(wxPanel, ParamPage): + def __init__(self, parent, xxx): + wxPanel.__init__(self, parent, -1) + ParamPage.__init__(self) + if wxGetOsVersion()[1] == 1: + self.SetFont(wxFont(12, wxDEFAULT, wxNORMAL, wxNORMAL)) + else: + self.SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL)) + topSizer = wxBoxSizer(wxVERTICAL) + sizer = wxFlexGridSizer(len(xxx.styles), 2, 0, 1) + self.controls = {} # save python objects + for param in xxx.styles: + present = param in xxx.params.keys() + check = wxCheckBox(self, paramIDs[param], + param + ':', name = 'check_' + param) + check.SetValue(present) + control = paramDict[param](self, -1, '', (-1, -1), + 'data_' + param) + if present: + control.SetValue(xxx.params[param].data) + else: + control.SetValue('') + control.Enable(present) + sizer.AddMany([ (check, 0, 0), + (control, 0, 0) ]) + self.controls[param] = control + topSizer.Add(sizer, 1, wxALL, 5) + self.SetAutoLayout(true) + self.SetSizer(topSizer) + + self.modified = false + + # If some parameter has changed + def IsModified(self): + return self.modified + def SetModified(self, value): + self.modified = value + +################################################################################ + class HightLightBox: def __init__(self, pos, size): w = testWin.panel @@ -136,6 +281,8 @@ class HightLightBox: map(wxWindow.Destroy, self.lines) testWin.highLight = None +################################################################################ + class MemoryFile: def __init__(self, name): self.name = name @@ -151,7 +298,8 @@ class MemoryFile: class XML_Tree(wxTreeCtrl): def __init__(self, parent, id): - wxTreeCtrl.__init__(self, parent, id) + wxTreeCtrl.__init__(self, parent, id, + style=wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT) self.SetBackgroundColour(wxColour(224, 248, 224)) EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged) EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated) @@ -162,17 +310,19 @@ class XML_Tree(wxTreeCtrl): self.dom = None # Create image list il = wxImageList(16, 16, true) - xxxPanel.image = il.AddIcon( wxIconFromXPMData(images.getTreePanelData()) ) - xxxDialog.image = il.AddIcon( wxIconFromXPMData(images.getTreeDialogData()) ) - xxxFrame.image = il.AddIcon( wxIconFromXPMData(images.getTreeFrameData()) ) - xxxMenuBar.image = il.AddIcon( wxIconFromXPMData(images.getTreeMenuBarData()) ) - xxxMenu.image = il.AddIcon( wxIconFromXPMData(images.getTreeMenuData()) ) - xxxSizer.imageH = il.AddIcon( wxIconFromXPMData(images.getTreeSizerHData()) ) - xxxSizer.imageV = il.AddIcon( wxIconFromXPMData(images.getTreeSizerVData()) ) - xxxStaticBoxSizer.imageH = il.AddIcon( wxIconFromXPMData(images.getTreeStaticBoxSizerHData()) ) - xxxStaticBoxSizer.imageV = il.AddIcon( wxIconFromXPMData(images.getTreeStaticBoxSizerVData()) ) - xxxGridSizer.image = il.AddIcon( wxIconFromXPMData(images.getTreeSizerGridData()) ) - xxxFlexGridSizer.image = il.AddIcon( wxIconFromXPMData(images.getTreeSizerFlexGridData()) ) + self.rootImage = il.AddIcon(wxIconFromXPMData(images.getTreeRootData())) + xxxObject.image = il.AddIcon(wxIconFromXPMData(images.getTreeDefaultData())) + xxxPanel.image = il.AddIcon(wxIconFromXPMData(images.getTreePanelData())) + xxxDialog.image = il.AddIcon(wxIconFromXPMData(images.getTreeDialogData())) + xxxFrame.image = il.AddIcon(wxIconFromXPMData(images.getTreeFrameData())) + xxxMenuBar.image = il.AddIcon(wxIconFromXPMData(images.getTreeMenuBarData())) + xxxMenu.image = il.AddIcon(wxIconFromXPMData(images.getTreeMenuData())) + xxxSizer.imageH = il.AddIcon(wxIconFromXPMData(images.getTreeSizerHData())) + xxxSizer.imageV = il.AddIcon(wxIconFromXPMData(images.getTreeSizerVData())) + xxxStaticBoxSizer.imageH = il.AddIcon(wxIconFromXPMData(images.getTreeStaticBoxSizerHData())) + xxxStaticBoxSizer.imageV = il.AddIcon(wxIconFromXPMData(images.getTreeStaticBoxSizerVData())) + xxxGridSizer.image = il.AddIcon(wxIconFromXPMData(images.getTreeSizerGridData())) + xxxFlexGridSizer.image = il.AddIcon(wxIconFromXPMData(images.getTreeSizerFlexGridData())) self.il = il self.SetImageList(il) @@ -182,7 +332,7 @@ class XML_Tree(wxTreeCtrl): wxTreeCtrl.Unselect(self) def GetSelection(self): return self.selection - + def ExpandAll(self, item): if self.ItemHasChildren(item): self.Expand(item) @@ -226,7 +376,7 @@ class XML_Tree(wxTreeCtrl): elif n.nodeType != minidom.Node.ELEMENT_NODE: treeObj.element.removeChild(n) n.unlink() - + # Remove leaf of tree, return it's data object def RemoveLeaf(self, leaf): @@ -300,51 +450,12 @@ class XML_Tree(wxTreeCtrl): item = evt.GetItem() self.selection = item # !!! fix xxx = self.GetPyData(item) - html = htmlHeader - # List of parameters tuples (parameter, isDefined) - if not xxx: # root item - html += 'this item has no properties' + htmlFooter - panel.SetPage(html) - if testWin and testWin.highLight: - testWin.highLight.Remove() + # Update panel + panel.SetData(xxx) + # Remove highlight? + if not xxx and testWin and testWin.highLight: + testWin.highLight.Remove() return - # Normal nodes - ClearRegister() # empty register - html += xxx.generateHtml() - html += htmlFooter - panel.SetPage(html) - # Set values, checkboxes to false, disable defaults - if xxx.hasChild: prefix = '_' - else: prefix = '' - for param in xxx.allParams: - if xxx.params.has_key(param): - if param == 'content': - value = [] - for text in xxx.params[param]: - value.append(str(text.data)) # convert from unicode - else: - value = xxx.params[param].data - GetRegistered(prefix + param).SetValue(value) - if not param in xxx.required: - panel.FindWindowByName('check_' + param).SetValue(true) - else: - GetRegistered(prefix + param).Enable(false) - # Same for the child of sizeritem - if xxx.hasChild: - xxx = xxx.child - for param in xxx.allParams: - if xxx.params.has_key(param): - if param == 'content': - value = [] - for text in xxx.params[param]: - value.append(str(text.data)) # convert from unicode - else: - value = xxx.params[param].data - GetRegistered(param).SetValue(value) - if not param in xxx.required: - panel.FindWindowByName('check_' + param).SetValue(true) - else: - GetRegistered(param).Enable(false) # Clear flag panel.SetModified(false) # Hightlighting is done in OnIdle @@ -390,7 +501,7 @@ class XML_Tree(wxTreeCtrl): except AttributeError: testWin.highLight = HightLightBox(pos, size) testWin.highLight.item = item - + # Double-click def OnItemActivated(self, evt): item = evt.GetItem() @@ -399,7 +510,7 @@ class XML_Tree(wxTreeCtrl): if panel.IsModified(): self.Apply(xxx, item) # apply changes self.CreateTestWin(item) - + # (re)create test window def CreateTestWin(self, node): global testWin @@ -494,7 +605,7 @@ class XML_Tree(wxTreeCtrl): testWin.highLight = None if highLight and not tree.pendingHighLight: self.HighLight(highLight) - + def OnCloseTestWin(self, evt): global testWin, testWinPos testWinPos = testWin.GetPosition() @@ -510,14 +621,15 @@ class XML_Tree(wxTreeCtrl): if xxx.hasChildren and not self.ItemHasChildren(item): return false return not (self.IsExpanded(item) and self.ItemHasChildren(item)) - + # Pull-down def OnRightDown(self, evt): # Setup menu - pullDownMenu.menu = wxMenu() + menu = wxMenu() + item = self.GetSelection() - if not item.IsOk(): - pullDownMenu.menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand tree') + if not item.IsOk(): + menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand tree') else: self.ctrl = evt.ControlDown() # save Ctrl state m = wxMenu() # create menu @@ -543,33 +655,31 @@ class XML_Tree(wxTreeCtrl): m.Enable(pullDownMenu.ID_NEW_SPACER, false) # Select correct label for create menu if item == self.GetRootItem(): - pullDownMenu.menu.AppendMenu(wxNewId(), 'Create', m, 'Create top-level object') + menu.AppendMenu(wxNewId(), 'Create', m, 'Create top-level object') else: if not needInsert: - pullDownMenu.menu.AppendMenu(wxNewId(), 'Create child', m, - 'Create child object') + menu.AppendMenu(wxNewId(), 'Create child', m, + 'Create child object') else: - pullDownMenu.menu.AppendMenu(wxNewId(), 'Create Sibling', m, - 'Create sibling of selected object') - pullDownMenu.menu.AppendSeparator() - pullDownMenu.menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard') - pullDownMenu.menu.Append(wxID_COPY, 'Copy', 'Copy to the clipboard') - pullDownMenu.menu.Append(wxID_PASTE, 'Paste', 'Paste from the clipboard') - pullDownMenu.menu.Append(pullDownMenu.ID_DELETE, - 'Delete', 'Delete object') + menu.AppendMenu(wxNewId(), 'Create Sibling', m, + 'Create sibling of selected object') + menu.AppendSeparator() + menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard') + menu.Append(wxID_COPY, 'Copy', 'Copy to the clipboard') + menu.Append(wxID_PASTE, 'Paste', 'Paste from the clipboard') + menu.Append(pullDownMenu.ID_DELETE, + 'Delete', 'Delete object') if item.IsOk() and self.ItemHasChildren(item): - pullDownMenu.menu.AppendSeparator() - pullDownMenu.menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand subtree') - self.PopupMenu(pullDownMenu.menu, evt.GetPosition()) - pullDownMenu.menu.Destroy() - pullDownMenu.menu = None - + menu.AppendSeparator() + menu.Append(pullDownMenu.ID_EXPAND, 'Expand', 'Expand subtree') + self.PopupMenu(menu, evt.GetPosition()) + menu.Destroy() # Clear tree def Clear(self): self.DeleteAllItems() # Add minimal structure - root = self.AddRoot('XML tree') + root = self.AddRoot('XML tree', self.rootImage) self.Unselect() if self.dom: self.dom.unlink() self.dom = minidom.Document() @@ -577,7 +687,7 @@ class XML_Tree(wxTreeCtrl): # Create main node self.mainNode = self.dom.createElement('resource') self.dom.appendChild(self.mainNode) - + # Apply changes def Apply(self, xxx, item): if not xxx: return @@ -585,7 +695,7 @@ class XML_Tree(wxTreeCtrl): if xxx.undo: xxx.undo.unlink() xxx.undo = xxx.element.cloneNode(false) if xxx.hasName: - name = GetRegistered('name').GetValue() + name = panel.page1.FindWindowByName('data_name').GetValue() if xxx.name != name: xxx.name = name xxx.element.setAttribute('name', name) @@ -593,7 +703,7 @@ class XML_Tree(wxTreeCtrl): if xxx.hasChild: prefix = '_' else: prefix = '' for param, data in xxx.params.items(): - value = GetRegistered(prefix + param).GetValue() + value = panel.FindWindowByName(prefix + 'data_' + param).GetValue() if param == 'content': # If number if items is not the same, recreate children if len(value) != len(data): @@ -611,6 +721,8 @@ class XML_Tree(wxTreeCtrl): else: for i in range(len(value)): data[i].data = value[i] + elif param == 'font': + data.updateXML(value) else: data.data = value if xxx.hasChild: @@ -622,10 +734,63 @@ class XML_Tree(wxTreeCtrl): # Set global modified state frame.modified = true +class PullDownMenu: + ID_NEW_PANEL = wxNewId() + ID_NEW_DIALOG = wxNewId() + ID_NEW_FRAME = wxNewId() + ID_NEW_MENU_BAR = wxNewId() + ID_NEW_MENU = wxNewId() + + ID_NEW_STATIC_TEXT = wxNewId() + ID_NEW_TEXT_CTRL = wxNewId() + + ID_NEW_BUTTON = wxNewId() + ID_NEW_BITMAP_BUTTON = wxNewId() + ID_NEW_RADIO_BUTTON = wxNewId() + ID_NEW_SPIN_BUTTON = wxNewId() + + ID_NEW_STATIC_BOX = wxNewId() + ID_NEW_CHECK_BOX = wxNewId() + ID_NEW_RADIO_BOX = wxNewId() + ID_NEW_COMBO_BOX = wxNewId() + ID_NEW_LIST_BOX = wxNewId() + + ID_NEW_STATIC_LINE = wxNewId() + ID_NEW_CHOICE = wxNewId() + ID_NEW_SLIDER = wxNewId() + ID_NEW_GAUGE = wxNewId() + ID_NEW_SCROLL_BAR = wxNewId() + ID_NEW_TREE_CTRL = wxNewId() + ID_NEW_LIST_CTRL = wxNewId() + ID_NEW_CHECK_LIST = wxNewId() + ID_NEW_NOTEBOOK = wxNewId() + ID_NEW_HTML_WINDOW = wxNewId() + ID_NEW_CALENDAR = wxNewId() + + ID_NEW_BOX_SIZER = wxNewId() + ID_NEW_STATIC_BOX_SIZER = wxNewId() + ID_NEW_GRID_SIZER = wxNewId() + ID_NEW_FLEX_GRID_SIZER = wxNewId() + ID_NEW_SPACER = wxNewId() + ID_NEW_MENU = wxNewId() + ID_NEW_MENU_ITEM = wxNewId() + ID_NEW_SEPARATOR = wxNewId() + ID_NEW_LAST = wxNewId() + ID_EXPAND = wxNewId() + + def __init__(self, parent): + self.ID_DELETE = parent.ID_DELETE + EVT_MENU_RANGE(parent, self.ID_NEW_PANEL, + self.ID_NEW_LAST, parent.OnCreate) + EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand) + # We connect to tree, but process in frame + EVT_MENU_HIGHLIGHT_ALL(tree, parent.OnPullDownHighlight) + class Frame(wxFrame): def __init__(self, size): wxFrame.__init__(self, None, -1, '', size=size) self.CreateStatusBar() + self.SetIcon(wxIconFromXPMData(images.getIconData())) # Make menus menuBar = wxMenuBar() @@ -638,7 +803,7 @@ class Frame(wxFrame): menu.AppendSeparator() menu.Append(wxID_EXIT, '&Quit\tCtrl-Q', 'Exit application') menuBar.Append(menu, '&File') - + menu = wxMenu() menu.Append(wxID_UNDO, '&Undo\tCtrl-Z', 'Undo') menu.Append(wxID_REDO, '&Redo\tCtrl-R', 'Redo') @@ -649,7 +814,7 @@ class Frame(wxFrame): self.ID_DELETE = wxNewId() menu.Append(self.ID_DELETE, '&Delete\tCtrl-D', 'Delete object') menuBar.Append(menu, '&Edit') - + menu = wxMenu() self.ID_REFRESH = wxNewId() menu.Append(self.ID_REFRESH, '&Refresh\tCtrl-R', 'Refresh view') @@ -658,7 +823,7 @@ class Frame(wxFrame): 'Toggle auto-refresh mode', true) menu.Check(self.ID_AUTO_REFRESH, conf.autoRefresh) menuBar.Append(menu, '&View') - + menu = wxMenu() menu.Append(wxID_ABOUT, 'About...', 'About XCRed') if debug: @@ -671,8 +836,8 @@ class Frame(wxFrame): self.SetMenuBar(menuBar) # Create toolbar - tb = self.CreateToolBar()#wxTB_DOCKABLE | wxTB_FLAT) - tb.SetToolBitmapSize((24,23)) + tb = self.CreateToolBar(wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT) + tb.SetToolBitmapSize((24, 23)) tb.AddSimpleTool(wxID_NEW, images.getNewBitmap(), 'New', 'New file') tb.AddSimpleTool(wxID_OPEN, images.getOpenBitmap(), 'Open', 'Open file') tb.AddSimpleTool(wxID_SAVE, images.getSaveBitmap(), 'Save', 'Save file') @@ -686,8 +851,8 @@ class Frame(wxFrame): tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(), 'Auto-refresh', 'Toggle auto-refresh mode', true) tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh) - self.tb = tb tb.Realize() + self.tb = tb # File EVT_MENU(self, wxID_NEW, self.OnNew) @@ -715,85 +880,26 @@ class Frame(wxFrame): EVT_UPDATE_UI(self, self.ID_DELETE, self.OnUpdateUI) # Build interface - splitter = wxSplitterWindow(self, -1) + sizer = wxBoxSizer(wxVERTICAL) + sizer.Add(wxStaticLine(self, -1), 0, wxEXPAND) + splitter = wxSplitterWindow(self, -1, style=wxSP_3DSASH) + splitter.SetMinimumPaneSize(100) # Create tree global tree tree = XML_Tree(splitter, -1) sys.modules['xxx'].tree = tree # Create panel for parameters global panel - #panel = wxPanel(self, -1) - # Sizer for static box - #sizer = wxBoxSizer() - panel = Panel(splitter, -1) - sys.modules['params'].panel = panel - #sizer.Add(panel, 1, wxEXPAND) - #box = wxStaticBox(panel, -1, 'Parameters') - #boxSizer = wxStaticBoxSizer(box) - #boxSizer.Add(wxButton(panel, -1, 'BUTT ON')) - #sizer.Add(boxSizer, 1, wxEXPAND | wxALL, 10) - #panel.SetAutoLayout(true) - #panel.SetSizer(sizer) + panel = Panel(splitter) # Set plitter windows splitter.SplitVertically(tree, panel, 200) - #topSizer = wxBoxSizer() - #topSizer.Add(splitter, 1, wxEXPAND) - #self.SetAutoLayout(true) - #self.SetSizer(topSizer) + sizer.Add(splitter, 1, wxEXPAND) + self.SetAutoLayout(true) + self.SetSizer(sizer) # Init pull-down menu data - class MenuData: pass global pullDownMenu - pullDownMenu = MenuData() - pullDownMenu.menu = None - pullDownMenu.ID_NEW_PANEL = wxNewId() - pullDownMenu.ID_NEW_DIALOG = wxNewId() - pullDownMenu.ID_NEW_FRAME = wxNewId() - pullDownMenu.ID_NEW_MENU_BAR = wxNewId() - pullDownMenu.ID_NEW_MENU = wxNewId() - - pullDownMenu.ID_NEW_STATIC_TEXT = wxNewId() - pullDownMenu.ID_NEW_TEXT_CTRL = wxNewId() - - pullDownMenu.ID_NEW_BUTTON = wxNewId() - pullDownMenu.ID_NEW_BITMAP_BUTTON = wxNewId() - pullDownMenu.ID_NEW_RADIO_BUTTON = wxNewId() - pullDownMenu.ID_NEW_SPIN_BUTTON = wxNewId() - - pullDownMenu.ID_NEW_STATIC_BOX = wxNewId() - pullDownMenu.ID_NEW_CHECK_BOX = wxNewId() - pullDownMenu.ID_NEW_RADIO_BOX = wxNewId() - pullDownMenu.ID_NEW_COMBO_BOX = wxNewId() - pullDownMenu.ID_NEW_LIST_BOX = wxNewId() - - pullDownMenu.ID_NEW_STATIC_LINE = wxNewId() - pullDownMenu.ID_NEW_CHOICE = wxNewId() - pullDownMenu.ID_NEW_SLIDER = wxNewId() - pullDownMenu.ID_NEW_GAUGE = wxNewId() - pullDownMenu.ID_NEW_SCROLL_BAR = wxNewId() - pullDownMenu.ID_NEW_TREE_CTRL = wxNewId() - pullDownMenu.ID_NEW_LIST_CTRL = wxNewId() - pullDownMenu.ID_NEW_CHECK_LIST = wxNewId() - pullDownMenu.ID_NEW_NOTEBOOK = wxNewId() - pullDownMenu.ID_NEW_HTML_WINDOW = wxNewId() - pullDownMenu.ID_NEW_CALENDAR = wxNewId() - - pullDownMenu.ID_NEW_BOX_SIZER = wxNewId() - pullDownMenu.ID_NEW_STATIC_BOX_SIZER = wxNewId() - pullDownMenu.ID_NEW_GRID_SIZER = wxNewId() - pullDownMenu.ID_NEW_FLEX_GRID_SIZER = wxNewId() - pullDownMenu.ID_NEW_SPACER = wxNewId() - pullDownMenu.ID_NEW_MENU = wxNewId() - pullDownMenu.ID_NEW_MENU_ITEM = wxNewId() - pullDownMenu.ID_NEW_SEPARATOR = wxNewId() - pullDownMenu.ID_NEW_LAST = wxNewId() - pullDownMenu.ID_DELETE = self.ID_DELETE - pullDownMenu.ID_EXPAND = wxNewId() - EVT_MENU_RANGE(self, pullDownMenu.ID_NEW_PANEL, - pullDownMenu.ID_NEW_LAST, self.OnCreate) - EVT_MENU(self, pullDownMenu.ID_EXPAND, self.OnExpand) - # We connect to tree, but process in frame - EVT_MENU_HIGHLIGHT_ALL(tree, self.OnPullDownHighlight) + pullDownMenu = PullDownMenu(self) # Mapping from IDs to element names self.createMap = { pullDownMenu.ID_NEW_PANEL: 'wxPanel', @@ -809,13 +915,13 @@ class Frame(wxFrame): pullDownMenu.ID_NEW_BITMAP_BUTTON: 'wxBitmapButton', pullDownMenu.ID_NEW_RADIO_BUTTON: 'wxRadioButton', pullDownMenu.ID_NEW_SPIN_BUTTON: 'wxSpinButton', - + pullDownMenu.ID_NEW_STATIC_BOX: 'wxStaticBox', pullDownMenu.ID_NEW_CHECK_BOX: 'wxCheckBox', pullDownMenu.ID_NEW_RADIO_BOX: 'wxRadioBox', pullDownMenu.ID_NEW_COMBO_BOX: 'wxComboBox', pullDownMenu.ID_NEW_LIST_BOX: 'wxListBox', - + pullDownMenu.ID_NEW_STATIC_LINE: 'wxStaticLine', pullDownMenu.ID_NEW_CHOICE: 'wxChoice', pullDownMenu.ID_NEW_SLIDER: 'wxSlider', @@ -827,7 +933,7 @@ class Frame(wxFrame): pullDownMenu.ID_NEW_NOTEBOOK: 'wxNotebook', pullDownMenu.ID_NEW_HTML_WINDOW: 'wxHtmlWindow', pullDownMenu.ID_NEW_CALENDAR: 'wxCalendar', - + pullDownMenu.ID_NEW_BOX_SIZER: 'wxBoxSizer', pullDownMenu.ID_NEW_STATIC_BOX_SIZER: 'wxStaticBoxSizer', pullDownMenu.ID_NEW_GRID_SIZER: 'wxGridSizer', @@ -882,7 +988,7 @@ class Frame(wxFrame): (pullDownMenu.ID_NEW_MENU_ITEM, 'MenuItem', 'Create menu item'), (pullDownMenu.ID_NEW_SEPARATOR, 'Separator', 'Create separator'), ] - + # Initialize self.Clear() @@ -905,7 +1011,7 @@ class Frame(wxFrame): self.Open(path) wxEndBusyCursor() self.SetStatusText('Ready') - dlg.Destroy() + dlg.Destroy() def OnSaveOrSaveAs(self, evt): if evt.GetId() == wxID_SAVEAS or not self.dataFile: @@ -914,9 +1020,12 @@ class Frame(wxFrame): dlg = wxFileDialog(self, 'Save As', os.path.dirname(self.dataFile), defaultName, '*.xrc', wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR) - if dlg.ShowModal() == wxID_CANCEL: return - path = dlg.GetPath() - dlg.Destroy() + if dlg.ShowModal() == wxID_OK: + path = dlg.GetPath() + dlg.Destroy() + else: + dlg.Destroy() + return else: path = self.dataFile self.SetStatusText('Saving...') @@ -939,10 +1048,10 @@ class Frame(wxFrame): xxx = MakeXXXFromDOM(tree.GetPyData(parent).treeObject(), elem) item = tree.InsertItem( parent, prev, xxx.treeObject().className, data=wxTreeItemData(xxx) ) - + def OnRedo(self, evt): print '*** being implemented' - + def OnCut(self, evt): selected = tree.GetSelection() # Undo info @@ -985,7 +1094,7 @@ class Frame(wxFrame): appendChild = true selected = tree.GetItemParent(selected) # Expanded container (must have children) - elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): + elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): appendChild = false nextItem = tree.GetFirstChild(selected, 0)[0] parentLeaf = selected @@ -1111,11 +1220,9 @@ class Frame(wxFrame): self.tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh) def OnAbout(self, evt): - dlg = wxMessageDialog(self, '%s %s\n\nRoman Rolinsky ' % \ + wxMessageDialog(self, '%s %s\n\nRoman Rolinsky ' % \ (progname, version), - 'About %s' % progname, wxOK | wxCENTRE) - dlg.ShowModal() - dlg.Destroy() + 'About %s' % progname, wxOK | wxCENTRE).ShowModal() # Simple emulation of python command line def OnDebugCMD(self, evt): @@ -1146,7 +1253,7 @@ class Frame(wxFrame): appendChild = true selected = tree.GetItemParent(selected) # Expanded container (must have children) - elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): + elif tree.IsExpanded(selected) and tree.ItemHasChildren(selected): appendChild = false nextItem = tree.GetFirstChild(selected, 0)[0] parentLeaf = selected @@ -1203,9 +1310,12 @@ class Frame(wxFrame): def OnPullDownHighlight(self, evt): menuId = evt.GetMenuId() - help = '' - if menuId != -1: help = pullDownMenu.GetHelpString(menuId) - self.SetStatusText(help) + if menuId != -1: + menu = evt.GetEventObject() + help = menu.GetHelpString(menuId) + self.SetStatusText(help) + else: + self.SetStatusText('') def OnUpdateUI(self, evt): if evt.GetId() in [wxID_CUT, wxID_COPY, self.ID_DELETE]: @@ -1258,9 +1368,11 @@ class Frame(wxFrame): self.SetTitle(progname + ': ' + os.path.basename(path)) except: wxLogError('Error reading file: ' + path) + raise def Save(self, path): try: + self.OnRefresh(wxCommandEvent()) memFile = MemoryFile(path) tree.dom.writexml(memFile) memFile.close() @@ -1268,14 +1380,13 @@ class Frame(wxFrame): panel.SetModified(false) except: wxLogError('Error writing file: ' + path) + raise def AskSave(self): if not (self.modified or panel.IsModified()): return true flags = wxICON_EXCLAMATION | wxYES_NO | wxCANCEL | wxCENTRE - dlg = wxMessageDialog( self, 'File is modified. Save before exit?', - 'Save before too late?', flags ) - say = dlg.ShowModal() - dlg.Destroy() + say = wxMessageDialog( self, 'File is modified. Save before exit?', + 'Save before too late?', flags ).ShowModal() if say == wxID_YES: self.OnSaveOrSaveAs(wxCommandEvent(wxID_SAVE)) # If save was successful, modified flag is unset @@ -1286,6 +1397,8 @@ class Frame(wxFrame): return true return false +################################################################################ + class App(wxApp): def OnInit(self): self.SetAppName("xrced") diff --git a/wxPython/tools/XRCed/xrced.xrc b/wxPython/tools/XRCed/xrced.xrc index f675f87bb2..ee21945bfb 100644 --- a/wxPython/tools/XRCed/xrced.xrc +++ b/wxPython/tools/XRCed/xrced.xrc @@ -1,89 +1,2 @@ - - -Content -250,300 - -wxVERTICAL - - - - -wxHORIZONTAL - - - - - - -wxTOP|wxBOTTOM|wxLEFT|wxEXPAND -5 - - - -wxVERTICAL - - - - -wxBOTTOM -5 - - - - - - - - - - - - - -wxBOTTOM -5 - - - - - - - -wxALL|wxEXPAND -5 - - - -wxEXPAND - - - - - -wxEXPAND - - - -wxHORIZONTAL - - - -1 - -wxRIGHT -10 - - - - - - - - -wxALL|wxALIGN_CENTRE_HORIZONTAL -10 - - - - \ No newline at end of file +Content250,300wxVERTICALwxHORIZONTALwxTOP|wxBOTTOM|wxLEFT|wxEXPAND5wxVERTICALwxBOTTOM510,20wxBOTTOM5wxALL|wxEXPAND5wxEXPANDwxEXPANDwxHORIZONTAL1wxRIGHT10wxALL|wxALIGN_CENTRE_HORIZONTAL10 \ No newline at end of file diff --git a/wxPython/tools/XRCed/xxx.py b/wxPython/tools/XRCed/xxx.py index 0459af1a2f..3187456095 100644 --- a/wxPython/tools/XRCed/xxx.py +++ b/wxPython/tools/XRCed/xxx.py @@ -1,7 +1,8 @@ -# Name: xxx.py (xxx is easy to distinguish from 'wx' :) ) +# Name: xxx.py ('xxx' is easy to distinguish from 'wx' :) ) # Purpose: XML interface classes # Author: Roman Rolinsky # Created: 22.08.2001 +# RCS-ID: $Id$ from wxPython.wx import * from wxPython.xrc import * @@ -12,23 +13,23 @@ from params import * # Classes to interface DOM objects class xxxObject: - # Param ids for controls - ID_CHECK_PARAMS = wxNewId() - ID_TEXT_PARAMS = wxNewId() # Default behavior hasChildren = false # has children elements? + hasStyle = true # almost everyone hasName = true # has name attribute? isSizer = hasChild = false + # Style parameters (all optional) + styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip'] # Required paremeters: none by default required = [] # Default parameters with default values default = {} # Parameter types paramDict = {} - # Additional styles - styles = [] + # Window styles and extended styles + winStyles = [] # Tree icon index - image = -1 + #image = -1 # Construct a new xxx object from DOM element # parent is parent xxx object (or None if none), element is DOM element object def __init__(self, parent, element): @@ -45,9 +46,10 @@ class xxxObject: if node.nodeType == minidom.Node.ELEMENT_NODE: if node.tagName == 'object': continue # do nothing for object children here - if not node.tagName in self.allParams: + if not node.tagName in self.allParams and not node.tagName in self.styles: print 'WARNING: unknown parameter for %s: %s' % \ (self.className, node.tagName) + continue if node.tagName == 'content': # has items # Param value is a list of text nodes l = [] @@ -68,6 +70,9 @@ class xxxObject: node.removeChild(n) n.unlink() self.params[node.tagName] = l + elif node.tagName == 'font': # has children + # we read and write all font parameters at once + self.params[node.tagName] = xxxFont(self, node) else: # simple parameter if not node.hasChildNodes(): # If does not have child nodes, create empty text node @@ -81,37 +86,35 @@ class xxxObject: # Remove all other nodes element.removeChild(node) node.unlink() - # Generate HTML def generateHtml(self, prefix=''): SetCurrentXXX(self) - html = '
\ + html = '' % self.className # Has id (name) attribute if self.hasName: html += """\ """ % (self.ID_TEXT_PARAMS, self.name) +""" % (-1, self.name) html += '
\ %s - + - -

' html += '\n' # Add required parameters for param in self.allParams: # Add checkbox or just text if param in self.required: - html += '' % param + html += '' % param else: # optional parameter html += """\ -""" % (self.ID_CHECK_PARAMS, param, param + ' ') + +""" % (paramIDs[param], prefix + 'check_' + param, param) # Add value part if self.params.has_key(param): if param == 'content': @@ -137,12 +140,10 @@ class xxxObject: html += """\ -""" % (typeClass, self.ID_TEXT_PARAMS, - prefix + param, value, prefix + param) +""" % (typeClass, -1, prefix + 'data_' + param, value) html += '
%s:
%s:
- + -%s: %s: - + -
\n' return html # Returns real tree object @@ -161,6 +162,41 @@ class xxxObject: ################################################################################ +class xxxFont(xxxObject): + allParams = ['size', 'style', 'weight', 'family', 'underlined', + 'face', 'encoding'] + def __init__(self, parent, element): + xxxObject.__init__(self, parent, element) + self.parentNode = element # required to behave similar to DOM node + self.data = self.value() + def updateXML(self, value): + # `value' is a list of strings corresponding to all parameters + elem = self.element + for node in elem.childNodes: + elem.removeChild(node) + i = 0 + self.params.clear() + for param in self.allParams: + if value[i]: + fontElem = tree.dom.createElement(param) + textNode = tree.dom.createTextNode(value[i]) + self.params[param] = textNode + fontElem.appendChild(textNode) + elem.appendChild(fontElem) + i += 1 + # Update data + self.data = self.value() + def value(self): + v = [] + for p in self.allParams: + try: + v.append(str(self.params[p].data)) + except KeyError: + v.append('') + return v + +################################################################################ + class xxxContainer(xxxObject): hasChildren = true @@ -169,21 +205,30 @@ class xxxContainer(xxxObject): class xxxPanel(xxxContainer): allParams = ['pos', 'size', 'style'] + styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', + 'tooltip'] + exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY'] class xxxDialog(xxxContainer): allParams = ['title', 'pos', 'size', 'style'] required = ['title'] - styles = ['wxDIALOG_MODAL', 'wxCAPTION', 'wxDEFAULT_DIALOG_STYLE', + winStyles = ['wxDIALOG_MODAL', 'wxCAPTION', 'wxDEFAULT_DIALOG_STYLE', 'wxRESIZE_BORDER', 'wxSYSTEM_MENU', 'wxTHICK_FRAME', 'wxSTAY_ON_TOP'] + 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'] - styles = ['wxDEFAULT_FRAME_STYLE', 'wxICONIZE', 'wxCAPTION', 'wxMINIMIZE', + winStyles = ['wxDEFAULT_FRAME_STYLE', 'wxICONIZE', 'wxCAPTION', 'wxMINIMIZE', 'wxICONIZE', 'wxMINIMIZE_BOX', 'wxMAXIMIZE', 'wxMAXIMIZE_BOX', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW'] + styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', + 'tooltip'] + exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY'] ################################################################################ # Controls @@ -191,15 +236,15 @@ class xxxFrame(xxxContainer): class xxxStaticText(xxxObject): allParams = ['label', 'pos', 'size', 'style'] required = ['label'] - styles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE'] + winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE'] class xxxStaticLine(xxxObject): allParams = ['pos', 'size', 'style'] - styles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL'] + winStyles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL'] class xxxTextCtrl(xxxObject): allParams = ['value', 'pos', 'size', 'style'] - styles = ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE', + winStyles = ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE', 'wxTE_PASSWORD', 'wxTE_READONLY'] class xxxChoice(xxxObject): @@ -214,24 +259,24 @@ class xxxSlider(xxxObject): 'linesize': ParamInt, 'thumb': ParamInt, 'thumb': ParamInt, 'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt} required = ['value', 'min', 'max'] - styles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', + winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', 'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_SELRANGE'] class xxxGauge(xxxObject): allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel'] paramDict = {'range': ParamInt, 'value': ParamInt, 'shadow': ParamInt, 'bezel': ParamInt} - styles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH'] + winStyles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH'] class xxxScrollBar(xxxObject): allParams = ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize'] paramDict = {'value': ParamInt, 'range': ParamInt, 'thumbsize': ParamInt, 'pagesize': ParamInt} - styles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL'] + winStyles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL'] class xxxListCtrl(xxxObject): allParams = ['pos', 'size', 'style'] - styles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', + winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', 'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE', 'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER', 'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING'] @@ -241,13 +286,13 @@ xxxCheckList = xxxListCtrl class xxxTreeCtrl(xxxObject): allParams = ['pos', 'size', 'style'] - styles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT', + winStyles = ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT', 'wxTR_EDIT_LABELS', 'wxTR_MULTIPLE'] class xxxHtmlWindow(xxxObject): allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode'] paramDict = {'borders': ParamInt} - styles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO'] + winStyles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO'] class xxxCalendar(xxxObject): allParams = ['pos', 'size', 'style'] @@ -255,7 +300,7 @@ class xxxCalendar(xxxObject): class xxxNotebook(xxxContainer): allParams = ['usenotebooksizer', 'pos', 'size', 'style'] paramDict = {'usenotebooksizer': ParamBool} - styles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM'] + winStyles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM'] ################################################################################ # Buttons @@ -264,23 +309,23 @@ class xxxButton(xxxObject): allParams = ['label', 'default', 'pos', 'size', 'style'] paramDict = {'default': ParamBool} required = ['label'] - styles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] + winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] class xxxBitmapButton(xxxObject): allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default', 'pos', 'size', 'style'] required = ['bitmap'] - styles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] + winStyles = ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] class xxxRadioButton(xxxObject): allParams = ['label', 'value', 'pos', 'size', 'style'] paramDict = {'value': ParamBool} required = ['label'] - styles = ['wxRB_GROUP'] + winStyles = ['wxRB_GROUP'] class xxxSpinButton(xxxObject): allParams = ['pos', 'size', 'style'] - styles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP'] + winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP'] ################################################################################ # Boxes @@ -293,7 +338,7 @@ class xxxRadioBox(xxxObject): allParams = ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style'] paramDict = {'dimension': ParamInt} required = ['label', 'content'] - styles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS'] + winStyles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS'] class xxxCheckBox(xxxObject): allParams = ['label', 'pos', 'size', 'style'] @@ -302,20 +347,20 @@ class xxxCheckBox(xxxObject): class xxxComboBox(xxxObject): allParams = ['content', 'selection', 'value', 'pos', 'size', 'style'] required = ['content'] - styles = ['wxCB_SIMPLE', 'wxCB_DROPDOWN', 'wxCB_READONLY', 'wxCB_DROPDOWN', + winStyles = ['wxCB_SIMPLE', 'wxCB_DROPDOWN', 'wxCB_READONLY', 'wxCB_DROPDOWN', 'wxCB_SORT'] class xxxListBox(xxxObject): allParams = ['content', 'selection', 'pos', 'size', 'style'] required = ['content'] - styles = ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL', + winStyles = ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL', 'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT'] ################################################################################ # Sizers class xxxSizer(xxxContainer): - hasName = false + hasName = hasStyle = false paramDict = {'orient': ParamOrient} isSizer = true @@ -344,10 +389,7 @@ class xxxFlexGridSizer(xxxGridSizer): # Container with only one child. # Not shown in tree. class xxxChildContainer(xxxObject): - # Special param ids - ID_CHECK_PARAMS = wxNewId() - ID_TEXT_PARAMS = wxNewId() - hasName = false + hasName = hasStyle = false hasChild = true def __init__(self, parent, element): xxxObject.__init__(self, parent, element) @@ -396,7 +438,7 @@ class xxxNotebookPage(xxxChildContainer): self.child.allParams.remove('size') class xxxSpacer(xxxObject): - hasName = false + hasName = hasStyle = false allParams = ['size', 'option', 'flag', 'border'] paramDict = {'option': ParamInt} default = {'size': '0,0'} @@ -413,9 +455,11 @@ class xxxMenuItem(xxxObject): default = {'label': ''} class xxxSeparator(xxxObject): - hasName = false + hasName = hasStyle = false allParams = [] +################################################################################ + xxxDict = { 'wxPanel': xxxPanel, 'wxDialog': xxxDialog, @@ -460,6 +504,17 @@ xxxDict = { 'separator': xxxSeparator, } +# 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() + } +for cl in xxxDict.values(): + for param in cl.allParams + cl.paramDict.keys(): + if not paramIDs.has_key(param): + paramIDs[param] = wxNewId() + +################################################################################ # Helper functions # Test for object elements