[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9345 - trunk/gnue-forms/src/uidrivers/qt3/widgets
From: |
johannes |
Subject: |
[gnue] r9345 - trunk/gnue-forms/src/uidrivers/qt3/widgets |
Date: |
Wed, 31 Jan 2007 10:08:27 -0600 (CST) |
Author: johannes
Date: 2007-01-31 10:08:26 -0600 (Wed, 31 Jan 2007)
New Revision: 9345
Added:
trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py
trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
Log:
Implemented <menu> and <menuitem>
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2007-01-31 07:50:00 UTC
(rev 9344)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2007-01-31 16:08:26 UTC
(rev 9345)
@@ -106,8 +106,9 @@
self.__status_bar = self.main_window.statusBar()
self.__setup_status_bar()
- if not self._form._features['GUI:MENUBAR:SUPPRESS']:
- MenuBar(self._uiDriver, self.main_window, self._form)
+ if not self._form.findChildNamed('__main__', 'GFMenu'):
+ if not self._form._features['GUI:MENUBAR:SUPPRESS']:
+ MenuBar(self._uiDriver, self.main_window, self._form)
if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
tlb = ToolBar(self._uiDriver, self.main_window, self._form)
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py 2007-01-31 07:50:00 UTC
(rev 9344)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py 2007-01-31 16:08:26 UTC
(rev 9345)
@@ -0,0 +1,67 @@
+# GNU Enterprise Forms - QT 3 UI driver - Menu
+#
+# 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 qt
+
+from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
+
+# =============================================================================
+# Wrap an UI layer around a menu
+# =============================================================================
+
+class UIMenu(UIHelper):
+ """
+ Implements a menu object.
+ """
+
+ # -------------------------------------------------------------------------
+ # Create a new menu widget
+ # -------------------------------------------------------------------------
+
+ def _create_widget_(self, event, spacer):
+ """
+ Create a menu widget
+ """
+
+ if self._gfObject.name == '__main__':
+ widget = self._uiForm.main_window.menuBar()
+
+ else:
+ widget = qt.QPopupMenu(event.container)
+ if isinstance(event.container, (qt.QPopupMenu, qt.QMenuBar)):
+ event.container.insertItem(self._gfObject.label, widget)
+
+ self._container = widget
+ return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIMenu,
+ 'provides' : 'GFMenu',
+ 'container': 1,
+}
+
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py 2007-01-31
07:50:00 UTC (rev 9344)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py 2007-01-31
16:08:26 UTC (rev 9345)
@@ -0,0 +1,127 @@
+# Short line describing the purpose of this file
+#
+# 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 qt
+
+from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
+
+# =============================================================================
+# Wrap an UI layer around a menu item
+# =============================================================================
+
+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)
+
+ self.parent = event.container
+
+ if label is not None:
+ if icon_file:
+ icon = qt.QIconSet(qt.QPixmap(icon_file))
+ self.__widget = self.parent.insertItem(icon, label,
+ self.__on_menu)
+ else:
+ self.__widget = self.parent.insertItem(label, self.__on_menu)
+
+ if hotkey:
+ self.parent.setAccel(qt.QKeySequence(hotkey), self.__widget)
+
+ self.parent.setWhatsThis(self.__widget, description or '')
+ else:
+ self.__widget = None
+ self.parent.insertSeparator()
+
+ return self.__widget
+
+
+
+ # -------------------------------------------------------------------------
+ # Events
+ # -------------------------------------------------------------------------
+
+ def __on_menu(self, *args):
+
+ self._gfObject._event_fire()
+
+
+ # -------------------------------------------------------------------------
+ # Check/uncheck menu item
+ # -------------------------------------------------------------------------
+
+ def _ui_switch_on_(self):
+
+ if self.__widget is not None:
+ self.parent.setItemChecked(self.__widget, True)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_switch_off_(self):
+
+ if self.__widget is not None:
+ self.parent.setItemChecked(self.__widget, False)
+
+
+ # -------------------------------------------------------------------------
+ # Enable/disable menu item
+ # -------------------------------------------------------------------------
+
+ def _ui_enable_(self):
+
+ if self.__widget is not None:
+ self.parent.setItemEnabled(self.__widget, True)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_disable_(self):
+
+ if self.__widget is not None:
+ self.parent.setItemEnabled(self.__widget, False)
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIMenuItem,
+ 'provides' : 'GFMenuItem',
+ 'container': False
+}
+
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py
___________________________________________________________________
Name: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9345 - trunk/gnue-forms/src/uidrivers/qt3/widgets,
johannes <=