From c032d94e606dae4cd9712a02eb7bf6e2f42dcf51 Mon Sep 17 00:00:00 2001 From: Roman Rolinsky Date: Fri, 4 Nov 2005 20:17:52 +0000 Subject: [PATCH] version 0.1.6-6 Improved some dialogs (window styles, growable cols). Changed the range for wxSpinCtrl min/max to all integers (default 0/100 is not always good). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wx/tools/XRCed/CHANGES.txt | 7 ++ wxPython/wx/tools/XRCed/globals.py | 2 +- wxPython/wx/tools/XRCed/params.py | 124 ++++++++++++++++++++++------ wxPython/wx/tools/XRCed/tools.py | 6 +- wxPython/wx/tools/XRCed/xrced.xrc | 104 ++++++++++++++++++++--- wxPython/wx/tools/XRCed/xxx.py | 21 +++-- 6 files changed, 215 insertions(+), 49 deletions(-) diff --git a/wxPython/wx/tools/XRCed/CHANGES.txt b/wxPython/wx/tools/XRCed/CHANGES.txt index 5d62bed367..84cff500ac 100644 --- a/wxPython/wx/tools/XRCed/CHANGES.txt +++ b/wxPython/wx/tools/XRCed/CHANGES.txt @@ -1,3 +1,10 @@ +0.1.6-6 +------- + +Improved some dialogs (window styles, growable cols). Changed the +range for wxSpinCtrl min/max to all integers (default 0/100 is not +always good). + 0.1.6-5 ------- diff --git a/wxPython/wx/tools/XRCed/globals.py b/wxPython/wx/tools/XRCed/globals.py index 572629efea..f74e78d020 100644 --- a/wxPython/wx/tools/XRCed/globals.py +++ b/wxPython/wx/tools/XRCed/globals.py @@ -15,7 +15,7 @@ import sys # Global constants progname = 'XRCed' -version = '0.1.6-4' +version = '0.1.6-6' # Can be changed to set other default encoding different #defaultEncoding = '' # you comment above and can uncomment this: diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index 848f2793ac..5ba1bccd68 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -74,7 +74,10 @@ class ParamBinaryOr(PPanel): self.freeze = False def OnButtonChoices(self, evt): dlg = g.frame.res.LoadDialog(self, 'DIALOG_CHOICES') - listBox = XRCCTRL(dlg, 'CHECK_LIST') + if self.GetName() == 'flag': dlg.SetTitle('Sizer item flags') + elif self.GetName() == 'style': dlg.SetTitle('Window styles') + elif self.GetName() == 'exstyle': dlg.SetTitle('Extended window styles') + listBox = XRCCTRL(dlg, 'CHECKLIST') listBox.InsertItems(self.values, 0) value = map(string.strip, self.text.GetValue().split('|')) if value == ['']: value = [] @@ -116,16 +119,67 @@ class ParamFlag(ParamBinaryOr): def __init__(self, parent, name): ParamBinaryOr.__init__(self, parent, name) -class ParamStyle(ParamBinaryOr): - equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'} +class ParamNonGenericStyle(ParamBinaryOr): def __init__(self, parent, name): - self.values = g.currentXXX.winStyles + genericStyles + self.values = g.currentXXX.winStyles ParamBinaryOr.__init__(self, parent, name) -class ParamNonGenericStyle(ParamBinaryOr): +class ParamStyle(ParamBinaryOr): + equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'} def __init__(self, parent, name): - self.values = g.currentXXX.winStyles ParamBinaryOr.__init__(self, parent, name) + self.valuesSpecific = g.currentXXX.winStyles + if self.valuesSpecific: # override if using specific styles + # Remove duplicates + self.valuesGeneric = [s for s in genericStyles + if s not in self.valuesSpecific] + EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoicesBoth) + else: + self.values = genericStyles + def OnButtonChoicesBoth(self, evt): + dlg = g.frame.res.LoadDialog(self, 'DIALOG_STYLES') + listBoxSpecific = XRCCTRL(dlg, 'CHECKLIST_SPECIFIC') + listBoxSpecific.InsertItems(self.valuesSpecific, 0) + listBoxGeneric = XRCCTRL(dlg, 'CHECKLIST_GENERIC') + listBoxGeneric.InsertItems(self.valuesGeneric, 0) + value = map(string.strip, self.text.GetValue().split('|')) + if value == ['']: value = [] + # Set specific styles + value2 = [] # collect generic and ignored here + for i in value: + try: + listBoxSpecific.Check(self.valuesSpecific.index(i)) + except ValueError: + # Try to find equal + if self.equal.has_key(i): + listBoxSpecific.Check(self.valuesSpecific.index(self.equal[i])) + else: + value2.append(i) + ignored = [] + # Set generic styles, collect non-standart values + for i in value2: + try: + listBoxGeneric.Check(self.valuesGeneric.index(i)) + except ValueError: + # Try to find equal + if self.equal.has_key(i): + listBoxGeneric.Check(self.valuesGeneric.index(self.equal[i])) + else: + print 'WARNING: unknown flag: %s: ignored.' % i + ignored.append(i) + if dlg.ShowModal() == wxID_OK: + value = [self.valuesSpecific[i] + for i in range(listBoxSpecific.GetCount()) + if listBoxSpecific.IsChecked(i)] + \ + [self.valuesGeneric[i] + for i in range(listBoxGeneric.GetCount()) + if listBoxGeneric.IsChecked(i)] + ignored + if value: + self.SetValue(reduce(lambda a,b: a+'|'+b, value)) + else: + self.SetValue('') + self.SetModified() + dlg.Destroy() class ParamExStyle(ParamBinaryOr): def __init__(self, parent, name): @@ -134,6 +188,7 @@ class ParamExStyle(ParamBinaryOr): else: self.values = [] ParamBinaryOr.__init__(self, parent, name) + self.SetTitle('Extended window styles') class ParamColour(PPanel): def __init__(self, parent, name): @@ -284,7 +339,6 @@ class ParamFont(PPanel): font.GetFaceName().encode(), encName ] - # Add ignored flags self.SetValue(value) self.SetModified() self.textModified = False @@ -297,7 +351,29 @@ class ParamInt(PPanel): PPanel.__init__(self, parent, name) self.ID_SPIN_CTRL = wxNewId() sizer = wxBoxSizer() - self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(50,-1)) + self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) + self.spin.SetRange(-2147483648, 2147483647) # min/max integers + sizer.Add(self.spin) + self.SetAutoLayout(True) + self.SetSizer(sizer) + sizer.Fit(self) + EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) + def GetValue(self): + return str(self.spin.GetValue()) + def SetValue(self, value): + self.freeze = True + if not value: value = 0 + self.spin.SetValue(int(value)) + self.freeze = False + +# Non-negative number +class ParamIntNN(PPanel): + def __init__(self, parent, name): + PPanel.__init__(self, parent, name) + self.ID_SPIN_CTRL = wxNewId() + sizer = wxBoxSizer() + self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) + self.spin.SetRange(0, 10000) # min/max integers sizer.Add(self.spin) self.SetAutoLayout(True) self.SetSizer(sizer) @@ -317,12 +393,14 @@ class ParamUnit(PPanel): PPanel.__init__(self, parent, name) self.ID_TEXT_CTRL = wxNewId() self.ID_SPIN_BUTTON = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(35,-1)) + sizer = wxBoxSizer(wxHORIZONTAL) self.spin = wxSpinButton(self, self.ID_SPIN_BUTTON, style = wxSP_VERTICAL, size=(-1,1)) + textW = 60 - self.spin.GetSize()[0] + self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(textW,-1)) self.spin.SetRange(-10000, 10000) - sizer.Add(self.text, 0, wxEXPAND | wxRIGHT, 2) + sizer.Add(self.text, 0, wxEXPAND) sizer.Add(self.spin, 0, wxEXPAND) + #sizer.SetMinSize((50,-1)) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) @@ -476,10 +554,10 @@ class ContentDialog(wxDialog): class ContentCheckListDialog(wxDialog): def __init__(self, parent, value): pre = wxPreDialog() - g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECK_LIST') + g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECKLIST') self.this = pre.this self._setOORInfo(self) - self.list = XRCCTRL(self, 'CHECK_LIST') + self.list = XRCCTRL(self, 'CHECKLIST') # Set list items i = 0 for v,ch in value: @@ -577,7 +655,6 @@ class ParamContent(PPanel): value = [] for i in range(dlg.list.GetCount()): value.append(dlg.list.GetString(i)) - # Add ignored flags self.SetValue(value) self.SetModified() self.textModified = False @@ -599,7 +676,6 @@ class ParamContentCheckList(ParamContent): value = [] for i in range(dlg.list.GetCount()): value.append((dlg.list.GetString(i), int(dlg.list.IsChecked(i)))) - # Add ignored flags self.SetValue(value) self.SetModified() self.textModified = False @@ -622,17 +698,16 @@ class IntListDialog(wxDialog): self.SetAutoLayout(True) self.GetSizer().Fit(self) # Callbacks - self.ID_BUTTON_ADD = XRCID('BUTTON_ADD') + self.spinCtrl = XRCCTRL(self, 'SPIN') + EVT_BUTTON(self, XRCID('BUTTON_ADD'), self.OnButtonAdd) self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE') - EVT_BUTTON(self, self.ID_BUTTON_ADD, self.OnButtonAppend) EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) + EVT_BUTTON(self, XRCID('BUTTON_CLEAR'), self.OnButtonClear) EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) - def OnButtonAppend(self, evt): - s = wxGetTextFromUser('Enter new number:', 'Add', '', self) - if not s: return + def OnButtonAdd(self, evt): # Check that it's unique try: - v = int(s) + v = self.spinCtrl.GetValue() s = str(v) # to be sure i = self.list.FindString(s) if i == -1: # ignore non-unique @@ -648,6 +723,8 @@ class IntListDialog(wxDialog): wxLogError('List item is not an int!') def OnButtonRemove(self, evt): self.list.Delete(self.list.GetSelection()) + def OnButtonClear(self, evt): + self.list.Clear() def OnUpdateUI(self, evt): if evt.GetId() == self.ID_BUTTON_REMOVE: evt.Enable(self.list.GetSelection() != -1) @@ -668,7 +745,6 @@ class ParamIntList(ParamContent): value = [] for i in range(dlg.list.GetCount()): value.append(int(dlg.list.GetString(i))) - # Add ignored flags self.SetValue(value) self.SetModified() self.textModified = False @@ -865,12 +941,12 @@ paramDict = { 'style': ParamStyle, 'exstyle': ParamExStyle, 'pos': ParamPosSize, 'size': ParamPosSize, 'cellpos': ParamPosSize, 'cellspan': ParamPosSize, - 'border': ParamUnit, 'cols': ParamInt, 'rows': ParamInt, + 'border': ParamUnit, 'cols': ParamIntNN, 'rows': ParamIntNN, 'vgap': ParamUnit, 'hgap': ParamUnit, 'checkable': ParamBool, 'checked': ParamBool, 'radio': ParamBool, 'accel': ParamAccel, 'label': ParamMultilineText, 'title': ParamText, 'value': ParamText, - 'content': ParamContent, 'selection': ParamInt, + 'content': ParamContent, 'selection': ParamIntNN, 'min': ParamInt, 'max': ParamInt, 'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont, 'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool, diff --git a/wxPython/wx/tools/XRCed/tools.py b/wxPython/wx/tools/XRCed/tools.py index d6264f22aa..6f5c9a0f8b 100644 --- a/wxPython/wx/tools/XRCed/tools.py +++ b/wxPython/wx/tools/XRCed/tools.py @@ -15,7 +15,7 @@ GROUPNUM = 4 GROUP_WINDOWS, GROUP_MENUS, GROUP_SIZERS, GROUP_CONTROLS = range(GROUPNUM) # States depending on current selection and Control/Shift keys -STATE_ROOT, STATE_MENUBAR, STATE_TOOLBAR, STATE_MENU, STATE_ELSE = range(5) +STATE_ROOT, STATE_MENUBAR, STATE_TOOLBAR, STATE_MENU, STATE_STDDLGBTN, STATE_ELSE = range(6) # Left toolbar for GUI elements class Tools(wxPanel): @@ -210,6 +210,8 @@ class Tools(wxPanel): state = STATE_TOOLBAR elif xxx.__class__ in [xxxMenu, xxxMenuItem]: state = STATE_MENU + elif xxx.__class__ == xxxStdDialogButtonSizer: + state = STATE_STDDLGBTN else: state = STATE_ELSE @@ -228,6 +230,8 @@ class Tools(wxPanel): ID_NEW.MENU_ITEM, ID_NEW.SEPARATOR ], False) + if state == STATE_STDDLGBTN: + pass # nothing can be added from toolbar elif state == STATE_MENUBAR: self.EnableGroup(GROUP_MENUS) self.EnableGroupItems(GROUP_MENUS, diff --git a/wxPython/wx/tools/XRCed/xrced.xrc b/wxPython/wx/tools/XRCed/xrced.xrc index 01f9588345..70e7772a84 100644 --- a/wxPython/wx/tools/XRCed/xrced.xrc +++ b/wxPython/wx/tools/XRCed/xrced.xrc @@ -1,4 +1,4 @@ - + Text Dialog @@ -133,7 +133,7 @@ - + Content 1 250,300 @@ -224,7 +224,7 @@ wxVERTICAL - + 250,250 @@ -260,6 +260,72 @@ + + Window styles + 1 + + wxVERTICAL + + + + + wxTOP|wxLEFT + 5 + + + + + 250,150 + + + + wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND + 5 + + + + + + wxLEFT + 5 + + + + + 250,150 + + + + wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND + 5 + + + + wxEXPAND + + + + wxHORIZONTAL + + + + 1 + + wxRIGHT + 10 + + + + + + + + wxALL|wxALIGN_CENTRE_HORIZONTAL + 10 + + + + Numbers 1 @@ -268,32 +334,46 @@ wxVERTICAL - wxVERTICAL + wxHORIZONTAL - 80,100 + 80,150 wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 + 5 wxVERTICAL + + + 20,-1d + + wxBOTTOM + 5 + - + wxBOTTOM - 3 + 5 + + + + + wxTOP + 5 + wxALL|wxALIGN_CENTRE_HORIZONTAL 5 @@ -308,14 +388,14 @@ - wxVERTICAL + wxHORIZONTAL 1 - wxBOTTOM - 5 + wxRIGHT + 10 @@ -431,4 +511,4 @@ - + \ No newline at end of file diff --git a/wxPython/wx/tools/XRCed/xxx.py b/wxPython/wx/tools/XRCed/xxx.py index 62e7aaa8b8..609b6fc1cc 100644 --- a/wxPython/wx/tools/XRCed/xxx.py +++ b/wxPython/wx/tools/XRCed/xxx.py @@ -452,7 +452,7 @@ class xxxToolBar(xxxContainer): 'pos', 'size', 'style'] hasStyle = False paramDict = {'bitmapsize': ParamPosSize, 'margins': ParamPosSize, - 'packing': ParamInt, 'separation': ParamInt, + 'packing': ParamUnit, 'separation': ParamUnit, 'dontattachtoframe': ParamBool, 'style': ParamNonGenericStyle} winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL', 'wxTB_3DBUTTONS','wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER', @@ -519,8 +519,8 @@ class xxxSlider(xxxObject): allParams = ['value', 'min', 'max', 'pos', 'size', 'style', 'tickfreq', 'pagesize', 'linesize', 'thumb', 'tick', 'selmin', 'selmax'] - paramDict = {'value': ParamInt, 'tickfreq': ParamInt, 'pagesize': ParamInt, - 'linesize': ParamInt, 'thumb': ParamInt, 'thumb': ParamInt, + paramDict = {'value': ParamInt, 'tickfreq': ParamIntNN, 'pagesize': ParamIntNN, + 'linesize': ParamIntNN, 'thumb': ParamUnit, 'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt} required = ['value', 'min', 'max'] winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', @@ -529,14 +529,14 @@ class xxxSlider(xxxObject): class xxxGauge(xxxObject): allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel'] - paramDict = {'range': ParamInt, 'value': ParamInt, - 'shadow': ParamInt, 'bezel': ParamInt} + paramDict = {'range': ParamIntNN, 'value': ParamIntNN, + 'shadow': ParamIntNN, 'bezel': ParamIntNN} 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} + paramDict = {'value': ParamIntNN, 'range': ParamIntNN, 'thumbsize': ParamIntNN, + 'pagesize': ParamIntNN} winStyles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL'] class xxxListCtrl(xxxObject): @@ -553,7 +553,7 @@ class xxxTreeCtrl(xxxObject): class xxxHtmlWindow(xxxObject): allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode'] - paramDict = {'borders': ParamInt, 'htmlcode':ParamMultilineText} + paramDict = {'borders': ParamUnit, 'htmlcode':ParamMultilineText} winStyles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO'] class xxxCalendarCtrl(xxxObject): @@ -573,7 +573,7 @@ class xxxSplitterWindow(xxxContainer): class xxxGenericDirCtrl(xxxObject): allParams = ['defaultfolder', 'filter', 'defaultfilter', 'pos', 'size', 'style'] - paramDict = {'defaultfilter': ParamInt} + paramDict = {'defaultfilter': ParamIntNN} winStyles = ['wxDIRCTRL_DIR_ONLY', 'wxDIRCTRL_3D_INTERNAL', 'wxDIRCTRL_SELECT_FIRST', 'wxDIRCTRL_SHOW_FILTERS', 'wxDIRCTRL_EDIT_LABELS'] @@ -627,7 +627,7 @@ class xxxStaticBox(xxxObject): class xxxRadioBox(xxxObject): allParams = ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style'] - paramDict = {'dimension': ParamInt} + paramDict = {'dimension': ParamIntNN} required = ['label', 'content'] default = {'content': '[]'} winStyles = ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS'] @@ -845,7 +845,6 @@ class xxxSeparator(xxxObject): class xxxUnknown(xxxObject): allParams = ['pos', 'size', 'style'] - paramDict = {'style': ParamNonGenericStyle} # no generic styles ################################################################################ -- 2.45.2