commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9366 - in trunk/gnue-forms/src/uidrivers/wx/widgets: . form


From: reinhard
Subject: [gnue] r9366 - in trunk/gnue-forms/src/uidrivers/wx/widgets: . form
Date: Fri, 9 Feb 2007 11:15:21 -0600 (CST)

Author: reinhard
Date: 2007-02-09 11:15:20 -0600 (Fri, 09 Feb 2007)
New Revision: 9366

Added:
   trunk/gnue-forms/src/uidrivers/wx/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/toolbutton.py
Modified:
   trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
Log:
Added dynamic toolbar widgets for (old) wx driver.

issue79 in-progress


Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2007-02-09 
16:01:52 UTC (rev 9365)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2007-02-09 
17:15:20 UTC (rev 9366)
@@ -127,13 +127,14 @@
     self._container = newWidget
 
     if self._form.style != 'dialog':
-      # Add the menu
-      if not self._form._features['GUI:MENUBAR:SUPPRESS']:
-        MenuBar(self._uiDriver, self.containerFrame, self._form)
+      if not self._form.findChildNamed('__main__', 'GFMenu'):
+        # Add the menu
+        if not self._form._features['GUI:MENUBAR:SUPPRESS']:
+          MenuBar(self._uiDriver, self.containerFrame, self._form)
 
-      # and the Toolbar
-      if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
-        ToolBar(self._uiDriver, self.containerFrame, self._form)
+        # and the Toolbar
+        if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+          ToolBar(self._uiDriver, self.containerFrame, self._form)
 
     self._eventHandler = event.eventHandler
     self._wrapper.finalize()

Added: trunk/gnue-forms/src/uidrivers/wx/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/toolbar.py        2007-02-09 
16:01:52 UTC (rev 9365)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/toolbar.py        2007-02-09 
17:15:20 UTC (rev 9366)
@@ -0,0 +1,70 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Toolbar widget
+#
+# Copyright 2001-2007 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import wx
+
+from gnue.forms.uidrivers.wx.widgets._base import UIHelper
+
+
+# =============================================================================
+# Wrap an UI layer around a wxMenu widget
+# =============================================================================
+
+class UIToolbar(UIHelper):
+    """
+    Implements a toolbar object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new toolbar widget.
+        """
+
+        widget = None
+
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+
+            # Toolbar of the form
+            if isinstance(self._uiForm.mainWindow, wx.Frame):
+                widget = self._uiForm.mainWindow.CreateToolBar()
+                widget.SetToolBitmapSize((24, 24))
+
+        self._container = widget
+
+        return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolbar,
+  'provides' : 'GFToolbar',
+  'container': 1,
+}


Property changes on: trunk/gnue-forms/src/uidrivers/wx/widgets/toolbar.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/gnue-forms/src/uidrivers/wx/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/toolbutton.py     2007-02-09 
16:01:52 UTC (rev 9365)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/toolbutton.py     2007-02-09 
17:15:20 UTC (rev 9366)
@@ -0,0 +1,124 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - ToolButton widget
+#
+# Copyright 2001-2007 Free Software Foundation
+#
+# 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.
+#
+# $Id$
+
+import wx
+
+from gnue.forms.uidrivers.wx.widgets._base import UIHelper
+
+
+# =============================================================================
+# UIToolButton
+# =============================================================================
+
+class UIToolButton(UIHelper):
+    """
+    Implements a toolbar button object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu item widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new toolbar button widget.
+        """
+
+        # These are the relevant parameters
+        icon_file = self._gfObject._get_icon_file(size="24x24", format="png")
+        label = self._gfObject.label
+        description = self._gfObject.description
+        check = (self._gfObject.action_off is not None)
+
+        if label is not None:
+            if check:
+                kind = wx.ITEM_CHECK
+            else:
+                kind = wx.ITEM_NORMAL
+
+            if icon_file:
+                image = wx.Image(icon_file, wx.BITMAP_TYPE_PNG)
+            else:
+                image = None
+
+            widget = event.container.AddLabelTool(wx.ID_ANY, label,
+                    image.ConvertToBitmap(), kind=kind, shortHelp=label,
+                    longHelp=(description or u""))
+
+            wx.EVT_TOOL(event.container, widget.GetId(), self.__on_tool)
+        else:
+            widget = None
+            event.container.AddSeparator()
+
+        self.__widget = widget
+
+        return widget
+
+
+    # -------------------------------------------------------------------------
+    # Events
+    # -------------------------------------------------------------------------
+
+    def __on_tool(self, event):
+        self._gfObject._event_fire()
+
+
+    # -------------------------------------------------------------------------
+    # Check/uncheck menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_on_(self):
+        if self.__widget is not None:
+            self.__widget.GetToolBar().ToggleTool(self.__widget.GetId(), True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            self.__widget.GetToolBar().ToggleTool(self.__widget.GetId(), False)
+
+
+    # -------------------------------------------------------------------------
+    # Enable/disable menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_enable_(self):
+        if self.__widget is not None:
+            self.__widget.GetToolBar().EnableTool(self.__widget.GetId(), True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_disable_(self):
+        if self.__widget is not None:
+            self.__widget.GetToolBar().EnableTool(self.__widget.GetId(), False)
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolButton,
+  'provides' : 'GFToolButton',
+  'container': False
+}


Property changes on: trunk/gnue-forms/src/uidrivers/wx/widgets/toolbutton.py
___________________________________________________________________
Name: svn:keywords
   + Id





reply via email to

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