[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9506 - in trunk/gnue-forms/src/uidrivers: _commonGuiToolkit html
From: |
reinhard |
Subject: |
[gnue] r9506 - in trunk/gnue-forms/src/uidrivers: _commonGuiToolkit html html/widgets qt4 qt4/widgets |
Date: |
Tue, 24 Apr 2007 07:33:39 -0500 (CDT) |
Author: reinhard
Date: 2007-04-24 07:33:38 -0500 (Tue, 24 Apr 2007)
New Revision: 9506
Removed:
trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py
trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py
trunk/gnue-forms/src/uidrivers/html/MenuBar.py
trunk/gnue-forms/src/uidrivers/html/ToolBar.py
trunk/gnue-forms/src/uidrivers/qt4/MenuBar.py
trunk/gnue-forms/src/uidrivers/qt4/ToolBar.py
Modified:
trunk/gnue-forms/src/uidrivers/html/widgets/form.py
trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py
Log:
Removed last remains of old menubar/toolbar code.
Deleted: trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py 2007-04-23
14:22:02 UTC (rev 9505)
+++ trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py 2007-04-24
12:33:38 UTC (rev 9506)
@@ -1,209 +0,0 @@
-# GNU Enterprise Forms - Common GUI Toolkit - Menubar
-#
-# 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: $
-
-from gnue.common.apps.i18n import utranslate as u_ # for epydoc
-from gnue.forms.uidrivers._base import UserActions
-
-
-# =============================================================================
-# Base class for menu bars
-# =============================================================================
-
-class MenuBar:
-
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
-
- def __init__ (self, uidriver, container, form):
-
- self.driver = uidriver
- self.container = container
- self.form = form
- self.enabled = 1
- self.__actionMap = {}
-
- self.finalize ()
-
-
-
- # Smile. It's menu-building time!
- def init (self):
- pass
-
- # Add a (sub)menu
- def addMenu (self, name, parent):
- pass
-
- # Add a menu item (action)
- def addAction (self, name, parent, userAction):
- pass
-
- # Add a separator
- def addSeparator(self, parent):
- pass
-
- # Enable a menu item
- def enableItem(self, item):
- pass
-
- # Disable a menu item
- def disableItem (self, item):
- pass
-
-
- # ---------------------------------------------------------------------------
- # Disable the menu bar
- # ---------------------------------------------------------------------------
-
- def disable (self):
-
- self.enabled = 0
-
-
- # ---------------------------------------------------------------------------
- # Finalize the menu creation
- # ---------------------------------------------------------------------------
-
- def finalize (self):
-
- if self.enabled:
- # Let specific drivers create themselves
- m = self.init ()
-
- self.__createmenu (_DEFAULT_MENU, m)
-
-
- # ---------------------------------------------------------------------------
- # Fire menu item
- # ---------------------------------------------------------------------------
-
- def _fire(self, userAction):
-
- self.form.event_begin()
- try:
- event = "request%s" % userAction.event
- self.driver.dispatchEvent (event, _form = self.form)
- finally:
- self.form.event_end()
-
-
- # ---------------------------------------------------------------------------
- # Create a menu item
- # ---------------------------------------------------------------------------
-
- def __createmenu (self, contents, parent):
-
- for item in contents:
- if item is None:
- self.addSeparator (parent)
- else:
- name, contents = item
- if isinstance (contents, str):
- userAction = UserActions.userActionMap [contents]
- self.__actionMap [userAction.event] = self.addAction (name, parent,
- userAction)
- self.driver.registerEventListeners ( \
- {'can%s' % userAction.event: self.__canRequestEvent,
- 'cannot%s' % userAction.event: self.__cannotRequestEvent})
- else:
- m = self.addMenu (name, parent)
- self.__createmenu (contents, m)
-
-
- # ---------------------------------------------------------------------------
- # Default event listener for 'enabling' a menu item
- # ---------------------------------------------------------------------------
-
- def __canRequestEvent (self, event):
-
- item = self.__actionMap [event.__event__ [3:]]
- self.enableItem (item)
-
-
- # ---------------------------------------------------------------------------
- # Default event listener for 'disabling' a menu item
- # ---------------------------------------------------------------------------
-
- def __cannotRequestEvent (self, event):
-
- item = self.__actionMap [event.__event__ [6:]]
- self.disableItem (item)
-
-
-# =============================================================================
-# Default menu definition
-# =============================================================================
-
-_DEFAULT_MENU = (
- ( u_('&File'), (
- (u_('&Save Changes'), "COMMIT"),
- (u_('&Revert Changes'), "ROLLBACK"),
- None,
- (u_('&Print'), "PRINTOUT"),
- None,
- (u_('&Close'), "EXIT") ) ),
-
- ( u_('&Edit'), (
- (u_('C&ut'), "CUT"),
- (u_('&Copy'), "COPY"),
-#TODO: POST 0.5.0# ('C&opy Special', (
-#TODO: POST 0.5.0# ('&Record as Text', 'COPYRECORD'),
-#TODO: POST 0.5.0# ('&Screen as Text', 'COPYSCREEN' ) ) ),
- (u_('&Paste'), "PASTE"),
- (u_('Select &All'), "SELECTALL"),
- None,
- (u_('&Insert New Record'),"NEWRECORD"),
- None,
- (u_('&Delete Current Record'),'MARKFORDELETE'),
- (u_('&Undelete Current Record'),'UNDELETE') ) ),
-
- ( u_('&Navigation'), (
- (u_('&Next Entry'), "NEXTENTRY"),
- (u_('&Previous Entry'), "PREVENTRY"),
- None,
- (u_('Next &Record'), "NEXTRECORD"),
- (u_('Previous R&ecord'), "PREVRECORD"),
- (u_('&First Record'), 'FIRSTRECORD'),
- (u_('&Last Record'), 'LASTRECORD'),
- (u_('&Go to record...'), 'JUMPPROMPT'),
- None,
- (u_('Next &Block'), 'NEXTBLOCK'),
- (u_('Previous Bl&ock'), 'PREVBLOCK'),
- None,
- (u_('Next P&age'), 'NEXTPAGE'),
- (u_('Pre&vious Page'), 'PREVPAGE') ) ),
-
- ( u_('&Search'), (
- (u_('Enter Query Mode'), "ENTERQUERY"),
- (u_('Cancel Query Mode'), "CANCELQUERY"),
- None,
- (u_('Repeat Last Query'), "COPYQUERY"),
- None,
- (u_('Perform Query'), "EXECQUERY") ) ),
-
- ( u_('&Help'), (
-#TODO: POST 0.5.0# (_('Keystrokes...'), "HELPKEYS"),
- (u_('About...'), "ABOUT"), ) ),
- )
-
Deleted: trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py 2007-04-23
14:22:02 UTC (rev 9505)
+++ trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py 2007-04-24
12:33:38 UTC (rev 9506)
@@ -1,198 +0,0 @@
-# GNU Enterprise Forms - Common UI Toolkit - Generic Toolbar
-#
-# 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: $
-
-from gnue.common.apps.i18n import utranslate as u_ # for epydoc
-from gnue.forms.uidrivers._base import UserActions
-
-# =============================================================================
-# a generic toolbar
-# =============================================================================
-
-class ToolBar:
-
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
-
- def __init__ (self, uidriver, container, form):
-
- self.driver = uidriver
- self.container = container
- self.form = form
- self.enabled = 1
- self.__actionMap = {}
-
- self.finalize ()
-
-
- ####################################################################
- #
- # These methods should be superclassed
- # by the toolkit-specific ToolBar
- #
-
- def init(self):
- pass
-
- # Add a menu item (action)
- def addAction(self, name, parent, userAction):
- pass
-
- # Add a separator
- def addSeparator(self, parent):
- pass
-
- # Enable a menu item
- def enableItem(self, item):
- pass
-
- # Disable a menu item
- def disableItem(self, item):
- pass
-
- def startingItem(self, item):
- pass
-
- def endingItem(self, item):
- pass
-
-
- ####################################################################
- #
- # These methods should not be touched
- # by the toolkit-specific ToolBar.
- #
- # Or, in the words of the great poet,
- # M.C. Hammer, "Can't touch this!"
- #
-
- def disable(self):
- self.enabled = 0
-
- def finalize(self):
- if self.enabled:
-
- # Let specific drivers create themselves
- self.init ()
-
- for item in _DEFAULT_TOOLBAR:
- if item == None:
- self.addSeparator ()
- else:
- name, contents = item
- userAction = UserActions.userActionMap [contents]
- button = self.addAction(name, userAction)
- button.__action = userAction
- button.__press_enabled = False
- button.__toggle_enabled = False
- self.__actionMap[userAction.event] = button
- eventListeners = {
- 'can%s' % userAction.event: self.__canRequestEvent,
- 'cannot%s' % userAction.event: self.__cannotRequestEvent}
-
- if userAction.canToggle:
- userAction = UserActions.userActionMap [userAction.canToggle]
- self.__actionMap[userAction.event] = button
- eventListeners.update({
- 'can%s' % userAction.event: self.__canRequestEvent,
- 'cannot%s' % userAction.event: self.__cannotRequestEvent})
-
- self.driver.registerEventListeners (eventListeners)
-
- # ---------------------------------------------------------------------------
- # Fire tool bar item
- # ---------------------------------------------------------------------------
-
- def _fire(self, userAction, toggle):
-
- self.form.event_begin()
- try:
- if toggle:
- event = "request%s" % userAction.canToggle
- else:
- event = "request%s" % userAction.event
- self.driver.dispatchEvent (event, _form = self.form)
- finally:
- self.form.event_end()
-
-
- def __canRequestEvent(self, event):
- e = event.__event__[3:]
- item = self.__actionMap[e]
- if e == item.__action.canToggle:
- item.__toggle_enabled = True
- if not item.__press_enabled:
- self.enableItem(item)
- self.startingItem(item)
- else:
- item.__press_enabled = True
- if item.__toggle_enabled:
- self.endingItem(item)
- else:
- self.enableItem(item)
- # Usually, the button should already be displayed as not pressed
- # in. We pull it out nevertheless in case it was presssed in by the
- # user and the action caused by that did raise an exception.
- self.endingItem(item)
-
- def __cannotRequestEvent(self, event):
- e = event.__event__[6:]
- item = self.__actionMap[e]
- if e == item.__action.canToggle:
- item.__toggle_enabled = False
- if not item.__press_enabled:
- self.endingItem(item)
- self.disableItem(item)
- else:
- item.__press_enabled = False
- if item.__toggle_enabled:
- self.startingItem(item)
- else:
- self.disableItem(item)
-
-
-
-####################################################################
-#
-#
-
-_DEFAULT_TOOLBAR = (
- (u_('Save Changes'), "COMMIT"),
- # (u_('Edit Current Record'),'ENTEREDIT'),
- None,
- (u_('Insert New Record'),"NEWRECORD"),
- (u_('Delete Current Record'),'MARKFORDELETE'),
- None,
- (u_('First Record'), 'FIRSTRECORD'),
- (u_('Previous Record'), "PREVRECORD"),
- (u_('Next Record'), "NEXTRECORD"),
- (u_('Last Record'), 'LASTRECORD'),
- (u_('Go to record...'), 'JUMPPROMPT'),
- None,
- (u_('Enter Search Mode'), "ENTERQUERY"),
- (u_('Perform Search'), "EXECQUERY"),
- (u_('Print Form'), "PRINTOUT"),
- None,
- (u_('Revert Changes'), "ROLLBACK"),
- None,
- (u_('Close'), "EXIT") )
Deleted: trunk/gnue-forms/src/uidrivers/html/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/MenuBar.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/html/MenuBar.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -1,108 +0,0 @@
-#
-# 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.
-#
-# Copyright 2000-2007 Free Software Foundation
-#
-# FILE:
-# uidrivers/html/MenuBar.py
-#
-# DESCRIPTION:
-#
-# NOTES:
-#
-
-from gnue.forms.uidrivers._commonGuiToolkit.MenuBar import MenuBar as
_BaseMenuBar
-from gnue.forms.uidrivers.html.widgets._base import HtmlWidget
-from gnue.forms.uidrivers.html.common import getNextId
-
-class MenuBar(_BaseMenuBar):
-
- # Create the menu
- def init(self):
- self.container.MenuBar = self
- self.menu = MenuWidget(self.container, self.driver, 'MENU', "",
getNextId())
- self.lastsubmenu = None
-
-
- def get_html(self):
- # TODO: add HTML caching
- return self.menu.get_html()
-
- # Add a (sub)menu
- def addMenu(self, name, parent):
- self.lastsubmenu = MenuWidget(self.menu, self.driver, 'SUBMENU', "",
getNextId())
- self.lastsubmenu.name = name.replace('&','')
- return self.lastsubmenu
-
- # Add a menu item (action)
- def addAction(self, name, parent, userAction):
- if self.lastsubmenu!=None:
- item = MenuWidget(self.lastsubmenu, self.driver, 'MENUITEM', "",
getNextId())
- item.name = name.replace('&','')
- item.action = userAction
-
- return item
-
- # Add a separator
- def addSeparator(self, parent):
- if self.lastsubmenu!=None:
- item = MenuWidget(self.lastsubmenu, self.driver, 'SEPARATOR', "",
getNextId())
-
- # Enable a menu item
- def enableItem(self, item):
- item.set_sensitive(True)
-
- # Disable a menu item
- def disableItem(self, item):
- item.set_sensitive(False)
-
-
-class MenuWidget(HtmlWidget):
-
- def get_html(self):
- if self._type == "MENU":
- self.dhtml=u""
- # add submenu code
- for child in self._children:
- self.dhtml += child.get_html()
- self.dhtml += u'<div dojoType="MenuBar2">'
- for child in self._children:
- self.dhtml += (u'<div dojoType="MenuBarItem2" '+\
- u'caption="%s" submenuId="%s"></div>') % \
- (child.name, child._id)
- self.dhtml += u'</div>'
- return self.dhtml
- elif self._type == "SUBMENU":
- self.dhtml = u'<div dojoType="PopupMenu2" '+\
- u'widgetId="%s" id="%s">\n' % (self._id,self._id)
- for child in self._children:
- self.dhtml += child.get_html()
- self.dhtml += u'</div>'
- return self.dhtml
- elif self._type == "MENUITEM":
- event = "request%s" % self.action.event
- self.dhtml = (u'<div dojoType="MenuItem2" caption="%s"' +\
- u' onClick="sendCmd(\'event\',\'id=%s&event=%s\');"'
+\
- u' id="%s" widgetId="%s"%s></div>') % \
- (self.name, self._id, event, self._id, self._id, \
- self._disabled and ' disabled="True"' or "")
-
- return self.dhtml
- elif self._type == "SEPARATOR":
- # TODO add seperator
- return u'<div dojoType="MenuSeparator2"></div>'
Deleted: trunk/gnue-forms/src/uidrivers/html/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/ToolBar.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/html/ToolBar.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -1,101 +0,0 @@
-#
-# 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.
-#
-# Copyright 2000-2007 Free Software Foundation
-#
-# FILE:
-# uidrivers/html/ToolBar.py
-#
-# DESCRIPTION:
-#
-# NOTES:
-#
-
-from gnue.forms.uidrivers.html.widgets._base import HtmlWidget
-from gnue.forms.uidrivers.html.common import getNextId
-from gnue.forms.uidrivers.html.Generator import *
-from gnue.forms.uidrivers._commonGuiToolkit.ToolBar import ToolBar as
_BaseToolBar
-from gnue.common.apps import GConfig
-
-_iconpath = GConfig.getInstalledBase('form_images', 'common_images')
-
-class ToolBar(_BaseToolBar):
-
- # Create the menu
- def init(self):
- self.container.ToolBar = self
- self.widget = ToolbarWidget(self.container, self.driver, 'TOOLBAR',
"", getNextId())
-
- # Add a menu item (action)
- def addAction(self, name, userAction):
- iconloc = userAction.getIconLocation(size="24x24")
-
- # make iconloc relative to iconpath
- iconloc = iconloc[len(_iconpath)+1:].replace("\\","/")
-
- id = getNextId()
- event = 'request' + userAction.event
- label = name
- tooltip = userAction.description
- toggleItem = userAction.canToggle
-
- # create correct event string, in case toolbutton can toggle
- if toggleItem:
- toggleItem = 'request' + toggleItem
-
- dhtml = build_toolbar_button(id, label, event, "/icon/%s" % iconloc,
tooltip, toggleItem, "%s")
- return ToolbarWidget(self.widget, self.driver, 'TOOLBUTTON', dhtml, id)
-
- def get_html(self):
- return self.widget.get_html()
-
- # Add a separator
- def addSeparator(self):
- id = getNextId()
- dhtml = build_toolbar_separator(id)
- return ToolbarWidget(self.widget, self.driver, 'SEPARATOR', dhtml, id)
-
- # Enable a menu item
- def enableItem(self, item):
- item.set_sensitive(True)
-
- # Disable a menu item
- def disableItem(self, item):
- item.set_sensitive(False)
-
- def startingItem(self, item):
- item.set_active(True)
-
- def endingItem(self, item):
- item.set_active(False)
-
-class ToolbarWidget(HtmlWidget):
-
- def get_html(self):
-
- if self._type == "TOOLBAR":
- dhtml = u""
- for child in self._children:
- dhtml += child.get_html()
- return build_toolbar("toolbar",dhtml)
-
- elif self._type == "TOOLBUTTON":
- return self.dhtml % (self._disabled and ' disabled="True"' or "")
-
- elif self._type == "SEPARATOR":
- return self.dhtml
Modified: trunk/gnue-forms/src/uidrivers/html/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/widgets/form.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/html/widgets/form.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -29,8 +29,8 @@
import string, struct
from gnue.forms.uidrivers.html.widgets._base import UIHelper, HtmlWidget
-from gnue.forms.uidrivers.html.MenuBar import MenuBar
-from gnue.forms.uidrivers.html.ToolBar import ToolBar
+# from gnue.forms.uidrivers.html.MenuBar import MenuBar
+# from gnue.forms.uidrivers.html.ToolBar import ToolBar
from gnue.forms.uidrivers.html.common import *
@@ -66,12 +66,12 @@
self.mainWindow.updates = []
# Add the menu
- if not self._form._features['GUI:MENUBAR:SUPPRESS']:
- MenuBar(self._uiDriver, self.mainWindow, self._form)
+ # if not self._form._features['GUI:MENUBAR:SUPPRESS']:
+ # MenuBar(self._uiDriver, self.mainWindow, self._form)
# and the Toolbar
- if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
- ToolBar(self._uiDriver, self.mainWindow, self._form)
+ # if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+ # ToolBar(self._uiDriver, self.mainWindow, self._form)
dhtml = "<hr/>"
HtmlWidget(self.mainWindow, self._uiDriver, 'LINE', dhtml, getNextId())
@@ -219,4 +219,4 @@
'baseClass' : UIForm,
'provides' : 'GFForm',
'container' : 1,
- }
\ No newline at end of file
+ }
Deleted: trunk/gnue-forms/src/uidrivers/qt4/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt4/MenuBar.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/qt4/MenuBar.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -1,141 +0,0 @@
-# GNU Enterprise Forms - qt4 UI driver - MenuBar
-#
-# 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$
-"""
-Menu bar
-"""
-
-from PyQt4 import Qt as qt
-from gnue.forms.uidrivers._commonGuiToolkit import MenuBar as _Base
-
-_ICON_CACHE = {}
-
-# =============================================================================
-# Implementation of the menu bar for qt4
-# =============================================================================
-
-class MenuBar(_Base.MenuBar):
-
- # -------------------------------------------------------------------------
- # Constructor
- # -------------------------------------------------------------------------
-
- def init(self):
- self.menubar = self.container.menuBar()
- self.__actions = []
- return self.menubar
-
- # -------------------------------------------------------------------------
- # Add a sub menu
- # -------------------------------------------------------------------------
-
- def addMenu(self, name, parent):
- """
- Add another menu to the given parent menu or menubar
-
- @param name: name of the menu
- @param parent: parent menu or menubar to append the new menu to
-
- @result: newly created menu
- """
-
- menu = qt.QMenu(name, parent)
- parent.addMenu(menu)
-# qt.QObject.connect(menu, qt.SIGNAL('activated(int)'),
-# self.__item_selected)
- return menu
-
-
- # -------------------------------------------------------------------------
- # Add an action
- # -------------------------------------------------------------------------
-
- def addAction(self, name, parent, userAction):
- """
- Add a new menu item to a given menu.
-
- @param name: name of the menu item
- @param parent: menu to add this new item to
- @param userAction: userAction instance representing the new menu item
-
- @returns: the newly created menu item
- """
-
- iconloc = userAction.getIconLocation(size="16x16")
- label = name
-
- # Set the action icon if available
- if iconloc:
- icon = _ICON_CACHE.setdefault(iconloc,
- qt.QIcon(qt.QPixmap(iconloc)))
- mid = parent.addAction(icon, label)
- else:
- mid = parent.addAction(label)
-
- hotkey = userAction.getHotKeyText({'PAGEDOWN': 'PgDown'})
- if hotkey:
- mid.setShortcut(qt.QKeySequence(hotkey))
-
- mid.setWhatsThis(userAction.description or '')
-
- handler = event_proxy(self._fire, userAction)
- # We're keeping a list of actions so GC won't delete them
- self.__actions.append(handler)
-
- qt.QObject.connect(mid, qt.SIGNAL('triggered()'),
- handler)
-
- return (parent, mid)
-
- # -------------------------------------------------------------------------
- # Add a separator
- # -------------------------------------------------------------------------
- def addSeparator(self, parent):
- parent.addSeparator()
-
-
- # -------------------------------------------------------------------------
- # Enable a menu item
- # -------------------------------------------------------------------------
-
- def enableItem(self, item):
- parent, mid = item
- mid.setEnabled(True)
-
-
- # -------------------------------------------------------------------------
- # Disable a menu item
- # -------------------------------------------------------------------------
-
- def disableItem(self, item):
- parent, mid = item
- mid.setEnabled(False)
-
-
-class event_proxy(object):
- def __init__(self, method, arg):
- self.method = method
- self.arg = arg
-
- def __call__(self):
- print "foo"
- self.method(self.arg)
Deleted: trunk/gnue-forms/src/uidrivers/qt4/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt4/ToolBar.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/qt4/ToolBar.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -1,164 +0,0 @@
-# GNU Enterprise Forms - qt4 UI driver - ToolBar
-#
-# 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$
-
-from PyQt4 import Qt as qt
-
-from gnue.forms.uidrivers._commonGuiToolkit import ToolBar as _Base
-
-__all__ = ['ToolBar']
-
-_ICON_CACHE = {}
-
-# =============================================================================
-# ToolBar widget
-# =============================================================================
-
-class ToolBar(_Base.ToolBar):
- """
- Implementation of the qt4 tool bar
- """
-
- # -------------------------------------------------------------------------
- # Initialize the toolbar
- # -------------------------------------------------------------------------
-
- def init(self):
- """
- Create a new tool bar
- @returns: the QToolBar instance
- """
-
- self.toolbar = qt.QToolBar(u_("Forms Toolbar"), self.container)
- self.container.addToolBar(self.toolbar)
- self.toolbar.show()
- return self.toolbar
-
-
- # -------------------------------------------------------------------------
- # Add a menu item (action)
- # -------------------------------------------------------------------------
-
- def addAction(self, name, userAction):
- """
- Add an action to the toolbar
-
- @param name: name of the action
- @param userAction: userAction instance representing the action to add
- """
-
- action = Action(self, name, userAction)
- return action
-
-
- # -------------------------------------------------------------------------
- # Add a separator
- # -------------------------------------------------------------------------
-
- def addSeparator(self):
- self.toolbar.addSeparator()
-
-
- # -------------------------------------------------------------------------
- # Enable a menu item
- # -------------------------------------------------------------------------
-
- def enableItem(self, item):
- item.setEnabled(True)
-
- # -------------------------------------------------------------------------
- # Disable a menu item
- # -------------------------------------------------------------------------
-
- def disableItem(self, item):
- item.setEnabled(False)
-
- # -------------------------------------------------------------------------
- # Set a toggle action to 'on'
- # -------------------------------------------------------------------------
-
- def startingItem(self, item):
- item.setChecked(True)
-
- # -------------------------------------------------------------------------
- # Set a toggle action to 'off'
- # -------------------------------------------------------------------------
-
- def endingItem(self, item):
- item.setChecked(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.toolbar)
-
- 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.QIcon(qt.QPixmap(iconloc)))
- self.setIcon(icon)
- else:
- print u_("** WARNING: Cannot add '%s' to toolbar; no icon") \
- % user_action.event
-
- self.setText(name)
- if user_action.canToggle:
- self.setCheckable(True)
-
- self.setToolTip(user_action.description or '')
-
- self.connect(self, qt.SIGNAL('activated()'), self.__activated)
-
- parent.toolbar.addAction(self)
-
- # -------------------------------------------------------------------------
- # 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)
Modified: trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py 2007-04-23 14:22:02 UTC
(rev 9505)
+++ trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py 2007-04-24 12:33:38 UTC
(rev 9506)
@@ -29,8 +29,8 @@
from gnue.common.apps import GConfig
from gnue.forms.uidrivers.qt4 import dialogs, QTApp
-from gnue.forms.uidrivers.qt4.MenuBar import MenuBar
-from gnue.forms.uidrivers.qt4.ToolBar import ToolBar
+# from gnue.forms.uidrivers.qt4.MenuBar import MenuBar
+# from gnue.forms.uidrivers.qt4.ToolBar import ToolBar
from gnue.forms.uidrivers.qt4.widgets._base import UIHelper
# =============================================================================
@@ -106,11 +106,11 @@
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._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)
+ # if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+ # tlb = ToolBar(self._uiDriver, self.main_window, self._form)
if self._form._layout.tabbed != 'none':
self._container = qt.QTabWidget(self.main_widget)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9506 - in trunk/gnue-forms/src/uidrivers: _commonGuiToolkit html html/widgets qt4 qt4/widgets,
reinhard <=