commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9364 - trunk/gnue-forms/src/uidrivers/wx26/widgets


From: reinhard
Subject: [gnue] r9364 - trunk/gnue-forms/src/uidrivers/wx26/widgets
Date: Fri, 9 Feb 2007 05:17:52 -0600 (CST)

Author: reinhard
Date: 2007-02-09 05:17:51 -0600 (Fri, 09 Feb 2007)
New Revision: 9364

Added:
   trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbutton.py
Modified:
   trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
Log:
Added dynamic toolbar implementation for wx26.


Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-09 11:15:46 UTC 
(rev 9363)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2007-02-09 11:17:51 UTC 
(rev 9364)
@@ -161,11 +161,12 @@
                 self.__status_bar.SetFieldsCount(5)
                 self.__status_bar.SetStatusWidths([-1, 50, 50, 75, 75])
 
-            if not self._form._features.get('GUI:MENUBAR:SUPPRESS'):
-                MenuBar(self._uiDriver, self.main_window, self._form)
+            if not self._form.findChildNamed('__main__', 'GFMenu'):
+                if not self._form._features.get('GUI:MENUBAR:SUPPRESS'):
+                    MenuBar(self._uiDriver, self.main_window, self._form)
 
-            if not self._form._features.get ('GUI:TOOLBAR:SUPPRESS'):
-                tlb = ToolBar(self._uiDriver, self.main_window, self._form)
+                if not self._form._features.get ('GUI:TOOLBAR:SUPPRESS'):
+                    tlb = ToolBar(self._uiDriver, self.main_window, self._form)
 
         # If the form is using tabs, we need to create a Notebook control as
         # page container, otherwise we can just use the base panel

Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbar.py      2007-02-09 
11:15:46 UTC (rev 9363)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbar.py      2007-02-09 
11:17:51 UTC (rev 9364)
@@ -0,0 +1,73 @@
+# 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.wx26.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']:
+
+            # Make sure to disable the color-remapping in windows
+            wx.SystemOptions.SetOption ('msw.remap', '0')
+
+            # Toolbar of the form
+            if isinstance(self._uiForm.main_window, wx.Frame):
+                widget = self._uiForm.main_window.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/wx26/widgets/toolbar.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbutton.py   2007-02-09 
11:15:46 UTC (rev 9363)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/toolbutton.py   2007-02-09 
11:17:51 UTC (rev 9364)
@@ -0,0 +1,128 @@
+# 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.wx26.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.SetToggle(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            self.__widget.SetToggle(False)
+
+
+    # -------------------------------------------------------------------------
+    # Enable/disable menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_enable_(self):
+        if self.__widget is not None:
+            # FIXME: why doesn't the next line work?
+            # self.__widget.Enable(True)
+            self.__widget.GetToolBar().EnableTool(self.__widget.GetId(), True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_disable_(self):
+        if self.__widget is not None:
+            # FIXME: why doesn't the next line work?
+            # self.__widget.Enable(False)
+            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/wx26/widgets/toolbutton.py
___________________________________________________________________
Name: svn:keywords
   + Id





reply via email to

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