commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8752 - in trunk/gnue-forms/src/uidrivers: _base/widgets qt3 qt3/


From: johannes
Subject: [gnue] r8752 - in trunk/gnue-forms/src/uidrivers: _base/widgets qt3 qt3/widgets wx26/widgets
Date: Wed, 11 Oct 2006 09:11:21 -0500 (CDT)

Author: johannes
Date: 2006-10-11 09:11:18 -0500 (Wed, 11 Oct 2006)
New Revision: 8752

Modified:
   trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/qt3/MenuBar.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/box.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/label.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
Log:
Add Menu- and Statusbar (and silly entries)


Modified: trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-10-11 
14:06:37 UTC (rev 8751)
+++ trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-10-11 
14:11:18 UTC (rev 8752)
@@ -321,7 +321,7 @@
     # -------------------------------------------------------------------------
     # TODO: add docstrings to these methods and pep8-ify them
 
-    def _create_widget_(event, spacer):
+    def _create_widget_(self, event, spacer):
         assert gDebug(1, "UI does not support %s" % self.__class__)
 
     def _ui_set_focus_(self, index):

Modified: trunk/gnue-forms/src/uidrivers/qt3/MenuBar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/MenuBar.py       2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/MenuBar.py       2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 UI driver - 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,84 +19,115 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# qt/MenuBar.py
-#
-# DESCRIPTION:
+# $Id: $
 """
-A generic UIdriver base for common message-based GUI toolkits.
+Menu bar
 """
-# NOTES:
-#
 
-import string
-from qt import *
-from gnue.forms.uidrivers._commonGuiToolkit.MenuBar import MenuBar as 
_BaseMenuBar
+import qt
+from gnue.forms.uidrivers._commonGuiToolkit import MenuBar as _Base
 
-class MenuBar(_BaseMenuBar):
+_ICON_CACHE = {}
 
-  # Create the menu
-  def init(self):
-    self.menu = self.container.menuBar()
-    self.__idmap = {}
-    return self.menu
+# =============================================================================
+# Implementation of the menu bar for qt3
+# =============================================================================
 
-  # Add a (sub)menu
-  def addMenu(self, name, parent):
-    menu = QPopupMenu(parent)
-    parent.insertItem(name, menu)
-    QObject.connect(menu, SIGNAL('activated(int)'), self.__itemSelected)
+class MenuBar(_Base.MenuBar):
 
-    return menu
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
 
-  # Add a menu item (action)
-  def addAction(self, name, parent, userAction):
-    label = name
-    hotkey = userAction.getHotKeyText()
-    iconloc = userAction.getIconLocation(size="16x16")
+    def init(self):
+        self.menubar = self.container.menuBar()
+        self.__idmap = {}
+        return self.menubar
 
-    if hotkey:
-      label += '\t%s' % hotkey
+    # -------------------------------------------------------------------------
+    # Add a sub menu
+    # -------------------------------------------------------------------------
 
-    # Set the action icon if available
-    if iconloc:
-      try:
-        # Some caching logic for faster second/third forms
-        icon = _cachedIcons[iconloc]
-      except KeyError:
-        icon = QIconSet(QPixmap(iconloc))
-        _cachedIcons[iconloc] = icon
-      id = parent.insertItem(icon, label)
-    else:
-      id = parent.insertItem(label)
+    def addMenu(self, name, parent):
+        """
+        Add antoher menu to the given parent menu or menubar
 
-    parent.setWhatsThis(id, userAction.description or '')
+        @param name: name of the menu
+        @param parent: parent menu or menubar to append the new menu to
 
-    self.__idmap[id] = 'request' + userAction.event
+        @result: newly created menu
+        """
 
-    return (parent, id)
+        menu = qt.QPopupMenu(parent)
+        parent.insertItem(name, menu)
+        qt.QObject.connect(menu, qt.SIGNAL('activated(int)'),
+                self.__item_selected)
+        return menu
 
-  # Add a separator
-  def addSeparator(self, parent):
-    parent.insertSeparator()
 
-  # Enable a menu item
-  def enableItem(self, item):
-    parent, id = item
-    parent.setItemEnabled(id, 1)
+    # -------------------------------------------------------------------------
+    # Add an action
+    # -------------------------------------------------------------------------
 
-  # Disable a menu item
-  def disableItem(self, item):
-    parent, id = item
-    parent.setItemEnabled(id, 0)
+    def addAction(self, name, parent, userAction):
+        """
+        Add a new menu item to a given menu.
 
-  # A menu item was selected
-  def __itemSelected(self, itemid):
-    self.driver.dispatchEvent(self.__idmap[itemid], _form=self.form)
+        @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
+        """
 
-_cachedIcons = {}
+        hotkey = userAction.getHotKeyText()
+        iconloc = userAction.getIconLocation(size="16x16")
+        label = hotkey and "%s\t%s" % (name, hotkey) or name
 
+        # Set the action icon if available
+        if iconloc:
+            icon = _ICON_CACHE.setdefault(iconloc,
+                                          qt.QIconSet(qt.QPixmap(iconloc)))
+            mid = parent.insertItem(icon, label)
+        else:
+            mid = parent.insertItem(label)
 
+        parent.setWhatsThis(mid, userAction.description or '')
+
+        self.__idmap[mid] = userAction
+
+        return (parent, mid)
+
+    # -------------------------------------------------------------------------
+    # Add a separator
+    # -------------------------------------------------------------------------
+
+    def addSeparator(self, parent):
+        parent.insertSeparator()
+
+
+    # -------------------------------------------------------------------------
+    # Enable a menu item
+    # -------------------------------------------------------------------------
+
+    def enableItem(self, item):
+        parent, mid = item
+        parent.setItemEnabled(mid, True)
+
+
+    # -------------------------------------------------------------------------
+    # Disable a menu item
+    # -------------------------------------------------------------------------
+
+    def disableItem(self, item):
+        parent, mid = item
+        parent.setItemEnabled(mid, False)
+
+
+    # -------------------------------------------------------------------------
+    # A menu item was selected
+    # -------------------------------------------------------------------------
+
+    def __item_selected(self, itemid):
+
+        self._fire(self.__idmap[itemid])

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/_base.py 2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 UI Driver - Basic UI widget
 #
-# 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,133 +19,81 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIqt.py
-#
-# DESCRIPTION:
-# A wxPython based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-from qt import *
+# $Id: $
 
-from gnue.common import events
+import qt
 
-from gnue.forms.GFForm import *
-from gnue.forms.uidrivers._base.widgets._base import *
-from gnue.forms.uidrivers.qt3.common import *
+from gnue.forms.uidrivers._base.widgets._base import UIWidget
 
 
-#############################################################################
-#############################################################################
-#
-# UI Objects
-#
-# A set of standard UI objects that allow us to move more code into UIbase
-# These map generic functionality to the specific UI widget set in use by
-# this driver.
-#
-#############################################################################
-#############################################################################
+# =============================================================================
+# Base class for all qt3 UI widgets 
+# =============================================================================
 
-#
-# UIHelper
-#
-# Provides a UI widget set of std functions to reduce the number of functions
-# require in each UIclass listed below.
-#
 class UIHelper(UIWidget):
-  #
-  # Functions limited to the Qt driver
-  #
-  def _addToCrossRef(self, widget,gfobject, uiobject):
-    i = id(widget)  # ????
-    self._uiDriver._IdToTkObj[i]=widget
-    self._uiDriver._IdToGFObj[i]=gfobject
-    self._uiDriver._IdToUIObj[i]=uiobject
-#    widget.__origBackgroundColor = Qt.White # widget.getBackgroundColor()
+    """
+    """
 
-  def _deleteFromCrossRef(self, widget, object):
-    i = id(widget)
-    try:
-      del self._uiDriver._IdToTkObj[i]
-      del self._uiDriver._IdToGFObj[i]
-      del self._uiDriver._IdToUIObj[i]
-    except:
-      pass
+    # -------------------------------------------------------------------------
+    # Set the focus to the given widget
+    # -------------------------------------------------------------------------
 
-  #
-  # Override the base UIWidget functions
-  #
-  def show(self):
-    print "showing", self.widgets
-    for widget in self.widgets:
-      widget.show()
-##      widget.raise()
+    def indexed_focus(self, index):
+        """
+        Set the focus to the qt widget specified by index.  For entries having
+        no rows the index will always be 0.
 
-  def hide(self):
-    print "hiding", self.widgets
-    for widget in self.widgets:
-      widget.show(0)
+        @param index: the index of the qt widget to set the focus to
+        """
+        self.widgets[index].setFocus()
 
-  def show_modal(self):
-    self.setModal(1)
 
-  def destroy(self):
-##    self.Destroy()
-    pass
+    # -------------------------------------------------------------------------
+    # The focus should move away from a widget
+    # -------------------------------------------------------------------------
 
-  def indexed_focus(self, index):
-    self.widgets[index].setFocus()
+    def lose_focus(self, index):
+        """
+        Take away the focus of the qt widget with the given index.  If this
+        object is used within a grid, losing the focus means hiding the entry
+        widget and displaying the label widget.
 
-  def _ui_set_value_(self, index, value):
-    # These must be here or dropdown style controls
-    # will get events they shouldn't and break.
-    widget = self.widgets[index]
+        @param index: the index of the qt widget to kill the focus for
+        """
+        pass
 
-    # Check if foreign key changed
-    object = self._uiDriver._IdToGFObj[id(widget)]
-    try:
-      if object.style == "dropdown" and \
-          not object._field._allowedValues == widget._origAllowedValues:
-        widget._origAllowedValues = object._field._allowedValues
-        widget.clear()
-        for value in object._field._allowedValuesDescr:
-          widget.insertString(value)
-    except AttributeError:
-      pass
 
-    if object.style == "checkbox":
-      widget.setChecked(value)
-    else:
-      widget.setText(value)
+    def _ui_set_value_(self, index, value):
+        # These must be here or dropdown style controls
+        # will get events they shouldn't and break.
+        widget = self.widgets[index]
 
+        # Check if foreign key changed
+        object = self._uiDriver._IdToGFObj[id(widget)]
+        try:
+          if object.style == "dropdown" and \
+              not object._field._allowedValues == widget._origAllowedValues:
+            widget._origAllowedValues = object._field._allowedValues
+            widget.clear()
+            for value in object._field._allowedValuesDescr:
+              widget.insertString(value)
+        except AttributeError:
+          pass
 
-  def _ui_set_cursor_position_(self, index, position):
-    try:
-      self.widgets[index].set_cursor_position(position)
-    except AttributeError:
-      pass  # For label-style entries
+        if object.style == "checkbox":
+          widget.setChecked(value)
+        else:
+          widget.setText(value)
 
-  def _ui_set_selected_area_(self, index, selection1, selection2):
-    try:
-      self.widgets[index].setSelection(selection1, selection2-selection1)
-    except (AttributeError, TypeError):
-      pass  # For label-style & dropdown entries
 
-  def create_widget(self, event, spacer):
-    newWidget = self._create_widget(event, spacer)
-    initFont(newWidget)
-    self._addToCrossRef(newWidget,event.object,self)
-    return newWidget
+    def _ui_set_cursor_position_(self, index, position):
+        try:
+          self.widgets[index].set_cursor_position(position)
+        except AttributeError:
+          pass  # For label-style entries
 
-  def cleanup(self, object):
-    for widget in self.widgets[:]:
-      i = id(widget)
-      del self._uiDriver._IdToTkObj[i]
-      del self._uiDriver._IdToGFObj[i]
-      del self._uiDriver._IdToUIObj[i]
-      self.widgets.pop(0)
-      self._deleteFromCrossRef(widget, object)
+    def _ui_set_selected_area_(self, index, selection1, selection2):
+        try:
+          self.widgets[index].setSelection(selection1, selection2-selection1)
+        except (AttributeError, TypeError):
+          pass  # For label-style & dropdown entries

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/box.py   2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/box.py   2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 UI Driver - Box widgets
 #
-# 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,49 +19,70 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIqt.py
-#
-# DESCRIPTION:
-# A QT-based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-from qt import *
+# $Id: $
 
+import qt
+
 from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
 
-#
-# UIBox
-#
-# Widget set specific function that creates a single instance of a border box
-#
+__all__ = ['UIBox']
+
+# =============================================================================
+# The Box Widget
+# =============================================================================
+
 class UIBox(UIHelper):
+    """
+    Implementation of the box tag
+    """
+
+    # -------------------------------------------------------------------------
+    # Create the widget
+    # -------------------------------------------------------------------------
     
-  def _create_widget(self, event, spacer):
-    object = event.object
+    def _create_widget_(self, event, spacer):
+        """
+        Create the QGroupBox and add it to the owner
+
+        @param event: the creation event instance
+        """
     
-    # Create a group box..
-    newWidget = QGroupBox(object.label, event.container)
+        self._container = qt.QGroupBox(self._gfObject.label, event.container)
+        self.widget = self._container
+
+        sizer = qt.QGridLayout(self._container, self.chr_h, self.chr_w, 2, 2)
+        self.getParent().add_widgets(self, 0)
         
-    # ..and move it to it's proper place
-    newWidget.setGeometry(object.Char__x*event.widgetWidth,
-                          
(object.Char__y+spacer+(spacer*object._gap))*event.widgetHeight,
-                          (object.Char__width-1)*event.widgetWidth,
-                                                         
(object.Char__height-1)*event.widgetHeight)
-#                          self.itemWidth,self.itemHeight)
-    newWidget.lowerW()
-    
-    return newWidget
+        return self._container
 
-#
-# Configuration data 
-#
+
+    # -------------------------------------------------------------------------
+    # Add child widgets (qt) to the layout
+    # -------------------------------------------------------------------------
+
+    def add_widgets(self, ui_widget, spacer):
+        """
+        Add a given UI-widget to the QGridLayout of the box
+
+        @param ui_widget: UI widget to add
+        @param spacer: not used for boxes
+        """
+
+        item = ui_widget.widget
+
+        self._container.layout().addMultiCellWidget(item, ui_widget.chr_y,
+                ui_widget.chr_y + ui_widget.chr_h - 1, ui_widget.chr_x,
+                ui_widget.chr_x + ui_widget.chr_w - 1)
+
+
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
 configuration = {
-    'baseClass'  : UIBox,
-    'provides'   : 'GFBox',
-    'container'  : 0,
-    }
-
+  'baseClass': UIBox,
+  'provides' : 'GFBox',
+  'container': 0,
+}

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/entry.py 2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 UI driver - Entry widgets
 #
-# 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,92 +19,33 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIwxpython.py
-#
-# DESCRIPTION:
+# $Id: $
 """
 Entry widget
 """
-# NOTES:
-#
-from qt import *
-from gnue.common import events
 
+import qt
+
 from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
-from gnue.forms.uidrivers.qt3.common import _eventObjToQtWindow
-from gnue.forms.uidrivers.qt3.common import uiBaseEvtHandler as _Base
 
-#
-# UIEntry
-#
-# Widget set specific function that creates a single instance of a data entry 
widget
-#
+# =============================================================================
+# Interface class for entry widgets
+# =============================================================================
+
 class UIEntry(UIHelper):
-  def _create_widget(self, event, spacer):
-    object = event.object
+    """
+    """
 
-    style = object.style
+    def _create_widget_(self, event, spacer):
 
-    if style == 'dropdown':
-      if event.initialize:
-        choices = object._field.allowedValues()[1]
-      else:
-        choices = [""]
+        style = self._gfObject.style.lower()
 
-      newWidget = _ComboBox(event, self)
-      newWidget.setInsertionPolicy(QComboBox.NoInsertion)
+        self.widget = qt.QLineEdit(event.container)
+        self.getParent().add_widgets(self, spacer)
 
-      if event.initialize:
-        newWidget.setChoices(choices)
-        newWidget._origAllowedValues = object._field._allowedValues
-        newWidget.setEditable(True)
-        newWidget.setCurrentItem(False)
+        return self.widget
 
-        # TODO: Listen for textChanged(), highlighted()
 
-
-    elif style == 'label':
-      newWidget = QLabel("", event.container)
-
-
-    elif style == 'checkbox':
-      newWidget = _CheckBox(event, self)
-
-      # .. set the label text..
-      newWidget.setText(object.label)
-
-      if event.initialize:
-        newWidget.setChecked(False)
-
-        # TODO: Listen for "clicked()"
-
-
-    else: # Normal text box
-      if hasattr(object,'Char__height') and object.Char__height > 1:
-        cls = _MultiLineEdit
-      else:
-        # TODO: According to the QT 3 docs, we should probably switch
-        # TODO: to QTextEdit.  However, I'm not sure how to check for
-        # TODO: the QT version in use :)
-        cls = _SingleLineEdit
-
-      newWidget = cls(event, self)
-
-      # TODO: Capture textChanged, returnPressed, selectionChanged signals
-
-
-    # Move it to it's proper place
-    newWidget.setGeometry(object.Char__x*event.widgetWidth,
-                          
(object.Char__y+spacer+(spacer*object._gap))*event.widgetHeight,
-                          self.itemWidth,self.itemHeight)
-
-
-    return newWidget
-
-
     # -------------------------------------------------------------------------
     # Enable/disable this entry
     # -------------------------------------------------------------------------
@@ -114,94 +58,23 @@
     def _ui_disable_(self, index):
         self.widgets[index].setEnabled(False)
 
+    # -------------------------------------------------------------------------
 
-###########################################################
-#
-#  Our custom event-riddled QObjects
-#
-class _SingleLineEdit (_Base, QLineEdit):
-  """
-  """
-  def __init__(self, event, uiwidget):
-    QLineEdit.__init__(self, event.container)
-    _Base.__init__(self, event, uiwidget, QLineEdit)
-    QObject.connect(self, SIGNAL('selectionChanged()'),
-                    self._selectionChanged)
+    def _ui_set_value_(self, index, value):
+        """
+        This function sets the value of a widget.
+        """
 
+        widget = self.widgets[index]
+        widget.setText(value)
 
 
 
-class _MultiLineEdit (_Base, QTextEdit):
-  """
-  """
-  def __init__(self, event, uiwidget):
-    QTextEdit.__init__(self, event.container)
-    _Base.__init__(self, event, uiwidget, QTextEdit)
-    QObject.connect(self, SIGNAL('selectionChanged()'),
-                    self._selectionChanged)
+# =============================================================================
+# Configuration
+# =============================================================================
 
-
-
-class _ComboBox (_Base, QComboBox):
-  """
-  """
-  def __init__(self, event, uiwidget):
-    QComboBox.__init__(self, True, event.container, "Foo")
-    _Base.__init__(self, event, uiwidget, QComboBox)
-    QComboBox.setLineEdit(self, _SingleLineEdit(event, uiwidget))
-    QObject.connect(self, SIGNAL('activated(int)'),
-                    self.__itemSelected)
-
-  def setChoices(self,choices):
-    self.__choices = choices
-    for choice in choices:
-      self.insertItem(choice)
-
-  def setText(self, text):
-    self.setCurrentItem(self.__choices.index(text))
-
-  def __itemSelected(self, selection):
-    selected_text = self.__choices[selection]
-
-    uiwidget = self._uiwidget
-    gfObject = uiwidget._gfObject
-    action = events.Event('requestREPLACEVALUE',object=gfObject,
-                          index=selection, text=selected_text,
-                          _form=gfObject._form)
-
-    # TODO: allow veto
-    self._eventHandler(action)
-
-  def focusInEvent(self,event):
-    uiwidget = self._uiwidget
-    gfObject = uiwidget._gfObject
-    self._eventHandler('requestFOCUS',gfObject,_form=gfObject._form)
-    count = uiwidget._uiDriver._IdToUIObj[id(self)].widgets.index(self)
-    self._eventHandler('requestJUMPRECORD',count - 
gfObject._visibleIndex,_form=gfObject._form)
-
-
-class _ComboBoxLineEdit(QLineEdit):
-  def __init__(self, parent, *args, **parms):
-    QLineEdit(*args, **parms)
-    self.__parent = parent
-    self.setFocusPolicy(QWidget.NoFocus)
-
-  def focusInEvent(self,event):
-    self.__parent.focusInEvent(event)
-
-
-class _CheckBox (_Base, QCheckBox):
-  """
-  """
-  def __init__(self, event, uiwidget):
-    QCheckBox.__init__(self, event.container)
-    _Base.__init__(self, event, uiwidget, QCheckBox)
-
-#
-#
-#
 configuration = {
-    'baseClass'  : UIEntry,
-    'provides'   : 'GFEntry',
-    'container'  : False,
-  }
+  'baseClass': UIEntry,
+  'provides' : 'GFEntry', 'container': False,
+}

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py  2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py  2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -26,7 +26,8 @@
 
 import qt
 
-from _base import UIHelper
+from gnue.forms.uidrivers.qt3.MenuBar import MenuBar
+from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
 
 # =============================================================================
 # The form
@@ -68,7 +69,7 @@
     # Create a new window object
     # -------------------------------------------------------------------------
 
-    def _create_widget(self, event, spacer):
+    def _create_widget_(self, event, spacer):
         
         if self._form.style != 'dialog':
             self.main_window = self._uiDriver._parentContainer
@@ -84,10 +85,16 @@
 
         base_sizer = qt.QVBoxLayout(self.main_widget)
         base_sizer.setMargin(6)
+        base_sizer.setResizeMode(qt.QLayout.Minimum)
 
         if self._form.style != 'dialog':
-            pass
+            if not self._form._features['GUI:STATUSBAR:SUPPRESS']:
+                self.__status_bar = self.main_window.statusBar()
+                self.__setup_status_bar()
 
+            if not self._form._features['GUI:MENUBAR:SUPPRESS']:
+                MenuBar(self._uiDriver, self.main_window, self._form)
+
         if self._form._layout.tabbed != 'none':
             self._container = qt.QTabWidget(self.main_widget)
             self._container.setTabPosition( \
@@ -152,22 +159,40 @@
                 self.main_window.repaint()
 
     # -------------------------------------------------------------------------
+    # Populate the status bar
+    # -------------------------------------------------------------------------
+
+    def __setup_status_bar(self):
+
+        self.__status_bar.setSizeGripEnabled(True)
+
+        for i in [-1, 50, 50, 75, 75]:
+            widget = qt.QLabel(self.__status_bar)
+            if i > -1:
+                widget.setMinimumWidth(75)
+                stretch = 0
+            else:
+                stretch = 1
+            self.__status_bar.addWidget(widget, stretch, True)
+
+
+    # -------------------------------------------------------------------------
     # User feedback functions
     # -------------------------------------------------------------------------
 
-    def _ui_begin_wait(self):
+    def _ui_begin_wait_(self):
         """
         Display the hourglass cursor on all windows of the application.
         """
-        self.main_window.setCursor(qt.Qt.WaitCursor)
+        self.main_window.setCursor(qt.QCursor(qt.Qt.WaitCursor))
 
     # -------------------------------------------------------------------------
 
-    def _ui_end_wait(self):
+    def _ui_end_wait_(self):
         """
         Display the normal mouse cursor on all windows of the application.
         """
-        self.main_window.setCursor(qt.Qt.ArrowCursor)
+        self.main_window.setCursor(qt.QCursor(qt.Qt.ArrowCursor))
 
     # -------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/label.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/label.py 2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/label.py 2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 UI driver - Label widgets
 #
-# 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,59 +19,45 @@
 # write to the Free Software Foundation, Inc., 59 Temple Place
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIqt.py
-#
-# DESCRIPTION:
-# A QT-based user interface driver for GNUe forms.
-#
-# NOTES:
-#
+# $Id: $
 
-from qt import *
+import qt
 
 from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
 
-_alignmentStyle = { 'left'  : 0, #AlignAuto|AlignVCenter,
-                    'center': 0, #AlignHCenter|AlignVCenter,
-                    'right' : 0, #AlignRight|AlignVCenter,
-                   }
+_alignment = {
+        'left'  : qt.Qt.AlignLeft | qt.Qt.AlignVCenter,
+        'center': qt.Qt.AlignHCenter | qt.Qt.AlignVCenter,
+        'right' : qt.Qt.AlignRight | qt.Qt.AlignVCenter}
 
+# =============================================================================
+# UI Label widget
+# =============================================================================
 
-#
-# UILabel
-#
-# Widget set specific function that creates a single instance of a label
-#
 class UILabel(UIHelper):
+    """
+    """
 
+    # -------------------------------------------------------------------------
+    # Create the widget
+    # -------------------------------------------------------------------------
 
-  def _create_widget(self, event, spacer):
-    object = event.object
-    
-    # Create a label..
-    newWidget = QLabel(object.text, event.container)
-    
-    # ..move it to it's proper place..
-    print object.Char__x*event.widgetWidth, \
-                              
(object.Char__y+spacer+(spacer*object._gap))*event.widgetHeight, \
-                                                        
self.itemWidth,self.itemHeight
-    newWidget.setGeometry(object.Char__x*event.widgetWidth,
-                          
(object.Char__y+spacer+(spacer*object._gap))*event.widgetHeight, 
-                          self.itemWidth,self.itemHeight)
+    def _create_widget_(self, event, spacer):
 
-    # ..and set justification
-    newWidget.setAlignment(_alignmentStyle[object.alignment])
-    
-    return newWidget
+        self.widget = qt.QLabel(self._gfObject.text, event.container)
+        self.widget.setAlignment(_alignment[self._gfObject.alignment])
 
-    
-    
-    
+        self.getParent().add_widgets(self, spacer)
+        
+        return self.widget
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
 configuration = {
-    'baseClass'  : UILabel,
-    'provides'   : 'GFLabel',
-    'container'  : 0,
-    }
+  'baseClass': UILabel,
+  'provides' : 'GFLabel',
+  'container': 0,
+}

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py  2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py  2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -43,7 +43,7 @@
     # Create a new page widget
     # -------------------------------------------------------------------------
 
-    def _create_widget(self, event, spacer):
+    def _create_widget_(self, event, spacer):
         """
         Create the page widget and add it to the page-container.  The spacer is
         ignored for page tags.
@@ -55,12 +55,15 @@
         self.page_index = len(self._uiForm.pages)
 
         parent = event.container
+        print "PARENT of", repr(self._gfObject), "==", repr(parent)
 
         self._container = qt.QWidget(parent)
         if self.managed:
             page_sizer = qt.QVBoxLayout(self._container)
         else:
-            page_sizer = qt.QGridLayout(self._container)
+            w = getattr(self._form._layout, 'Char__width', -1)
+            h = getattr(self._form._layout, 'Char__height', -1)
+            page_sizer = qt.QGridLayout(self._container, h, w, 2, 2)
 
         if isinstance(parent, qt.QTabWidget):
             title = "%s" % (self._gfObject.caption or self._gfObject.name)
@@ -72,6 +75,28 @@
 
         return self._container
 
+
+    # -------------------------------------------------------------------------
+    # Add an UI widget to the page
+    # -------------------------------------------------------------------------
+
+    def add_widgets(self, ui_widget, spacer):
+        """
+        Add an UI widget to the page
+
+        @param ui_widget: UI widget to be added
+        @param spacer: not used for pages
+        """
+
+        item = ui_widget.widget
+        sizer = self._container.layout()
+
+        if self.managed:
+            sizer.addWidget(item)
+        else:
+            sizer.addMultiCellWidget(item, ui_widget.chr_y, ui_widget.chr_y +
+                    ui_widget.chr_h - 1, ui_widget.chr_x, ui_widget.chr_x +
+                    ui_widget.chr_w - 1)
     
 # =============================================================================
 # Configuration

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -27,7 +27,6 @@
 
 import wx
 
-from gnue.common.definitions import GParser
 from gnue.forms.uidrivers.wx26.widgets import _base
 
 __all__ = ['UIBox']

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-10-11 14:06:37 UTC 
(rev 8751)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-10-11 14:11:18 UTC 
(rev 8752)
@@ -65,6 +65,7 @@
         self.page_index = len(self._uiForm.pages)
 
         parent = event.container
+        print "NOTE:", repr(self._gfObject), "==", repr(parent)
 
         self._container = wx.Panel(parent, -1)
 





reply via email to

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