Changeset 4081

Show
Ignore:
Timestamp:
05/12/2008 06:47:58 AM (2 months ago)
Author:
ed
Message:

incremental commit. Nothing earth-shattering yet, but began fleshing out support for components and plugins.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ed-ide/Studio.py

    r4074 r4081  
    99from dabo.dLocalize import _ 
    1010import dabo.dEvents as dEvents 
     11import components 
    1112from components.ClassDesigner import ClassDesigner 
    1213from components.CxnEditor import CxnEditor 
     
    3940    def onEditFile(self, evt): 
    4041        if not self._context: 
    41             print "WASSIP with dat?" 
    4242            return 
    4343        nd = self._context["node"] 
     
    4747 
    4848 
     49class StudioToolBar(dabo.ui.dToolBar): 
     50    """Overrides the _appendInsertButton() method, so that we get actual Dabo 
     51    dBitmapButton or dToggleButton controls instead of the default wx.ToolBarItem 
     52    buttons that are difficult to work with. 
     53    """ 
     54    def _appendInsertButton(self, pos, caption, pic, bindfunc, toggle, tip, help, *args, **kwargs): 
     55        buttonClass = {True: dabo.ui.dToggleButton, False: dabo.ui.dBitmapButton}[toggle] 
     56        if not toggle: 
     57            kwargs["AutoSize"] = True 
     58        ctl = buttonClass(self, Caption=caption, Picture=pic, ToolTipText=tip, *args, **kwargs) 
     59        # Don't show the caption if there is an image 
     60        def _dyncap(obj): 
     61            if obj.Picture: 
     62                return "" 
     63            else: 
     64                return obj._caption 
     65        ctl.DynamicCaption = (_dyncap, ctl) 
     66        return self.insertControl(pos, ctl, bindfunc=bindfunc) 
    4967 
    50 class StudioForm(dabo.ui.dSplitForm): 
     68 
     69class StudioForm(dabo.ui.dDockForm): 
    5170    def initProperties(self): 
    5271        self.Caption = _("Dabo Developer Studio") 
     
    5574 
    5675    def afterInit(self): 
    57         dabo.ui.setAfter(self.Splitter, "SashPercent", 30) 
    58         pnl1 = self.Panel1 
    59         pnl1.Sizer.Orientation = "v" 
    60         btn = dabo.ui.dButton(pnl1, Caption="Open Project", OnHit=self.onOpenProject) 
    61         pnl1.Sizer.append(btn, halign="center", border=30) 
    62         self.tree = ProjectTree(pnl1
     76        treePnl = self.projectTreePanel = self.addPanel(Caption=_("Projects"), Docked=True,  
     77               DockSide="Left", ShowPinButton=True) 
     78        sz = self.projectTreePanel.Sizer = dabo.ui.dSizer("v") 
     79        btn = dabo.ui.dButton(treePnl, Caption="Open Project", OnHit=self.onOpenProject) 
     80        sz.append(btn, halign="center", border=30) 
     81        self.tree = ProjectTree(treePnl
    6382        self.tree.controller = self 
    64         pnl1.Sizer.append1x(self.tree) 
    65         pnl2 = self.Panel2 
    66         self.pgfEditors = dabo.ui.dPageFrame(pnl2, PageCount=0) 
    67         pnl2.Sizer.append1x(self.pgfEditors) 
     83        sz.append1x(self.tree) 
     84         
     85        self.toolbar = self.addPanel(Toolbar=True, Docked=True, DockSide="Top", 
     86                ShowCaption=False, ShowGripper=True, BottomDockable=False,  
     87                LeftDockable=False, RightDockable=False) 
     88        self.toolbar.Sizer = dabo.ui.dSizer("h") 
     89        cp = self.CenterPanel 
     90        csz = cp.Sizer = dabo.ui.dSizer("v") 
     91#       self.toolbar = self.ToolBar = StudioToolBar(self) 
     92#       csz.append(self.toolbar) 
     93        self._toolSets = {None: []} 
     94        self._currentToolBar = None 
     95        self.pgfEditors = dabo.ui.dPageFrame(self.CenterPanel, PageCount=0) 
     96        csz.append1x(self.pgfEditors) 
     97         
     98        # Enable the various parts of the IDE. 
     99        self.registerComponents() 
     100        self.registerPlugins() 
     101 
     102        # Make sure that all components are visible 
     103        dabo.ui.callAfter(self._showAllPanels) 
     104 
     105 
     106    def _showAllPanels(self): 
     107        self.toolbar.Visible = self.projectTreePanel.Visible = True 
     108        self.toolbar.Show() 
     109        self._refreshState() 
     110 
     111    def registerComponents(self): 
     112        import types 
     113        comps = [getattr(components, comp) for comp in dir(components)  
     114                if isinstance(getattr(components, comp), types.ModuleType)] 
     115        for comp in comps: 
     116            try: 
     117                comp.register(self) 
     118            except AttributeError: 
     119                dabo.errorLog.write(_("Component '%s' lacks a 'register()' method.") % comp) 
     120 
     121 
     122    def registerPlugins(self): 
     123        pass 
     124 
     125 
     126    def setToolBarGroup(self, key, grp): 
     127        self._toolSets[key] = grp 
    68128 
    69129 
     
    72132        pg.openFile(pth) 
    73133        self.pgfEditors.SelectedPage = pg 
     134        self.CurrentToolBar = "TextEditor" 
    74135 
    75136 
     
    85146 
    86147 
     148    def _getCurrentToolBar(self): 
     149        return self._currentToolBar 
     150 
     151    def _setCurrentToolBar(self, val): 
     152        if self._constructed(): 
     153            if val == self._currentToolBar: 
     154                return 
     155            if val not in self._toolSets: 
     156                dabo.errorLog.write(_("Invalid toolbar specified: '%s'") % val) 
     157                 
     158                print self._toolSets.keys() 
     159                return 
     160            # Hide all visible buttons 
     161            for btn in self.toolbar.Children[::-1]: 
     162                self.toolbar.remove(btn, False) 
     163            self._currentToolBar = val 
     164            # Show the new button set 
     165            for btn in self._toolSets[self._currentToolBar]: 
     166                try: 
     167                    self.toolbar.appendItem(btn) 
     168                except AttributeError: 
     169                    # A control, not a tool item 
     170                    btn.Visible = True 
     171        else: 
     172            self._properties["CurrentToolBar"] = val 
     173 
     174 
     175    CurrentToolBar = property(_getCurrentToolBar, _setCurrentToolBar, None, 
     176            _("Name of the current toolbar to display. Changing this will change the buttons that are visible in the editing area.  (str)")) 
     177 
     178 
     179 
    87180def main(): 
    88181    app = dabo.dApp() 
     182    app.BasePrefKey = "DeveloperStudio" 
    89183    app.MainFormClass = StudioForm 
    90184    app.start() 
  • branches/ed-ide/components/ClassDesigner/__init__.py

    r4063 r4081  
    22# -*- coding: utf-8 -*- 
    33 
    4 # from ClassDesignerPropSheet import PropSheet 
    5 # from ClassDesignerPropSheet import PropertyGrid 
    6 # from ClassDesignerComponents import LayoutSaverMixin 
    7 # from ClassDesignerComponents import LayoutPanel 
    8 # from ClassDesignerComponents import LayoutSpacerPanel 
    9 # from ClassDesignerComponents import LayoutSizerMixin 
    10 # from ClassDesignerComponents import LayoutSizer 
    11 # from ClassDesignerComponents import LayoutBorderSizer 
    12 # from ClassDesignerComponents import LayoutGridSizer 
    13 # from ClassDesignerComponents import LayoutBasePanel 
    14 # from ClassDesignerComponents import NoSizerBasePanel 
    15 # from ClassDesignerTreeSheet import TreeSheet 
    16 # from ClassDesignerObjectPropertySheet import ObjectPropertySheet 
    17 # from ClassDesignerCustomPropertyDialog import ClassDesignerCustomPropertyDialog 
    18 # from ClassDesignerControlMixin import ClassDesignerControlMixin 
    19 # from ClassDesignerFormMixin import ClassDesignerFormMixin 
    20 # from ClassDesignerEditor import EditorControl 
    21 # from ClassDesignerEditor import EditorForm 
    22 # from ClassDesignerPemForm import PemForm 
    23 # from ClassDesignerMethodSheet import MethodSheet 
    24 # from ClassDesignerSizerPalette import ContentBoxSizerPanel 
    25 # from ClassDesignerSizerPalette import ContentGridSizerPanel 
    26 # from ClassDesignerSizerPalette import BoxSizerSelfPanel 
    27 # from ClassDesignerSizerPalette import GridSizerSelfPanel 
    28 # from ClassDesignerSizerPalette import SizerInfoFrame 
    29 # from ClassDesignerSizerPalette import SizerContentFrame 
    30 # from ClassDesignerSizerPalette import SizerSelfFrame 
    31 # from ClassDesignerSizerPalette import AbstractSizerPanel 
    32 # from ClassDesignerSizerPalette import SizerContentPanel 
    33 # from ClassDesignerSizerPalette import SizerSelfPanel 
    34 # from ClassDesignerSizerPalette import SizerPaletteForm 
    354from ClassDesigner import ClassDesigner 
    365from ClassDesignerExceptions import PropertyUpdateException 
     6 
     7 
     8def register(master): 
     9    print "Class Designer is registered" 
     10#   toolbar 
     11#   editor class 
     12#   extensions 
     13     
  • branches/ed-ide/components/TextEditor/__init__.py

    r4073 r4081  
    22# -*- coding: utf-8 -*- 
    33 
     4import dabo 
     5import dabo.dEvents as dEvents 
     6from dabo.dLocalize import _ 
     7import TextEditor 
    48from TextEditor import EditorPage as TextEditorPage 
     9 
     10masterForm = None 
     11 
     12def register(master): 
     13    global masterForm 
     14    masterForm = master 
     15    tb = master.toolbar 
     16 
     17    funcBtn = tb.appendButton(_("Functions"),  
     18            dabo.ui.bitmapFromData(TextEditor.funcButtonData()), 
     19            toggle=False, 
     20            OnMouseLeftDown=onFuncButton) 
     21    bmkBtn = tb.appendButton(_("Bookmarks"),  
     22            dabo.ui.bitmapFromData(TextEditor.bmkButtonData()), 
     23            toggle=False, 
     24            OnMouseLeftDown=onBmkButton) 
     25    printBtn = tb.appendButton(_("Print"),  
     26            "print", 
     27            toggle=False, 
     28            OnHit=onPrint) 
     29    lexSelector = dabo.ui.dDropdownList(tb, ValueMode="String", 
     30        Choices = dabo.ui.dEditor.getAvailableLanguages(), 
     31        OnHit = onLexSelect) 
     32    tb.appendControl(lexSelector) 
     33 
     34    master.setToolBarGroup("TextEditor", [funcBtn, bmkBtn, printBtn, lexSelector]) 
     35 
     36 
     37def onFuncButton(evt): 
     38    masterForm.Caption = "FUNC BUTT" 
     39def onBmkButton(evt): 
     40    masterForm.Caption = "BMK BUTT" 
     41def onPrint(evt): 
     42    masterForm.Caption = "PRINT BUTT" 
     43def onLexSelect(evt): 
     44    masterForm.Caption = evt.EventObject.Value 
     45 
     46    def updateLex(self): 
     47            if not self.lexSelector.Choices: 
     48                self.lexSelector.Choices = self.CurrentEditor.getAvailableLanguages()