commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9361 - trunk/gnue-forms/src/uidrivers/wx/widgets


From: reinhard
Subject: [gnue] r9361 - trunk/gnue-forms/src/uidrivers/wx/widgets
Date: Fri, 9 Feb 2007 04:04:24 -0600 (CST)

Author: reinhard
Date: 2007-02-09 04:04:23 -0600 (Fri, 09 Feb 2007)
New Revision: 9361

Added:
   trunk/gnue-forms/src/uidrivers/wx/widgets/menu.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/menuitem.py
Log:
Added menu widgets for (old) wx driver.


Added: trunk/gnue-forms/src/uidrivers/wx/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/menu.py   2007-02-08 19:34:22 UTC 
(rev 9360)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/menu.py   2007-02-09 10:04:23 UTC 
(rev 9361)
@@ -0,0 +1,75 @@
+# GNU Enterprise Forms - wx UI Driver - Menu 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 UIMenu(UIHelper):
+    """
+    Implements a menu object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new Menu widget.
+        """
+
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
+            # Menu bar of the form
+            widget = wx.MenuBar()
+            if isinstance(self._uiForm.mainWindow, wx.Frame):
+                self._uiForm.mainWindow.SetMenuBar(widget)
+        else:
+            # Submenu or popup menu
+            widget = wx.Menu()
+            if isinstance(event.container, wx.Menu):
+                event.container.AppendMenu(wx.ID_ANY, self._gfObject.label,
+                        widget)
+            elif isinstance(event.container, wx.MenuBar):
+                event.container.Append(widget, self._gfObject.label)
+
+        self._container = widget
+
+        return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIMenu,
+  'provides' : 'GFMenu',
+  'container': 1,
+}


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

Added: trunk/gnue-forms/src/uidrivers/wx/widgets/menuitem.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/menuitem.py       2007-02-08 
19:34:22 UTC (rev 9360)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/menuitem.py       2007-02-09 
10:04:23 UTC (rev 9361)
@@ -0,0 +1,129 @@
+# GNU Enterprise Forms - wx UI Driver - MenuItem 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 UIMenuItem(UIHelper):
+    """
+    Implements a menu item object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu item widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new MenuItem widget.
+        """
+
+        # These are the relevant parameters
+        icon_file = self._gfObject._get_icon_file(size="16x16", format="png")
+        label = self._gfObject.label
+        description = self._gfObject.description
+        hotkey = self._gfObject.hotkey
+        check = (self._gfObject.action_off is not None)
+
+        if check:
+            kind = wx.ITEM_CHECK
+        else:
+            kind = wx.ITEM_NORMAL
+
+        if label is not None:
+            if hotkey is not None:
+                text = label + u"\t" + hotkey
+            else:
+                text = label
+            widget = wx.MenuItem(event.container, wx.ID_ANY, text,
+                    description or u"", kind)
+    
+            if icon_file and not check:
+                image = wx.Image(icon_file, wx.BITMAP_TYPE_PNG)
+                widget.SetBitmap(image.ConvertToBitmap())
+
+            wx.EVT_MENU(wx.GetApp(), widget.GetId(), self.__on_menu)
+
+            event.container.AppendItem(widget)
+        else:
+            widget = None
+            event.container.AppendSeparator()
+
+        self.__widget = widget
+
+        return widget
+
+
+    # -------------------------------------------------------------------------
+    # Events
+    # -------------------------------------------------------------------------
+
+    def __on_menu(self, event):
+        self._gfObject._event_fire()
+
+
+    # -------------------------------------------------------------------------
+    # Check/uncheck menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_on_(self):
+        if self.__widget is not None:
+            self.__widget.Check(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            self.__widget.Check(False)
+
+
+    # -------------------------------------------------------------------------
+    # Enable/disable menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_enable_(self):
+        if self.__widget is not None:
+            self.__widget.Enable(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_disable_(self):
+        if self.__widget is not None:
+            self.__widget.Enable(False)
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIMenuItem,
+  'provides' : 'GFMenuItem',
+  'container': False
+}


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





reply via email to

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