PageRenderTime 301ms CodeModel.GetById 179ms app.highlight 70ms RepoModel.GetById 42ms app.codeStats 0ms

/Companions/LibCompanions.py

https://bitbucket.org/cwt/boa-constructor
Python | 703 lines | 668 code | 16 blank | 19 comment | 5 complexity | dfe0bc4a8df56e76e596d748fe0242c2 MD5 | raw file
  1#-----------------------------------------------------------------------------
  2# Name:        LibCompanions.py
  3# Purpose:
  4#
  5# Author:      Riaan Booysen
  6#
  7# Created:     2003
  8# RCS-ID:      $Id$
  9# Copyright:   (c) 2003 - 2007
 10# Licence:     GPL
 11#-----------------------------------------------------------------------------
 12print 'importing Companions.LibCompanions'
 13
 14import wx
 15
 16from Utils import _
 17
 18import Constructors, ContainerCompanions, BasicCompanions
 19from BaseCompanions import WindowDTC
 20from BasicCompanions import StaticTextDTC, TextCtrlDTC, ComboBoxDTC
 21from ContainerCompanions import PanelDTC
 22
 23from PropEdit import PropertyEditors, InspectorEditorControls
 24import EventCollections
 25
 26from PropEdit import MaskedEditFmtCodeDlg, BitmapListEditorDlg
 27
 28
 29class GenStaticTextDTC(StaticTextDTC):
 30    handledConstrParams = ('parent', 'ID')
 31    windowIdName = 'ID'
 32
 33    def writeImports(self):
 34        return '\n'.join( (StaticTextDTC.writeImports(self), 'import wx.lib.stattext'))
 35
 36#-------------------------------------------------------------------------------
 37
 38##class MaskConstrPropEdit(PropertyEditors.StrConstrPropEdit):
 39##    def inspectorEdit(self):
 40##        self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
 41##        self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
 42##
 43##    def edit(self, event):
 44##        pass
 45
 46class FormatCodePropEdit(PropertyEditors.StrPropEdit):
 47    def inspectorEdit(self):
 48        self.editorCtrl = InspectorEditorControls.TextCtrlButtonIEC(self, self.value)
 49        self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
 50
 51    def edit(self, event):
 52        dlg = MaskedEditFmtCodeDlg.MaskedEditFormatCodesDlg(self.parent, self.value)
 53        try:
 54            if dlg.ShowModal() != wx.ID_OK:
 55                return
 56
 57            self.value = dlg.getFormatCode()
 58            self.editorCtrl.setValue(self.value)
 59            self.inspectorPost(False)
 60        finally:
 61            dlg.Destroy()
 62
 63class AutoFormatPropMixin:
 64    dependents = ['mask', 'datestyle', 'formatcodes',
 65                  'description', 'excludeChars', 'validRegex']
 66
 67    def __init__(self):
 68        self.editors['Autoformat'] = PropertyEditors.StringEnumPropEdit
 69
 70        from wx.lib.masked import maskededit
 71        autofmt = maskededit.masktags.keys()
 72        autofmt.sort()
 73        self.options['Autoformat'] = [s for s in ['']+autofmt]
 74        self.names['Autoformat'] = {}
 75        for opt in self.options['Autoformat']:
 76            self.names['Autoformat'][opt] = opt
 77
 78        self.mutualDepProps += ['Autoformat'] + [s[0].upper()+s[1:]
 79                                                 for s in self.dependents]
 80
 81    def properties(self):
 82        props = {'Autoformat': ('CompnRoute', self.GetAutoformat,
 83                                              self.SetAutoformat)}
 84        return props
 85
 86    def GetAutoformat(self, x):
 87        return self.control.GetAutoformat()
 88
 89    def SetAutoformat(self, val):
 90        currVals = {}
 91        for dp in self.dependents:
 92            currVals[dp] = self.control.GetCtrlParameter(dp)
 93
 94        self.control.SetAutoformat(val)
 95
 96        # call delayed so that Inspector may update first
 97        wx.CallAfter(self.revertAutoFormatDeps, currVals)
 98
 99    def revertAutoFormatDeps(self, currVals):
100        # revert source for properties that were changed to default values
101        for dp in self.dependents:
102            newVal = self.control.GetCtrlParameter(dp)
103            if newVal != currVals[dp]:
104                prop = dp[0].upper()+dp[1:]
105                self.propRevertToDefault(prop, 'Set'+prop)
106
107
108class MaskedDTCMixin:
109    def __init__(self):
110        BoolPE = PropertyEditors.BoolPropEdit
111        StrEnumPE = PropertyEditors.StringEnumPropEdit
112        BITPropEdit = PropertyEditors.BITPropEditor
113        self.editors.update({'AutoCompleteKeycodes': BITPropEdit,
114                             'UseFixedWidthFont': BoolPE,
115                             'RetainFieldValidation': BoolPE,
116                             'Datestyle': StrEnumPE,
117                             'Choices': BITPropEdit,
118                             'ChoiceRequired': BoolPE,
119                             'CompareNoCase': BoolPE,
120                             'EmptyInvalid': BoolPE,
121                             'ValidRequired': BoolPE,
122                             'Formatcodes': FormatCodePropEdit,
123                            })
124
125        self.options['Datestyle'] = ['YMD','MDY','YDM','DYM','DMY','MYD']
126        self.names['Datestyle'] = {}
127        for opt in self.options['Datestyle']:
128            self.names['Datestyle'][opt] = opt
129
130    def hideDesignTime(self):
131        return ['Demo', 'Fields', 'Autoformat', 'ValidFunc']
132
133class BaseMaskedTextCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
134    def __init__(self, name, designer, parent, ctrlClass):
135        TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
136        MaskedDTCMixin.__init__(self)
137
138    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
139        dts = TextCtrlDTC.designTimeSource(self, position, size)
140        dts['value'] = "''"
141        return dts
142
143    def hideDesignTime(self):
144        return TextCtrlDTC.hideDesignTime(self) + MaskedDTCMixin.hideDesignTime(self)
145
146
147class MaskedTextCtrlDTC(BaseMaskedTextCtrlDTC, AutoFormatPropMixin):
148    def __init__(self, name, designer, parent, ctrlClass):
149        BaseMaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
150        AutoFormatPropMixin.__init__(self)
151
152    def properties(self):
153        props = BaseMaskedTextCtrlDTC.properties(self)
154        props.update(AutoFormatPropMixin.properties(self))
155        return props
156
157    def writeImports(self):
158        return '\n'.join( (BaseMaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.textctrl'))
159
160class IpAddrCtrlDTC(BaseMaskedTextCtrlDTC):
161    def writeImports(self):
162        return '\n'.join( (BaseMaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.ipaddrctrl'))
163
164
165class MaskedComboBoxDTC(ComboBoxDTC, MaskedDTCMixin, AutoFormatPropMixin):
166    def __init__(self, name, designer, parent, ctrlClass):
167        ComboBoxDTC.__init__(self, name, designer, parent, ctrlClass)
168        MaskedDTCMixin.__init__(self)
169        AutoFormatPropMixin.__init__(self)
170
171    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
172        dts = ComboBoxDTC.designTimeSource(self, position, size)
173        dts['value'] = "''"
174        return dts
175
176    def properties(self):
177        props = ComboBoxDTC.properties(self)
178        props.update(AutoFormatPropMixin.properties(self))
179        return props
180
181    def hideDesignTime(self):
182        return ComboBoxDTC.hideDesignTime(self) + \
183               MaskedDTCMixin.hideDesignTime(self)
184##               ['Mark', 'EmptyInvalid']
185
186    def writeImports(self):
187        return '\n'.join( (ComboBoxDTC.writeImports(self), 'import wx.lib.masked.combobox'))
188
189class MaskedNumCtrlDTC(TextCtrlDTC, MaskedDTCMixin):
190    def __init__(self, name, designer, parent, ctrlClass):
191        TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
192        MaskedDTCMixin.__init__(self)
193
194        self.editors.update({'Min': PropertyEditors.BITPropEditor,
195                             'Max': PropertyEditors.BITPropEditor,
196                             'Bounds': PropertyEditors.BITPropEditor})
197
198        self.mutualDepProps += ['Bounds', 'Min', 'Max']
199
200    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
201        dts = TextCtrlDTC.designTimeSource(self, position, size)
202        dts['value'] = '0'
203        return dts
204
205    def events(self):
206        return TextCtrlDTC.events(self) + ['MaskedNumCtrlEvent']
207
208    def writeImports(self):
209        return '\n'.join( (TextCtrlDTC.writeImports(self), 'import wx.lib.masked.numctrl'))
210
211    def hideDesignTime(self):
212        return TextCtrlDTC.hideDesignTime(self) + \
213               MaskedDTCMixin.hideDesignTime(self)
214##               ['Datestyle', 'AutoCompleteKeycodes', 'ExcludeChars',
215##               'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
216##               'ValidRange']
217
218
219#-------------------------------------------------------------------------------
220
221class SpinButtonEnumConstrPropEdit(PropertyEditors.ObjEnumConstrPropEdit):
222    def getObjects(self):
223        designer = self.companion.designer#.controllerView
224        windows = designer.getObjectsOfClass(wx.SpinButton)
225        windowNames = windows.keys()
226        windowNames.sort()
227        res = ['None'] + windowNames
228        if self.value != 'None':
229            res.insert(1, self.value)
230        return res
231
232    def getDisplayValue(self):
233        return `self.valueToIECValue()`
234
235    def getCtrlValue(self):
236        return self.companion.GetSpinButton()
237    def setCtrlValue(self, oldValue, value):
238        self.companion.SetSpinButton(value)
239
240class SpinButtonClassLinkPropEdit(PropertyEditors.ClassLinkPropEdit):
241    linkClass = wx.SpinButton
242
243#EventCollections.EventCategories['TimeCtrlEvent'] = (EVT_TIMEUPDATE,)
244#EventCollections.commandCategories.append('TimeCtrlEvent')
245
246# XXX min, max & limited params not supported yet
247# XXX should be implemented as a wxDateTime property editor using
248# XXX this very time ctrl, a problem is how to handle None values.
249
250class TimeCtrlDTC(MaskedTextCtrlDTC):
251    def __init__(self, name, designer, parent, ctrlClass):
252        MaskedTextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
253        BoolPE = PropertyEditors.BoolConstrPropEdit
254        ColourPE = PropertyEditors.ColourConstrPropEdit
255        self.editors.update({'Format24Hours': BoolPE,
256                             'SpinButton': SpinButtonClassLinkPropEdit,
257                             'OutOfBoundsColour': ColourPE,
258                             'DisplaySeconds': BoolPE,
259                             'UseFixedWidthFont': BoolPE,
260                             'Format': PropertyEditors.StringEnumPropEdit})
261
262        format = ['24HHMMSS', '24HHMM', 'HHMMSS', 'HHMM']
263        self.options['Format'] = format
264        self.names['Format'] = {}
265        for name in format: self.names['Format'][name] = name
266
267
268        self._spinbutton = None
269        self.initPropsThruCompanion.extend(['SpinButton', 'BindSpinButton'])
270
271    def constructor(self):
272        constr = MaskedTextCtrlDTC.constructor(self)
273        constr.update({'Format24Hours':     'fmt24hr',
274                       'DisplaySeconds':    'display_seconds',
275                       'OutOfBoundsColour': 'oob_color',
276                       'UseFixedWidthFont': 'useFixedWidthFont',
277                      })
278        return constr
279
280    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
281        dts = MaskedTextCtrlDTC.designTimeSource(self, position, size)
282        dts.update({'value': "'12:00:00 AM'",
283                    'fmt24hr': 'False',
284                    'display_seconds': 'True',
285                    'oob_color': "wx.NamedColour('Yellow')",
286                    'useFixedWidthFont': 'True',
287                   })
288        return dts
289
290    def properties(self):
291        props = MaskedTextCtrlDTC.properties(self)
292        if 'Autoformat' in props:
293            del props['Autoformat']
294        props['SpinButton'] = ('CompnRoute', self.GetSpinButton,
295                                             self.BindSpinButton)
296##        props['Format24Hours'] = ('CompnRoute', self.GetFormat24Hours,
297##                                                self.SetFormat24Hours)
298##        props['DisplaySeconds'] = ('CompnRoute', self.GetDisplaySeconds,
299##                                                 self.SetDisplaySeconds)
300
301        return props
302
303    def dependentProps(self):
304        return MaskedTextCtrlDTC.dependentProps(self) + ['SpinButton', 'BindSpinButton']
305
306    def events(self):
307        return MaskedTextCtrlDTC.events(self) + ['TimeCtrlEvent']
308
309    def writeImports(self):
310        return '\n'.join( (MaskedTextCtrlDTC.writeImports(self), 'import wx.lib.masked.timectrl'))
311
312##    def hideDesignTime(self):
313##        return MaskedTextCtrlDTC.hideDesignTime(self) + ['Mask',
314##               'Datestyle', 'AutoCompleteKeycodes', 'EmptyBackgroundColour',
315##               'SignedForegroundColour', 'GroupChar', 'DecimalChar',
316##               'ShiftDecimalChar', 'UseParensForNegatives', 'ExcludeChars',
317##               'IncludeChars', 'Choices', 'ChoiceRequired', 'CompareNoCase',
318##               'AutoSelect', 'ValidRegex', 'ValidRange']
319
320    def GetSpinButton(self, x):
321        return self._spinbutton
322
323    def BindSpinButton(self, value):
324        self._spinbutton = value
325        if value is not None:
326            spins = self.designer.getObjectsOfClass(wx.SpinButton)
327            if value in spins:
328                self.control.BindSpinButton(spins[value])
329
330##    def GetDisplaySeconds(self, x):
331##        return self.eval(self.textConstr.params['display_seconds'])
332##
333##    def SetDisplaySeconds(self, value):
334##        self.textConstr.params['display_seconds'] = self.eval(value)
335
336#-------------------------------------------------------------------------------
337
338#EventCollections.EventCategories['IntCtrlEvent'] = (EVT_INT,)
339#EventCollections.commandCategories.append('IntCtrlEvent')
340
341
342class IntCtrlDTC(TextCtrlDTC):
343    def __init__(self, name, designer, parent, ctrlClass):
344        TextCtrlDTC.__init__(self, name, designer, parent, ctrlClass)
345        BoolPE = PropertyEditors.BoolConstrPropEdit
346        ColourPE = PropertyEditors.ColourConstrPropEdit
347        self.editors.update({'Min': PropertyEditors.BITPropEditor,
348                             'Max': PropertyEditors.BITPropEditor,
349                             'Limited': BoolPE,
350                             'AllowNone': BoolPE,
351                             'AllowLong': BoolPE,
352                             'DefaultColour': ColourPE,
353                             'OutOfBoundsColour': ColourPE})
354
355    def constructor(self):
356        constr = TextCtrlDTC.constructor(self)
357        constr.update({'Min': 'min', 'Max': 'max', 'Limited': 'limited',
358            'AllowNone': 'allow_none', 'AllowLong': 'allow_long',
359            'DefaultColour': 'default_color', 'OutOfBoundsColour': 'oob_color'})
360        return constr
361
362    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
363        dts = TextCtrlDTC.designTimeSource(self, position, size)
364        dts.update({'value': '0',
365                    'min': 'None',
366                    'max': 'None',
367                    'limited': 'False',
368                    'allow_none': 'False',
369                    'allow_long': 'False',
370                    'default_color': 'wx.BLACK',
371                    'oob_color': 'wx.RED'})
372        return dts
373
374##    def hideDesignTime(self):
375##        return TextCtrlDTC.hideDesignTime(self) + ['Bounds', 'InsertionPoint']
376
377    def events(self):
378        return TextCtrlDTC.events(self) + ['IntCtrlEvent']
379
380    def writeImports(self):
381        return '\n'.join( (TextCtrlDTC.writeImports(self), 'import wx.lib.intctrl'))
382
383#-------------------------------------------------------------------------------
384
385class AnalogClockDTC(WindowDTC):
386    def __init__(self, name, designer, parent, ctrlClass):
387        WindowDTC.__init__(self, name, designer, parent, ctrlClass)
388        
389##        wx.lib.analogclock.SHOW_QUARTERS_TICKS, 
390##        wx.lib.analogclock.SHOW_HOURS_TICKS,
391##        wx.lib.analogclock.SHOW_MINUTES_TICKS,
392##        wx.lib.analogclock.ROTATE_TICKS,
393##        wx.lib.analogclock.SHOW_HOURS_HAND,
394##        wx.lib.analogclock.SHOW_MINUTES_HAND,
395##        wx.lib.analogclock.SHOW_SECONDS_HAND,
396##        wx.lib.analogclock.SHOW_SHADOWS,
397##        wx.lib.analogclock.OVERLAP_TICKS,
398##        wx.lib.analogclock.DEFAULT_CLOCK_STYLE,
399
400##        wx.lib.analogclock.TICKS_NONE,
401##        wx.lib.analogclock.TICKS_SQUARE,
402##        wx.lib.analogclock.TICKS_CIRCLE,
403##        wx.lib.analogclock.TICKS_POLY,
404##        wx.lib.analogclock.TICKS_DECIMAL,
405##        wx.lib.analogclock.TICKS_ROMAN,
406##        wx.lib.analogclock.TICKS_BINARY,
407##        wx.lib.analogclock.TICKS_HEX,
408
409    def hideDesignTime(self):
410        return WindowDTC.hideDesignTime(self) + ['HandSize', 'HandBorderWidth',
411              'HandBorderColour', 'HandFillColour', 'TickSize', 'TickStyle', 
412              'TickOffset', 'TickBorderWidth', 'TickBorderColour', 
413              'TickFillColour', 'TickFont', 'ClockStyle']
414
415    def writeImports(self):
416        return '\n'.join( (WindowDTC.writeImports(self), 'import wx.lib.analogclock'))
417
418#-------------------------------------------------------------------------------
419
420class ScrolledPanelDTC(Constructors.WindowConstr, 
421                       ContainerCompanions.ScrolledWindowDTC):
422    """Currently you need to manually add the following call to the source
423    after self._init_ctrls(parent).
424    
425    e.g.
426    self.panel1.SetupScrolling(scroll_x=True, scroll_y=True, rate_x=20, rate_y=20)
427    """
428    def __init__(self, name, designer, parent, ctrlClass):
429        ContainerCompanions.ScrolledWindowDTC.__init__(self, name, designer, parent, ctrlClass)
430
431    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
432        return {'pos':   position,
433                'size': self.getDefCtrlSize(),
434                'style': 'wx.TAB_TRAVERSAL',
435                'name':  `self.name`}
436
437    def writeImports(self):
438        return '\n'.join( (ContainerCompanions.ScrolledWindowDTC.writeImports(self),
439                          'import wx.lib.scrolledpanel'))
440
441#-------------------------------------------------------------------------------
442
443EventCollections.EventCategories['HyperLinkEvent'] = (
444    'wx.lib.hyperlink.EVT_HYPERLINK_LEFT',
445    'wx.lib.hyperlink.EVT_HYPERLINK_MIDDLE',
446    'wx.lib.hyperlink.EVT_HYPERLINK_RIGHT')
447
448#Link Visited LinkRollover
449
450class HyperLinkCtrlDTC(BasicCompanions.StaticTextDTC):
451    def __init__(self, name, designer, parent, ctrlClass):
452       BasicCompanions.StaticTextDTC.__init__(self, name, designer, parent, ctrlClass)
453       self.editors.update({
454            'AutoBrowse': PropertyEditors.BoolPropEdit,
455            'Bold': PropertyEditors.BoolPropEdit,
456            'DoPopup': PropertyEditors.BoolPropEdit,
457            'EnableRollover': PropertyEditors.BoolPropEdit,
458            'OpenInSameWindow': PropertyEditors.BoolPropEdit,
459            'ReportErrors': PropertyEditors.BoolPropEdit,
460            'Visited': PropertyEditors.BoolPropEdit,
461        })
462
463    def constructor(self):
464        return {'Position': 'pos', 'Size': 'size', 'Label': 'label',
465                'Style': 'style', 'Name': 'name', 'URL': 'URL'}
466
467    def initDesignTimeControl(self):
468        BasicCompanions.StaticTextDTC.initDesignTimeControl(self)
469        self.control.AutoBrowse(False)
470
471    def writeImports(self):
472        return '\n'.join( (BasicCompanions.StaticTextDTC.writeImports(self),
473                          'import wx.lib.hyperlink'))
474
475    def events(self):
476        return BasicCompanions.StaticTextDTC.events(self) + ['HyperLinkEvent']
477
478    def properties(self):
479        return {
480            'AutoBrowse': ('CompnRoute', self.GetAutoBrowse, self.AutoBrowse),
481            'Bold': ('CompnRoute', self.GetBold, self.SetBold), 
482        }
483
484    def GetAutoBrowse(self, x):
485        for prop in self.textPropList:
486            if prop.prop_setter == 'AutoBrowse':
487                return prop.params[0].lower() == 'true'
488        return True
489
490    def AutoBrowse(self, value):
491        pass
492
493    def GetBold(self, x):
494        return self.control.GetBold()
495
496    def SetBold(self, value):
497        self.control.SetBold(value)
498        self.control.UpdateLink()
499
500
501#-------------------------------------------------------------------------------
502
503class FileBrowseButtonDTC(PanelDTC):
504    def __init__(self, name, designer, parent, ctrlClass):
505        PanelDTC.__init__(self, name, designer, parent, ctrlClass)
506        StrPropEdit = PropertyEditors.StrConstrPropEdit
507        self.editors.update({
508            'LabelText': StrPropEdit, 'ButtonText': StrPropEdit,
509            'ToolTip': StrPropEdit, 'DialogTitle': StrPropEdit,
510            'StartDirectory': StrPropEdit, 'InitialValue': StrPropEdit, 
511            'FileMask': StrPropEdit,
512        })
513    
514    def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
515        return {'pos':   position,
516                'size': 'wx.Size(296, 48)',
517                'style': 'wx.TAB_TRAVERSAL',
518                'labelText': `'File Entry:'`,
519                'buttonText': `'Browse'`,
520                'toolTip': `'Type filename or click browse to choose file'`,
521                'dialogTitle': `'Choose a file'`,
522                'startDirectory': `'.'`,
523                'initialValue': `''`,
524                'fileMask': `'*.*'`,
525                }
526
527    def constructor(self):
528        return {'Position': 'pos', 'Size': 'size', 'Style': 'style',
529                'LabelText': 'labelText', 'ButtonText': 'buttonText',
530                'ToolTip': 'toolTip', 'DialogTitle': 'dialogTitle',
531                'StartDirectory': 'startDirectory', 
532                'InitialValue': 'initialValue', 'FileMask': 'fileMask'}
533
534    def writeImports(self):
535        return '\n'.join( (PanelDTC.writeImports(self),
536                          'import wx.lib.filebrowsebutton'))
537
538class FileBrowseButtonWithHistoryDTC(FileBrowseButtonDTC): 
539    pass
540
541class DirBrowseButtonDTC(FileBrowseButtonDTC):
542    def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
543        return {'pos':   position,
544                'size': 'wx.Size(296, 48)',
545                'style': 'wx.TAB_TRAVERSAL',
546                'labelText': `'Select a directory:'`,
547                'buttonText': `'Browse'`,
548                'toolTip': `'Type directory name or browse to select'`,
549                'dialogTitle': `''`,
550                'startDirectory': `'.'`,
551                'newDirectory': 'False',
552                }
553
554    def constructor(self):
555        return {'Position': 'pos', 'Size': 'size', 'Style': 'style',
556                'LabelText': 'labelText', 'ButtonText': 'buttonText',
557                'ToolTip': 'toolTip', 'DialogTitle': 'dialogTitle',
558                'StartDirectory': 'startDirectory', 
559                'NewDirectory': 'newDirectory'}
560    
561
562class MultiSplitterWindowDTC(PanelDTC):
563    def __init__(self, name, designer, parent, ctrlClass):
564        PanelDTC.__init__(self, name, designer, parent, ctrlClass)
565
566class BitmapsConstrPropEdit(PropertyEditors.ConstrPropEdit):
567    def getValue(self):
568        if self.editorCtrl:
569            self.value = self.editorCtrl.getValue()
570        else:
571            self.value = self.getCtrlValue()
572        return self.value
573
574    def inspectorEdit(self):
575        self.editorCtrl = InspectorEditorControls.ButtonIEC(self, self.value)
576        self.editorCtrl.createControl(self.parent, self.idx, self.width, self.edit)
577
578    def edit(self, event):
579        dlg = BitmapListEditorDlg.BitmapListEditorDlg(self.parent, self.value, self.companion)
580        try:
581            if dlg.ShowModal() == wx.ID_OK:
582                self.value = dlg.getBitmapsSource()
583                self.editorCtrl.setValue(self.value)
584                self.inspectorPost(False)
585        finally:
586            dlg.Destroy()
587
588class ThrobberDTC(PanelDTC):
589    def __init__(self, name, designer, parent, ctrlClass):
590        PanelDTC.__init__(self, name, designer, parent, ctrlClass)
591        self.editors.update({'Bitmaps': BitmapsConstrPropEdit})
592
593    def designTimeSource(self, position='wx.DefaultPosition', size='wx.DefaultSize'):
594        return {'pos':   position,
595                'size': self.getDefCtrlSize(),
596                'style': '0',
597                'name': `self.name`,
598                'bitmap': '[wx.NullBitmap]', 
599                'frameDelay': '0.1',
600                'label': 'None',
601                'overlay': 'None',
602                'reverse': '0',
603                'rest': '0',
604                'current': '0',
605                'direction': '1'}
606
607    def constructor(self):
608        return {'Position': 'pos', 'Size': 'size', 'Style': 'style', 'Name': 'name',
609                'Bitmaps': 'bitmap', 'FrameDelay': 'frameDelay', 'Label': 'label', 
610                'Overlay': 'overlay', 'Reverse': 'reverse', 'Rest': 'rest', 
611                'Current': 'current', 'Direction': 'direction'}
612
613    def writeImports(self):
614        return '\n'.join( (PanelDTC.writeImports(self),
615                          'import wx.lib.throbber'))
616
617
618class TickerDTC(WindowDTC):
619    def __init__(self, name, designer, parent, ctrlClass):
620        WindowDTC.__init__(self, name, designer, parent, ctrlClass)
621        self.editors['Start'] = PropertyEditors.BoolConstrPropEdit
622
623    def writeImports(self):
624        return '\n'.join((WindowDTC.writeImports(self), 'import wx.lib.ticker'))
625
626    def constructor(self):
627        return {'Position': 'pos', 'Size': 'size', 'Style': 'style', 
628                'Name': 'name', 'Text': 'text', 'Start': 'start',
629                'Direction': 'direction'}
630
631    def designTimeSource(self, position = 'wx.DefaultPosition', size = 'wx.DefaultSize'):
632        return {'text': `self.name`,
633                'start': 'False',
634                'direction': `'rtl'`,
635                'pos': position,
636                'size': size,
637                'style': '0',
638                'name': `self.name`}
639                                
640#-------------------------------------------------------------------------------
641
642import wx.lib.stattext
643import wx.lib.masked.textctrl
644import wx.lib.masked.ipaddrctrl
645import wx.lib.masked.combobox
646import wx.lib.masked.numctrl
647import wx.lib.masked.timectrl
648import wx.lib.intctrl
649
650import wx.lib.scrolledpanel
651import wx.lib.hyperlink
652
653import Plugins
654
655Plugins.registerPalettePage('Library', _('Library'))
656
657Plugins.registerComponents('Library',
658      (wx.lib.stattext.GenStaticText, 'wx.lib.stattext.GenStaticText', GenStaticTextDTC),
659      (wx.lib.masked.textctrl.TextCtrl, 'wx.lib.masked.textctrl.TextCtrl', MaskedTextCtrlDTC),
660      (wx.lib.masked.ipaddrctrl.IpAddrCtrl, 'wx.lib.masked.ipaddrctrl.IpAddrCtrl', IpAddrCtrlDTC),
661      (wx.lib.masked.combobox.ComboBox, 'wx.lib.masked.combobox.ComboBox', MaskedComboBoxDTC),
662      (wx.lib.masked.numctrl.NumCtrl, 'wx.lib.masked.numctrl.NumCtrl', MaskedNumCtrlDTC),
663      (wx.lib.masked.timectrl.TimeCtrl, 'wx.lib.masked.timectrl.TimeCtrl', TimeCtrlDTC),
664      (wx.lib.intctrl.IntCtrl, 'wx.lib.intctrl.IntCtrl', IntCtrlDTC),
665      (wx.lib.scrolledpanel.ScrolledPanel, 'wx.lib.scrolledpanel.ScrolledPanel', ScrolledPanelDTC),
666      (wx.lib.hyperlink.HyperLinkCtrl, 'wx.lib.hyperlink.HyperLinkCtrl', HyperLinkCtrlDTC),       
667    )
668
669try:
670    import wx.lib.splitter
671    Plugins.registerComponent('Library', wx.lib.splitter.MultiSplitterWindow, 'wx.lib.splitter.MultiSplitterWindow', MultiSplitterWindowDTC)
672except ImportError: pass
673
674try:
675    import wx.lib.analogclock
676    Plugins.registerComponent('Library', wx.lib.analogclock.AnalogClock, 'wx.lib.analogclock.AnalogClock', AnalogClockDTC)
677except (ImportError, AttributeError): pass
678    
679try:
680    import wx.lib.filebrowsebutton 
681    Plugins.registerComponents('Library',
682      (wx.lib.filebrowsebutton.FileBrowseButton, 'wx.lib.filebrowsebutton.FileBrowseButton', FileBrowseButtonDTC),
683      (wx.lib.filebrowsebutton.FileBrowseButtonWithHistory, 'wx.lib.filebrowsebutton.FileBrowseButtonWithHistory', FileBrowseButtonWithHistoryDTC),
684      (wx.lib.filebrowsebutton.DirBrowseButton, 'wx.lib.filebrowsebutton.DirBrowseButton', DirBrowseButtonDTC))
685except ImportError: pass
686
687try:
688    import wx.lib.throbber
689    Plugins.registerComponent('Library', wx.lib.throbber.Throbber, 'wx.lib.throbber.Throbber', ThrobberDTC)
690except ImportError: pass
691
692try:
693    import wx.lib.ticker
694    Plugins.registerComponent('Library', wx.lib.ticker.Ticker, 'wx.lib.ticker.Ticker', TickerDTC)
695except ImportError: pass
696
697
698EventCollections.EventCategories['MaskedNumCtrlEvent'] = ('wx.lib.masked.numctrl.EVT_NUM',)
699EventCollections.commandCategories.append('MaskedNumCtrlEvent')
700EventCollections.EventCategories['TimeCtrlEvent'] = ('wx.lib.masked.timectrl.EVT_TIMEUPDATE',)
701EventCollections.commandCategories.append('TimeCtrlEvent')
702EventCollections.EventCategories['IntCtrlEvent'] = ('wx.lib.intctrl.EVT_INT',)
703EventCollections.commandCategories.append('IntCtrlEvent')