示例#1
0
    def designTimeDefaults(self, vals, method=None):
        if method is None:
            method = self.insertionMethod

        if method in ('AddWindow', 'AddSizer', 'Insert'):
            if method in ('AddWindow', 'AddSizer'): ctrlIdx = 0
            elif method == 'Insert': ctrlIdx = 1

            if vals[ctrlIdx] != 'None':
                srcRef = vals[ctrlIdx]
                try:
                    # XXX improve
                    int(srcRef)
                except:
                    params = copy.copy(vals)
                    del params[ctrlIdx]
                    dtd = CollectionDTC.designTimeDefaults(
                        self, params, method)
                    dtd[ctrlIdx] = self.designer.controllerView.getAllObjects(
                    )[srcRef]
                    if method == 'AddSizer':
                        dtd[ctrlIdx]._sub_sizer = self.control
                    elif method == 'AddWindow':
                        dtd[ctrlIdx]._in_sizer = self.control
                    return dtd

        return CollectionDTC.designTimeDefaults(self, vals, method)
示例#2
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {
         'Position': IntConstrPropEdit,
         'Item': StrConstrPropEdit,
         'Bitmap': BitmapConstrPropEdit
     }
 def deleteItem(self, index):
     CollectionDTC.deleteItem(self, index)
     for idx in range(index, len(self.widths)):
         self.control.SetStatusText(self.control.GetStatusText(idx+1), idx)
     del self.widths[index]
     self.control.SetStatusWidths(self.widths)
     self.control.SetFieldsCount(len(self.widths))
示例#4
0
    def designTimeDefaults(self, vals, method=None):
        if method is None:
            method = self.insertionMethod

        if method in ('AddWindow', 'AddSizer', 'Insert'):
            if method in ('AddWindow', 'AddSizer'): ctrlIdx = 0
            elif method == 'Insert':                ctrlIdx = 1

            if vals[ctrlIdx] != 'None':
                srcRef = vals[ctrlIdx]
                try:
                    # XXX improve
                    int(srcRef)
                except:
                    params = copy.copy(vals)
                    del params[ctrlIdx]
                    dtd = CollectionDTC.designTimeDefaults(self, params, method)
                    dtd[ctrlIdx] = self.designer.controllerView.getAllObjects()[srcRef]
                    if method == 'AddSizer':
                        dtd[ctrlIdx]._sub_sizer = self.control
                    elif method == 'AddWindow':
                        dtd[ctrlIdx]._in_sizer = self.control
                    return dtd

        return CollectionDTC.designTimeDefaults(self, vals, method)
示例#5
0
 def deleteItem(self, index):
     CollectionDTC.deleteItem(self, index)
     for idx in range(index, len(self.widths)):
         self.control.SetStatusText(self.control.GetStatusText(idx+1), idx)
     del self.widths[index]
     self.control.SetStatusWidths(self.widths)
     self.control.SetFieldsCount(len(self.widths))
示例#6
0
 def appendItem(self, method=None):
     if not (self.control.GetWindowStyleFlag() & wx.LC_REPORT):
         wx.MessageBox(
             _('wx.ListCtrl must be created with the wx.LC_REPORT flag.'),
             'Error', wx.ICON_ERROR | wx.OK, self.designer)
         return
     CollectionDTC.appendItem(self, method)
示例#7
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
        self.editors = {'Width': IntConstrPropEdit,
                        'Heading': StrConstrPropEdit,
                        'Format': EnumConstrPropEdit}#StyleConstrPropEdit}
#        self.options = {'Format': formatStyle}
        self.names = {'Format': formatStyle}
示例#8
0
 def persistProp(self, name, setterName, value):
     CollectionDTC.persistProp(self, name, setterName, value)
     if name in ('Size', ):
         self.recreateSizers()
     elif name in ('Flag', 'Border', 'Proportion'):
         si = self.control.GetChildren()[self.index]
         getattr(si, 'Set' + name)(self.eval(value))
         self.updateGUI()
示例#9
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
        self.editors = {'Bitmap': BitmapConstrPropEdit,
                        'Mask': BitmapConstrPropEdit,
#                        'Icon': BitmapConstrPropEdit,
                        'MaskColour': ColourConstrPropEdit}
        from Views.CollectionEdit import ImageListCollectionEditor
        self.CollEditorFrame = ImageListCollectionEditor
示例#10
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
        self.editors = {'Page': ClassLinkConstrPropEdit,
                        'Text': StrConstrPropEdit,
                        'Selected' : BoolConstrPropEdit,
                        'ImageId': IntConstrPropEdit}

        self.tempPlaceHolders = []
示例#11
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
        self.editors = {'Page': ClassLinkConstrPropEdit,
                        'Text': StrConstrPropEdit,
                        'Selected' : BoolConstrPropEdit,
                        'ImageId': IntConstrPropEdit}

        self.tempPlaceHolders = []
示例#12
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {
         'Number': IntConstrPropEdit,
         'Text': StrConstrPropEdit,
         'Width': SBFWidthConstrPropEdit
     }
     self.widths = []
示例#13
0
 def persistProp(self, name, setterName, value):
     CollectionDTC.persistProp(self, name, setterName, value)
     if name in ('Size',):
         self.recreateSizers()
     elif name in ('Flag', 'Border', 'Proportion'):
         si = self.control.GetChildren()[self.index]
         getattr(si, 'Set'+name)(self.eval(value))
         self.updateGUI()
示例#14
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {
         'Width': IntConstrPropEdit,
         'Heading': StrConstrPropEdit,
         'Format': EnumConstrPropEdit
     }  #StyleConstrPropEdit}
     #        self.options = {'Format': formatStyle}
     self.names = {'Format': formatStyle}
示例#15
0
 def writeCollectionItems(self, output, stripFrmId=''):
     CollectionDTC.writeCollectionItems(self, output, stripFrmId)
     warn = 0
     for constr in self.textConstrLst:
         if constr.params['page'] == 'None':
             wx.LogWarning('No control for %s, page %s'%(
                   self.parentCompanion.name, constr.params['text']))
             warn = 1
     if warn:
         wx.LogWarning(_('The red-dashed area of a %s page must contain\n'\
         'a control or the generated source will be invalid outside the '\
         'Designer')% self.parentCompanion.bookCtrlName)
示例#16
0
 def writeCollectionItems(self, output, stripFrmId=''):
     CollectionDTC.writeCollectionItems(self, output, stripFrmId)
     warn = 0
     for constr in self.textConstrLst:
         if constr.params[0] == 'None':
             wx.LogWarning(_('No control/sizer for sizer item of %s')%(
                   self.parentCompanion.name))
             warn = 1
     if warn:
         wx.LogWarning(_('None values are only valid in the Designer.\n'
                         'The generated source will be invalid outside the '
                         'Designer and should be fixed before executing.'))
示例#17
0
 def writeCollectionItems(self, output, stripFrmId=''):
     CollectionDTC.writeCollectionItems(self, output, stripFrmId)
     warn = 0
     for constr in self.textConstrLst:
         if constr.params['page'] == 'None':
             wx.LogWarning('No control for %s, page %s'%(
                   self.parentCompanion.name, constr.params['text']))
             warn = 1
     if warn:
         wx.LogWarning(_('The red-dashed area of a %s page must contain\n'\
         'a control or the generated source will be invalid outside the '\
         'Designer')% self.parentCompanion.bookCtrlName)
示例#18
0
 def writeCollectionItems(self, output, stripFrmId=''):
     CollectionDTC.writeCollectionItems(self, output, stripFrmId)
     warn = 0
     for constr in self.textConstrLst:
         if constr.params[0] == 'None':
             wx.LogWarning(
                 _('No control/sizer for sizer item of %s') %
                 (self.parentCompanion.name))
             warn = 1
     if warn:
         wx.LogWarning(
             _('None values are only valid in the Designer.\n'
               'The generated source will be invalid outside the '
               'Designer and should be fixed before executing.'))
示例#19
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {'Window': SizerWinEnumConstrPropEdit,
                     'Sizer': SizerEnumConstrPropEdit,
                     'Proportion': IntConstrPropEdit,
                     'Flag': SizerFlagsConstrPropEdit,
                     'Border': IntConstrPropEdit,
                     'Size': SizeConstrPropEdit,
                    }
     self.windowStyles = ['wx.LEFT', 'wx.RIGHT', 'wx.TOP', 'wx.BOTTOM', 'wx.ALL',
                          'wx.SHRINK', 'wx.GROW', 'wx.EXPAND', 'wx.SHAPED',
                          'wx.ALIGN_LEFT', 'wx.ALIGN_CENTER_HORIZONTAL',
                          'wx.ALIGN_RIGHT', 'wx.ALIGN_BOTTOM',
                          'wx.ALIGN_CENTER_VERTICAL', 'wx.ALIGN_TOP',
                          'wx.ALIGN_CENTER', 'wx.ADJUST_MINSIZE']
示例#20
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({'Page': ('NoneRoute', None, None),
                   'Text': ('IndexRoute', wx.Notebook.GetPageText.im_func, wx.Notebook.SetPageText.im_func),
                   'Selected' : ('CompnRoute', self.GetPageSelected, self.SetPageSelected),
                   'ImageId': ('IndexRoute', wx.Notebook.GetPageImage.im_func, wx.Notebook.SetPageImage.im_func)})
     return props
示例#21
0
    def applyDesignTimeDefaults(self, params, method=None):
        if method is None:
            method = self.insertionMethod

        if (method in ('AddWindow', 'AddSizer') and params[0] == 'None') or \
           (method == 'Insert' and params[1] == 'None'):
            defaults = self.designTimeDefaults(params, method)
            if method == 'Insert':
                proportion = defaults[2]
                import warnings; warnings.warn('Insert called with BlankSizer')
            else:
                proportion = defaults[1]
            self.control.AddSizer(BlankSizer(), proportion, defaults['flag'],
                                  defaults['border'])
        else:
            CollectionDTC.applyDesignTimeDefaults(self, params, method)
示例#22
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         self.control.RemoveAll()
         for crt in self.textConstrLst:
             self.applyDesignTimeDefaults(crt.params, crt.method)
     return newIdx
示例#23
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({'Page': ('NoneRoute', None, None),
                   'Text': ('IndexRoute', wx.Notebook.GetPageText.im_func, wx.Notebook.SetPageText.im_func),
                   'Selected' : ('CompnRoute', self.GetPageSelected, self.SetPageSelected),
                   'ImageId': ('IndexRoute', wx.Notebook.GetPageImage.im_func, wx.Notebook.SetPageImage.im_func)})
     return props
示例#24
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         title = self.control.GetLabelTop(idx)
         menu = self.control.Remove(idx)
         self.control.Insert(newIdx, menu, title)
     return newIdx
示例#25
0
    def properties(self):
        props = CollectionDTC.properties(self)
        props.update({'Bitmap':    ('CompnRoute', None, self.setBitmap),
                      'Mask':      ('NoneRoute', None, None),
#                      'Icon':      ('CompnRoute', None, self.setBitmap),
                    })
        return props
示例#26
0
    def applyDesignTimeDefaults(self, params, method=None):
        if method is None:
            method = self.insertionMethod

        if (method in ('AddWindow', 'AddSizer') and params[0] == 'None') or \
           (method == 'Insert' and params[1] == 'None'):
            defaults = self.designTimeDefaults(params, method)
            if method == 'Insert':
                proportion = defaults[2]
                import warnings
                warnings.warn('Insert called with BlankSizer')
            else:
                proportion = defaults[1]
            self.control.AddSizer(BlankSizer(), proportion, defaults['flag'],
                                  defaults['border'])
        else:
            CollectionDTC.applyDesignTimeDefaults(self, params, method)
示例#27
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {
         'Window': SizerWinEnumConstrPropEdit,
         'Sizer': SizerEnumConstrPropEdit,
         'Proportion': IntConstrPropEdit,
         'Flag': SizerFlagsConstrPropEdit,
         'Border': IntConstrPropEdit,
         'Size': SizeConstrPropEdit,
     }
     self.windowStyles = [
         'wx.LEFT', 'wx.RIGHT', 'wx.TOP', 'wx.BOTTOM', 'wx.ALL',
         'wx.SHRINK', 'wx.GROW', 'wx.EXPAND', 'wx.SHAPED', 'wx.ALIGN_LEFT',
         'wx.ALIGN_CENTER_HORIZONTAL', 'wx.ALIGN_RIGHT', 'wx.ALIGN_BOTTOM',
         'wx.ALIGN_CENTER_VERTICAL', 'wx.ALIGN_TOP', 'wx.ALIGN_CENTER',
         'wx.ADJUST_MINSIZE'
     ]
示例#28
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({
         'Position': ('NoneRoute', None, None),
         'Item': ('NoneRoute', None, None),
         'Bitmap': ('CompnRoute', self.GetItemBitmap, self.SetItemBitmap)
     })
     return props
示例#29
0
    def properties(self):
        props = CollectionDTC.properties(self)
        props.update({'Column':  ('NoneRoute', None, None),
                      'Heading': ('NoneRoute', None, None),
#                      'Format':  ('IndexRoute', None, None),
                      'Width':   ('IndexRoute', wx.ListCtrl.GetColumnWidth,
                                                wx.ListCtrl.SetColumnWidth)})
        return props
示例#30
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({
         'Number': ('NoneRoute', None, None),
         'Text': ('CompnRoute', self.GetText, self.SetText),
         'Width': ('NoneRoute', None, None)
     })
     return props
示例#31
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         li = self.control.GetColumn(idx)
         text = li.GetText()
         self.control.DeleteColumn(idx)
         self.control.InsertColumnInfo(newIdx, li)
         self.control.SetColumn(newIdx, li) # doesn't update without this
     return newIdx
示例#32
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         li = self.control.GetColumn(idx)
         text = li.GetText()
         self.control.DeleteColumn(idx)
         self.control.InsertColumnInfo(newIdx, li)
         self.control.SetColumn(newIdx, li)  # doesn't update without this
     return newIdx
示例#33
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         focus = self.control.GetSelection() == idx
         text = self.control.GetPageText(idx)
         img = self.control.GetPageImage(idx)
         page = self.control.GetPage(idx)
         if self.control.RemovePage(idx):
             self.control.InsertPage(newIdx, page, text, focus, img)
     return newIdx
示例#34
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         focus = self.control.GetSelection() == idx
         text = self.control.GetPageText(idx)
         img = self.control.GetPageImage(idx)
         page = self.control.GetPage(idx)
         if self.control.RemovePage(idx):
             self.control.InsertPage(newIdx, page, text, focus, img)
     return newIdx
示例#35
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({
         'Column': ('NoneRoute', None, None),
         'Heading': ('NoneRoute', None, None),
         #                      'Format':  ('IndexRoute', None, None),
         'Width': ('IndexRoute', wx.ListCtrl.GetColumnWidth,
                   wx.ListCtrl.SetColumnWidth)
     })
     return props
示例#36
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         w = self.widths[idx]
         del self.widths[idx]
         self.widths.insert(newIdx, w)
         self.control.SetStatusWidths(self.widths)
         oldText = self.control.GetStatusText(idx)
         newText = self.control.GetStatusText(newIdx)
         self.control.SetStatusText(newText, idx)
         self.control.SetStatusText(oldText, newIdx)
     return newIdx
示例#37
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         w = self.widths[idx]
         del self.widths[idx]
         self.widths.insert(newIdx, w)
         self.control.SetStatusWidths(self.widths)
         oldText = self.control.GetStatusText(idx)
         newText = self.control.GetStatusText(newIdx)
         self.control.SetStatusText(newText, idx)
         self.control.SetStatusText(oldText, newIdx)
     return newIdx
示例#38
0
    def deleteItem(self, idx):
        activePageDeleted = self.control.GetSelection() == idx

        CollectionDTC.deleteItem(self, idx)

        # Delete BlankWindow
        self.tempPlaceHolders[idx].Destroy()
        del self.tempPlaceHolders[idx]

        # Set new active page if necesary
        if activePageDeleted:
            newIdx = idx
            if idx == len(self.textConstrLst):
                newIdx = newIdx - 1
            elif len(self.textConstrLst) == 0:
                newIdx = None

            if newIdx is not None:
                if newIdx < self.control.GetPageCount():
                    self.updateSelection(newIdx)
                    self.control.SetSelection(newIdx)
                    self.control.Refresh()

        del self.textConstrLst[idx]
示例#39
0
    def deleteItem(self, idx):
        activePageDeleted = self.control.GetSelection() == idx

        CollectionDTC.deleteItem(self, idx)

        # Delete BlankWindow
        self.tempPlaceHolders[idx].Destroy()
        del self.tempPlaceHolders[idx]

        # Set new active page if necesary
        if activePageDeleted:
            newIdx = idx
            if idx == len(self.textConstrLst):
                newIdx = newIdx - 1
            elif len(self.textConstrLst) == 0:
                newIdx = None

            if newIdx is not None:
                if newIdx < self.control.GetPageCount():
                    self.updateSelection(newIdx)
                    self.control.SetSelection(newIdx)
                    self.control.Refresh()

        del self.textConstrLst[idx]
示例#40
0
    def designTimeDefaults(self, vals, method=None):
        dtd = CollectionDTC.designTimeDefaults(self, vals)

        # resize wx.NullBitmap if different size than the imagelist
        ix, iy = self.parentCompanion.control.GetSize(0)
        for param in vals.keys():
            if vals[param] == 'wx.NullBitmap' and (\
                  dtd[param].GetWidth() != ix or\
                  dtd[param].GetHeight() != iy):
                newbmp = wx.EmptyBitmap(ix, iy)
                mdc = wx.MemoryDC()
                mdc.SelectObject(newbmp)
                mdc.DrawBitmap(dtd[param], 0, 0, False)
                mdc.SelectObject(wx.NullBitmap)
                dtd[param] = newbmp

        return dtd
示例#41
0
 def deleteItem(self, idx):
     CollectionDTC.deleteItem(self, idx)
     del self.textConstrLst[idx]
     self.recreateSizers()
示例#42
0
 def appendItem(self, method=None, srcParams={}):
     CollectionDTC.appendItem(self, method, srcParams)
     
     self.recreateSizers()
示例#43
0
 def properties(self):
     props = CollectionDTC.properties(self)
     props.update({'Number':  ('NoneRoute', None, None),
                   'Text':  ('CompnRoute', self.GetText, self.SetText),
                   'Width': ('NoneRoute', None, None)})
     return props
示例#44
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors['Index'] = IntConstrPropEdit
示例#45
0
 def initialiser(self):
     return [sourceconst.bodyIndent+'parent.SetFieldsCount(%d)'%(
             self.getCount())]+CollectionDTC.initialiser(self)
示例#46
0
 def vetoedMethods(self):
     return CollectionDTC.vetoedMethods(self)+['GetPosition', 'SetPosition',
           'GetSize', 'SetSize']
示例#47
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         self.recreateSizers()
     return newIdx
示例#48
0
 def appendItem(self, method=None):
     self.widths.append(-1)
     self.control.SetFieldsCount(len(self.widths))
     CollectionDTC.appendItem(self, method)
示例#49
0
 def setConstrs(self, constrLst, inits, fins):
     CollectionDTC.setConstrs(self, constrLst, inits, fins)
     if len(fins):
         self.widths = self.eval(fins[0]\
           [fins[0].find('(')+1 : fins[0].rfind(')')])
         self.control.SetFieldsCount(len(self.widths))
示例#50
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors.update({'Menu': MenuEnumConstrPropEdit,
                          'Title': StrConstrPropEdit})
示例#51
0
 def applyDesignTimeDefaults(self, params, method=None):
     dtparams = {}; dtparams.update(params)
     if 'mask' in dtparams and dtparams['mask'] == 'wx.NullBitmap':
         del dtparams['mask']
     CollectionDTC.applyDesignTimeDefaults(self, dtparams, method)
示例#52
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {'Number' : IntConstrPropEdit,
                     'Text': StrConstrPropEdit,
                     'Width': SBFWidthConstrPropEdit}
     self.widths = []
示例#53
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors['Index'] = IntConstrPropEdit
示例#54
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)

        self.editors['Entry'] = AcceleratorEntryPropEdit