commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9485 - trunk/gnue-forms/src/uidrivers/qt3/widgets


From: jamest
Subject: [gnue] r9485 - trunk/gnue-forms/src/uidrivers/qt3/widgets
Date: Tue, 10 Apr 2007 13:52:03 -0500 (CDT)

Author: jamest
Date: 2007-04-10 13:52:03 -0500 (Tue, 10 Apr 2007)
New Revision: 9485

Added:
   trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbutton.py
Log:
start of a working qt3 toolbar, actions aren't linked in yet


Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbar.py       2007-04-10 
15:44:51 UTC (rev 9484)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbar.py       2007-04-10 
18:52:03 UTC (rev 9485)
@@ -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 qt
+
+from gnue.forms.uidrivers.qt3.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_toolbar__' \
+                and not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+
+            # Toolbar of the form
+            if isinstance(self._uiForm.main_window, qt.QMainWindow):
+                widget = qt.QToolBar(self._uiForm.main_window)
+                #widget.setIconSize(qt.QSize(24, 24))
+
+        self._container = widget
+
+        return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolbar,
+  'provides' : 'GFToolbar',
+  'container': 1,
+}


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

Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbutton.py    2007-04-10 
15:44:51 UTC (rev 9484)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/toolbutton.py    2007-04-10 
18:52:03 UTC (rev 9485)
@@ -0,0 +1,187 @@
+# 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 qt
+
+from gnue.forms.uidrivers.qt3.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 event.container is not None:
+            if label is not None:
+                if check:
+                    toggle = True
+                else:
+                    toggle = False
+
+                if icon_file:
+                    image = qt.QIconSet(qt.QPixmap(icon_file))
+                else:
+                    image = None
+
+                widget = qt.QToolButton(event.container)
+                widget.setText(label)
+                widget.setTextLabel(label.replace('&', u''))
+                widget.setIconSet(image)
+                widget.setToggleButton(toggle)
+                
+                #wx.EVT_TOOL(event.container, widget.GetId(), self.__on_tool)
+            else:
+                widget = None
+                event.container.addSeparator()
+        else:
+            # TOOLBAR:SUPPRESS was set
+            widget = None
+
+        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:
+            print self.__widget
+            self.__widget.setDown(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            print self.__widget
+            self.__widget.setDown(False)
+
+
+    # -------------------------------------------------------------------------
+    # Enable/disable menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_enable_(self):
+        if self.__widget is not None:
+            self.__widget.setEnabled(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_disable_(self):
+        if self.__widget is not None:
+            self.__widget.setEnabled(False)
+
+# =============================================================================
+# Action
+# =============================================================================
+
+class Action(qt.QAction):
+    """
+    Implementation of an action used within a toolbar
+    """
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent, name, user_action):
+
+        qt.QAction.__init__(self, parent)
+
+        self.parent = parent
+        self.user_action = user_action
+
+        iconloc = user_action.getIconLocation(size="24x24")
+
+        # Set the action icon if available
+        if iconloc:
+            icon = _ICON_CACHE.setdefault(iconloc,
+                                          qt.QIconSet(qt.QPixmap(iconloc)))
+            self.setIconSet(icon)
+        else:
+            print u_("** WARNING: Cannot add '%s' to toolbar; no icon") \
+                                %  user_action.event
+
+        self.setText(name)
+        if user_action.canToggle:
+            self.setToggleAction(True)
+
+        self.setToolTip(user_action.description or '')
+
+        self.connect(self, qt.SIGNAL('activated()'), self.__activated)
+
+        self.addTo(parent)
+
+    # -------------------------------------------------------------------------
+    # String representation
+    # -------------------------------------------------------------------------
+
+    def __repr__(self):
+        return "<Action %s (%s)>" % (self.user_action.event,
+                self.user_action.canToggle)
+
+    # -------------------------------------------------------------------------
+    # Slot Implementations
+    # -------------------------------------------------------------------------
+
+    def __activated(self):
+        self.parent._fire(self.user_action, False)
+        
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolButton,
+  'provides' : 'GFToolButton',
+  'container': False
+}


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





reply via email to

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