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
This commit is contained in:
Roman Rolinsky 2005-11-04 20:17:52 +00:00
parent 46ae103b9f
commit c032d94e60
6 changed files with 217 additions and 51 deletions

View File

@ -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
-------

View File

@ -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:

View File

@ -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,17 +119,68 @@ class ParamFlag(ParamBinaryOr):
def __init__(self, parent, name):
ParamBinaryOr.__init__(self, parent, name)
class ParamStyle(ParamBinaryOr):
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'}
def __init__(self, parent, name):
self.values = g.currentXXX.winStyles + genericStyles
ParamBinaryOr.__init__(self, parent, name)
class ParamNonGenericStyle(ParamBinaryOr):
def __init__(self, parent, name):
self.values = g.currentXXX.winStyles
ParamBinaryOr.__init__(self, parent, name)
class ParamStyle(ParamBinaryOr):
equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE'}
def __init__(self, parent, name):
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):
if g.currentXXX:
@ -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,

View File

@ -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,

View File

@ -133,7 +133,7 @@
</object>
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
</object>
<object class="wxDialog" name="DIALOG_CONTENT_CHECK_LIST">
<object class="wxDialog" name="DIALOG_CONTENT_CHECKLIST">
<title>Content</title>
<centered>1</centered>
<size>250,300</size>
@ -224,7 +224,7 @@
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxCheckListBox" name="CHECK_LIST">
<object class="wxCheckListBox" name="CHECKLIST">
<content/>
<size>250,250</size>
<style></style>
@ -260,6 +260,72 @@
</object>
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
</object>
<object class="wxDialog" name="DIALOG_STYLES">
<title>Window styles</title>
<centered>1</centered>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxStaticText" name="LABEL_SPECIFIC">
<label>Specific styles:</label>
</object>
<flag>wxTOP|wxLEFT</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxCheckListBox" name="CHECKLIST_SPECIFIC">
<content/>
<size>250,150</size>
<style></style>
</object>
<option>1</option>
<flag>wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Generic styles:</label>
</object>
<flag>wxLEFT</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxCheckListBox" name="CHECKLIST_GENERIC">
<content/>
<size>250,150</size>
<style></style>
</object>
<option>1</option>
<flag>wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticLine"/>
<flag>wxEXPAND</flag>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
</object>
<flag>wxRIGHT</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_CANCEL">
<label>Cancel</label>
</object>
</object>
</object>
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>10</border>
</object>
</object>
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
</object>
<object class="wxDialog" name="DIALOG_INTLIST">
<title>Numbers</title>
<centered>1</centered>
@ -268,32 +334,46 @@
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxListBox" name="LIST">
<content/>
<size>80,100</size>
<size>80,150</size>
<style>wxLB_SORT</style>
</object>
<option>1</option>
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>10</border>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_ADD">
<label>Add...</label>
<object class="wxSpinCtrl" name="SPIN">
<size>20,-1d</size>
</object>
<flag>wxBOTTOM</flag>
<border>3</border>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_ADD">
<label>Add</label>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_REMOVE">
<label>Remove</label>
</object>
</object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_CLEAR">
<label>Clear</label>
</object>
<flag>wxTOP</flag>
<border>5</border>
</object>
</object>
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>5</border>
@ -308,14 +388,14 @@
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<orient>wxHORIZONTAL</orient>
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
</object>
<flag>wxBOTTOM</flag>
<border>5</border>
<flag>wxRIGHT</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_CANCEL">

View File

@ -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
################################################################################