[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8136 - in trunk/gnue-forms/src: . input uidrivers uidrivers/_com
From: |
johannes |
Subject: |
[gnue] r8136 - in trunk/gnue-forms/src: . input uidrivers uidrivers/_commonGuiToolkit uidrivers/wx26 uidrivers/wx26/widgets |
Date: |
Thu, 26 Jan 2006 08:26:21 -0600 (CST) |
Author: johannes
Date: 2006-01-26 08:26:19 -0600 (Thu, 26 Jan 2006)
New Revision: 8136
Added:
trunk/gnue-forms/src/uidrivers/wx26/
trunk/gnue-forms/src/uidrivers/wx26/MenuBar.py
trunk/gnue-forms/src/uidrivers/wx26/ToolBar.py
trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py
trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx26/__init__.py
trunk/gnue-forms/src/uidrivers/wx26/dialogs.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/
trunk/gnue-forms/src/uidrivers/wx26/widgets/__init__.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/input/GFKeyMapper.py
trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py
trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py
Log:
Added new UI driver for wx 2.6+
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-01-21 16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/GFForm.py 2006-01-26 14:26:19 UTC (rev 8136)
@@ -181,6 +181,7 @@
}
self._in_trigger_lock = False
+ self._form = self
#---------------------------------------------------------------------------
# Called during phaseInit startup by GParser.
@@ -1396,16 +1397,17 @@
@param modal: whether the dialog should be modal or not
@return: None
"""
- userParameters = CaselessDict.CaselessDict ()
- for (k, v) in parameters.items():
+ userParameters = CaselessDict.CaselessDict ()
+ for (k, v) in parameters.items ():
userParameters [k] = v
- # No longer used?
- #if dialogName == '_about':
- # self._instance._uiinstance.showAbout (**parameters)
- #else:
- self._instance.activateForm (dialogName, userParameters, modal)
+ # Keep this to allow calling of about-box from trigger namespace
+ if dialogName == '_about':
+ self._instance._uiinstance.showAbout (**parameters)
+ else:
+ self._instance.activateForm (dialogName, userParameters, modal)
+
#---------------------------------------------------------------------------
# Close this copy of gnue-forms
#---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/input/GFKeyMapper.py
===================================================================
--- trunk/gnue-forms/src/input/GFKeyMapper.py 2006-01-21 16:20:53 UTC (rev
8135)
+++ trunk/gnue-forms/src/input/GFKeyMapper.py 2006-01-26 14:26:19 UTC (rev
8136)
@@ -217,15 +217,15 @@
try:
return (self._translatedUserKeyMap[(basekey, shift, ctrl, meta)], None)
except KeyError:
- if (ctrl or meta):
+ if (ctrl or meta) and basekey < 255:
actionText = ""
- if ctrl:
+ if ctrl and basekey < 64:
basekey += 64 # TODO: Need a real way to get the key pressed when
# control is depressed
actionText += ctrl and 'CTRL-' or ''
actionText += meta and 'ALT-' or ''
- actionText += '%s' % chr(basekey).upper()
+ actionText += '%s' % chr (basekey).upper ()
return ("USERCOMMAND", actionText)
else:
return (None,None)
Modified: trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/MenuBar.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - Common GUI Toolkit - Menubar
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 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
@@ -16,45 +19,47 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# MenuBar.py
-#
-# DESCRIPTION:
-# A generic UIdriver base for common message-based GUI toolkits.
-#
-# NOTES:
-#
+# $Id: $
-import string
-from types import StringType
-
from gnue.forms.uidrivers._base import UserActions
+
+# =============================================================================
+# Base class for menu bars
+# =============================================================================
+
class MenuBar:
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
- ####################################################################
- #
- # These methods should be superclassed
- # by the toolkit-specific MenuBar
- #
-
+ 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):
+ def init (self):
pass
# Add a (sub)menu
- def addMenu(self, name, parent):
+ def addMenu (self, name, parent):
pass
# Add a menu item (action)
- def addAction(self, name, parent, userAction):
+ def addAction (self, name, parent, userAction):
pass
# Add a separator
- def addSeparator(self, parent):
+ def addSeparator(self, parent):
pass
# Enable a menu item
@@ -62,72 +67,81 @@
pass
# Disable a menu item
- def disableItem(self, item):
+ def disableItem (self, item):
pass
- ####################################################################
- #
- # These methods should not be touched
- # by the toolkit-specific MenuBar.
- #
- # Or, in the words of the great poet,
- # M.C. Hammer, "Can't touch this!"
- #
-
- def __init__(self, uidriver, container, form):
- self.driver = uidriver
- self.container = container
- self.form = form
- self.enabled = 1
- self.__actionMap = {}
-
- self.finalize()
-
- def disable(self):
+ # ---------------------------------------------------------------------------
+ # Disable the menu bar
+ # ---------------------------------------------------------------------------
+
+ def disable (self):
+
self.enabled = 0
- def finalize(self):
- if self.enabled:
+ # ---------------------------------------------------------------------------
+ # Finalize the menu creation
+ # ---------------------------------------------------------------------------
+
+ def finalize (self):
+
+ if self.enabled:
# Let specific drivers create themselves
- m = self.init()
+ m = self.init ()
- self.__createmenu(_DEFAULT_MENU,m)
+ self.__createmenu (_DEFAULT_MENU, m)
- def __createmenu(self, contents, parent):
+ # ---------------------------------------------------------------------------
+ # Create a menu item
+ # ---------------------------------------------------------------------------
+
+ def __createmenu (self, contents, parent):
+
for item in contents:
- if item == None:
- self.addSeparator(parent)
+ if item is None:
+ self.addSeparator (parent)
else:
name, contents = item
- if type(contents) == StringType:
- 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)
+ 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)
- def __canRequestEvent(self, event):
- item = self.__actionMap[event.__event__[3:]]
- self.enableItem(item)
- def __cannotRequestEvent(self, event):
- item = self.__actionMap[event.__event__[6:]]
- self.disableItem(item)
+ # ---------------------------------------------------------------------------
+ # 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"),
@@ -144,7 +158,7 @@
#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"),
+ (u_('Select &All'), "SELECTALL"),
None,
(u_('&Insert New Record'),"NEWRECORD"),
None,
@@ -169,8 +183,8 @@
( u_('&Search'), (
(u_('Enter Query Mode'), "ENTERQUERY"),
- (u_('Cancel Query Mode'), "CANCELQUERY"),
- None,
+ (u_('Cancel Query Mode'), "CANCELQUERY"),
+ None,
(u_('Repeat Last Query'), "COPYQUERY"),
None,
(u_('Perform Query'), "EXECQUERY") ) ),
Modified: trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/_commonGuiToolkit/ToolBar.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - Common UI Toolkit - Generic Toolbar
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 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
@@ -16,25 +19,31 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# ToolBar.py
-#
-# DESCRIPTION:
-# A generic UIdriver base for common message-based GUI toolkits.
-#
-# NOTES:
-#
+# $Id: $
-import string
-from types import StringType
-
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
@@ -76,15 +85,6 @@
# M.C. Hammer, "Can't touch this!"
#
- def __init__(self, uidriver, container, form):
- self.driver = uidriver
- self.container = container
- self.form = form
- self.enabled = 1
- self.__actionMap = {}
-
- self.finalize()
-
def disable(self):
self.enabled = 0
@@ -92,14 +92,14 @@
if self.enabled:
# Let specific drivers create themselves
- self.init()
+ self.init ()
for item in _DEFAULT_TOOLBAR:
if item == None:
- self.addSeparator()
+ self.addSeparator ()
else:
name, contents = item
- userAction = UserActions.userActionMap[contents]
+ userAction = UserActions.userActionMap [contents]
self.__actionMap[userAction.event] = self.addAction(name, userAction)
eventListeners = {
'can%s' % userAction.event: self.__canRequestEvent,
@@ -110,7 +110,7 @@
'begin%s' % userAction.event: self.__beginRequestEvent,
'end%s' % userAction.event: self.__endRequestEvent } )
- self.driver.registerEventListeners(eventListeners)
+ self.driver.registerEventListeners (eventListeners)
def __canRequestEvent(self, event):
item = self.__actionMap[event.__event__[3:]]
@@ -159,4 +159,3 @@
(u_('Revert Changes'), "ROLLBACK"),
None,
(u_('Close'), "EXIT") )
-
Property changes on: trunk/gnue-forms/src/uidrivers/wx26
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Added: trunk/gnue-forms/src/uidrivers/wx26/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/MenuBar.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/MenuBar.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,143 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Menubar
+#
+# Copyright 2001-2006 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._commonGuiToolkit import MenuBar as _Base
+
+# =============================================================================
+# Constants
+# =============================================================================
+
+_ICON_CACHE = {}
+
+# =============================================================================
+# Implementation of a Menubar using wx 2.6
+# =============================================================================
+
+class MenuBar (_Base.MenuBar):
+
+
+ # ---------------------------------------------------------------------------
+ # Create the main menu
+ # ---------------------------------------------------------------------------
+
+ def init (self):
+ """
+ Create a new menu bar and attach it to the bound container
+
+ @return: the wx.MenuBar instance created
+ """
+
+ self.menubar = wx.MenuBar ()
+ self.container.SetMenuBar (self.menubar)
+
+ return self.menubar
+
+
+ # ---------------------------------------------------------------------------
+ # Add a new menu to a given parent
+ # ---------------------------------------------------------------------------
+
+ 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
+ """
+
+ result = wx.Menu ()
+ if parent == self.menubar:
+ parent.Append (result, name)
+ else:
+ parent.AppendMenu (wx.ID_ANY, name, result)
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Add a menu item to a given menu
+ # ---------------------------------------------------------------------------
+
+ 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
+ """
+
+ hotkey = userAction.getHotKeyText ()
+ iconloc = userAction.getIconLocation (size = "16x16")
+ label = hotkey and "%s\t%s" % (name, hotkey) or name
+ help = userAction.description
+
+ result = wx.MenuItem (parent, wx.ID_ANY, label, help)
+
+ if iconloc:
+ icon = _ICON_CACHE.setdefault (iconloc, wx.Image (iconloc,
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap ())
+
+ result.SetBitmap (icon)
+
+ event = 'request' + userAction.event
+ wx.EVT_MENU (wx.GetApp (), result.GetId (), \
+ lambda event, l = self.driver, e = event, f = self.form: \
+ l.dispatchEvent (e, _form = f))
+
+ parent.AppendItem (result)
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Add a separator to the given parent menu
+ # ---------------------------------------------------------------------------
+
+ def addSeparator (self, parent):
+
+ parent.AppendSeparator ()
+
+
+ # ---------------------------------------------------------------------------
+ # Enable a given menu item
+ # ---------------------------------------------------------------------------
+
+ def enableItem (self, item):
+
+ item.Enable (True)
+
+
+ # ---------------------------------------------------------------------------
+ # Disable a given menu item
+ # ---------------------------------------------------------------------------
+
+ def disableItem (self, item):
+
+ item.Enable (False)
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/MenuBar.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/ToolBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/ToolBar.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/ToolBar.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,193 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Toolbar
+#
+# Copyright 2001-2006 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._commonGuiToolkit import ToolBar as _Base
+
+# =============================================================================
+# Constants
+# =============================================================================
+
+_ICON_CACHE = {}
+
+
+# =============================================================================
+# Toolbar widget
+# =============================================================================
+
+class ToolBar (_Base.ToolBar):
+ """
+ wx 2.6 implementation of the generic toolbar.
+ """
+
+
+ # ---------------------------------------------------------------------------
+ # Create the toolbar
+ # ---------------------------------------------------------------------------
+
+ def init (self):
+ """
+ Create a new toolbar.
+
+ @returns: the newly created toolbar
+ """
+
+ self.toolbar = self.container.CreateToolBar ()
+ self.toolbar.SetToolBitmapSize ((24, 24))
+
+ return self.toolbar
+
+
+ # ---------------------------------------------------------------------------
+ # Add an action to the toolbar
+ # ---------------------------------------------------------------------------
+
+ 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
+
+ @returns: wx.ToolBarBaseTool instance with the added tool
+ """
+
+ label = name
+ iconloc = userAction.getIconLocation (size = "24x24")
+ event = 'request%s' % userAction.event
+
+ if iconloc:
+ icon = _ICON_CACHE.setdefault (iconloc, wx.Image (iconloc,
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap ())
+
+ else:
+ print u_("** WARNING: Cannot add '%s' to toolbar; no icon") \
+ % userAction.event
+ return
+
+ descr = userAction.description and userAction.description or ''
+ flags = userAction.canToggle and 1 or 0
+
+ result = self.toolbar.AddSimpleTool (wx.ID_ANY, icon, descr, isToggle =
+ flags)
+ result.SetClientData (userAction)
+
+ wx.EVT_TOOL (self.toolbar, result.GetId (), self.__clickEvent)
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Event processed on selecting a tool
+ # ---------------------------------------------------------------------------
+
+ def __clickEvent (self, event):
+
+ item = self.toolbar.FindById (event.GetId ())
+ action = item.GetClientData ()
+
+ tEvent = 'request%s' % action.event
+
+ if action.canToggle:
+ if not self.toolbar.GetToolState (item.GetId ()):
+ tEvent = 'request%s' % action.canToggle
+
+ self.driver.dispatchEvent (tEvent, _form = self.form)
+
+
+
+ # ---------------------------------------------------------------------------
+ # Finalize the toolbar creation process
+ # ---------------------------------------------------------------------------
+
+ def finalize (self):
+ """
+ After building the toolbar, make sure to realize all added tools
+ """
+
+ _Base.ToolBar.finalize (self)
+ self.toolbar.Realize ()
+
+
+ # ---------------------------------------------------------------------------
+ # Add a separator to the toolbar
+ # ---------------------------------------------------------------------------
+
+ def addSeparator (self):
+ """
+ Add a separator to the toolbar
+ """
+
+ self.toolbar.AddSeparator ()
+
+
+ # ---------------------------------------------------------------------------
+ # Enable toolbar item
+ # ---------------------------------------------------------------------------
+
+ def enableItem (self, item):
+ """
+ Enable a toolbar item
+ """
+
+ if item is not None:
+ self.toolbar.EnableTool (item.GetId (), True)
+
+ # ---------------------------------------------------------------------------
+ # Disable toolbar item
+ # ---------------------------------------------------------------------------
+
+ def disableItem (self, item):
+ """
+ Disable a toolbar item
+ """
+
+ if item is not None:
+ self.toolbar.EnableTool (item.GetId (), False)
+
+
+ # ---------------------------------------------------------------------------
+ # Check a toggle button
+ # ---------------------------------------------------------------------------
+
+ def startingItem (self, item):
+ """
+ Check a toogle item in the toolbar
+ """
+
+ if item is not None:
+ self.toolbar.ToggleTool (item.GetId (), True)
+
+
+ # ---------------------------------------------------------------------------
+ # Uncheck a toggle button
+ # ---------------------------------------------------------------------------
+
+ def endingItem (self, item):
+ """
+ Uncheck a toogle item in the toolbar
+ """
+
+ if item is not None:
+ self.toolbar.ToggleTool (item.GetId (), False)
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/ToolBar.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,69 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Login Handler
+#
+# Copyright 2001-2005 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 os.path
+import wx
+
+from gnue.common.datasources import GLoginHandler
+from gnue.common.apps import GConfig, i18n
+from gnue.forms.uidrivers.wx26 import dialogs
+
+
+# =============================================================================
+# This class implements a login handler for wx 2.6
+# =============================================================================
+
+class UILoginHandler (GLoginHandler.LoginHandler):
+
+ # ---------------------------------------------------------------------------
+ # Prompt for all fields
+ # ---------------------------------------------------------------------------
+
+ def __init__(self):
+
+ # Make sure to have an application instance available
+ self.app = wx.GetApp () or wx.App ()
+
+
+ def _askLogin_ (self, title, fields):
+
+ lfields = fields [:]
+ if lfields [0][2] != 'image':
+ imageFile = gConfigForms('loginPNG')
+ if not os.path.exists (imageFile):
+ imageFile = os.path.join (os.path.normpath ( \
+ GConfig.getInstalledBase ('forms_images', 'common_images')),
+ gConfigForms ('loginPNG'))
+
+ if os.path.exists (imageFile):
+ lfields.insert (0, (None, imageFile, 'image', None, None, []))
+
+ dialog = dialogs.InputDialog (title, lfields)
+
+ try:
+ dialog.ShowModal ()
+ result = dialog.inputData
+ finally:
+ dialog.Destroy ()
+
+ return result
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/UILoginHandler.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,264 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - User Interface
+#
+# Copyright 2001-2005 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.forms.uidrivers._base import Exceptions
+
+try:
+ import wx
+ if wx.VERSION [:2] < (2, 6):
+ raise ImportError
+
+except ImportError:
+ raise Exceptions.DriverNotSupported, \
+ _("This GNUe-Forms UI Driver requires at least wx 2.6.")
+
+from gnue.forms.uidrivers._commonGuiToolkit import UIdriver as commonToolkit
+from gnue.forms.uidrivers.wx26 import dialogs
+
+
+# =============================================================================
+# This class implements a User Interface for wx 2.6
+# =============================================================================
+
+class GFUserInterface (commonToolkit.GFUserInterface):
+ """
+ An implementation of the common GUI toolkit interface using wx 2.6+.
+ """
+
+ _WidgetToGFObj = {}
+ _WidgetToUIObj = {}
+
+ _MBOX_KIND = {'info' : {'type' : wx.ICON_INFORMATION,
+ 'buttons': wx.OK,
+ 'title' : u_("Information")},
+ 'warning' : {'type' : wx.ICON_EXCLAMATION,
+ 'buttons': wx.OK,
+ 'title' : u_("Warning")},
+ 'question': {'type' : wx.ICON_QUESTION,
+ 'buttons': wx.YES_NO,
+ 'title' : u_("Question")},
+ 'error' : {'type' : wx.ICON_ERROR,
+ 'buttons': wx.OK,
+ 'title' : u_("Error")}}
+
+ _RESPONSE = {wx.ID_OK : True,
+ wx.ID_YES : True,
+ wx.ID_NO : False,
+ wx.ID_CANCEL: None }
+
+
+ # ---------------------------------------------------------------------------
+ # Initialize the user interface
+ # ---------------------------------------------------------------------------
+
+ def _initialize (self):
+ """
+ Initialize the interface and determine the dimensions of a form-cell.
+ """
+
+ self.name = "wx 2.6"
+ self.app = wx.GetApp () or wx.App ()
+ (self.controlHeight, self.cellWidth, self.cellHeight) = self.__getSizes ()
+
+ self.textWidth = self.widgetWidth = self.cellWidth
+ self.textHeight = self.widgetHeight = self.cellHeight
+
+
+ # ---------------------------------------------------------------------------
+ # Get the widget sizes and the dimension of a form cell
+ # ---------------------------------------------------------------------------
+
+ def __getSizes (self):
+
+ frame = wx.Frame (None)
+ result = {}
+
+ try:
+ # First of all find out the preferred size of all widgets needed
+ label = wx.StaticText (frame, wx.ID_ANY)
+ result ['label'] = label.GetBestSize () [1]
+
+ text = wx.TextCtrl (frame, wx.ID_ANY)
+ result ['default'] = text.GetBestSize () [1]
+
+ combo = wx.ComboBox (frame, wx.ID_ANY)
+ result ['dropdown'] = combo.GetBestSize () [1]
+
+ check = wx.CheckBox (frame, wx.ID_ANY)
+ result ['checkbox'] = check.GetBestSize () [1]
+
+ button = wx.Button (frame, wx.ID_ANY)
+ result ['button'] = button.GetBestSize () [1]
+
+ # Get the height and width of a form-cell for which we use the tallest
+ # control and the avarage character width of the application font
+ cellHeight = max (result.values ()) + 1
+ cellWidth = frame.GetCharWidth () + 1
+
+ finally:
+ frame.Destroy ()
+
+ return (result, cellWidth, cellHeight)
+
+
+ # ---------------------------------------------------------------------------
+ # Close the main window
+ # ---------------------------------------------------------------------------
+
+ def _exit (self, formName):
+ """
+ Hide all forms with a given name. If no window is open anymore, close all
+ child windows.
+ """
+
+ assert gEnter (6)
+
+ exitApp = True
+
+ for child in self._children:
+ if child._form.name == formName:
+ child.mainWindow.Hide ()
+
+ exitApp = exitApp and not child.mainWindow.IsShown ()
+
+ if exitApp:
+ for child in self._children:
+ child.mainWindow.Close (True)
+
+ wx.GetApp ().ExitMainLoop ()
+
+ assert gLeave (6)
+
+
+ # ---------------------------------------------------------------------------
+ # Start the application's main loop
+ # ---------------------------------------------------------------------------
+
+ def mainLoop (self):
+ """
+ Start the main loop of the current application instance (wx.App ())
+ """
+
+ assert gEnter (6)
+
+ self.app.MainLoop ()
+
+ assert gLeave (6)
+
+
+ # ---------------------------------------------------------------------------
+ # create a modal message box
+ # ---------------------------------------------------------------------------
+
+ def _showMessage (self, message, kind = 'Info', title = None, cancel =
False):
+ """
+ This function creates a message box of a given kind and returns True, False
+ or None depending on the button pressed.
+
+ @param message: the text of the messagebox
+ @param kind: type of the message box. Valid types are 'Info', 'Warning',
+ 'Question', 'Error'
+ @param title: title of the message box
+ @param cancel: If True a cancel button will be added to the dialog
+
+ @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
+ No-button was pressed or None if the Cancel-button was pressed.
+ """
+
+ mbRec = self._MBOX_KIND.get (kind.lower ())
+ flags = mbRec ['type'] | mbRec ['buttons']
+ title = title and title or mbRec ['title']
+
+ dialog = wx.MessageDialog (None, message, title, flags)
+ try:
+ result = dialog.ShowModal ()
+
+ finally:
+ dialog.Destroy ()
+
+ return self._RESPONSE [result]
+
+
+ # ---------------------------------------------------------------------------
+ # Display an about box
+ # ---------------------------------------------------------------------------
+
+ def _showAbout (self, name, appversion, formversion, author, description):
+
+ dlg = dialogs.AboutBox (name, appversion, formversion, author, description)
+ try:
+ dlg.ShowModal ()
+
+ finally:
+ dlg.Destroy ()
+
+
+ # ---------------------------------------------------------------------------
+ # Show an exception dialog
+ # ---------------------------------------------------------------------------
+
+ def _showException (self, group, name, message, detail):
+
+ dlg = dialogs.ExceptionDialog (group, name, message, detail)
+ try:
+ dlg.ShowModal ()
+
+ finally:
+ dlg.Destroy ()
+
+
+ # ---------------------------------------------------------------------------
+ # Form alert
+ # ---------------------------------------------------------------------------
+
+ def formAlert (self, event):
+
+ self._beep ()
+ ui = self._gfObjToUIWidget [event._form]
+ if ui.statusBar is not None:
+ ui.statusBar.SetStatusText (event.data, 0)
+
+
+ # ---------------------------------------------------------------------------
+ # Ring the bell
+ # ---------------------------------------------------------------------------
+
+ def _beep (self):
+
+ wx.Bell ()
+
+
+ # ---------------------------------------------------------------------------
+ # Create and run an input dialog
+ # ---------------------------------------------------------------------------
+
+ def _getInput (self, title, fields, cancel = True):
+
+ dialog = dialogs.InputDialog (title, fields, cancel)
+
+ try:
+ dialog.ShowModal ()
+ return dialog.inputData
+
+ finally:
+ dialog.Destroy ()
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/__init__.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/__init__.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/__init__.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,25 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - User Interface
+#
+# Copyright 2001-2005 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 UIdriver import GFUserInterface
+from UILoginHandler import *
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/dialogs.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/dialogs.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/dialogs.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,638 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - UI specific dialogs
+#
+# Copyright 2001-2005 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 textwrap
+import wx
+
+from gnue.forms import VERSION
+from gnue.common.apps import GConfig
+
+
+# =============================================================================
+# This class implements an about dialog for the wx UI driver
+# =============================================================================
+
+class AboutBox (wx.Dialog):
+ """
+ Displays an about dialog for the current application as defined by the given
+ arguments.
+ """
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, name = "Unknown", appversion = VERSION,
+ formversion = "?", author = "Unknown", description = 'n/a'):
+ """
+ @param name: name of the application
+ @param appversion: version of the application (GNUe Forms)
+ @param formversion: version of the form
+ @param author: author of the form
+ @param description: text describing the form
+ """
+
+ title = u_("About %s") % name
+ wx.Dialog.__init__ (self, None, -1, title, size = wx.Size (400, 200))
+
+ self.SetIcon (wx.ArtProvider.GetIcon (wx.ART_INFORMATION,
+ wx.ART_FRAME_ICON))
+
+ topSizer = wx.BoxSizer (wx.VERTICAL)
+ innerSizer = wx.BoxSizer (wx.VERTICAL)
+
+ gfBox = wx.StaticBox (self, -1, ' GNUe Forms ')
+ gfBoxSizer = wx.StaticBoxSizer (gfBox, wx.VERTICAL)
+
+ gfFlex = wx.FlexGridSizer (2, 2, 4, 10)
+ gfFlex.Add (wx.StaticText (self, -1, u_("Version:")))
+ gfFlex.Add (wx.StaticText (self, -1, appversion))
+ gfFlex.Add (wx.StaticText (self, -1, u_("Driver:")))
+ gfFlex.Add (wx.StaticText (self, -1, "wx %s" % wx.__version__))
+
+ gfBoxSizer.Add (gfFlex, 1, wx.ALL, 8)
+
+ innerSizer.Add (gfBoxSizer, 0, wx.EXPAND | wx.BOTTOM, 4)
+
+ fiBox = wx.StaticBox (self, -1, u_(' Form Information '))
+ fiBoxSizer = wx.StaticBoxSizer (fiBox, wx.VERTICAL)
+
+ # Make sure to have a seriously sized description
+ descr = '\n'.join (textwrap.wrap (description, 78))
+
+ fiFlex = wx.FlexGridSizer (4, 2, 4, 10)
+ fiFlex.Add (wx.StaticText (self, -1, u_("Name:")))
+ fiFlex.Add (wx.StaticText (self, -1, name))
+ fiFlex.Add (wx.StaticText (self, -1, u_("Version:")))
+ fiFlex.Add (wx.StaticText (self, -1, formversion))
+ fiFlex.Add (wx.StaticText (self, -1, u_("Author:")))
+ fiFlex.Add (wx.StaticText (self, -1, author))
+ fiFlex.Add (wx.StaticText (self, -1, u_("Description:")))
+ fiFlex.Add (wx.StaticText (self, -1, descr))
+
+ fiBoxSizer.Add (fiFlex, 1, wx.ALL, 8)
+
+ innerSizer.Add (fiBoxSizer, 1, wx.EXPAND | wx.ALL)
+
+ buttonSizer = wx.BoxSizer (wx.HORIZONTAL)
+ buttonSizer.Add (wx.Button (self, wx.ID_OK, "OK"), 0, wx.ALL, 8)
+
+ topSizer.Add (innerSizer, 1, wx.EXPAND | wx.ALL, 8)
+
+ topSizer.Add (buttonSizer, 0, wx.ALIGN_RIGHT)
+
+ self.SetSizer (topSizer)
+ topSizer.SetSizeHints (self)
+
+
+# =============================================================================
+# Class implementing a versatile input dialog
+# =============================================================================
+
+class InputDialog (wx.Dialog):
+ """
+ Dialog class prompting the user for a given number of fields. These field
+ definitions are specified as follows:
+
+ A field definition is a tuple having these elements:
+ - fieldlabel: This text will be used as label in the left column
+ - fieldname: This is the key in the result-dictionary to contain the value
+ entered by the user
+ - fieldtype: Currently these types are supported:
+ - label: The contents of 'fieldlabel' as static text
+ - warning: The contents of 'fieldlabel' as static text, formatted as
+ warning
+ - string: A text entry control
+ - password: A text entry control with obscured characters
+ - dropdown: Foreach element given in 'elements' a separate ComboBox
+ control will be created, where each one has it's own dictionary of
+ allowed values. If a value is selected in one control, all others are
+ synchronized to represent the same key-value.
+ - default: Default value to use
+ - masterfield: Used for 'dropdowns'. This item specifies another field
+ definition acting as master field. If this master field is changed, the
+ allowedValues of this dropdown will be changed accordingly. If a
+ masterfield is specified the 'allowedValues' dictionaries are built like
+ {master1: {key: value, key: value, ...}, master2: {key: value, ...}}
+ - elements: sequence of input element tuples (label, allowedValues). This is
+ used for dropdowns only. 'label' will be used as ToolTip for the control
+ and 'allowedValues' gives a dictionary with all valid keys to be selected
+ in the dropdown.
+
+ @return: If closed by 'Ok' the result is a dictionary with all values entered
+ by the user, where the "fieldname"s will be used as keys. If the user has
+ not selected a value from a dropdown (i.e. it has no values to select)
+ there will be no such key in the result dictionary. If the dialog is
+ canceled ('Cancel'-Button) the result will be None.
+ """
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, title, fields, cancel = True):
+ """
+ Create a new input dialog
+
+ @param title: Dialog title
+ @param fields: sequence of field definition tuples
+ @param cancel: If True add a Cancel button to the dialog
+ """
+
+ wx.Dialog.__init__ (self, None, wx.ID_ANY, title)
+
+ self.SetIcon (wx.ArtProvider.GetIcon (wx.ART_QUESTION, wx.ART_FRAME_ICON))
+
+ topSizer = wx.BoxSizer (wx.VERTICAL)
+ self.gbs = gbs = wx.GridBagSizer (0, 6)
+
+ self.inputData = {}
+ self.__dropdowns = {}
+ self.__controls = []
+ self.__lastEntry = None
+
+ row = 0
+ for (label, name, fieldtype, default, master, elements) in fields:
+ ftp = fieldtype.lower ()
+
+ if ftp in ['label', 'warning']:
+ self.__add_text (row, label, ftp == 'warning')
+
+ elif ftp == 'image':
+ self.__addImage (row, name)
+
+ elif ftp == 'string':
+ self.__add_string (row, label, name, default, elements)
+
+ elif ftp == 'password':
+ self.__add_string (row, label, name, default, elements, True)
+
+ elif ftp == 'dropdown':
+ self.__add_dropdown (row, label, name, default, master, elements)
+
+ gbs.AddGrowableCol (1)
+ row += 1
+
+ topSizer.Add (gbs, 1, wx.EXPAND | wx.ALL, 6)
+
+ topSizer.Add (wx.StaticLine (self, wx.ID_STATIC, wx.DefaultPosition,
+ wx.DefaultSize, wx.LI_HORIZONTAL), 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 8)
+
+ buttonSizer = self.CreateButtonSizer (wx.OK | (cancel and wx.CANCEL or 0))
+ topSizer.Add (buttonSizer, 0, wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, 8)
+
+ self.SetSizerAndFit (topSizer)
+
+
+
+ # ---------------------------------------------------------------------------
+ # Add a centered, static label or warning
+ # ---------------------------------------------------------------------------
+
+ def __add_text (self, row, label, warning = False):
+
+ text = wx.StaticText (self, -1, label, style = wx.ALIGN_CENTRE)
+
+ if warning:
+ text.SetForegroundColour (wx.RED)
+
+ self.gbs.Add (text, (row, 0), (1, 2), wx.EXPAND |
+ wx.ALIGN_CENTER_HORIZONTAL)
+
+
+
+ # ---------------------------------------------------------------------------
+ # Add a text control for a string or a password
+ # ---------------------------------------------------------------------------
+
+ def __add_string (self, row, label, name, default, elements, pwd = False):
+
+ text = wx.StaticText (self, wx.ID_ANY, "%s:" % label)
+ self.gbs.Add (text, (row, 0), flag = wx.ALIGN_CENTER_VERTICAL)
+
+ eStyle = wx.TE_PROCESS_ENTER
+ if pwd:
+ eStyle |= wx.TE_PASSWORD
+
+ self.inputData [name] = default or ''
+
+ entry = wx.TextCtrl (self, wx.ID_ANY, default or '', style = eStyle)
+ entry._field = name
+
+ if elements and elements [0][0]:
+ entry.SetToolTip (wx.ToolTip (elements [0][0]))
+
+ wx.EVT_TEXT (entry, -1, self.__entryChanged)
+ wx.EVT_TEXT_ENTER (entry, -1, self.__enterPressed)
+
+ self.gbs.Add (entry, (row, 1), flag = wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
+
+ self.__addToControls (entry)
+
+
+
+ # ---------------------------------------------------------------------------
+ # Add a series of dropdowns into a single row
+ # ---------------------------------------------------------------------------
+
+ def __add_dropdown (self, row, label, name, default, master, elements):
+
+ self.gbs.Add (wx.StaticText (self, wx.ID_ANY, label), (row, 0),
+ flag = wx.ALIGN_CENTER_VERTICAL)
+
+ rowSizer = wx.BoxSizer (wx.HORIZONTAL)
+
+ perMaster = self.__dropdowns.setdefault (master, {})
+ drops = perMaster.setdefault (name, [])
+
+ border = 0
+ for (tip, allowedValues) in elements:
+ (keys, data, defItem) = self.__getModel (master, allowedValues, default)
+
+ data = [str (d) for d in data]
+ combo = wx.ComboBox (self, -1, defItem or '', choices = data,
+ style = wx.CB_READONLY)
+
+ combo._keys = keys
+ combo._data = data
+ combo._default = default
+ combo._field = name
+ combo._master = master
+ combo._allowedValues = allowedValues
+
+ if tip:
+ combo.SetToolTip (wx.ToolTip (tip))
+
+ drops.append (combo)
+ wx.EVT_COMBOBOX (combo, -1, self.__comboChanged)
+ wx.EVT_TEXT_ENTER (combo, -1, self.__enterPressed)
+
+ if defItem:
+ self.inputData [name] = default
+
+ rowSizer.Add (combo, 1, wx.EXPAND | wx.LEFT, border)
+ border = 4
+
+ self.__addToControls (combo)
+
+ self.gbs.Add (rowSizer, (row, 1), flag =
wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)
+
+
+ # ---------------------------------------------------------------------------
+ # Add a centered image to the dialog
+ # ---------------------------------------------------------------------------
+
+ def __addImage (self, row, imageURL):
+
+ sizer = wx.BoxSizer (wx.HORIZONTAL)
+
+ sizer.Add ((0, 0), 1)
+ sizer.Add (wx.StaticBitmap (self, wx.ID_ANY,
+ wx.Image (imageURL).ConvertToBitmap ()), 0)
+ sizer.Add ((0, 0), 1)
+
+ self.gbs.Add (sizer, (row, 0), (1, 2),
+ wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL)
+
+
+ # ---------------------------------------------------------------------------
+ # Whenever an entry will be changed, keep inputData in snyc
+ # ---------------------------------------------------------------------------
+
+ def __entryChanged (self, event):
+
+ entry = event.GetEventObject ()
+ self.inputData [entry._field] = entry.GetValue ()
+
+
+ # ---------------------------------------------------------------------------
+ # If <Enter> is pressed within a text control, move the focus
+ # ---------------------------------------------------------------------------
+
+ def __enterPressed (self, event):
+
+ entry = event.GetEventObject ()
+ if entry == self.__lastEntry:
+ self.EndModal (wx.ID_OK)
+
+ for item in self.__controls:
+ if item._index == entry._index + 1:
+ item.SetFocus ()
+
+
+ # ---------------------------------------------------------------------------
+ # On change of a combo, make sure to keep all others and depending in sync
+ # ---------------------------------------------------------------------------
+
+ def __comboChanged (self, event):
+
+ combo = event.GetEventObject ()
+ value = combo.GetStringSelection ()
+ newKey = combo._keys [combo._data.index (value)]
+
+ self.inputData [combo._field] = newKey
+ self.__updateDeps (combo, combo._master, combo._field, newKey)
+
+
+ # ---------------------------------------------------------------------------
+ # Get the data model for a given master from a data dictionary
+ # ---------------------------------------------------------------------------
+
+ def __getModel (self, master, dataDict, default = None):
+
+ defaultItem = None
+
+ if master:
+ values = dataDict.get (self.inputData.get (master), {})
+ else:
+ values = dataDict
+
+ if values:
+ (keys, data) = (values.keys (), values.values ())
+ if default and default in keys:
+ defaultItem = data [keys.index (default)]
+ else:
+ keys = data = []
+
+ return (keys, data, defaultItem)
+
+
+ # ---------------------------------------------------------------------------
+ # Keep all combos in sync and make sure to have depending combos up to date
+ # ---------------------------------------------------------------------------
+
+ def __updateDeps (self, combo, master, element, newKey):
+
+ drops = self.__dropdowns [master] [element]
+
+ # First synchronize all dropdowns of the same element
+ if len (drops) > 1:
+ for item in drops:
+ item.SetValue (item._data [item._keys.index (newKey)])
+
+ # If this dropdown is master of others, make sure to keep them in sync too
+ if self.__dropdowns.has_key (element):
+ self.__updateDepending (element, newKey)
+
+
+ # ---------------------------------------------------------------------------
+ # Update all depending combos of a given master
+ # ---------------------------------------------------------------------------
+
+ def __updateDepending (self, master, masterKey):
+
+ drops = self.__dropdowns [master]
+
+ for (datakey, combos) in drops.items ():
+ for combo in combos:
+ (keys, data, defItem) = self.__getModel (master, combo._allowedValues,
+ combo._default)
+ data = [str(d) for d in data]
+ if keys or combo._keys:
+ combo.Enable (True)
+ combo.Clear ()
+ for description in data:
+ combo.Append (str(description))
+
+ combo._keys = keys
+ combo._data = data
+
+ if not keys:
+ combo.SetValue ('')
+ combo.Disable ()
+ if datakey in self.inputData:
+ del self.inputData [datakey]
+ else:
+ if defItem is not None:
+ combo.SetValue (defItem)
+ self.inputData [datakey] = combo._default
+
+ else:
+ ckey = combo._keys [combo._data.index (combo.GetValue ())]
+ self.inputData [datakey] = ckey
+
+
+ # ---------------------------------------------------------------------------
+ # Add a widget to the list of controls, and give it an index
+ # ---------------------------------------------------------------------------
+
+ def __addToControls (self, widget):
+
+ self.__controls.append (widget)
+ widget._index = len (self.__controls)
+
+ if not isinstance (widget, wx.Button):
+ self.__lastEntry = widget
+
+
+ # ---------------------------------------------------------------------------
+ # Show the modal dialog and clear inputData on cancelling
+ # ---------------------------------------------------------------------------
+
+ def ShowModal (self):
+ """
+ Starts the modal dialog. If it get's cancelled inputData will be cleared.
+ """
+
+ result = wx.Dialog.ShowModal (self)
+ if result == wx.ID_CANCEL:
+ self.inputData = None
+
+
+# =============================================================================
+# Exception display dialog
+# =============================================================================
+
+class ExceptionDialog (wx.Dialog):
+
+ _TITLE = {'system' : _("GNUe Internal System Error"),
+ 'admin' : _("GNUe Unexpected Error"),
+ 'application': _("GNUe Application Error")}
+
+ _FORMAT = {
+ 'system': u_("An unexpected internal error has occured:\n%s.\n"
+ "This means you have found a bug in GNU Enterprise. "
+ "Please report it to address@hidden"),
+ 'admin': u_("An unexpected error has occured:\n%s.\n"
+ "Please contact your system administrator."),
+ 'application': u_("An unexpected error has occured:\n%s.\n"
+ "Please contact your system administrator.")}
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, group, name, message, detail):
+
+ wx.Dialog.__init__ (self, None, wx.ID_ANY,
+ self._TITLE.get (group, _('Error')), wx.DefaultPosition,
+ wx.DefaultSize, wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
+
+ self.dls = dls = wx.BoxSizer (wx.VERTICAL)
+ self.gbs = gbs = wx.GridBagSizer (6, 6)
+
+ self.SetIcon (wx.ArtProvider.GetIcon (wx.ART_ERROR, wx.ART_FRAME_ICON))
+
+ # ---- Message panel
+ icon = wx.StaticBitmap (self, wx.ID_ANY,
+ wx.ArtProvider.GetBitmap (wx.ART_ERROR, wx.ART_MESSAGE_BOX),
+ wx.DefaultPosition)
+ gbs.Add (icon, (0, 0))
+
+ msg =wx.StaticText (self, wx.ID_STATIC,
+ self._FORMAT.get (group, "%s") % message, wx.DefaultPosition,
+ wx.DefaultSize, 0)
+ gbs.Add (msg, (0, 1), flag = wx.EXPAND | wx.ALIGN_LEFT)
+
+ self.detailText = wx.TextCtrl (self, wx.ID_ANY, detail, wx.DefaultPosition,
+ wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_DONTWRAP)
+
+ gbs.Add (self.detailText, (1, 1), flag = wx.EXPAND | wx.ALIGN_LEFT)
+ gbs.Hide (self.detailText)
+
+ gbs.AddGrowableCol (1)
+ gbs.AddGrowableRow (1)
+
+ dls.Add (gbs, 1, wx.EXPAND | wx.ALIGN_TOP | wx.ALL, 6)
+
+ # ---- Static line
+
+ line = wx.StaticLine (self, wx.ID_STATIC, wx.DefaultPosition,
+ wx.DefaultSize, wx.LI_HORIZONTAL)
+ dls.Add (line, 0, wx.EXPAND | wx.ALIGN_TOP | wx.LEFT | wx.RIGHT, 6)
+
+ # ---- Button box
+ buttonBox = wx.BoxSizer (wx.HORIZONTAL)
+ close = wx.Button (self, wx.ID_CLOSE)
+ detail = wx.Button (self, wx.ID_ANY, ">> Details")
+
+ self.Bind (wx.EVT_BUTTON, self.__closeButton , close)
+ self.Bind (wx.EVT_BUTTON, self.__detailButton, detail)
+
+ buttonBox.Add (close , 1, wx.ALIGN_LEFT)
+ buttonBox.Add (detail, 1, wx.ALIGN_LEFT | wx.LEFT, 6)
+
+ dls.Add (buttonBox, 0, wx.ALIGN_RIGHT | wx.ALL, 6)
+ self.__showDetail = False
+ self.__changedFont = False
+
+ self.SetSizerAndFit (dls)
+
+
+ # ---------------------------------------------------------------------------
+ # Detail button click
+ # ---------------------------------------------------------------------------
+
+ def __detailButton (self, event):
+
+ self.__showDetail = not self.__showDetail
+
+ if not self.__changedFont:
+ cur = self.detailText.GetFont ()
+ fix = wx.Font (cur.GetPointSize (), wx.MODERN, wx.NORMAL, wx.NORMAL)
+ if fix.Ok ():
+ self.detailText.SetFont (fix)
+ self.detailText.SetInsertionPoint (0)
+
+ self.__changedFont = True
+
+ btn = event.GetEventObject ()
+ if self.__showDetail:
+ btn.SetLabel ('<< Details')
+ self.gbs.Show (self.detailText)
+ else:
+ btn.SetLabel ('>> Details')
+ self.gbs.Hide (self.detailText)
+
+ self.gbs.Layout ()
+ self.Fit ()
+
+
+ # ---------------------------------------------------------------------------
+ # Close the dialog
+ # ---------------------------------------------------------------------------
+
+ def __closeButton (self, event):
+
+ self.EndModal (wx.ID_CLOSE)
+
+
+
+# =============================================================================
+# Module self test
+# =============================================================================
+
+if __name__ == '__main__':
+ app = wx.PySimpleApp ()
+
+ desc = "This is a quite long description of the application.\n" \
+ "It also contains newlines as well as a lot of text. This text " \
+ "get's continued in the third line too.\n" \
+ "WWWWWWW WWWWWWW WWWWWWWWWWWW WWWWWWW WWWWWWWWWW WWWWWWW WWWWWWW" \
+ "WWWW WWWWW WWWW! And here comes the rest. Here we go."
+
+ dialog = AboutBox ('FooBar', author = 'BarBaz', description = desc)
+ try:
+ dialog.ShowModal ()
+ finally:
+ dialog.Destroy ()
+
+ # ---------------------------------------------------------------------------
+
+ cname = {'c1': 'demoa', 'c2': 'demob'}
+ ckey = {'c1': 'ck-A', 'c2': 'ck-B'}
+
+ wija = {'c1': {'04': '2004', '05': '2005'},
+ 'c2': {'24': '2024', '25': '2025', '26': '2026'}}
+
+ codes = {'24': {'241': 'c-24-1', '242': 'c-24-2'},
+ '25': {'251': 'c-25-1'}}
+
+ fields = [('Foo!', '/home/johannes/gnue/share/gnue/images/gnue.png', 'image',
+ None, None, []),
+ ('Username', '_username', 'string', 'frodo', None, \
+ [('Name of the user', None)]),
+ ('Password', '_password', 'password', 'foo', None, [('yeah',1)]),
+ ('Foobar', '_foobar', 'dropdown', 'frob', None, \
+ [('single', {'trash': 'Da Trash', 'frob': 'Frob'})]),
+ ('Multi', '_multi', 'dropdown', '100', None, \
+ [('name', {'50': 'A 50', '100': 'B 100', '9': 'C 9'}),
+ ('sepp', {'50': 'se 50', '100': 'se 100', '9': 'se 9'})]),
+ ('Noe', '_depp', 'label', 'furz', None, []),
+ ('Das ist jetzt ein Fehler', None, 'warning', None, None, []),
+ ('Firma', 'company', 'dropdown', 'c1', None,
+ [('Name', cname), ('Code', ckey)]),
+ ('Wirtschaftsjahr', 'wija', 'dropdown', '05', 'company',
+ [('Jahr', wija)]),
+ ('Codes', 'codes', 'dropdown', None, 'wija',
+ [('Code', codes)])]
+
+ dialog = InputDialog ('Foobar', fields)
+ try:
+ dialog.ShowModal ()
+ print "Result:", dialog.inputData
+
+ finally:
+ dialog.Destroy ()
+
+ app.MainLoop ()
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/dialogs.py
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/__init__.py
===================================================================
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,247 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - base class for UI widgets
+#
+# Copyright 2001-2006 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.GFForm import *
+from gnue.forms.uidrivers._base.widgets._base import UIWidget
+
+
+# =============================================================================
+# This class implements the common behaviour of wx 2.6 widgets
+# =============================================================================
+
+class UIHelper (UIWidget):
+ """
+ Implements the common behaviour of wx 2.6 widgets
+ """
+
+ # ---------------------------------------------------------------------------
+ # Create a new wx widget
+ # ---------------------------------------------------------------------------
+
+ def createWidget (self, event, spacer):
+ """
+ This function creates a new wx widget and adds it to the cross reference
+ table.
+ """
+
+ self._eventHandler = event.eventHandler
+
+ if hasattr (self._gfObject, 'Char__y'):
+ posY = self._gfObject.Char__y
+ gap = self._gfObject._gap + 1
+ self.itemY = (posY + spacer * gap) * self._uiDriver.cellHeight
+
+ if hasattr (self._gfObject, 'Char__height'):
+ self.itemHeight = self._gfObject.Char__height * event.textHeight
+
+ newWidget = self._createWidget (event, spacer)
+ if event.initialize:
+ self._addToCrossRef (newWidget, self._gfObject, self)
+
+ return newWidget
+
+
+ # ---------------------------------------------------------------------------
+ # Add a widget to the cross reference tables
+ # ---------------------------------------------------------------------------
+
+ def _addToCrossRef (self, widget, gfobject, uiobject):
+
+ self._uiDriver._WidgetToGFObj [widget] = gfobject
+ self._uiDriver._WidgetToUIObj [widget] = uiobject
+
+
+ # ---------------------------------------------------------------------------
+ # Remove a widget from the cross reference tables
+ # ---------------------------------------------------------------------------
+
+ def _deleteFromCrossRef (self, widget, object):
+
+ try:
+ del self._uiDriver._WidgetToGFObj [widget]
+ del self._uiDriver._WidgetToUIObj [widget]
+
+ except:
+ pass
+
+
+ # ---------------------------------------------------------------------------
+ # Show all ui-widgets managed by this object
+ # ---------------------------------------------------------------------------
+
+ def show (self):
+ """
+ Call Show () on all wx-widgets managed by this instance. This is needed if
+ a row-count greater than 0 is given.
+ """
+
+ for widget in self.widgets:
+ widget.Show ()
+
+
+ # ---------------------------------------------------------------------------
+ # Hide all ui-widgets managed by this object
+ # ---------------------------------------------------------------------------
+
+ def hide (self):
+ """
+ Call Hide () on all wx-widgets managed by this instance. This is needed if
+ a row-count greater than 0 is given.
+ """
+
+ for widget in self.widgets:
+ widget.Hide ()
+
+
+ # ---------------------------------------------------------------------------
+ # Show widgets in a modal way
+ # ---------------------------------------------------------------------------
+
+ def showModal (self):
+
+ for widget in self.widgets:
+ widget.ShowModal ()
+
+ # ---------------------------------------------------------------------------
+ # Destroy all widgets associated with an instance
+ # ---------------------------------------------------------------------------
+
+ def destroy (self):
+
+ for widget in self.widgets:
+ widget.Destroy ()
+
+
+ # ---------------------------------------------------------------------------
+ # Set the focus to a given widget
+ # ---------------------------------------------------------------------------
+
+ def indexedFocus (self, index):
+ """
+ This function set's the focus to the gtk-widget specified by index. If the
+ widget has a focusHandler it will be blocked and unblocked to prevent a
+ recursion. The focused widget will have a highlight color if it is set
+ in gnue.conf.
+ """
+
+ widget = self.widgets [index]
+ widget.SetFocus ()
+
+
+ # ---------------------------------------------------------------------------
+ # On lose of the focus we un-select ComboBox-Entries
+ # ---------------------------------------------------------------------------
+
+ def loseFocus (self):
+ pass
+
+
+ # ---------------------------------------------------------------------------
+ # Set the value of a widget
+ # ---------------------------------------------------------------------------
+
+ def setValue (self, value, index = 0, enabled = True):
+ """
+ This function sets the value of a widget and optionally enables or disables
+ the widget.
+ """
+
+ widget = self.widgets [index]
+ widget.SetEvtHandlerEnabled (False)
+
+ try:
+ if self._gfObject.style in ['dropdown', 'listbox']:
+ if self._gfObject._field._allowedValues != widget._origAllowedValues:
+ widget.Freeze ()
+
+ try:
+ widget.Clear ()
+ widget._origAllowedValues = self._gfObject._field._allowedValues
+ choices = self._gfObject._field.allowedValues () [1]
+ choices.sort ()
+
+ for item in choices:
+ widget.Append (item)
+
+ finally:
+ widget.Thaw ()
+
+ if isinstance (widget, wx.StaticText):
+ widget.SetLabel (value)
+
+ elif isinstance (widget, wx.ListBox):
+ widget.SetStringSelection (value, True)
+
+ else:
+ widget.SetValue (value)
+
+ widget.Enable (enabled)
+
+ finally:
+ widget.SetEvtHandlerEnabled (True)
+ widget.Refresh ()
+
+
+ # --------------------------------------------------------------------------
+ # Set the cursor's location in a widget
+ # --------------------------------------------------------------------------
+
+ def setCursorPosition (self, position, index = 0):
+ """
+ Set the cursor position to the given location inside a capable widget.
+
+ @param position: new position of the insertion point
+ @param index: index of the widget to be changed (if rows > 0)
+ """
+
+ widget = self.widgets [index]
+
+ if isinstance (widget, wx.ComboBox):
+ widget.SetMark (position, position)
+
+ elif hasattr (widget, 'SetInsertionPoint'):
+ widget.SetInsertionPoint (position)
+
+
+ # --------------------------------------------------------------------------
+ # Set the selection inside a widget
+ # --------------------------------------------------------------------------
+
+ def setSelectedArea (self, selection1, selection2, index=0):
+ """
+ Sets the selection start/end inside a capable widget.
+
+ @param selection1: start position of the selection
+ @param selection2: end position of the selection
+ @param index: index of the widget to be changed
+ """
+
+ widget = self.widgets [index]
+
+ if isinstance (widget, wx.ComboBox):
+ widget.SetMark (selection1, selection2)
+
+ elif hasattr (widget, 'SetSelection'):
+ widget.SetSelection (selection1, selection2)
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,62 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Box widget
+#
+# Copyright 2001-2006 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 import _base
+
+
+# =============================================================================
+# Interface implementation for a box widget
+# =============================================================================
+
+class UIBox (_base.UIHelper):
+
+ # ---------------------------------------------------------------------------
+ # Create a wx box widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+
+ offsX = self._uiDriver.cellWidth / 2
+ offsY = self._uiDriver.cellHeight / 2
+
+ pos = (self.itemX + offsX, self.itemY + offsY)
+ size = (self.itemWidth - offsX * 2, self.itemHeight - offsY * 2)
+
+ newWidget = wx.StaticBox (event.container, wx.ID_ANY, self._gfObject.label,
+ pos, size)
+
+ return newWidget
+
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIBox,
+ 'provides' : 'GFBox',
+ 'container': 0
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,76 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Button widget
+#
+# Copyright 2001-2006 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.common import events
+from gnue.forms.uidrivers.wx26.widgets._base import UIHelper
+
+# =============================================================================
+# Wrap an UI layer around a wxButton widget
+# =============================================================================
+
+class UIButton (UIHelper):
+ """
+ Creates a single instance of a button.
+ """
+
+ # --------------------------------------------------------------------------
+ # Create a button widget
+ # --------------------------------------------------------------------------
+ def _createWidget (self, event, spacer):
+ """
+ Creates a new Button widget.
+ """
+
+ offs = (self._uiDriver.cellHeight - \
+ self._uiDriver.controlHeight.get ('button', 0)) / 2
+ pos = (self.itemX, self.itemY + offs)
+ size = (self.itemWidth, -1)
+
+ newWidget = wx.Button (event.container, wx.ID_ANY, self._gfObject.label,
+ pos, size)
+
+ newWidget.Connect (-1, -1, wx.wxEVT_COMMAND_BUTTON_CLICKED, self.__click)
+
+ return newWidget
+
+
+ # ---------------------------------------------------------------------------
+ # Eventhandler for button clicks
+ # ---------------------------------------------------------------------------
+
+ def __click (self, event):
+
+ self._eventHandler (events.Event ('buttonActivated', self._gfObject))
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIButton,
+ 'provides' : 'GFButton',
+ 'container': 0,
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,223 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Entry widgets
+#
+# Copyright 2001-2006 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
+import string
+
+from gnue.forms.uidrivers.wx26.widgets import _base
+from gnue.forms.input import GFKeyMapper
+from gnue.forms.input.GFKeyMapper import vk
+
+
+# =============================================================================
+# Interface class for entry widgets
+# =============================================================================
+
+class UIEntry (_base.UIHelper):
+ """
+ Interface implementation for entry widgets.
+ """
+
+ # ---------------------------------------------------------------------------
+ # Create the real wx widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+ """
+ Create the wx widget.
+ """
+
+ cellH = self._uiDriver.cellHeight
+ ctrlH = self._uiDriver.controlHeight.get (self._gfObject.style, cellH)
+ offset = (cellH - ctrlH) / 2
+ pos = (self.itemX, self.itemY + offset)
+ lines = hasattr (self._gfObject, 'Char__height') and \
+ self._gfObject.Char__height or 1
+ size = (self.itemWidth, lines == 1 and -1 or self.itemHeight)
+
+ # ----- label style entries
+ if self._gfObject.style == 'label':
+ newWidget = wx.StaticText (event.container, wx.ID_ANY, "x", pos, size)
+
+ # ----- dropdown- and listbox-entries
+ elif self._gfObject.style in ['dropdown', 'listbox']:
+ choices = self._gfObject._field.allowedValues () [1]
+ choices.sort ()
+
+ if self._gfObject.style == 'dropdown':
+ newWidget = wx.ComboBox (event.container, wx.ID_ANY, "", pos, size,
+ choices, wx.CB_READONLY | wx.CB_SORT)
+ changeEvt = wx.wxEVT_COMMAND_COMBOBOX_SELECTED
+
+ else:
+ newWidget = wx.ListBox (event.container, wx.ID_ANY, pos, size, choices,
+ wx.LB_SINGLE | wx.LB_SORT)
+ changeEvt = wx.wxEVT_COMMAND_LISTBOX_SELECTED,
+
+ newWidget.Connect (-1, -1, changeEvt, self.__itemSelected)
+ newWidget._origAllowedValues = self._gfObject._field._allowedValues
+
+ # ----- checkbox-entries
+ elif self._gfObject.style == 'checkbox':
+ newWidget = wx.CheckBox (event.container, wx.ID_ANY,
+ self._gfObject.label, pos, size)
+ wx.EVT_CHECKBOX (newWidget, newWidget.GetId (), self.__toggleCheckbox)
+
+ # ----- text-entries
+ else:
+ if lines == 1:
+ size = (self.itemWidth, -1)
+ flags = 0
+ else:
+ size = (self.itemWidth, (lines * cellH) - (cellH - offset * 2))
+ flags = wx.TE_MULTILINE
+
+ newWidget = wx.TextCtrl (event.container, -1, '', pos, size, flags)
+
+ newWidget.Connect (-1, -1, wx.wxEVT_SET_FOCUS, self.__setFocus)
+ newWidget.Connect (-1, -1, wx.wxEVT_CHAR, self.__keypress)
+
+ if self._gfObject.style in ['default', 'dropdown']:
+ newWidget.Connect (-1, -1, wx.wxEVT_LEFT_UP, self.__leftMouseUp)
+
+ return newWidget
+
+
+ # ---------------------------------------------------------------------------
+ # Make sure to keep the focus in gf-layer in sync with the UI
+ # ---------------------------------------------------------------------------
+
+ def __setFocus (self, event):
+
+ self._request ('FOCUS', data = self._gfObject)
+
+ # adjust the record number if necessary
+ count = self.widgets.index (event.GetEventObject ())
+ adjust = count - self._gfObject._visibleIndex
+ if adjust:
+ self._request ('JUMPRECORD', data = adjust)
+
+ event.Skip ()
+
+
+ # ---------------------------------------------------------------------------
+ # Release of the left mouse-button for textcontrols and combos
+ # ---------------------------------------------------------------------------
+
+ def __leftMouseUp (self, event):
+
+ widget = event.GetEventObject ()
+
+ if isinstance (widget, wx.TextCtrl):
+ (left, right) = widget.GetSelection ()
+
+ elif isinstance (widget, wx.ComboBox):
+ # FIXME: check why widget.GetMark () returns useless values !?!
+ left = right = widget.GetInsertionPoint ()
+
+ if left == right:
+ self._request ('CURSORMOVE', position = left)
+ else:
+ self._request ('SELECTWITHMOUSE', position1 = left, position2 = right,
+ cursor = widget.GetInsertionPoint ())
+
+ event.Skip ()
+
+
+ # ---------------------------------------------------------------------------
+ # Toggle the state of a checkbox
+ # ---------------------------------------------------------------------------
+
+ def __toggleCheckbox (self, event):
+
+ self._request ('TOGGLECHKBOX')
+
+
+ # ---------------------------------------------------------------------------
+ # An item of a listbox has been selected
+ # ---------------------------------------------------------------------------
+
+ def __itemSelected (self, event):
+
+ self._request ('REPLACEVALUE', index = event.GetSelection (),
+ text = event.GetString ())
+
+
+ # ---------------------------------------------------------------------------
+ # Process a key-press in an entry
+ # ---------------------------------------------------------------------------
+
+ def __keypress (self, event):
+
+ keycode = event.GetKeyCode ()
+
+ if self._gfObject.style == 'listbox' and (keycode in [wx.WXK_UP,
+ wx.WXK_DOWN, wx.WXK_SPACE, wx.WXK_PRIOR, wx.WXK_NEXT, wx.WXK_HOME,
+ wx.WXK_END]):
+ event.Skip ()
+
+ else:
+ (command, args) = GFKeyMapper.KeyMapper.getEvent (keycode,
+ event.ShiftDown (),
+ event.CmdDown (),
+ event.AltDown ())
+
+ if command:
+ self._request (command, triggerName = args)
+
+ elif keycode < 256 and (chr (keycode) in string.printable or
keycode>127):
+ self._keypress (chr (keycode))
+
+ else:
+ event.Skip ()
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIEntry,
+ 'provides' : 'GFEntry',
+ 'container': 0
+}
+
+# Translate from wx keystrokes to our virtual keystrokes
+wxKeyTranslations = {
+ vk.C : 3, vk.V : 22,
+ vk.X : 24, vk.A : 1,
+ vk.F1 : wx.WXK_F1, vk.F2 : wx.WXK_F2,
+ vk.F3 : wx.WXK_F3, vk.F4 : wx.WXK_F4,
+ vk.F5 : wx.WXK_F5, vk.F6 : wx.WXK_F6,
+ vk.F7 : wx.WXK_F7, vk.F8 : wx.WXK_F8,
+ vk.F9 : wx.WXK_F9, vk.F10 : wx.WXK_F10,
+ vk.F11 : wx.WXK_F11, vk.F12 : wx.WXK_F12,
+ vk.INSERT : wx.WXK_INSERT, vk.DELETE : wx.WXK_DELETE,
+ vk.HOME : wx.WXK_HOME, vk.END : wx.WXK_END,
+ vk.PAGEUP : wx.WXK_PRIOR, vk.PAGEDOWN : wx.WXK_NEXT,
+ vk.UP : wx.WXK_UP, vk.DOWN : wx.WXK_DOWN,
+ vk.LEFT : wx.WXK_LEFT, vk.RIGHT : wx.WXK_RIGHT,
+ vk.TAB : wx.WXK_TAB,
+ vk.ENTER : wx.WXK_RETURN, vk.BACKSPACE : wx.WXK_BACK }
+
+GFKeyMapper.KeyMapper.setUIKeyMap (wxKeyTranslations)
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,360 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Form widget
+#
+# Copyright 2001-2006 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.MenuBar import MenuBar
+from gnue.forms.uidrivers.wx26.ToolBar import ToolBar
+from gnue.forms.uidrivers.wx26.widgets._base import UIHelper
+
+
+# =============================================================================
+# Interface implementation of a form widget
+# =============================================================================
+
+class UIForm (UIHelper):
+ """
+ Interface implementation of form widgets (forms and dialogs)
+ """
+
+ # ---------------------------------------------------------------------------
+ # Create a new form widget
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, event):
+
+ self._wxPages = []
+ self.statusBar = None
+
+ UIHelper.__init__ (self, event)
+ self._inits.append (self._updateSizers)
+
+
+ # ---------------------------------------------------------------------------
+ # Create a new wx frame widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+
+ if self._form.style != 'dialog':
+ self.mainWindow = self._uiDriver._parentContainer
+ if not self.mainWindow:
+ self.mainWindow = wx.Frame (None, -1, "", wx.DefaultPosition)
+ else:
+ self.mainWindow = wx.Dialog (None, wx.ID_ANY, "", wx.DefaultPosition,
+ wx.DefaultSize, wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
+
+ self.containerFrame = self.mainWindow
+ self.mainWindow.SetTitle (self._form.title)
+
+ topSizer = wx.BoxSizer (wx.VERTICAL)
+
+ self.mainWindow.Connect (wx.ID_ANY, wx.ID_ANY, wx.wxEVT_CLOSE_WINDOW,
+ self.__closeTrap)
+
+ if not self._form._features ['GUI:STATUSBAR:SUPPRESS']:
+ if isinstance (self.mainWindow, wx.Frame):
+ self.statusBar = self.mainWindow.CreateStatusBar ()
+ self.statusBar.SetFieldsCount (5)
+ self.statusBar.SetStatusWidths ([-1, 50, 50, 75, 75])
+
+ if self._form._layout.tabbed != 'none':
+ newWidget = TabbedWrapper (self)
+ else:
+ newWidget = BaseWrapper (self)
+
+ # Add the ScrolledWindow to the sizer, let it grow with newly available
+ # space and add a border of 6 pixels around it
+ topSizer.Add (newWidget, 1, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL, 6)
+
+ if self._form.style != 'dialog':
+ if not self._form._features.get ('GUI:MENUBAR:SUPPRESS'):
+ MenuBar (self._uiDriver, self.containerFrame, self._form)
+
+ if not self._form._features.get ('GUI:TOOLBAR:SUPPRESS'):
+ tlb = ToolBar (self._uiDriver, self.containerFrame, self._form)
+ # TODO: find a cleaner way to specify required size of the toolbar
+ newWidget.SetSizeHints (tlb.toolbar.GetSize () [0], -1)
+
+ # self.mainWindow.SetSizerAndFit (topSizer)
+
+ self._containerToolkitWidget = newWidget
+ self._sizers = [(self.mainWindow, topSizer), (newWidget,
+ newWidget.pageSizer)]
+
+ return newWidget
+
+
+ # ---------------------------------------------------------------------------
+ # Set sizers, specify the size hints and fit all child controls
+ # ---------------------------------------------------------------------------
+
+ def _updateSizers (self):
+
+ for (window, sizer) in self._sizers:
+ window.SetSizerAndFit (sizer)
+
+
+
+ # ---------------------------------------------------------------------------
+ # Show the form/dialog
+ # ---------------------------------------------------------------------------
+
+ def show (self):
+
+ self.containerFrame.Fit ()
+ self.containerFrame.Show ()
+
+
+ # ---------------------------------------------------------------------------
+ # Show the form/dialog modal
+ # ---------------------------------------------------------------------------
+
+ def showModal (self):
+
+ self.containerFrame.Fit ()
+ self.containerFrame.ShowModal ()
+
+
+ # ---------------------------------------------------------------------------
+
+ def _setStatusBar (self, tip, statusValue, insertValue, currentRecord,
+ maxRecord, currentPage, maxPage, procMsg = True):
+
+ if not self.statusBar:
+ return
+
+ if tip is not None:
+ self.statusBar.SetStatusText (tip, 0)
+
+ if statusValue is not None:
+ self.statusBar.SetStatusText (statusValue, 1)
+
+ if insertValue is not None:
+ self.statusBar.SetStatusText (insertValue, 2)
+
+ if currentRecord and maxRecord:
+ self.statusBar.SetStatusText ( \
+ ("%s/%s" % (currentRecord, maxRecord)).strip (), 3)
+
+ if currentPage and maxPage:
+ self.statusBar.SetStatusText ( \
+ ("%s/%s" % (currentPage, maxPage)).strip (), 4)
+
+
+ # ---------------------------------------------------------------------------
+ # Close the form
+ # ---------------------------------------------------------------------------
+
+ def __closeTrap (self, event):
+
+ if event.CanVeto ():
+ self._request ('EXIT')
+ event.Veto ()
+
+ else:
+ event.GetEventObject ().Destroy ()
+
+
+ # ---------------------------------------------------------------------------
+ # Change to the requested page
+ # ---------------------------------------------------------------------------
+
+ def gotoPage (self, page):
+
+ self._containerToolkitWidget.showPage (page._pageIndex)
+
+
+
+# =============================================================================
+# Simple scrolled window containing multiple page panels
+# =============================================================================
+
+class BaseWrapper (wx.ScrolledWindow):
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, uiForm):
+
+ self._uiForm = uiForm
+ self._uiDriver = uiForm._uiDriver
+ self._gfObject = uiForm._gfObject
+ self.frame = uiForm.containerFrame
+ self._pages = []
+
+ wx.ScrolledWindow.__init__ (self, self.frame, wx.ID_ANY)
+ self.pageSizer = wx.BoxSizer (wx.VERTICAL)
+ self.pageContainer = self._createPageContainer ()
+
+ self.pageSizer.Add (self.pageContainer, 1, wx.EXPAND | wx.ALIGN_LEFT)
+
+
+ # ---------------------------------------------------------------------------
+ # Create the container widget for all the wrapped pages
+ # ---------------------------------------------------------------------------
+
+ def _createPageContainer (self):
+
+ return wx.Panel (self, wx.ID_ANY)
+
+
+ # ---------------------------------------------------------------------------
+ # Create a new page for the given GFPage instance
+ # ---------------------------------------------------------------------------
+
+ def createPage (self, gfPage):
+ """
+ Create a new page for the given GFPage instance and add it to the page
+ container.
+
+ @param gfPage: GFPage instance to create a page widget for
+ """
+
+ basePanel = wx.Panel (self.pageContainer, wx.ID_ANY)
+ pageSizer = wx.BoxSizer (wx.VERTICAL)
+
+ pagePanel = wx.Panel (basePanel, wx.ID_ANY)
+
+ fw = self._uiForm._form._layout.Char__width * self._uiDriver.cellWidth
+ fh = self._uiForm._form._layout.Char__height * self._uiDriver.cellHeight
+
+ pagePanel.SetSizeHints (fw, fh)
+ pageSizer.Add (pagePanel, 1, wx.EXPAND | wx.ALIGN_LEFT)
+
+ basePanel.SetSizerAndFit (pageSizer)
+
+ self._addToContainer (gfPage, basePanel)
+
+ self.SetVirtualSize ((fw, fh))
+ self.SetScrollRate (self._uiDriver.cellWidth, self._uiDriver.cellHeight)
+
+ return pagePanel
+
+
+ # ---------------------------------------------------------------------------
+ # Add a given page widget to the page container
+ # ---------------------------------------------------------------------------
+
+ def _addToContainer (self, gfPage, pageWidget):
+
+ self._pages.append (pageWidget)
+
+
+ # ---------------------------------------------------------------------------
+ # Show the given page
+ # ---------------------------------------------------------------------------
+
+ def showPage (self, page):
+ """
+ Show the requested page in the page container
+
+ @param page: the zero-based index of the page to be shown
+ """
+
+ for (pIx, widget) in enumerate (self._pages):
+ if pIx != page:
+ widget.Hide ()
+ else:
+ widget.Show ()
+
+
+ # ---------------------------------------------------------------------------
+ # Get the number of pages
+ # ---------------------------------------------------------------------------
+
+ def pageCount (self):
+ """
+ Returns the number of pages controlled by this instance.
+ @return: number of pages
+ """
+
+ return len (self._pages)
+
+
+# =============================================================================
+# A scrolled window using a notebook widget to manage pages
+# =============================================================================
+
+class TabbedWrapper (BaseWrapper):
+
+ _TAB_STYLE = {'left': wx.NB_LEFT,
+ 'right': wx.NB_RIGHT,
+ 'bottom': wx.NB_BOTTOM,
+ 'top': wx.NB_TOP}
+
+
+ # ---------------------------------------------------------------------------
+ # Show the given page
+ # ---------------------------------------------------------------------------
+
+ def showPage (self, page):
+
+ self.pageContainer.SetSelection (page)
+
+
+ # ---------------------------------------------------------------------------
+ # Create the container widget for all the wrapped pages
+ # ---------------------------------------------------------------------------
+
+ def _createPageContainer (self):
+
+ notebook = wx.Notebook (self, wx.ID_ANY, wx.DefaultPosition,
+ wx.DefaultSize, self._TAB_STYLE [self._uiForm._form._layout.tabbed])
+ notebook.Connect (wx.ID_ANY, wx.ID_ANY,
+ wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, self.__changePage)
+
+ return notebook
+
+
+ # ---------------------------------------------------------------------------
+ # Add a given page widget to the page container
+ # ---------------------------------------------------------------------------
+
+ def _addToContainer (self, gfPage, pageWidget):
+
+ title = hasattr (gfPage, 'caption') and gfPage.caption or gfPage.name
+
+ self.pageContainer.AddPage (pageWidget, title)
+ self._pages.append (pageWidget)
+
+
+ # ---------------------------------------------------------------------------
+ # Change a notebook page
+ # ---------------------------------------------------------------------------
+
+ def __changePage (self, event):
+
+ self._uiForm._request ('PAGE', data = event.GetSelection ())
+
+
+# =============================================================================
+# Widget configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIForm,
+ 'provides' : 'GFForm',
+ 'container': 1,
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,127 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Image widgets
+#
+# Copyright 2001-2006 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
+
+try:
+ from PIL import Image as PILImage
+
+except:
+ PILImage = None
+
+from gnue.forms.uidrivers.wx26.widgets import _base
+
+# =============================================================================
+# Wrap an UI layer around a wx image
+# =============================================================================
+
+class UIImage (_base.UIHelper):
+ """
+ Creates a single instance of an image.
+ """
+
+ # --------------------------------------------------------------------------
+ # Create an image widget
+ # --------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+ """
+ Creates a new StaticBitmap widget.
+ """
+
+ pos = (self.itemX, self.itemY)
+ size = (self.itemWidth, self.itemHeight)
+
+ self.imagePanel = wx.ScrolledWindow (event.container, wx.ID_ANY, pos, size)
+
+ newWidget = wx.StaticBitmap (self.imagePanel, wx.ID_ANY, wx.NullBitmap,
+ wx.DefaultPosition, wx.DefaultSize)
+
+ return newWidget
+
+
+ # --------------------------------------------------------------------------
+ # Set the widget's PIL
+ # --------------------------------------------------------------------------
+
+ def setValue (self, value, index = 0, enabled = True):
+ """
+ Loads an image.
+ """
+
+ if PILImage is None:
+ return
+
+ widget = self.widgets [index]
+
+ scrx, scry = self.imagePanel.GetClientSizeTuple ()
+ imgx, imgy = value.size
+
+ self.imagePanel.SetVirtualSize ((imgx, imgy))
+
+ scalex = scaley = 1
+
+ fit = self._gfObject.fit
+
+ if fit == "auto":
+ if float (scrx) / imgx < float (scry) / imgy:
+ fit = "width"
+ else:
+ fit = "height"
+
+ if fit == "width":
+ scalex = scaley = float (scrx) / imgx
+
+ elif fit == "height":
+ scalex = scaley = float (scry) / imgy
+
+ elif fit == "both":
+ scalex = float (scrx) / imgx
+ scaley = float (scry) / imgy
+ else:
+ self.imagePanel.SetScrollRate (10, 10)
+
+ if scalex != 1 or scaley != 1:
+ value = value.resize ((abs (int (imgx * scalex)),
+ abs (int (imgy * scaley))), PILImage.BICUBIC)
+
+ # Convert the PIL Image to a wxBitmap
+ wxImg = wx.EmptyImage (value.size [0], value.size [1])
+ wxImg.SetData (value.convert ("RGB").tostring ())
+ image = wxImg.ConvertToBitmap ()
+
+ widget.SetSize (wx.Size (image.GetWidth (), image.GetHeight ()))
+ widget.SetBitmap (image)
+
+ widget.Refresh ()
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIImage,
+ 'provides' : 'GFImage',
+ 'container': 0,
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,68 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Label widgets
+#
+# Copyright 2001-2006 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 import _base
+
+
+# =============================================================================
+# Interface implementation of label widgets
+# =============================================================================
+
+class UILabel (_base.UIHelper):
+
+ _ALIGNMENT = {'left' : wx.ALIGN_LEFT,
+ 'right' : wx.ALIGN_RIGHT,
+ 'center': wx.ALIGN_CENTRE}
+
+ # ---------------------------------------------------------------------------
+ # Create a label widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+
+ offs = (self._uiDriver.cellHeight - \
+ self._uiDriver.controlHeight.get ('label')) / 2
+ pos = (self.itemX, self.itemY + offs)
+ if self._gfObject.Char__height == 1:
+ size = (self.itemWidth, -1)
+ else:
+ size = (self.itemWidth, self.itemHeight)
+
+ newWidget = wx.StaticText (event.container, wx.ID_ANY,
+ self._gfObject.text, pos, size,
+ self._ALIGNMENT [self._gfObject.alignment] | wx.ST_NO_AUTORESIZE)
+
+ return newWidget
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UILabel,
+ 'provides' : 'GFLabel',
+ 'container': 0
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-01-21 16:20:53 UTC
(rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-01-26 14:26:19 UTC
(rev 8136)
@@ -0,0 +1,52 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Page widget
+#
+# Copyright 2001-2006 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 import _base
+
+# =============================================================================
+# Interface implementation of a page
+# =============================================================================
+
+class UIPage (_base.UIHelper):
+
+ # ---------------------------------------------------------------------------
+ # Create a new page widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+
+ self._pageIndex = event.container.pageCount ()
+ self._containerToolkitWidget = event.container.createPage (self._gfObject)
+ return self._containerToolkitWidget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIPage,
+ 'provides' : 'GFPage',
+ 'container': 1
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py 2006-01-21
16:20:53 UTC (rev 8135)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py 2006-01-26
14:26:19 UTC (rev 8136)
@@ -0,0 +1,78 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Scrollbar widget
+#
+# Copyright 2001-2006 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 import _base
+
+# =============================================================================
+# This class implements a scrollbar for navigating multiple records
+# =============================================================================
+
+class UIScrollBar (_base.UIHelper):
+
+ # ---------------------------------------------------------------------------
+ # Create the wx widget
+ # ---------------------------------------------------------------------------
+
+ def _createWidget (self, event, spacer):
+
+ newWidget = self.widget = wx.ScrollBar (event.container, wx.ID_ANY,
+ (self.itemX, self.itemY), (-1, self.itemHeight), wx.SB_VERTICAL)
+
+ (crec, recs, self.pageSize) = self._gfObject.getRecordAndPageCount ()
+ wx.EVT_COMMAND_SCROLL (newWidget, newWidget.GetId (), self.__scrollEvent)
+ self.adjustScrollbar (crec, recs)
+
+ return newWidget
+
+
+ # ---------------------------------------------------------------------------
+ # adjust the scrollbar to a new position
+ # ---------------------------------------------------------------------------
+
+ def adjustScrollbar (self, position, count):
+
+ self.widget.SetScrollbar (position, self.pageSize, count,
+ self.pageSize - 1, True)
+
+
+ # ---------------------------------------------------------------------------
+ # Handle changes of the adjustment's value
+ # ---------------------------------------------------------------------------
+
+ def __scrollEvent (self, event):
+
+ self._gfObject.scrollToRecord (event.GetPosition ())
+ event.Skip ()
+
+
+# -----------------------------------------------------------------------------
+# Configuration data
+# -----------------------------------------------------------------------------
+
+configuration = {
+ 'baseClass' : UIScrollBar,
+ 'provides' : 'GFScrollBar',
+ 'container' : 0,
+}
Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py
___________________________________________________________________
Name: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8136 - in trunk/gnue-forms/src: . input uidrivers uidrivers/_commonGuiToolkit uidrivers/wx26 uidrivers/wx26/widgets,
johannes <=