Beispiel #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)
Beispiel #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))
Beispiel #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)
Beispiel #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))
Beispiel #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)
Beispiel #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}
Beispiel #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()
Beispiel #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
Beispiel #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 = []
    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 = []
Beispiel #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 = []
Beispiel #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()
Beispiel #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}
 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)
Beispiel #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.'))
Beispiel #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)
Beispiel #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.'))
Beispiel #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']
Beispiel #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
Beispiel #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)
Beispiel #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
 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
Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #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'
     ]
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
 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
Beispiel #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
Beispiel #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
 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
Beispiel #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
Beispiel #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]
    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]
Beispiel #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
Beispiel #41
0
 def deleteItem(self, idx):
     CollectionDTC.deleteItem(self, idx)
     del self.textConstrLst[idx]
     self.recreateSizers()
Beispiel #42
0
 def appendItem(self, method=None, srcParams={}):
     CollectionDTC.appendItem(self, method, srcParams)
     
     self.recreateSizers()
 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
Beispiel #44
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors['Index'] = IntConstrPropEdit
 def initialiser(self):
     return [sourceconst.bodyIndent+'parent.SetFieldsCount(%d)'%(
             self.getCount())]+CollectionDTC.initialiser(self)
Beispiel #46
0
 def vetoedMethods(self):
     return CollectionDTC.vetoedMethods(self)+['GetPosition', 'SetPosition',
           'GetSize', 'SetSize']
Beispiel #47
0
 def moveItem(self, idx, dir):
     newIdx = CollectionDTC.moveItem(self, idx, dir)
     if newIdx != idx:
         self.recreateSizers()
     return newIdx
 def appendItem(self, method=None):
     self.widths.append(-1)
     self.control.SetFieldsCount(len(self.widths))
     CollectionDTC.appendItem(self, method)
 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))
Beispiel #50
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors.update({'Menu': MenuEnumConstrPropEdit,
                          'Title': StrConstrPropEdit})
Beispiel #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)
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors = {'Number' : IntConstrPropEdit,
                     'Text': StrConstrPropEdit,
                     'Width': SBFWidthConstrPropEdit}
     self.widths = []
Beispiel #53
0
 def __init__(self, name, designer, parentCompanion, ctrl):
     CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)
     self.editors['Index'] = IntConstrPropEdit
Beispiel #54
0
    def __init__(self, name, designer, parentCompanion, ctrl):
        CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl)

        self.editors['Entry'] = AcceleratorEntryPropEdit