From 18fc9fa3b5f812dc699488877c4f081f7a7253ce Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 7 Mar 2002 21:33:31 +0000 Subject: [PATCH] More XRCed updates from Roman git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14484 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/CHANGES.txt | 2 + wxPython/tools/XRCed/CHANGES | 3 + wxPython/tools/XRCed/params.py | 157 +++++++++++++++++----------- wxPython/tools/XRCed/xrced.ico | Bin 766 -> 2238 bytes wxPython/tools/XRCed/xrced.py | 182 ++++++++++++++++++++++----------- wxPython/tools/XRCed/xrced.xrc | 92 ++++++++++++++--- wxPython/tools/XRCed/xxx.py | 53 +++++++--- 7 files changed, 346 insertions(+), 143 deletions(-) diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index 5d91cdb7c2..6d1f99f7b6 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -28,6 +28,8 @@ for each item, as well as optional column or row spanning. Cells with no item assigned to it are just left blank. Stretchable rows or columns are specified and work the same as in wxFlexGridSizer. +Updated XRCed from Roman Rolinsky + 2.3.2.1 diff --git a/wxPython/tools/XRCed/CHANGES b/wxPython/tools/XRCed/CHANGES index eecd2c0ebe..89b20ff696 100644 --- a/wxPython/tools/XRCed/CHANGES +++ b/wxPython/tools/XRCed/CHANGES @@ -39,17 +39,20 @@ Fixed double-clicking problem with tree control on Windows. Some performance improovements. + 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/params.py b/wxPython/tools/XRCed/params.py index 89513a1fbf..93b8d2fb3e 100644 --- a/wxPython/tools/XRCed/params.py +++ b/wxPython/tools/XRCed/params.py @@ -8,6 +8,7 @@ from wxPython.wx import * from wxPython.xrc import * import string import os.path +from types import * # Object which is currently processed currentXXX = None @@ -21,6 +22,8 @@ genericStyles = ['wxSIMPLE_BORDER', 'wxDOUBLE_BORDER', 'wxTRANSPARENT_WINDOW', 'wxWANTS_CHARS', 'wxNO_FULL_REPAINT_ON_RESIZE'] +buttonSize = (55,-1) + # Class that can properly disable children class PPanel(wxPanel): def __init__(self, parent, name): @@ -43,8 +46,8 @@ class ParamBinaryOr(PPanel): self.SetBackgroundColour(panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10) - self.button = wxButton(self, self.ID_BUTTON_CHOICES, 'Edit...') + sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) + self.button = wxButton(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize) sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) self.SetAutoLayout(true) self.SetSizer(sizer) @@ -90,7 +93,7 @@ class ParamBinaryOr(PPanel): dlg.SetSizer(topSizer) topSizer.Fit(dlg) dlg.Center() - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wxID_OK: value = [] for i in range(listBox.Number()): if listBox.IsChecked(i): @@ -141,8 +144,8 @@ class ParamColour(PPanel): self.ID_BUTTON = wxNewId() self.SetBackgroundColour(panel.GetBackgroundColour()) sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(60,-1)) - sizer.Add(self.text, 0, wxRIGHT, 10) + self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=buttonSize) + sizer.Add(self.text, 0, wxRIGHT, 5) self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(40, -1)) sizer.Add(self.button, 0, wxGROW) self.SetAutoLayout(true) @@ -207,8 +210,8 @@ class ParamFont(PPanel): self.SetBackgroundColour(panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10) - self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...') + sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) + self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize) sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) self.SetAutoLayout(true) self.SetSizer(sizer) @@ -353,21 +356,21 @@ class ParamPosSize(ParamText): class ContentDialog(wxDialogPtr): def __init__(self, parent, value): # Is this normal??? - w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT') + w = frame.res.LoadDialog(parent, 'DIALOG_CONTENT') wxDialogPtr.__init__(self, w.this) self.thisown = 1 self.Center() - self.list = self.FindWindowByName('ID_LIST') + self.list = self.FindWindowByName('LIST') # Set list items for v in value: self.list.Append(v) self.SetAutoLayout(true) self.GetSizer().Fit(self) # Callbacks - self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND') - self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE') - self.ID_BUTTON_UP = XMLID('ID_BUTTON_UP') - self.ID_BUTTON_DOWN = XMLID('ID_BUTTON_DOWN') + self.ID_BUTTON_APPEND = XMLID('BUTTON_APPEND') + self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE') + self.ID_BUTTON_UP = XMLID('BUTTON_UP') + self.ID_BUTTON_DOWN = XMLID('BUTTON_DOWN') EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend) @@ -404,11 +407,11 @@ class ContentDialog(wxDialogPtr): class ContentCheckListDialog(wxDialogPtr): def __init__(self, parent, value): # Is this normal??? - w = frame.res.LoadDialog(parent, 'ID_DIALOG_CONTENT_CHECK_LIST') + w = frame.res.LoadDialog(parent, 'DIALOG_CONTENT_CHECK_LIST') wxDialogPtr.__init__(self, w.this) self.thisown = 1 self.Center() - self.list = self.FindWindowByName('ID_CHECK_LIST') + self.list = self.FindWindowByName('CHECK_LIST') # Set list items i = 0 for v,ch in value: @@ -418,10 +421,10 @@ class ContentCheckListDialog(wxDialogPtr): self.SetAutoLayout(true) self.GetSizer().Fit(self) # Callbacks - self.ID_BUTTON_APPEND = XMLID('ID_BUTTON_APPEND') - self.ID_BUTTON_REMOVE = XMLID('ID_BUTTON_REMOVE') - self.ID_BUTTON_UP = XMLID('ID_BUTTON_UP') - self.ID_BUTTON_DOWN = XMLID('ID_BUTTON_DOWN') + self.ID_BUTTON_APPEND = XMLID('BUTTON_APPEND') + self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE') + self.ID_BUTTON_UP = XMLID('BUTTON_UP') + self.ID_BUTTON_DOWN = XMLID('BUTTON_DOWN') EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck) EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) @@ -469,8 +472,8 @@ class ParamContent(PPanel): self.SetBackgroundColour(panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10) - self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...') + sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) + self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) self.SetAutoLayout(true) self.SetSizer(sizer) @@ -493,6 +496,7 @@ class ParamContent(PPanel): return self.value def SetValue(self, value): self.freeze = true + if not value: value = [] self.value = value self.text.SetValue(str(value)) # update text ctrl self.freeze = false @@ -515,41 +519,78 @@ class ParamContent(PPanel): dlg.Destroy() # CheckList content -class ParamContentCheckList(PPanel): +class ParamContentCheckList(ParamContent): def __init__(self, parent, name): - PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_EDIT = wxNewId() - self.SetBackgroundColour(panel.GetBackgroundColour()) - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10) - self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...') - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) - self.SetAutoLayout(true) - self.SetSizer(sizer) - sizer.Fit(self) - self.textModified = false - EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) - def OnChange(self, evt): - if self.freeze: return - self.SetModified() - self.textModified = true - evt.Skip() - def GetValue(self): + ParamContent.__init__(self, parent, name) + def OnButtonEdit(self, evt): if self.textModified: # text has newer value try: - return eval(self.text.GetValue()) + self.value = eval(self.text.GetValue()) except SyntaxError: wxLogError('Syntax error in parameter value: ' + self.GetName()) - return [] - return self.value - def SetValue(self, value): - self.freeze = true - self.value = value - self.text.SetValue(str(value)) # update text ctrl - self.freeze = false + self.value = [] + dlg = ContentCheckListDialog(self, self.value) + if dlg.ShowModal() == wxID_OK: + value = [] + for i in range(dlg.list.Number()): + value.append((dlg.list.GetString(i), dlg.list.IsChecked(i))) + # Add ignored flags + self.SetValue(value) + self.SetModified() + self.textModified = false + dlg.Destroy() + +class IntListDialog(wxDialogPtr): + def __init__(self, parent, value): + # Is this normal??? + w = frame.res.LoadDialog(parent, 'DIALOG_INTLIST') + wxDialogPtr.__init__(self, w.this) + self.thisown = 1 + self.Center() + self.list = self.FindWindowByName('LIST') + # Set list items + value.sort() + for v in value: + if type(v) != IntType: + wxLogError('Invalid item type') + else: + self.list.Append(str(v)) + self.SetAutoLayout(true) + self.GetSizer().Fit(self) + # Callbacks + self.ID_BUTTON_ADD = XMLID('BUTTON_ADD') + self.ID_BUTTON_REMOVE = XMLID('BUTTON_REMOVE') + EVT_BUTTON(self, self.ID_BUTTON_ADD, self.OnButtonAppend) + EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) + EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) + def OnButtonAppend(self, evt): + s = wxGetTextFromUser('Enter new number:', 'Add', '', self) + # Check that it's unique + try: + v = int(s) + s = str(v) # to be sure + i = self.list.FindString(s) + if i == -1: # ignore non-unique + # Find place to insert + found = false + for i in range(self.list.Number()): + if int(self.list.GetString(i)) > v: + found = true + break + if found: self.list.InsertItems([s], i) + else: self.list.Append(s) + except ValueError: + wxLogError('List item is not an int!') + def OnButtonRemove(self, evt): + self.list.Delete(self.list.GetSelection()) + def OnUpdateUI(self, evt): + if evt.GetId() == self.ID_BUTTON_REMOVE: + evt.Enable(self.list.GetSelection() != -1) + +# For growable list +class ParamIntList(ParamContent): + def __init__(self, parent, name): + ParamContent.__init__(self, parent, name) def OnButtonEdit(self, evt): if self.textModified: # text has newer value try: @@ -557,18 +598,18 @@ class ParamContentCheckList(PPanel): except SyntaxError: wxLogError('Syntax error in parameter value: ' + self.GetName()) self.value = [] - dlg = ContentCheckListDialog(self, self.value) + dlg = IntListDialog(self, self.value) if dlg.ShowModal() == wxID_OK: value = [] for i in range(dlg.list.Number()): - value.append((dlg.list.GetString(i), dlg.list.IsChecked(i))) + value.append(int(dlg.list.GetString(i))) # Add ignored flags self.SetValue(value) self.SetModified() self.textModified = false dlg.Destroy() -# Boxless radiobox +# Boxless radiobox class RadioBox(PPanel): def __init__(self, parent, id, choices, pos=wxDefaultPosition, name='radiobox'): @@ -620,15 +661,15 @@ class ParamOrient(RadioBox): self.SetStringSelection(self.seulav[value]) class ParamFile(PPanel): - def __init__(self, parent, name): + def __init__(self, parent, name): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_BUTTON_BROWSE = wxNewId() self.SetBackgroundColour(panel.GetBackgroundColour()) sizer = wxBoxSizer() self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 10) - self.button = wxButton(self, self.ID_BUTTON_BROWSE, 'Browse...') + sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) + self.button = wxButton(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize) sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) self.SetAutoLayout(true) self.SetSizer(sizer) @@ -637,7 +678,7 @@ class ParamFile(PPanel): EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse) EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def OnChange(self, evt): - if self.freeze: return + if self.freeze: return self.SetModified() self.textModified = true evt.Skip() diff --git a/wxPython/tools/XRCed/xrced.ico b/wxPython/tools/XRCed/xrced.ico index c1652ba91fd520a805ef342d26c9cea0058551f9..6c9964d2fb0b43ddf412d0a9d288e9838f98eb77 100644 GIT binary patch literal 2238 zcmeHHOKt)&42{S0%S_BLGg5a*EPDlZy#yEG1U&)gsJI9R;UMX=14S9Bn9S#R~JRaTY zbaK1h&WM}M#zkNexrj^zCxRcri>Qr?U%7YXr}x~za|8c*1N2)KW|5%HdUb+G-gqTu z2^K+^;XP7BlMJ*L8EFJL!-LE{(HKS=lt|0^Ak$zr4mQQIKjLKJJA4`m+5&urKHiY^ zCy`knH4v^<(AVU+PAoE|(Li3}6jsBqMi1)Ytd{fTVx(P`sVsgJ?}PnTndZ-eni+)^ zH&k;$R9Xn1kx?r;Ur^zFN$inne5-V?mI$?H>Tqs2Jdmu$1j^R4@8DkRjaef`-Utvk zDfU&QH{f=4DQ0VmK^Az4JSK-e>Txac)~8O^pHwS(ocb5Ovp1$J#E9@Dn_pEi lW`%@R*#J5;CW2K87tE#Zudtml*NC9-wLgs>u)qFq`UF*rGCBYN literal 766 zcmb7Cp;E&@5Zw^kW`F_;+e&0-GAKm*2{k7(bE=ZTC9XG9(JJ~6$k@s=ahM8B~= zcnGb*gT>;kt_O=mmApNXT8F_rQRso;Y5#T=#EBYJToQE}T!?WT*K`pH)Q(mIcwS8y zfq|!**C4DGF~8TkD8N7iK2P>KX&srI2Np7sAKnPT1G$?mP4Dau0}Jvmx0Q$TG4D3{ z;w`Lfv1^qO`M9A+1`P+9jCrm~i`X>{O4O8VBL4(aU - + Content 250,300 @@ -9,7 +9,7 @@ wxHORIZONTAL - + @@ -20,14 +20,14 @@ wxVERTICAL - + wxBOTTOM 5 - + @@ -36,14 +36,14 @@ - + wxBOTTOM 5 - + @@ -82,7 +82,7 @@ - + Content 250,300 @@ -91,7 +91,7 @@ wxHORIZONTAL - + @@ -102,14 +102,14 @@ wxVERTICAL - + wxBOTTOM 5 - + @@ -118,14 +118,14 @@ - + wxBOTTOM 5 - + @@ -164,4 +164,72 @@ + + Numbers + 100,300 + + wxVERTICAL + + + wxVERTICAL + + + + 80,100 + + + + wxALL|wxALIGN_CENTRE_HORIZONTAL + 10 + + + + wxVERTICAL + + + + + wxBOTTOM + 3 + + + + + + + + wxALL|wxALIGN_CENTRE_HORIZONTAL + 5 + + + + wxEXPAND + + + + wxEXPAND + + + + wxVERTICAL + + + + 1 + + wxBOTTOM + 5 + + + + + + + + wxALL|wxALIGN_CENTRE_HORIZONTAL + 10 + + + + \ No newline at end of file diff --git a/wxPython/tools/XRCed/xxx.py b/wxPython/tools/XRCed/xxx.py index 0435ea5737..7dfdeb4900 100644 --- a/wxPython/tools/XRCed/xxx.py +++ b/wxPython/tools/XRCed/xxx.py @@ -26,13 +26,27 @@ class xxxParam: self.textNode = text # Value returns string def value(self): - return str(self.textNode.data) + return self.textNode.data def update(self, value): self.textNode.data = value def remove(self): self.node.parentNode.removeChild(self.node) self.node.unlink() +# Integer parameter +class xxxParamInt(xxxParam): + # Standard use: for text nodes + def __init__(self, node): + xxxParam.__init__(self, node) + # Value returns string + def value(self): + try: + return int(self.textNode.data) + except ValueError: + return -1 # invalid value + def update(self, value): + self.textNode.data = str(value) + # Content parameter class xxxParamContent: def __init__(self, node): @@ -118,10 +132,10 @@ class xxxParamContentCheckList: self.node.appendChild(itemElem) l.append((itemText, itemElem)) self.l = l -# else: -# for i in range(len(value)): -# self.l[i][0].data = value[i] -# self.l[i][1].setAttributedata = value[i] + else: + for i in range(len(value)): + self.l[i][0].data = value[i][0] + self.l[i][1].setAttribute('checked', str(value[i][1])) self.data = value ################################################################################ @@ -176,7 +190,7 @@ class xxxObject: else: self.params[tag] = xxxParamContent(node) elif tag == 'font': # has children - self.params[tag] = xxxParamFont(self, node) + self.params[tag] = xxxParamFont(element, node) else: # simple parameter self.params[tag] = xxxParam(node) else: @@ -199,24 +213,26 @@ class xxxObject: ################################################################################ -class xxxParamFont(xxxParam): +# This is a little special +class xxxParamFont(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.parentNode = parent # required to behave similar to DOM node v = [] for p in self.allParams: try: - v.append(str(self.params[p].data)) + v.append(str(self.params[p].value())) except KeyError: v.append('') self.data = v def update(self, value): # `value' is a list of strings corresponding to all parameters elem = self.element - for node in elem.childNodes: - elem.removeChild(node) + # Remove old elements first + childNodes = elem.childNodes[:] + for node in childNodes: elem.removeChild(node) i = 0 self.params.clear() v = [] @@ -230,6 +246,11 @@ class xxxParamFont(xxxParam): v.append(value[i]) i += 1 self.data = v + def value(self): + return self.data + def remove(self): + self.parentNode.removeChild(self.element) + self.element.unlink() ################################################################################ @@ -483,20 +504,20 @@ class xxxParamMulti: class xxxFlexGridSizer(xxxGridSizer): specials = ['growablecols', 'growablerows'] allParams = ['cols', 'rows', 'vgap', 'hgap'] + specials - paramDict = {'growablecols':ParamContent, 'growablerows':ParamContent} + paramDict = {'growablecols':ParamIntList, 'growablerows':ParamIntList} # Special processing for growable* parameters # (they are represented by several nodes) def special(self, tag, node): - if tag not in self.params.keys(): + if tag not in self.params: self.params[tag] = xxxParamMulti() - self.params[tag].append(xxxParam(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 str in value: + for i in value: node = tree.dom.createElement(param) - text = tree.dom.createTextNode(str) + text = tree.dom.createTextNode(str(i)) node.appendChild(text) self.element.appendChild(node) self.special(param, node) -- 2.45.2