1
#-----------------------------------------------------------------------------
2
# Name: LibCompanions.py
5
# Author: Riaan Booysen
8
# RCS-ID: $Id: LibCompanions.py,v 1.5 2004/08/16 13:16:56 riaan Exp $
9
# Copyright: (c) 2003 - 2004
11
#-----------------------------------------------------------------------------
12
print 'importing Companions.LibCompanions'
14
from wxPython.wx import *
16
##from wxPython.lib.colourselect import ColourSelect, EVT_COLOURSELECT
17
from wxPython.lib.stattext import wxGenStaticText
19
from BaseCompanions import WindowDTC
20
from BasicCompanions import StaticTextDTC, TextCtrlDTC, ComboBoxDTC
22
from PropEdit import PropertyEditors, InspectorEditorControls
23
import EventCollections
26
import MaskedEditFmtCodeDlg
28
##class ColourSelectDTC(ButtonDTC):
29
## def __init__(self, name, designer, parent, ctrlClass):
30
## ButtonDTC.__init__(self, name, designer, parent, ctrlClass)
32
## def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
33
## return {'label': `self.name`,
34
## 'bcolour': `(0, 0, 0)`,
37
## 'name': `self.name`,
41
## return WindowDTC.events(self) + ['ButtonEvent']
43
## def defaultAction(self):
44
## insp = self.designer.inspector
45
## insp.pages.SetSelection(2)
46
## insp.events.doAddEvent('ButtonEvent', 'EVT_BUTTON')
49
class GenStaticTextDTC(StaticTextDTC):
50
handledConstrParams = ('parent', 'ID')
53
def writeImports(self):
54
return 'from wxPython.lib.stattext import wxGenStaticText'
56
#-------------------------------------------------------------------------------
58
##class MaskConstrPropEdit(PropertyEditors.StrConstrPropEdit):
59
## def inspectorEdit(self):
60
## self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
61
## self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
63
## def edit(self, event):
66
class FormatCodePropEdit(PropertyEditors.StrPropEdit):
67
def inspectorEdit(self):
68
self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
69
self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
71
def edit(self, event):
72
dlg = MaskedEditFmtCodeDlg.MaskedEditFormatCodesDlg(self.parent, self.value)
74
if dlg.ShowModal() != wxID_OK:
77
self.value = dlg.getFormatCode()
78
self.editorCtrl.setValue(self.value)
79
self.inspectorPost(false)
83
class AutoFormatPropMixin:
84
dependents = ['mask', 'datestyle', 'formatcodes',
85
'description', 'excludeChars', 'validRegex']
88
self.editors['Autoformat'] = PropertyEditors.StringEnumPropEdit
90
from wxPython.lib import maskededit
91
autofmt = maskededit.masktags.keys()
93
self.options['Autoformat'] = [s for s in ['']+autofmt]
94
self.names['Autoformat'] = {}
95
for opt in self.options['Autoformat']:
96
self.names['Autoformat'][opt] = opt
98
self.mutualDepProps += ['Autoformat'] + [s[0].upper()+s[1:]
99
for s in self.dependents]
101
def properties(self):
102
props = {'Autoformat': ('CompnRoute', self.GetAutoformat,
106
def GetAutoformat(self, x):
107
return self.control.GetAutoformat()
109
def SetAutoformat(self, val):
111
for dp in self.dependents:
112
currVals[dp] = self.control.GetCtrlParameter(dp)
114
self.control.SetAutoformat(val)
116
# call delayed so that Inspector may update first
117
wxCallAfter(self.revertAutoFormatDeps, currVals)
119
def revertAutoFormatDeps(self, currVals):
120
# revert source for properties that were changed to default values
121
for dp in self.dependents:
122
newVal = self.control.GetCtrlParameter(dp)
123
if newVal != currVals[dp]:
124
prop = dp[0].upper()+dp[1:]
125
self.propRevertToDefault(prop, 'Set'+prop)
128
class MaskedDTCMixin:
130
BoolPE = PropertyEditors.BoolPropEdit
131
StrEnumPE = PropertyEditors.StringEnumPropEdit
132
BITPropEdit = PropertyEditors.BITPropEditor
133
self.editors.update({'AutoCompleteKeycodes': BITPropEdit,
134
'UseFixedWidthFont': BoolPE,
135
'RetainFieldValidation': BoolPE,
136
'Datestyle': StrEnumPE,
137
'Choices': BITPropEdit,
138
'ChoiceRequired': BoolPE,
139
'CompareNoCase': BoolPE,
140
'EmptyInvalid': BoolPE,
141
'ValidRequired': BoolPE,
142
'Formatcodes': FormatCodePropEdit,
145
self.options['Datestyle'] = ['YMD','MDY','YDM','DYM','DMY','MYD']
146
self.names['Datestyle'] = {}
147
for opt in self.options['Datestyle']:
148
self.names['Datestyle'][opt] = opt
150
def hideDesignTime(self):
151
return ['Demo', 'Fields', 'Autoformat', 'ValidFunc']
153
class BaseMaskedTextCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
154
def __init__(self, name, designer, parent, ctrlClass):
155
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
156
MaskedDTCMixin.__init__(self)
158
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
159
dts = TextCtrlDTC.designTimeSource(self, position, size)
163
def hideDesignTime(self):
164
return TextCtrlDTC.hideDesignTime(self) + MaskedDTCMixin.hideDesignTime(self)
166
def writeImports(self):
167
return 'from wxPython.lib.maskededit import *'
169
class MaskedTextCtrlDTC(BaseMaskedTextCtrlDTC, AutoFormatPropMixin):
170
def __init__(self, name, designer, parent, ctrlClass):
171
BaseMaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
172
AutoFormatPropMixin.__init__(self)
174
def properties(self):
175
props = BaseMaskedTextCtrlDTC.properties(self)
176
props.update(AutoFormatPropMixin.properties(self))
180
class IpAddrCtrlDTC(BaseMaskedTextCtrlDTC):
182
## def hideDesignTime(self):
183
## return BaseMaskedTextCtrlDTC.hideDesignTime(self) + ['Datestyle',
184
## 'AutoCompleteKeycodes', 'SignedForegroundColour',
185
## 'GroupChar', 'DecimalChar', 'ShiftDecimalChar',
186
## 'UseParensForNegatives', 'ExcludeChars', 'IncludeChars',
189
class MaskedComboBoxDTC(ComboBoxDTC, MaskedDTCMixin, AutoFormatPropMixin):
190
def __init__(self, name, designer, parent, ctrlClass):
191
ComboBoxDTC.__init__(self, name, designer, parent, ctrlClass)
192
MaskedDTCMixin.__init__(self)
193
AutoFormatPropMixin.__init__(self)
195
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
196
dts = ComboBoxDTC.designTimeSource(self, position, size)
200
def properties(self):
201
props = ComboBoxDTC.properties(self)
202
props.update(AutoFormatPropMixin.properties(self))
205
def hideDesignTime(self):
206
return ComboBoxDTC.hideDesignTime(self) + \
207
MaskedDTCMixin.hideDesignTime(self)
208
## ['Mark', 'EmptyInvalid']
210
def writeImports(self):
211
return 'from wxPython.lib.maskededit import *'
213
class MaskedNumCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
214
def __init__(self, name, designer, parent, ctrlClass):
215
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
216
MaskedDTCMixin.__init__(self)
218
self.editors.update({'Min': PropertyEditors.BITPropEditor,
219
'Max': PropertyEditors.BITPropEditor,
220
'Bounds': PropertyEditors.BITPropEditor})
222
self.mutualDepProps += ['Bounds', 'Min', 'Max']
224
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
225
dts = TextCtrlDTC.designTimeSource(self, position, size)
230
return TextCtrlDTC.events(self) + ['MaskedNumCtrlEvent']
232
def writeImports(self):
233
return 'from wxPython.lib.maskednumctrl import *'
235
def hideDesignTime(self):
236
return TextCtrlDTC.hideDesignTime(self) + \
237
MaskedDTCMixin.hideDesignTime(self)
238
## ['Datestyle', 'AutoCompleteKeycodes', 'ExcludeChars',
239
## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
243
#-------------------------------------------------------------------------------
245
class SpinButtonEnumConstrPropEdit(PropertyEditors.ObjEnumConstrPropEdit):
246
def getObjects(self):
247
designer = self.companion.designer#.controllerView
248
windows = designer.getObjectsOfClass(wxSpinButtonPtr)
249
windowNames = windows.keys()
251
res = ['None'] + windowNames
252
if self.value != 'None':
253
res.insert(1, self.value)
256
def getDisplayValue(self):
257
return `self.valueToIECValue()`
259
def getCtrlValue(self):
260
return self.companion.GetSpinButton()
261
def setCtrlValue(self, oldValue, value):
262
self.companion.SetSpinButton(value)
264
class SpinButtonClassLinkPropEdit(PropertyEditors.ClassLinkPropEdit):
265
linkClass = wxSpinButtonPtr
267
#EventCollections.EventCategories['TimeCtrlEvent'] = (EVT_TIMEUPDATE,)
268
#EventCollections.commandCategories.append('TimeCtrlEvent')
270
# XXX min, max & limited params not supported yet
271
# XXX should be implemented as a wxDateTime property editor using
272
# XXX this very time ctrl, a problem is how to handle None values.
274
class TimeCtrlDTC(MaskedTextCtrlDTC):
275
def __init__(self, name, designer, parent, ctrlClass):
276
MaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
277
BoolPE = PropertyEditors.BoolConstrPropEdit
278
ColourPE = PropertyEditors.ColourConstrPropEdit
279
self.editors.update({'Format24Hours': BoolPE,
280
'SpinButton': SpinButtonClassLinkPropEdit,
281
'OutOfBoundsColour': ColourPE,
282
'DisplaySeconds': BoolPE,
283
'UseFixedWidthFont': BoolPE,
284
'Format': PropertyEditors.StringEnumPropEdit})
286
format = ['MILHHMMSS', 'MILHHMM', 'HHMMSS', 'HHMM']
287
self.options['Format'] = format
288
self.names['Format'] = {}
289
for name in format: self.names['Format'][name] = name
292
self._spinbutton = None
293
self.initPropsThruCompanion.extend(['SpinButton', 'BindSpinButton'])
295
def constructor(self):
296
constr = MaskedTextCtrlDTC.constructor(self)
297
constr.update({'Format24Hours': 'fmt24hr',
298
'DisplaySeconds': 'display_seconds',
299
'OutOfBoundsColour': 'oob_color',
300
'UseFixedWidthFont': 'useFixedWidthFont',
304
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
305
dts = MaskedTextCtrlDTC.designTimeSource(self, position, size)
306
dts.update({'value': "'12:00:00 AM'",
308
'display_seconds': 'True',
309
'oob_color': "wxNamedColour('Yellow')",
310
'useFixedWidthFont': 'True',
314
def properties(self):
315
props = MaskedTextCtrlDTC.properties(self)
316
if props.has_key('Autoformat'):
317
del props['Autoformat']
318
props['SpinButton'] = ('CompnRoute', self.GetSpinButton,
320
## props['Format24Hours'] = ('CompnRoute', self.GetFormat24Hours,
321
## self.SetFormat24Hours)
322
## props['DisplaySeconds'] = ('CompnRoute', self.GetDisplaySeconds,
323
## self.SetDisplaySeconds)
327
def dependentProps(self):
328
return MaskedTextCtrlDTC.dependentProps(self) + ['SpinButton', 'BindSpinButton']
331
return MaskedTextCtrlDTC.events(self) + ['TimeCtrlEvent']
333
def writeImports(self):
334
return 'from wxPython.lib.timectrl import *'
336
## def hideDesignTime(self):
337
## return MaskedTextCtrlDTC.hideDesignTime(self) + ['Mask',
338
## 'Datestyle', 'AutoCompleteKeycodes', 'EmptyBackgroundColour',
339
## 'SignedForegroundColour', 'GroupChar', 'DecimalChar',
340
## 'ShiftDecimalChar', 'UseParensForNegatives', 'ExcludeChars',
341
## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
342
## 'AutoSelect', 'ValidRegex', 'ValidRange']
344
def GetSpinButton(self, x):
345
return self._spinbutton
347
def BindSpinButton(self, value):
348
self._spinbutton = value
349
if value is not None:
350
spins = self.designer.getObjectsOfClass(wxSpinButtonPtr)
352
self.control.BindSpinButton(spins[value])
354
## def GetDisplaySeconds(self, x):
355
## return self.eval(self.textConstr.params['display_seconds'])
357
## def SetDisplaySeconds(self, value):
358
## self.textConstr.params['display_seconds'] = self.eval(value)
360
#-------------------------------------------------------------------------------
362
#EventCollections.EventCategories['IntCtrlEvent'] = (EVT_INT,)
363
#EventCollections.commandCategories.append('IntCtrlEvent')
366
class IntCtrlDTC(TextCtrlDTC):
367
def __init__(self, name, designer, parent, ctrlClass):
368
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
369
BoolPE = PropertyEditors.BoolConstrPropEdit
370
ColourPE = PropertyEditors.ColourConstrPropEdit
371
self.editors.update({'Min': PropertyEditors.BITPropEditor,
372
'Max': PropertyEditors.BITPropEditor,
376
'DefaultColour': ColourPE,
377
'OutOfBoundsColour': ColourPE})
379
def constructor(self):
380
constr = TextCtrlDTC.constructor(self)
381
constr.update({'Min': 'min', 'Max': 'max', 'Limited': 'limited',
382
'AllowNone': 'allow_none', 'AllowLong': 'allow_long',
383
'DefaultColour': 'default_color', 'OutOfBoundsColour': 'oob_color'})
386
def designTimeSource(self, position = 'wxDefaultPosition', size = 'wxDefaultSize'):
387
dts = TextCtrlDTC.designTimeSource(self, position, size)
388
dts.update({'value': '0',
392
'allow_none': 'False',
393
'allow_long': 'False',
394
'default_color': 'wxBLACK',
395
'oob_color': 'wxRED'})
398
## def hideDesignTime(self):
399
## return TextCtrlDTC.hideDesignTime(self) + ['Bounds', 'InsertionPoint']
402
return TextCtrlDTC.events(self) + ['IntCtrlEvent']
404
def writeImports(self):
405
return 'from wxPython.lib.intctrl import *'
408
#-------------------------------------------------------------------------------
412
PaletteStore.paletteLists['wxPython.lib'] = []
413
PaletteStore.palette.append(['wxPython.lib', 'Editor/Tabs/Basic',
414
PaletteStore.paletteLists['wxPython.lib']])
416
# XXX clean up special casing when 2.4.1 is minimum!
418
libPalette = [wxGenStaticText]
419
libCompInfo = {wxGenStaticText: ['wxGenStaticText', GenStaticTextDTC]}
422
from wxPython.lib.maskednumctrl import wxMaskedNumCtrl, EVT_MASKEDNUM
423
from wxPython.lib.maskededit import wxMaskedTextCtrl, wxMaskedComboBox, wxIpAddrCtrl, Field
424
from wxPython.lib.timectrl import wxTimeCtrl, EVT_TIMEUPDATE
425
except ImportError: # <= 2.4.1.2
428
libPalette.extend([wxMaskedTextCtrl, wxIpAddrCtrl, wxMaskedComboBox,
429
wxMaskedNumCtrl, wxTimeCtrl])
431
wxMaskedTextCtrl: ['wxMaskedTextCtrl', MaskedTextCtrlDTC],
432
wxIpAddrCtrl: ['wxIpAddrCtrl', IpAddrCtrlDTC],
433
wxMaskedComboBox: ['wxMaskedComboBox', MaskedComboBoxDTC],
434
wxMaskedNumCtrl: ['wxMaskedNumCtrl', MaskedNumCtrlDTC],
435
wxTimeCtrl: ['wxTimeCtrl', TimeCtrlDTC],
438
EventCollections.EventCategories['MaskedNumCtrlEvent'] = (EVT_MASKEDNUM,)
439
EventCollections.commandCategories.append('MaskedNumCtrlEvent')
441
EventCollections.EventCategories['TimeCtrlEvent'] = (EVT_TIMEUPDATE,)
442
EventCollections.commandCategories.append('TimeCtrlEvent')
444
from wxPython.lib.intctrl import wxIntCtrl, EVT_INT
446
EventCollections.EventCategories['IntCtrlEvent'] = (EVT_INT,)
447
EventCollections.commandCategories.append('IntCtrlEvent')
449
libPalette.append(wxIntCtrl)
450
libCompInfo[wxIntCtrl] = ['wxIntCtrl', IntCtrlDTC]
452
PaletteStore.paletteLists['wxPython.lib'].extend(libPalette)
453
PaletteStore.compInfo.update(libCompInfo)
1
#-----------------------------------------------------------------------------
2
# Name: LibCompanions.py
5
# Author: Riaan Booysen
8
# RCS-ID: $Id: LibCompanions.py,v 1.10 2005/07/04 19:14:24 riaan Exp $
9
# Copyright: (c) 2003 - 2005
11
#-----------------------------------------------------------------------------
12
print 'importing Companions.LibCompanions'
16
from BaseCompanions import WindowDTC
17
from BasicCompanions import StaticTextDTC, TextCtrlDTC, ComboBoxDTC
19
from PropEdit import PropertyEditors, InspectorEditorControls
20
import EventCollections
23
import MaskedEditFmtCodeDlg
26
class GenStaticTextDTC(StaticTextDTC):
27
handledConstrParams = ('parent', 'ID')
30
def writeImports(self):
31
return 'import wx.lib.stattext'
33
#-------------------------------------------------------------------------------
35
##class MaskConstrPropEdit(PropertyEditors.StrConstrPropEdit):
36
## def inspectorEdit(self):
37
## self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
38
## self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
40
## def edit(self, event):
43
class FormatCodePropEdit(PropertyEditors.StrPropEdit):
44
def inspectorEdit(self):
45
self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
46
self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
48
def edit(self, event):
49
dlg = MaskedEditFmtCodeDlg.MaskedEditFormatCodesDlg(self.parent, self.value)
51
if dlg.ShowModal() != wx.ID_OK:
54
self.value = dlg.getFormatCode()
55
self.editorCtrl.setValue(self.value)
56
self.inspectorPost(False)
60
class AutoFormatPropMixin:
61
dependents = ['mask', 'datestyle', 'formatcodes',
62
'description', 'excludeChars', 'validRegex']
65
self.editors['Autoformat'] = PropertyEditors.StringEnumPropEdit
67
from wx.lib.masked import maskededit
68
autofmt = maskededit.masktags.keys()
70
self.options['Autoformat'] = [s for s in ['']+autofmt]
71
self.names['Autoformat'] = {}
72
for opt in self.options['Autoformat']:
73
self.names['Autoformat'][opt] = opt
75
self.mutualDepProps += ['Autoformat'] + [s[0].upper()+s[1:]
76
for s in self.dependents]
79
props = {'Autoformat': ('CompnRoute', self.GetAutoformat,
83
def GetAutoformat(self, x):
84
return self.control.GetAutoformat()
86
def SetAutoformat(self, val):
88
for dp in self.dependents:
89
currVals[dp] = self.control.GetCtrlParameter(dp)
91
self.control.SetAutoformat(val)
93
# call delayed so that Inspector may update first
94
wx.CallAfter(self.revertAutoFormatDeps, currVals)
96
def revertAutoFormatDeps(self, currVals):
97
# revert source for properties that were changed to default values
98
for dp in self.dependents:
99
newVal = self.control.GetCtrlParameter(dp)
100
if newVal != currVals[dp]:
101
prop = dp[0].upper()+dp[1:]
102
self.propRevertToDefault(prop, 'Set'+prop)
105
class MaskedDTCMixin:
107
BoolPE = PropertyEditors.BoolPropEdit
108
StrEnumPE = PropertyEditors.StringEnumPropEdit
109
BITPropEdit = PropertyEditors.BITPropEditor
110
self.editors.update({'AutoCompleteKeycodes': BITPropEdit,
111
'UseFixedWidthFont': BoolPE,
112
'RetainFieldValidation': BoolPE,
113
'Datestyle': StrEnumPE,
114
'Choices': BITPropEdit,
115
'ChoiceRequired': BoolPE,
116
'CompareNoCase': BoolPE,
117
'EmptyInvalid': BoolPE,
118
'ValidRequired': BoolPE,
119
'Formatcodes': FormatCodePropEdit,
122
self.options['Datestyle'] = ['YMD','MDY','YDM','DYM','DMY','MYD']
123
self.names['Datestyle'] = {}
124
for opt in self.options['Datestyle']:
125
self.names['Datestyle'][opt] = opt
127
def hideDesignTime(self):
128
return ['Demo', 'Fields', 'Autoformat', 'ValidFunc']
130
class BaseMaskedTextCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
131
def __init__(self, name, designer, parent, ctrlClass):
132
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
133
MaskedDTCMixin.__init__(self)
135
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
136
dts = TextCtrlDTC.designTimeSource(self, position, size)
140
def hideDesignTime(self):
141
return TextCtrlDTC.hideDesignTime(self) + MaskedDTCMixin.hideDesignTime(self)
144
class MaskedTextCtrlDTC(BaseMaskedTextCtrlDTC, AutoFormatPropMixin):
145
def __init__(self, name, designer, parent, ctrlClass):
146
BaseMaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
147
AutoFormatPropMixin.__init__(self)
149
def properties(self):
150
props = BaseMaskedTextCtrlDTC.properties(self)
151
props.update(AutoFormatPropMixin.properties(self))
154
def writeImports(self):
155
return 'import wx.lib.masked.textctrl'
157
class IpAddrCtrlDTC(BaseMaskedTextCtrlDTC):
158
def writeImports(self):
159
return 'import wx.lib.masked.ipaddrctrl'
162
class MaskedComboBoxDTC(ComboBoxDTC, MaskedDTCMixin, AutoFormatPropMixin):
163
def __init__(self, name, designer, parent, ctrlClass):
164
ComboBoxDTC.__init__(self, name, designer, parent, ctrlClass)
165
MaskedDTCMixin.__init__(self)
166
AutoFormatPropMixin.__init__(self)
168
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
169
dts = ComboBoxDTC.designTimeSource(self, position, size)
173
def properties(self):
174
props = ComboBoxDTC.properties(self)
175
props.update(AutoFormatPropMixin.properties(self))
178
def hideDesignTime(self):
179
return ComboBoxDTC.hideDesignTime(self) + \
180
MaskedDTCMixin.hideDesignTime(self)
181
## ['Mark', 'EmptyInvalid']
183
def writeImports(self):
184
return 'import wx.lib.masked.combobox'
186
class MaskedNumCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
187
def __init__(self, name, designer, parent, ctrlClass):
188
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
189
MaskedDTCMixin.__init__(self)
191
self.editors.update({'Min': PropertyEditors.BITPropEditor,
192
'Max': PropertyEditors.BITPropEditor,
193
'Bounds': PropertyEditors.BITPropEditor})
195
self.mutualDepProps += ['Bounds', 'Min', 'Max']
197
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
198
dts = TextCtrlDTC.designTimeSource(self, position, size)
203
return TextCtrlDTC.events(self) + ['MaskedNumCtrlEvent']
205
def writeImports(self):
206
return 'import wx.lib.masked.numctrl'
208
def hideDesignTime(self):
209
return TextCtrlDTC.hideDesignTime(self) + \
210
MaskedDTCMixin.hideDesignTime(self)
211
## ['Datestyle', 'AutoCompleteKeycodes', 'ExcludeChars',
212
## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
216
#-------------------------------------------------------------------------------
218
class SpinButtonEnumConstrPropEdit(PropertyEditors.ObjEnumConstrPropEdit):
219
def getObjects(self):
220
designer = self.companion.designer#.controllerView
221
windows = designer.getObjectsOfClass(wx.SpinButton)
222
windowNames = windows.keys()
224
res = ['None'] + windowNames
225
if self.value != 'None':
226
res.insert(1, self.value)
229
def getDisplayValue(self):
230
return `self.valueToIECValue()`
232
def getCtrlValue(self):
233
return self.companion.GetSpinButton()
234
def setCtrlValue(self, oldValue, value):
235
self.companion.SetSpinButton(value)
237
class SpinButtonClassLinkPropEdit(PropertyEditors.ClassLinkPropEdit):
238
linkClass = wx.SpinButton
240
#EventCollections.EventCategories['TimeCtrlEvent'] = (EVT_TIMEUPDATE,)
241
#EventCollections.commandCategories.append('TimeCtrlEvent')
243
# XXX min, max & limited params not supported yet
244
# XXX should be implemented as a wxDateTime property editor using
245
# XXX this very time ctrl, a problem is how to handle None values.
247
class TimeCtrlDTC(MaskedTextCtrlDTC):
248
def __init__(self, name, designer, parent, ctrlClass):
249
MaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
250
BoolPE = PropertyEditors.BoolConstrPropEdit
251
ColourPE = PropertyEditors.ColourConstrPropEdit
252
self.editors.update({'Format24Hours': BoolPE,
253
'SpinButton': SpinButtonClassLinkPropEdit,
254
'OutOfBoundsColour': ColourPE,
255
'DisplaySeconds': BoolPE,
256
'UseFixedWidthFont': BoolPE,
257
'Format': PropertyEditors.StringEnumPropEdit})
259
format = ['MILHHMMSS', 'MILHHMM', 'HHMMSS', 'HHMM']
260
self.options['Format'] = format
261
self.names['Format'] = {}
262
for name in format: self.names['Format'][name] = name
265
self._spinbutton = None
266
self.initPropsThruCompanion.extend(['SpinButton', 'BindSpinButton'])
268
def constructor(self):
269
constr = MaskedTextCtrlDTC.constructor(self)
270
constr.update({'Format24Hours': 'fmt24hr',
271
'DisplaySeconds': 'display_seconds',
272
'OutOfBoundsColour': 'oob_color',
273
'UseFixedWidthFont': 'useFixedWidthFont',
277
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
278
dts = MaskedTextCtrlDTC.designTimeSource(self, position, size)
279
dts.update({'value': "'12:00:00 AM'",
281
'display_seconds': 'True',
282
'oob_color': "wx.NamedColour('Yellow')",
283
'useFixedWidthFont': 'True',
287
def properties(self):
288
props = MaskedTextCtrlDTC.properties(self)
289
if props.has_key('Autoformat'):
290
del props['Autoformat']
291
props['SpinButton'] = ('CompnRoute', self.GetSpinButton,
293
## props['Format24Hours'] = ('CompnRoute', self.GetFormat24Hours,
294
## self.SetFormat24Hours)
295
## props['DisplaySeconds'] = ('CompnRoute', self.GetDisplaySeconds,
296
## self.SetDisplaySeconds)
300
def dependentProps(self):
301
return MaskedTextCtrlDTC.dependentProps(self) + ['SpinButton', 'BindSpinButton']
304
return MaskedTextCtrlDTC.events(self) + ['TimeCtrlEvent']
306
def writeImports(self):
307
return 'import wx.lib.masked.timectrl'
309
## def hideDesignTime(self):
310
## return MaskedTextCtrlDTC.hideDesignTime(self) + ['Mask',
311
## 'Datestyle', 'AutoCompleteKeycodes', 'EmptyBackgroundColour',
312
## 'SignedForegroundColour', 'GroupChar', 'DecimalChar',
313
## 'ShiftDecimalChar', 'UseParensForNegatives', 'ExcludeChars',
314
## 'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
315
## 'AutoSelect', 'ValidRegex', 'ValidRange']
317
def GetSpinButton(self, x):
318
return self._spinbutton
320
def BindSpinButton(self, value):
321
self._spinbutton = value
322
if value is not None:
323
spins = self.designer.getObjectsOfClass(wx.SpinButton)
325
self.control.BindSpinButton(spins[value])
327
## def GetDisplaySeconds(self, x):
328
## return self.eval(self.textConstr.params['display_seconds'])
330
## def SetDisplaySeconds(self, value):
331
## self.textConstr.params['display_seconds'] = self.eval(value)
333
#-------------------------------------------------------------------------------
335
#EventCollections.EventCategories['IntCtrlEvent'] = (EVT_INT,)
336
#EventCollections.commandCategories.append('IntCtrlEvent')
339
class IntCtrlDTC(TextCtrlDTC):
340
def __init__(self, name, designer, parent, ctrlClass):
341
TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
342
BoolPE = PropertyEditors.BoolConstrPropEdit
343
ColourPE = PropertyEditors.ColourConstrPropEdit
344
self.editors.update({'Min': PropertyEditors.BITPropEditor,
345
'Max': PropertyEditors.BITPropEditor,
349
'DefaultColour': ColourPE,
350
'OutOfBoundsColour': ColourPE})
352
def constructor(self):
353
constr = TextCtrlDTC.constructor(self)
354
constr.update({'Min': 'min', 'Max': 'max', 'Limited': 'limited',
355
'AllowNone': 'allow_none', 'AllowLong': 'allow_long',
356
'DefaultColour': 'default_color', 'OutOfBoundsColour': 'oob_color'})
359
def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
360
dts = TextCtrlDTC.designTimeSource(self, position, size)
361
dts.update({'value': '0',
365
'allow_none': 'False',
366
'allow_long': 'False',
367
'default_color': 'wx.BLACK',
368
'oob_color': 'wx.RED'})
371
## def hideDesignTime(self):
372
## return TextCtrlDTC.hideDesignTime(self) + ['Bounds', 'InsertionPoint']
375
return TextCtrlDTC.events(self) + ['IntCtrlEvent']
377
def writeImports(self):
378
return 'import wx.lib.intctrl'
381
#-------------------------------------------------------------------------------
383
import wx.lib.stattext
384
import wx.lib.masked.textctrl
385
import wx.lib.masked.ipaddrctrl
386
import wx.lib.masked.combobox
387
import wx.lib.masked.numctrl
388
import wx.lib.masked.timectrl
389
import wx.lib.intctrl
393
Plugins.registerPalettePage('Library', 'Library')
395
Plugins.registerComponents('Library',
396
(wx.lib.stattext.GenStaticText, 'wx.lib.stattext.GenStaticText', GenStaticTextDTC),
397
(wx.lib.masked.textctrl.TextCtrl, 'wx.lib.masked.textctrl.TextCtrl', MaskedTextCtrlDTC),
398
(wx.lib.masked.ipaddrctrl.IpAddrCtrl, 'wx.lib.masked.ipaddrctrl.IpAddrCtrl', IpAddrCtrlDTC),
399
(wx.lib.masked.combobox.ComboBox, 'wx.lib.masked.combobox.ComboBox', MaskedComboBoxDTC),
400
(wx.lib.masked.numctrl.NumCtrl, 'wx.lib.masked.numctrl.NumCtrl', MaskedNumCtrlDTC),
401
(wx.lib.masked.timectrl.TimeCtrl, 'wx.lib.masked.timectrl.TimeCtrl', TimeCtrlDTC),
402
(wx.lib.intctrl.IntCtrl, 'wx.lib.intctrl.IntCtrl', IntCtrlDTC),
405
EventCollections.EventCategories['MaskedNumCtrlEvent'] = ('wx.lib.masked.numctrl.EVT_MASKEDNUM',)
406
EventCollections.commandCategories.append('MaskedNumCtrlEvent')
407
EventCollections.EventCategories['TimeCtrlEvent'] = ('wx.lib.masked.timectrl.EVT_TIMEUPDATE',)
408
EventCollections.commandCategories.append('TimeCtrlEvent')
409
EventCollections.EventCategories['IntCtrlEvent'] = ('wx.lib.intctrl.EVT_INT',)
410
EventCollections.commandCategories.append('IntCtrlEvent')