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 = []
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):
else:
self.values = []
ParamBinaryOr.__init__(self, parent, name)
+ self.SetTitle('Extended window styles')
class ParamColour(PPanel):
def __init__(self, parent, name):
font.GetFaceName().encode(),
encName
]
- # Add ignored flags
self.SetValue(value)
self.SetModified()
self.textModified = False
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)
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)
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:
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
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
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
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)
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
'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,
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
<resource>
<object class="wxDialog" name="DIALOG_TEXT">
<title>Text Dialog</title>
</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>
<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>
</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>
<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="wxSpinCtrl" name="SPIN">
+ <size>20,-1d</size>
+ </object>
+ <flag>wxBOTTOM</flag>
+ <border>5</border>
+ </object>
<object class="sizeritem">
<object class="wxButton" name="BUTTON_ADD">
- <label>Add...</label>
+ <label>Add</label>
</object>
<flag>wxBOTTOM</flag>
- <border>3</border>
+ <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>
</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">
</object>
</object>
</object>
-</resource>
+</resource>
\ No newline at end of file
'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',
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',
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):
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):
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']
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']
class xxxUnknown(xxxObject):
allParams = ['pos', 'size', 'style']
- paramDict = {'style': ParamNonGenericStyle} # no generic styles
################################################################################