|
From: Kevin A. <ka...@us...> - 2004-05-12 22:02:21
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25028/tools/resourceEditor Modified Files: resourceEditor.py resourceEditor.rsrc.py Log Message: resourceEditor now dynamically builds its list of Components Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -d -r1.195 -r1.196 *** resourceEditor.py 11 May 2004 11:46:11 -0000 1.195 --- resourceEditor.py 12 May 2004 22:02:10 -0000 1.196 *************** *** 8,14 **** # TODO: Start using exceptions! ! from PythonCard import about, clipboard, configuration, dialog, graphic, log, model, resource, util import wx ! import os, sys, pprint from modules.backgroundInfoDialog import BackgroundInfoDialog --- 8,19 ---- # TODO: Start using exceptions! ! import os, sys ! import pprint ! import webbrowser ! import wx ! ! from PythonCard import about, clipboard, configuration, dialog, graphic, log ! from PythonCard import menu, model, registry, resource, util from modules.backgroundInfoDialog import BackgroundInfoDialog *************** *** 20,24 **** from modules.propertyEditor import PropertyEditor from modules import resourceOutput - import webbrowser SIZING_HANDLE_SIZE = 7 --- 25,28 ---- *************** *** 60,63 **** --- 64,69 ---- wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.OnFileHistory) + self.buildComponentsMenu() + self.cursors = {} self.cursors['topRight'] = wx.StockCursor(wx.CURSOR_SIZENESW) *************** *** 215,218 **** --- 221,285 ---- self.openFile(path) + # KEA 2004-05-12 + # transition to dynamic component menu + # and component addition + + def buildComponentsMenu(self): + """ + Dynamically build the menu for the components supported by the + resourceEditor. Eventually this will be a list or some form of palette + instead of a menu. + """ + + # only built-in components are handled currently, so an appcomponents + # directory or fully-qualified component paths are handled + # theoretically when the user loads a resource file the menu should + # be updated, but this is all highly dependent on how imports are + # handled, registry updated, etc. + # One idea would be for the resourceEditor to register itself as + # a change listener and have the registry subclass Changeable so it could + # notify the resourceEditor. In that case, the algorithm below would + # have to be modified since each menu item would be added as it receives + # a change notice from the registry and would need to check the existing + # menu to prevent duplicates as well as insert into the menu in the correct + # order. Or perhaps, the menu items could be wiped out and recreated which + # is probably simpler. + + # get a list of all the modules in components + moduleNames = registry.Registry.getInstance().findBuiltInComponents() + # KEA 2004-05-12 + # I know that IEHtmlWindow is platform specific and has problems + # in the resourceEditor and Grid doesn't work right either so I'm + # conditionally preventing them from being loaded here until I figure + # out how to deal with them + if True: + try: + moduleNames.remove('iehtmlwindow') + except ValueError: + pass + if True: + try: + moduleNames.remove('grid') + except ValueError: + pass + + # need to force an import of all of the modules in components + for name in moduleNames: + resource.loadComponentModule(name) + + # should match based on name instead + # name to object or id like menubar helpers? + m = self.menuBar.menus[2] + + names = registry.Registry.getInstance().components.keys() + names.sort() + for key in names: + rsrc = resource.Resource({'type':'MenuItem', + 'name': 'menuComponentAdd' + key, + 'label': key, + 'command':'componentAdd'}) + mi = menu.MenuItem(self, m, rsrc) + m.appendMenuItem(mi) + def clearWidgets(self): for w in self.components.keys(): Index: resourceEditor.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.rsrc.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** resourceEditor.rsrc.py 10 May 2004 05:02:49 -0000 1.51 --- resourceEditor.rsrc.py 12 May 2004 22:02:10 -0000 1.52 *************** *** 128,258 **** 'name':'menuComponent', 'label':'&Component', ! 'items': [ ! {'type':'MenuItem', ! 'name':'menuComponentAddBitmapCanvas', ! 'label':'BitmapCan&vas', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddButton', ! 'label':'&Button', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCalendar', ! 'label':'Calendar', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCheckBox', ! 'label':'&CheckBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddChoice', ! 'label':'Ch&oice', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddCodeEditor', ! 'label':'CodeEditor', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddComboBox', ! 'label':'ComboBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddGauge', ! 'label':'Gauge', ! 'command':'componentAdd', ! }, ! ## {'type':'MenuItem', ! ## 'name':'menuComponentAddGrid', ! ## 'label':'Grid', ! ## 'command':'componentAdd', ! ## }, ! {'type':'MenuItem', ! 'name':'menuComponentAddHtmlWindow', ! 'label':'&HtmlWindow', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddImage', ! 'label':'&Image', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddImageButton', ! 'label':'I&mageButton', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddList', ! 'label':'&List', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddMultiColumnList', ! 'label':'MultiColumnList', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddPasswordField', ! 'label':'&PasswordField', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddRadioGroup', ! 'label':'&RadioGroup', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddSlider', ! 'label':'&Slider', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddSpinner', ! 'label':'Spinner', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticBox', ! 'label':'StaticBox', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticLine', ! 'label':'St&aticLine', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddStaticText', ! 'label':'StaticT&ext', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTextArea', ! 'label':'&TextArea', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTextField', ! 'label':'Te&xtField', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddToggleButton', ! 'label':'ToggleButton', ! 'command':'componentAdd', ! }, ! {'type':'MenuItem', ! 'name':'menuComponentAddTree', ! 'label':'Tree', ! 'command':'componentAdd', ! }, ! ] }, {'type':'Menu', --- 128,132 ---- 'name':'menuComponent', 'label':'&Component', ! 'items': [] }, {'type':'Menu', *************** *** 309,318 **** 'label':'-', }, - #{'type':'MenuItem', - # 'name':'menuViewPositionSize', - # 'label':'Position and Size', - # 'checkable':1, - # 'checked':1, - #}, {'type':'MenuItem', 'name':'menuViewPropertyEditor', --- 183,186 ---- |