commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7271 - in trunk/gnue-designer/src: . base uidrivers/wx uidrivers


From: jcater
Subject: [gnue] r7271 - in trunk/gnue-designer/src: . base uidrivers/wx uidrivers/wx/docks
Date: Tue, 29 Mar 2005 03:37:50 -0600 (CST)

Author: jcater
Date: 2005-03-29 03:37:48 -0600 (Tue, 29 Mar 2005)
New Revision: 7271

Added:
   trunk/gnue-designer/src/uidrivers/wx/Instance.py
   trunk/gnue-designer/src/uidrivers/wx/MenuBar.py
Modified:
   trunk/gnue-designer/src/Designer.py
   trunk/gnue-designer/src/base/Instance.py
   trunk/gnue-designer/src/base/MenuBar.py
   trunk/gnue-designer/src/base/PopupMenu.py
   trunk/gnue-designer/src/base/TemplateParser.py
   trunk/gnue-designer/src/uidrivers/wx/Base.py
   trunk/gnue-designer/src/uidrivers/wx/docks/DockedPane.py
   trunk/gnue-designer/src/uidrivers/wx/docks/Docker.py
   trunk/gnue-designer/src/uidrivers/wx/docks/FloatingPane.py
Log:
Removed wx references from the base MenuBar and Instance classes

Modified: trunk/gnue-designer/src/Designer.py
===================================================================
--- trunk/gnue-designer/src/Designer.py 2005-03-29 05:55:30 UTC (rev 7270)
+++ trunk/gnue-designer/src/Designer.py 2005-03-29 09:37:48 UTC (rev 7271)
@@ -412,8 +412,8 @@
     instance = self.newInstance(product, style=style)
 
     if not TemplateParser.TemplateParser(instance, instance.rootObject,
-          instance, templateInformation).run():
-      instance.Close()
+          instance.uiinstance, templateInformation).run():
+      instance.uiinstance.close()
 
 #
 # Workaround for Python 2.2's big unicode bug!!!

Modified: trunk/gnue-designer/src/base/Instance.py
===================================================================
--- trunk/gnue-designer/src/base/Instance.py    2005-03-29 05:55:30 UTC (rev 
7270)
+++ trunk/gnue-designer/src/base/Instance.py    2005-03-29 09:37:48 UTC (rev 
7271)
@@ -31,7 +31,6 @@
 __all__ = ['BaseInstance']
 
 import sys, os, time, dircache, string
-from wxPython.wx import *
 from gnue.common.apps import GDebug
 from gnue.common.apps import RuntimeSettings
 from gnue.common.utils.FileUtils import dyn_import
@@ -42,17 +41,12 @@
 from gnue.designer.base.ObjectList import ObjectList
 from gnue.designer.base import TemplateBase
 from gnue.designer.base.TemplateParser import WizardRunner
-from PrimaryToolBar import PrimaryToolBar
-from gnue.designer import VERSION, PACKAGE
+from gnue.designer import VERSION, PACKAGE as TITLE
 from ModuleSupport import SupportedModules
-from gnue.designer.base import Goat
 
-from gnue.designer.uidrivers.wx.docks.Docker import Docker
 
-TITLE=PACKAGE
+class BaseInstance(EventController):
 
-class BaseInstance(wxFrame, EventController):
-
   ########################################################################
   #
   # Virtual functions...
@@ -110,11 +104,9 @@
   # a hook of some sorts.
   #
   def __init__(self, app, location=None, buffer=None, style=None):
-    wxFrame.__init__(self, NULL, -1, "")
     EventController.__init__(self)
 
-    icon = Goat.getGoatIcon()
-    self.SetIcon(icon)
+    self.uiinstance = app.ui.createInstance(self)
 
     # During startup, we will cache all events
     # so we can execute them when everything has
@@ -141,6 +133,7 @@
     self._isNew = True
 
     self._app = self.base = app
+    self.uiinstance = app.ui.createInstance(self)
     self.connections = app.connections
     self.nameMappings = {}
     self.usedNames = []
@@ -181,35 +174,33 @@
     else:
 
       if not os.access (location, os.R_OK):
-        self.Show(True)
+        self.show()
         if not self.base.ui.dialogYesNo(
           _('The requested file does not exist.\n') +
           _('Do you want to create this file?') +
           _('\n\nFile: %s') \
-            % location, _("File Not Found"), self):
+            % location, _("File Not Found"), self.uiinstance):
           # TODO: Is this right?
           sys.exit()
-        self.Show(0)
+        self.hide()
         self.__createEmptyInstance(style)
         self._path = location
         self.makeDirty()
 
       elif not os.access (location, os.W_OK):
-        self.Show(True)
+        self.show()
         if not self.base.ui.dialogCancel(
           _('The requested file is Read Only.\n') +
           _('To save any changes, you will \n') +
           _('be required to do a "Save As..."\n\nFile: %s') \
-            % location, _("Read Only Warning"), self) :
+            % location, _("Read Only Warning"), self.uiinstance) :
           # TODO: Is this right?
           sys.exit()
-        self.Show(0)
+        self.hide()
         self.__loadFromFile(location)
       else:
         self.__loadFromFile(location)
 
-    self.statusbar = self.CreateStatusBar()
-    self.SetStatusText(_('Welcome to GNUe Designer -- Do not expose to direct 
sunlight, do not feed after midnight, and do not get wet.'))
     self.menubar = MenuBar(self)
 
 
@@ -227,14 +218,13 @@
 
     self.createWizards()
     self.createTools()
-    self._initTools()
+    self.uiinstance.initTools()
 
     # Finalize menu bar
     self.menubar.finalize()
     self._app.mru.addMenu(self.menubar.getMenu('File|Open Recent|'), self)
 
-    self.toolbar = PrimaryToolBar(self, self)
-    self.SetToolBar(self.toolbar)
+    self.toolbar = self.uiinstance.toolbar
     self.initToolBar()
 
     # TODO: This is a hack to disable any menu items
@@ -243,34 +233,15 @@
                    'RequestPaste','RequestPasteSpecial','RequestCut'):
       self.dispatchEvent('Disable:%s' % action)
 
-
-    # Build accelerator list
-    accel = wxAcceleratorTable(self.globalAccelerators)
-    for child in [self] + self.globalAcceleratorListeners:
-      child.SetAcceleratorTable(accel)
-
     # Add ourselve to the main app's instance list
     self._app.addInstance(self)
 
-    # Fit the widgets to the screen
-    self.Fit()
 
-    self.SetSize((
-       RuntimeSettings.getint(self.runtime_section, 'width', 550),
-       RuntimeSettings.getint(self.runtime_section, 'height', 400)))
-
-    self.SetPosition((
-       RuntimeSettings.getint(self.runtime_section, 'x', -1),
-       RuntimeSettings.getint(self.runtime_section, 'y', -1)))
-
     self.dispatchEvent('ObjectSelected', originator=self,
                        object=self.rootObject)
 
-    self.Show(true)
-    self.Refresh()
+    self.uiinstance.finalize()
 
-    EVT_CLOSE(self, self.OnClose)
-
     self.stopCachingEvents()
 
   def _initMenu(self):
@@ -320,16 +291,12 @@
 
     # Add connections
     for conn in self.connections.getAllConnectionParameters().keys():
-      id = wxNewId()
       self.menubar.addAction('File|Connect To', conn, 'Connect:%s' % conn,
                help=_("Login to %s connection") % conn,
                eventdata={'connection': conn})
       self.registerEventListeners({'Connect:%s' % conn:self.__OnConnectTo})
 
 
-  def _initTools(self):
-    self.docker = Docker(self, self, self._toolCache)
-
   def addTool(self, id, title, baseclass, hotkey=None, menuGroup=499):
     self._toolCache.append( (id, title, baseclass, hotkey, menuGroup) )
 
@@ -404,16 +371,9 @@
   #  Used by RuntimeSettings
   #
   def saveRuntimeSettings(self):
-    x, y = self.GetPositionTuple()
-    width, height = self.GetSizeTuple()
-    settings = { 'x': abs(x),
-                 'y': abs(y),
-                 'height': height,
-                 'width': width  }
+    return ( self.runtime_section, self.uiinstance.getRuntimeSettings() )
 
-    return ( self.runtime_section, settings )
 
-
   # Do we need to be saved?
   def isDirty(self):
     return self._isdirty
@@ -423,9 +383,9 @@
     if not self._isdirty:
       self._isdirty = True
       if self._path == "":
-        self.SetTitle( TITLE + _(" - <New %s> *") % self.properties.nickname)
+        self.uiinstance.setTitle( _("<New %s> *") % self.properties.nickname)
       else:
-        self.SetTitle( TITLE + " - " + self._path + " *")
+        self.uiinstance.setTitle(self._path + " *")
     self.dispatchEvent('MakeDirty')
 
   # Mark our form as "clean" (no unsaved changes)
@@ -433,9 +393,9 @@
     self._isdirty = 0
     self._isnew = 0
     if self._path == "":
-      self.SetTitle( TITLE + _(" - <New %s>") % self.properties.nickname)
+      self.uiinstance.setTitle( _("<New %s>") % self.properties.nickname)
     else:
-      self.SetTitle( TITLE + " - " + self._path)
+      self.uiinstance.setTitle( self._path)
     self.dispatchEvent('MakeClean')
 
 
@@ -619,7 +579,7 @@
 
     path = self.base.ui.dialogSaveFile(_("Save %s As...") % 
self.properties.description,
                 wildcards = wildcards,
-                parentWindow=self)
+                parentWindow=self.uiinstance)
 
     if path:
 #       if len(path) < 4 or not (path[-4] == '.' and string.lower(path[-3:]) 
in self.properties.fileExtensions.keys()):
@@ -629,13 +589,13 @@
         path = self.base.ui.dialogYesNo(
               _('The file "%s".\n' % path) +
               _("exists. Overwrite?"),
-              _("Unsaved Changes"), icon="warn")
+              _("Unsaved Changes"), icon="warn", parentWindow=self.uiinstance)
         if not path:
           self.OnSaveAs(event)
           return
 
       self._path = path
-      self.SetTitle (TITLE + " - " + self._path)
+      self.uiinstance.setTitle (self._path)
       self.save()
 
 
@@ -645,7 +605,7 @@
       save = self.base.ui.dialogYesNoCancel(
               _("This document has unsaved changes.\n") +
               _("Save changes before closing?"),
-              _("Unsaved Changes"), icon="warn")
+              _("Unsaved Changes"), icon="warn", parentWindow=self.uiinstance)
       if save == True:
         self.OnSave(event)
       elif save == -1:
@@ -655,7 +615,7 @@
     RuntimeSettings.saveRuntimeSettings(self)
     self._app.mru.removeMenu(self.menubar.getMenu('File|Open Recent|'), self)
     self._app.removeInstance(self)
-    self.Destroy()
+    self.uiinstance.close()
 
 
   #################################################################
@@ -728,6 +688,8 @@
     self.instance.dispatchEvent('ObjectModified',
        object = object, new={key:value}, old=ov, originator = '__inline__')
 
+  def setStatus(self, text):
+    self.uiinstance.setStatus(text)
 
 #
 # Helper class used by the tool-specific packages

Modified: trunk/gnue-designer/src/base/MenuBar.py
===================================================================
--- trunk/gnue-designer/src/base/MenuBar.py     2005-03-29 05:55:30 UTC (rev 
7270)
+++ trunk/gnue-designer/src/base/MenuBar.py     2005-03-29 09:37:48 UTC (rev 
7271)
@@ -26,7 +26,6 @@
 # NOTES:
 
 import sys, os, string
-from wxPython.wx import *
 from gnue.common.apps import GDebug
 import MRUManager
 from ModuleSupport import SupportedModules
@@ -35,16 +34,15 @@
 #
 #
 
-class MenuBar(wxMenuBar):
+class MenuBar:
   def __init__(self, instance):
-    wxMenuBar.__init__(self)
     self.instance = instance
-    self.instance.SetMenuBar(self)
 
     self._menus = {}
     self._menuItems = {'':[]}
 
-    self._locationToWx= {}
+    print instance
+    self.uimenu = instance.uiinstance.createMenuBar()
 
 
   # Locations can be <loc>|<loc> where <loc> is <location>/<translation>@group
@@ -85,20 +83,14 @@
                                  eventdata, help))
 
 
-  #
-  # Return the wxMenu(Item) associated with a location
-  def getMenu(self, location):
-    return self._locationToWx[location]
 
-
-
   #
   # Called by Instance.py when the menu can finally be built
   #
   def finalize(self):
     for group, order, text, isMenu, action, canToggle, canDisable, \
         icon, hotkey, eventdata, help in self._menuItems['']:
-      self.__setupMenu(self, action, text)
+      self.__setupMenu(None, action, text)
 
 
   #
@@ -111,51 +103,26 @@
     if not items:
       return
 
-    menu = wxMenu()
-    self._locationToWx[location] = menu
-    parent.AppendMenu(wxNewId(), text, menu)
+    if parent:
+      menu = self.uimenu.createSubMenu(text, location, parent)
+    else:
+      menu = self.uimenu.createMenu(text, location)
+
     items.sort()
     lastgroup = items[0][0]
 
     for group, order, text, isMenu, action, canToggle, canDisable, \
         icon, hotkey, eventdata, help in self._menuItems[location]:
       if group != lastgroup:
-        menu.AppendSeparator()
+        self.uimenu.createSeparator(menu)
         lastgroup = group
 
       if isMenu:
         self.__setupMenu(menu, action, text)
       else:
-        mid = wxNewId()
-        if hotkey:
-          text += '\t' + hotkey
-        item = wxMenuItem(menu, mid, text, help,
-                  (canToggle and [wxITEM_CHECK] or [wxITEM_NORMAL])[0])
-        if canToggle:
-          EVT_MENU(self.instance.base.ui, mid,
-            lambda event, l=self.instance, m=item, e=action, x=eventdata:
-                  l.dispatchEvent('%s:%s' % (m.IsChecked() and 'Show' or 
'Hide',e), **x))
-          self.instance.registerEventListeners( {
-                   'Show:%s' % action:  lambda event, m=item: m.Check(1),
-                   'Hide:%s' % action: lambda event, m=item: m.Check(0) })
-        else:
-          EVT_MENU(self.instance.base.ui, mid,
-            lambda event, l=self.instance, e=action, x=eventdata: 
l.dispatchEvent(e, **x))
+        self.uimenu.createMenuItem(menu, text, canToggle, canDisable, icon, 
hotkey, eventdata, help, action)
 
-        if canDisable:
-          self.instance.registerEventListeners( {
-                   'Enable:%s' % action:  lambda event, m=item: m.Enable(1),
-                   'Disable:%s' % action: lambda event, m=item: m.Enable(0) })
-        menu.AppendItem(item)
 
-
-  #
-  # Convenience methods to make the main menu bar appear to be a menu container
-  #
-  def AppendMenu(self, wxId, text, menu):
-    self.Append(menu, text)
-
-
   def getEventHelp(self, handle):
     """
     Return the help string of a menu event,
@@ -172,3 +139,10 @@
       pass
 
     return None
+
+  #
+  # Return the wxMenu(Item) associated with a location
+  def getMenu(self, location):
+    return self.uimenu.getMenu(location)
+
+

Modified: trunk/gnue-designer/src/base/PopupMenu.py
===================================================================
--- trunk/gnue-designer/src/base/PopupMenu.py   2005-03-29 05:55:30 UTC (rev 
7270)
+++ trunk/gnue-designer/src/base/PopupMenu.py   2005-03-29 09:37:48 UTC (rev 
7271)
@@ -108,7 +108,7 @@
     tid = wxNewId()
     self._newMap[tid] = tag
     self.Append(tid, text)
-    EVT_MENU(self.instance, tid, self.OnCreateObject)
+    EVT_MENU(self.instance.uiinstance, tid, self.OnCreateObject)
 
 
   def OnEditProperties(self, event):
@@ -125,7 +125,7 @@
     attributes=hasattr(self,'Char__x') and {'Char:x': self.Char__x, 'Char:y': 
self.Char__y} or {}
     if tag == 'trigger':
       attributes['type']='named'
-      
+
     self.instance.incubator.createObject(self.instance.rootObject, tag,
       self._object, attributes)
 
@@ -236,26 +236,26 @@
       self.instance.incubator.elementMapping[tag].sort()
       for element in self.instance.incubator.elementMapping[tag]:
         descr = string.upper(element[0])+string.lower(element[1:])
-        if descr == 'Import': 
+        if descr == 'Import':
           descr = 'Import Library'
-        elif len(descr) > 7 and descr[:7] == 'Import-': 
+        elif len(descr) > 7 and descr[:7] == 'Import-':
           descr = 'Imported ' + string.upper(descr[7])+ \
             string.lower(descr[8:])
 
         self.addCreateTag(element, descr)
-    
 
 
+
 # This menu is the popup menu on the object tree
-class ObjectMenu(ActionMenu): 
-  def __init__(self, instance, object): 
+class ObjectMenu(ActionMenu):
+  def __init__(self, instance, object):
     ActionMenu.__init__(self, instance, object, None, _("Object Tasks..."))
 
 
-     
+
 # This menu is the popup menu on the layout screen
-class PageMenu(ActionMenu): 
-  def __init__(self, instance, object, x, y): 
+class PageMenu(ActionMenu):
+  def __init__(self, instance, object, x, y):
     ActionMenu.__init__(self, instance, object, None, hasattr(object,'name') 
and \
        object.name or string.upper(object._type[2]) + \
        string.lower(object._type[3:]) )

Modified: trunk/gnue-designer/src/base/TemplateParser.py
===================================================================
--- trunk/gnue-designer/src/base/TemplateParser.py      2005-03-29 05:55:30 UTC 
(rev 7270)
+++ trunk/gnue-designer/src/base/TemplateParser.py      2005-03-29 09:37:48 UTC 
(rev 7271)
@@ -421,9 +421,9 @@
         set.append(self.mapping[v])
       self.SetSelections(set)
     else:
-      try: 
+      try:
         self.SetSelection(self.mapping[value])
-      except KeyError: 
+      except KeyError:
         pass
 
 
@@ -535,27 +535,27 @@
     if len(sel):
       self.delButton.Enable(1)
 
-      if 0 in sel: 
+      if 0 in sel:
         self.upButton.Enable(0)
-      else: 
+      else:
         self.upButton.Enable(1)
 
       if self.list2.Number()-1 in sel:
         self.downButton.Enable(0)
-      else: 
+      else:
         self.downButton.Enable(1)
     else:
       self.delButton.Enable(0)
       self.upButton.Enable(0)
       self.downButton.Enable(0)
-    
 
+
     self.addButton.Enable(0)
     for i in self.list1.GetSelections():
       self.list1.SetSelection(i,0)
 
   def OnSelectAll(self, event):
-    
+
     count = self.list1.Number()
     for count in range(count):
       self.list1.SetSelection(count)
@@ -581,12 +581,12 @@
     self.OnSelectRight(None)
 
 
-  def OnRemove(self, event): 
+  def OnRemove(self, event):
     sel = list(self.list2.GetSelections())
     sel.sort(lambda a,b : cmp (b,a))
     appendages1 = []
     appendages2 = []
-    for i in sel: 
+    for i in sel:
       appendages1.insert(0,self.list2.GetString(i))
       appendages2.insert(0,self.included[i])
       self.included.pop(i)
@@ -645,7 +645,7 @@
     self.instance.dispatchEvent('BeginWizard', template=self.template)
     self.instance.dispatchEvent('BeginUndoGroup')
     self.parser = TemplateParser(self.instance, self.instance.rootObject,
-          self.instance, self.template)
+          self.instance.uiinstance, self.template)
     self.parser.run(*args, **parms)
     self.instance.dispatchEvent('EndUndoGroup')
     self.instance.dispatchEvent('EndWizard', template=self.template)

Modified: trunk/gnue-designer/src/uidrivers/wx/Base.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/Base.py        2005-03-29 05:55:30 UTC 
(rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/Base.py        2005-03-29 09:37:48 UTC 
(rev 7271)
@@ -30,9 +30,12 @@
 
 import sys, os, string
 from wxPython.wx import *
-from startup.Startup import Startup
 from gnue.forms.uidrivers.wx.GFwxApp import setWxApp
 
+from startup.Startup import Startup
+from Instance import Instance
+from MenuBar import MenuBar
+
 class UIBase(wxApp):
 
 
@@ -60,6 +63,8 @@
     self.app.init()
     self.MainLoop()
 
+  def createInstance(self, instance):
+    return Instance(instance)
 
   ######################################################################
   #

Added: trunk/gnue-designer/src/uidrivers/wx/Instance.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/Instance.py    2005-03-29 05:55:30 UTC 
(rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/Instance.py    2005-03-29 09:37:48 UTC 
(rev 7271)
@@ -0,0 +1,110 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# FILE:
+# wx/Instance.py
+#
+# DESCRIPTION:
+"""
+Instance class for wxWidgets
+"""
+# NOTES:
+#
+
+from wxPython.wx import *
+from gnue.designer.base import Goat
+from gnue.common.apps import RuntimeSettings
+from docks.Docker import Docker
+from gnue.designer import PACKAGE as TITLE
+
+from gnue.designer.base.PrimaryToolBar import PrimaryToolBar
+
+from MenuBar import MenuBar
+
+class Instance(wxFrame):
+  def __init__(self, instance):
+    wxFrame.__init__(self, NULL, -1, "")
+    self.instance = instance
+    icon = Goat.getGoatIcon()
+    self.SetIcon(icon)
+
+    self.toolbar = PrimaryToolBar(self, self.instance)
+    self.SetToolBar(self.toolbar)
+
+    self.statusbar = self.CreateStatusBar()
+    self.SetStatusText(_('Welcome to GNUe Designer -- Do not expose to direct 
sunlight, do not feed after midnight, and do not get wet.'))
+
+    EVT_CLOSE(self, self.instance.OnClose)
+
+  def createMenuBar(self):
+    menuBar = MenuBar(self.instance)
+    self.SetMenuBar(menuBar)
+    return menuBar
+
+  def setTitle(self, title):
+    self.SetTitle(TITLE + " - " + title)
+
+  def show(self):
+    self.Show(True)
+
+  def hide(self):
+    self.Show(False)
+
+  def finalize(self):
+    # Build accelerator list
+    accel = wxAcceleratorTable(self.instance.globalAccelerators)
+    for child in [self] + self.instance.globalAcceleratorListeners:
+      child.SetAcceleratorTable(accel)
+
+    # Fit the widgets to the screen
+    self.Fit()
+
+    self.SetSize((
+       RuntimeSettings.getint(self.instance.runtime_section, 'width', 550),
+       RuntimeSettings.getint(self.instance.runtime_section, 'height', 400)))
+
+    self.SetPosition((
+       RuntimeSettings.getint(self.instance.runtime_section, 'x', -1),
+       RuntimeSettings.getint(self.instance.runtime_section, 'y', -1)))
+
+    self.Show(true)
+    self.Refresh()
+
+  def initTools(self):
+    self.docker = Docker(self, self.instance, self.instance._toolCache)
+
+  #
+  #  Used by RuntimeSettings
+  #
+  def getRuntimeSettings(self):
+    x, y = self.GetPositionTuple()
+    width, height = self.GetSizeTuple()
+    settings = { 'x': abs(x),
+                 'y': abs(y),
+                 'height': height,
+                 'width': width  }
+
+    return settings
+
+  def close(self):
+    self.Destroy()
+
+  def setStatus(self, text):
+    self.statusbar.SetStatusText(text)

Added: trunk/gnue-designer/src/uidrivers/wx/MenuBar.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/MenuBar.py     2005-03-29 05:55:30 UTC 
(rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/MenuBar.py     2005-03-29 09:37:48 UTC 
(rev 7271)
@@ -0,0 +1,92 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# FILE:
+# wx/MenuBar.py
+#
+# DESCRIPTION:
+"""
+MenuBar class for wxWidgets
+"""
+# NOTES:
+#
+
+from wxPython.wx import *
+
+class MenuBar(wxMenuBar):
+  def __init__(self, instance):
+    wxMenuBar.__init__(self)
+    self.instance = instance
+
+    self._locationToWx= {}
+
+  #
+  # Return the wxMenu(Item) associated with a location
+  def getMenu(self, location):
+    return self._locationToWx[location]
+
+
+  def createMenu(self, title, location):
+    return self.createSubMenu(title, location, self)
+
+  def createSubMenu(self, title, location, parent):
+    menu = wxMenu()
+    self._locationToWx[location] = menu
+    parent.AppendMenu(wxNewId(), title, menu)
+    return menu
+
+  def createSeparator(self, menu):
+    menu.AppendSeparator()
+
+  def createMenuItem(self, menu, text, canToggle,
+      canDisable, icon, hotkey, eventdata, help, action):
+
+    mid = wxNewId()
+    if hotkey:
+      text += '\t' + hotkey
+    item = wxMenuItem(menu, mid, text, help,
+              (canToggle and [wxITEM_CHECK] or [wxITEM_NORMAL])[0])
+    if canToggle:
+      EVT_MENU(self.instance.base.ui, mid,
+        lambda event, l=self.instance, m=item, e=action, x=eventdata:
+              l.dispatchEvent('%s:%s' % (m.IsChecked() and 'Show' or 
'Hide',e), **x))
+      self.instance.registerEventListeners( {
+                'Show:%s' % action:  lambda event, m=item: m.Check(1),
+                'Hide:%s' % action: lambda event, m=item: m.Check(0) })
+    else:
+      EVT_MENU(self.instance.base.ui, mid,
+        lambda event, l=self.instance, e=action, x=eventdata: 
l.dispatchEvent(e, **x))
+
+    if canDisable:
+      self.instance.registerEventListeners( {
+                'Enable:%s' % action:  lambda event, m=item: m.Enable(1),
+                'Disable:%s' % action: lambda event, m=item: m.Enable(0) })
+    menu.AppendItem(item)
+    return item
+
+
+  #
+  # Convenience methods to make the main menu bar appear to be a menu container
+  #
+  def AppendMenu(self, wxId, text, menu):
+    self.Append(menu, text)
+
+
+

Modified: trunk/gnue-designer/src/uidrivers/wx/docks/DockedPane.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/docks/DockedPane.py    2005-03-29 
05:55:30 UTC (rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/docks/DockedPane.py    2005-03-29 
09:37:48 UTC (rev 7271)
@@ -47,7 +47,7 @@
     BasePane.__init__(self, parent, instance, tool)
     # These are used exclusively by ToolDock
 
-    self.statusbar = instance.statusbar
+#    self.statusbar = instance.uiinstance.statusbar
     self.minimumVerticalSize = 0
     self.lastSize = 0
 
@@ -147,4 +147,4 @@
     self.parent.resize(self, newHeight)
 
   def setFeedback(self, text):
-    self.instance.statusbar.SetStatusText(text)
+    self.instance.uiinstance.statusbar.SetStatusText(text)

Modified: trunk/gnue-designer/src/uidrivers/wx/docks/Docker.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/docks/Docker.py        2005-03-29 
05:55:30 UTC (rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/docks/Docker.py        2005-03-29 
09:37:48 UTC (rev 7271)
@@ -45,7 +45,7 @@
       pos = (0, 36)
     else:
       pos = (-1,-1)
-      
+
     wxPanel.__init__(self, parent, -1, pos=pos)
     self.parent = parent
     self.instance = instance
@@ -53,7 +53,7 @@
     self.horizSplitter = horizSplitter = wxSplitterWindow(self, -1, 
style=wxSP_3D)
     self.leftDock = leftWin = SplitDock(horizSplitter, self, 'left')
     self.rightDock = rightWin = SplitDock(horizSplitter, self,'right')
-    EVT_SIZE(instance, self.__OnSize)
+    EVT_SIZE(parent, self.__OnSize)
 
     instance.registerEventListeners({
                    'Docker:Undock': self.undock,
@@ -100,7 +100,7 @@
         dock.add(DockedPane(dock, instance, tool), tool._dock_index)
       else:
         # Frame type
-        FloatingPane(instance, instance, tool)
+        FloatingPane(instance.uiinstance, instance, tool)
 
       # Keep track of the tools we created
       self.tools.append(tool)
@@ -124,7 +124,7 @@
               RuntimeSettings.getint(self.runtime_section, 
'DockSplitter-TopBottom',500))
 
   def __OnSize(self, event):
-    self.SetSize(self.instance.GetClientSize())
+    self.SetSize(self.parent.GetClientSize())
     self.horizSplitter.SetSize(self.GetClientSize())
 
   def saveRuntimeSettings(self):
@@ -150,9 +150,10 @@
   def undock(self, event):
     tool = event.tool
     instance = self.instance
+    parent = self.parent
     dockpane = tool.dockpane
     panel = dockpane.parent.remove(dockpane)
-    FloatingPane(instance, instance, tool)
+    FloatingPane(parent, instance, tool)
     tool._docked = 0
     dockpane.Destroy()
     instance.dispatchEvent('Show:Tool:%s' % tool.id)

Modified: trunk/gnue-designer/src/uidrivers/wx/docks/FloatingPane.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/docks/FloatingPane.py  2005-03-29 
05:55:30 UTC (rev 7270)
+++ trunk/gnue-designer/src/uidrivers/wx/docks/FloatingPane.py  2005-03-29 
09:37:48 UTC (rev 7271)
@@ -49,7 +49,7 @@
   def __init__(self, parent, instance, tool):
     style = 
wxMINIMIZE_BOX|wxRESIZE_BORDER|wxCAPTION|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT
 
-    wxFrame.__init__(self, instance, -1, tool.title, style=style)
+    wxFrame.__init__(self, parent, -1, tool.title, style=style)
     BasePane.__init__(self, parent, instance, tool)
 
     icon = Goat.getGoatIcon()





reply via email to

[Prev in Thread] Current Thread [Next in Thread]