commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8524 - in trunk/gnue-forms: doc/technotes samples/intro samples/


From: johannes
Subject: [gnue] r8524 - in trunk/gnue-forms: doc/technotes samples/intro samples/zipcode src src/GFObjects src/uidrivers/_base src/uidrivers/_base/widgets src/uidrivers/curses/widgets src/uidrivers/gtk2/widgets src/uidrivers/wx/widgets src/uidrivers/wx26/widgets
Date: Wed, 5 Jul 2006 08:46:02 -0500 (CDT)

Author: johannes
Date: 2006-07-05 08:45:59 -0500 (Wed, 05 Jul 2006)
New Revision: 8524

Added:
   trunk/gnue-forms/samples/zipcode/zipgrid.gfd
   trunk/gnue-forms/src/GFObjects/GFGrid.py
   trunk/gnue-forms/src/GFObjects/GFGridLine.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/gridline.py
Modified:
   trunk/gnue-forms/doc/technotes/00006.txt
   trunk/gnue-forms/samples/intro/intro.gfd
   trunk/gnue-forms/samples/zipcode/zipcode.gsd
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFObjects/GFEntry.py
   trunk/gnue-forms/src/GFObjects/GFObj.py
   trunk/gnue-forms/src/GFObjects/__init__.py
   trunk/gnue-forms/src/GFParser.py
   trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
   trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/_base.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/hbox.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
   trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
Log:
More work in layout management and started work on grid controls. This 
commit is more like a backup-to-svn, although the basic concepts are 
working. More 'clean-up' commits and improvements will follow soon.

issue89 in-progress


Modified: trunk/gnue-forms/doc/technotes/00006.txt
===================================================================
--- trunk/gnue-forms/doc/technotes/00006.txt    2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/doc/technotes/00006.txt    2006-07-05 13:45:59 UTC (rev 
8524)
@@ -91,3 +91,16 @@
 Comment: [-----------------------------------------------------]
 [------] [-----] [-----------------------] [--------] [--------]
 Comment: [-----------------------------------------------------]
+
+<grid block="foo">
+  <gridline>
+      <entry name="number" label="Number" field="bar"/>
+      <entry name="account" label="Accout" />
+      <entry name="name" label="Account Name" />
+      <entry name="debit" label="Debit" />
+  </gridline>
+  <gridline>
+      <label text="Comment:"/>
+      <entry name="Comment" Sizer:span="4"/>
+  </gridline>
+</grid>

Modified: trunk/gnue-forms/samples/intro/intro.gfd
===================================================================
--- trunk/gnue-forms/samples/intro/intro.gfd    2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/samples/intro/intro.gfd    2006-07-05 13:45:59 UTC (rev 
8524)
@@ -122,7 +122,7 @@
       <entry block="SampleBlock" field="Entry_1" c:width="34" c:x="3" c:y="9"/>
     </page>
     <page name="Sample">
-      <box name="Box_2" c:height="8" label="Sample" c:width="38" c:x="1"
+      <box name="Box_2" c:height="8" label="Sample" c:width="39" c:x="1"
            c:y="0"/>
       <label for="nameField" name="Label_5" text="Your Name:" c:width="11" 
c:x="3" c:y="2"/>
       <label for="yearField" name="Label_6" text="Year you were born:" 
c:width="20" c:x="3"
@@ -131,7 +131,7 @@
              c:y="5"/>
       <entry name="nameField" block="SampleBlock" field="NameEntry" 
c:width="23" c:x="14"
              c:y="2"/>
-      <entry name="yearField" block="SampleBlock" field="YearEntry" 
c:width="6" c:x="22"
+      <entry name="yearField" block="SampleBlock" field="YearEntry" 
c:width="6" c:x="23"
              c:y="3"/>
       <button name="btnClear" c:height="1" label="Fortune" c:width="8"
               c:x="29" c:y="3">

Modified: trunk/gnue-forms/samples/zipcode/zipcode.gsd
===================================================================
--- trunk/gnue-forms/samples/zipcode/zipcode.gsd        2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/samples/zipcode/zipcode.gsd        2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -253,6 +253,31 @@
     </rows>
   </tabledata>
 
+  <tabledata name="city_data" tablename="zipcode">
+    <rows>
+      <row>
+        <value field="zip">19901</value>
+        <value field="city">Dover</value>
+        <value field="state">DE</value>
+        <value field="longitude">-75.5268</value>
+        <value field="latitude">39.1618</value>
+      </row>
+      <row>
+        <value field="zip">19952</value>
+        <value field="city">Harrington</value>
+        <value field="state">DE</value>
+        <value field="longitude">-75.57472</value>
+        <value field="latitude">38.924446</value>
+      </row>
+      <row>
+        <value field="zip">19958</value>
+        <value field="city">Lewes</value>
+        <value field="state">DE</value>
+        <value field="longitude">-75.142101</value>
+        <value field="latitude">38.775939</value>
+      </row>
+    </rows>
+  </tabledata>
 </data>
 
 </schema>

Added: trunk/gnue-forms/samples/zipcode/zipgrid.gfd
===================================================================
--- trunk/gnue-forms/samples/zipcode/zipgrid.gfd        2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/samples/zipcode/zipgrid.gfd        2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+
+<form title="ZIP Code Maintenance">
+  <options>
+    <option name="version" value="0.0.2"/>
+  </options>
+
+  <datasource name="zips" cache="5" connection="gnue" order_by="state,city"
+              prequery="Y" table="zipcode"/>
+  <datasource name="validator" connection="gnue" order_by="description"
+              prequery="Y" table="state"/>
+  <logic>
+    <block name="zip" datasource="zips" rows="15">
+      <field name="city" case="upper" field="city" required="Y">
+        <options>
+          <option name="tip" value="Full name of city"/>
+        </options>
+      </field>
+      <field name="state" field="state" fk_description="description"
+             fk_key="state" fk_source="validator">
+        <options>
+          <option name="tip" value="State"/>
+        </options>
+      </field>
+      <field name="zip" field="zip" max_length="5" typecast="number">
+        <options>
+          <option name="tip" value="US Postal Zip Code"/>
+        </options>
+      </field>
+      <field name="longitude" field="longitude" typecast="number"/>
+      <field name="latitude" field="latitude" typecast="number"/>
+    </block>
+  </logic>
+
+  <layout xmlns:s="GNUe:Layout:Sizer" tabbed="top">
+    <page name="Page_1">
+      <grid block="zip" rows="5">
+        <gridline>
+          <entry name="city" field="city" label="City" />
+          <entry name="zip" field="zip" label="ZIP" />
+          <entry name="state" field="state" label="State"/>
+        </gridline>
+        <gridline>
+          <entry name="longitude" field="longitude" label="Longitude"/>
+          <entry name="latitude" field="latitude" label="Latitude" s:span="2"/>
+        </gridline>
+      </grid>
+    </page>
+  </layout>
+</form>

Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-06-29 21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/GFForm.py      2006-07-05 13:45:59 UTC (rev 8524)
@@ -1423,7 +1423,7 @@
 
     def __refreshDisplay(self, object):
         if object._type in ('GFEntry', "GFImage"):
-          self.dispatchEvent('updateENTRY',object, _form=self)
+            self.dispatchEvent('updateENTRY',object, _form=self)
 
 
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFObjects/GFEntry.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFEntry.py   2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/src/GFObjects/GFEntry.py   2006-07-05 13:45:59 UTC (rev 
8524)
@@ -115,8 +115,12 @@
                              self._inputmask)
 
         # Row settings
-        self._rows = getattr(self, 'rows', self._field._rows)
-        self._gap  = getattr(self, 'rowSpacer', self._field._gap)
+        grid = self.findParentOfType('GFGrid')
+        if grid:
+            self._rows = int(getattr(grid, 'rows', 1))
+        else:
+            self._rows = getattr(self, 'rows', self._field._rows)
+            self._gap  = getattr(self, 'rowSpacer', self._field._gap)
 
 
     # -------------------------------------------------------------------------

Added: trunk/gnue-forms/src/GFObjects/GFGrid.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFGrid.py    2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/src/GFObjects/GFGrid.py    2006-07-05 13:45:59 UTC (rev 
8524)
@@ -0,0 +1,58 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Box
+#
+# 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$
+"""
+Logical box support
+"""
+
+from GFContainer import GFContainer
+
+__all__ = ['GFGrid']
+
+# =============================================================================
+# <vbox>
+# =============================================================================
+
+class GFGrid(GFContainer):
+
+    # -------------------------------------------------------------------------
+    # Attributes
+    # -------------------------------------------------------------------------
+
+    label = None
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent=None):
+        GFContainer.__init__(self, parent, "GFGrid")
+
+    def _phase_1_init_(self):
+        GFContainer._phase_1_init_(self)
+
+        self.__rows = int(getattr(self, "rows", 1))
+        self.walk(self.__row_walker)
+
+    def __row_walker(self, item):
+        if item != self:
+            item._rows = self.__rows


Property changes on: trunk/gnue-forms/src/GFObjects/GFGrid.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/gnue-forms/src/GFObjects/GFGridLine.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFGridLine.py        2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/GFObjects/GFGridLine.py        2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -0,0 +1,48 @@
+# GNU Enterprise Forms - GF Object Hierarchy - Box
+#
+# 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$
+"""
+Logical box support
+"""
+
+from GFContainer import GFContainer
+
+__all__ = ['GFGridLine']
+
+# =============================================================================
+# <vbox>
+# =============================================================================
+
+class GFGridLine(GFContainer):
+
+    # -------------------------------------------------------------------------
+    # Attributes
+    # -------------------------------------------------------------------------
+
+    label = None
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent=None):
+        GFContainer.__init__(self, parent, "GFGridLine")


Property changes on: trunk/gnue-forms/src/GFObjects/GFGridLine.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/gnue-forms/src/GFObjects/GFObj.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFObj.py     2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/src/GFObjects/GFObj.py     2006-07-05 13:45:59 UTC (rev 
8524)
@@ -191,7 +191,14 @@
         """
 
         if not hasattr(self, 'block'):
-            return None
+            owner = self.getParent()
+            while owner:
+                self.block = getattr(owner, 'block', None)
+                if self.block:
+                    break
+                owner = owner.getParent()
+            else:
+                return None
 
         if not self.block in self._form._logic._blockMap:
             raise BlockNotFoundError, self

Modified: trunk/gnue-forms/src/GFObjects/__init__.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/__init__.py  2006-06-29 21:16:34 UTC (rev 
8523)
+++ trunk/gnue-forms/src/GFObjects/__init__.py  2006-07-05 13:45:59 UTC (rev 
8524)
@@ -43,7 +43,9 @@
         "GFParameter",
         "GFComponent",
         "GFTabStop",
-        "GFContainer"
+        "GFContainer",
+        "GFGrid",
+        "GFGridLine"
        ]
 
 for module in __all__:

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2006-06-29 21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/GFParser.py    2006-07-05 13:45:59 UTC (rev 8524)
@@ -669,7 +669,7 @@
                'Description': 'The name of the field that this ties to.' },
             'block': {
                'Typecast': GTypecast.name,
-               'Required': True,
+               'Required': False,
                'References': 'block.name',
                'Description': 'The name of the block that this ties to.' },
             'focusorder': {
@@ -732,7 +732,7 @@
                'Description': 'Defines how the field data will be formatted '
                               'for display.' } },
          'Positionable': True,
-         'ParentTags': ('page','hbox','vbox','box'),
+         'ParentTags': ('page','hbox','vbox','box','gridline'),
          'Description': 'An {entry} is the visual counterpart to a {field}, '
                         'it defines how the data in a field will be displayed '
                         'and how it can be edited.'},
@@ -822,6 +822,38 @@
          'Description': 'A box is a visual element that draws a box around '
                         'other visual elements, thus providing logical '
                         'separation for them.' },
+      'grid': {
+         'BaseClass': GFObjects.GFGrid,
+         'Attributes': {
+            'name': {
+               'Unique': True,
+               'Typecast': GTypecast.name,
+               'Description': 'The unique ID of the grid.' },
+            'block': {
+               'Required': True,
+               'Typecast': GTypecast.name,
+               'Description': 'The block for this grid.' },
+            'rows': {
+               'Typecast': GTypecast.whole,
+               'Description': 'Overrides the rows setting defined at the '
+                              'block level.'},
+
+            },
+         'Positionable': True,
+         'ParentTags': ('page','box','hbox','vbox'),
+         'Description': 'Displays a grid control' },
+      'gridline': {
+         'BaseClass': GFObjects.GFGridLine,
+         'Attributes': {
+            'name': {
+               'Unique': True,
+               'Typecast': GTypecast.name,
+               'Description': 'The unique ID of the grid.' },
+            },
+         'Positionable': True,
+         'ParentTags': ('grid'),
+         'Description': 'Contains all elements of a sing line in a grid' },
+
       'image': {
          'BaseClass': GFObjects.GFImage,
          'Attributes': {
@@ -963,7 +995,7 @@
                'Typecast': GTypecast.name,
                'Description': 'Action to be executed when the button is 
fired'}},
          'Positionable': True,
-         'ParentTags': ('page','vbox','hbox','box'),
+         'ParentTags': ('page','vbox','hbox','box','gridline'),
          'Description': 'A visual element with text placed on it, that '
                         'the user can push or click, and that event can run '
                         'a bound trigger.' },

Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -338,7 +338,8 @@
     object = event.object
     if object: # Some pages might not have any widgets that can be active
       if self._uiFocusWidget:
-        self._uiFocusWidget.loseFocus ()
+          index = self._uiFocusIndex
+          self._uiFocusWidget.loseFocus (index)
       self._uiFocusWidget = self._gfObjToUIWidget [object]
       self._uiFocusIndex = object._visibleIndex
       self._uiFocusWidget.indexedFocus (object._visibleIndex)

Modified: trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-07-05 
13:45:59 UTC (rev 8524)
@@ -73,6 +73,12 @@
         if self.managed:
             self.stretch = int(getattr(self._gfObject, 'Sizer__stretch', 1))
 
+
+        self.in_grid = self.findParentOfType('UIGrid') is not None
+
+        if self.in_grid:
+            self.span = int(getattr(self._gfObject, 'Sizer__span', 1))
+
         self.widgets = []
 
         # TODO: The following assignments of itemWidth/Height as well as itemX
@@ -204,7 +210,7 @@
     def indexedFocus(self, index):
         pass
 
-    def loseFocus(self):
+    def loseFocus(self, index):
         pass
 
     def showModal(self):

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2006-07-05 
13:45:59 UTC (rev 8524)
@@ -74,10 +74,8 @@
   # Remove focus from widget
   # ---------------------------------------------------------------------------
 
-  def loseFocus (self):
+  def loseFocus (self, index):
 
-    # should go in base uidriver
-    index = self._focusIndex
     self._focusIndex = None
     self._loseFocus (index)
 

Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py        2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/_base.py        2006-07-05 
13:45:59 UTC (rev 8524)
@@ -233,7 +233,7 @@
   # On lose of the focus we un-select ComboBox-Entries
   # ---------------------------------------------------------------------------
 
-  def loseFocus (self):
+  def loseFocus (self, index):
     for widget in self.widgets:
       assert gDebug (6, "Lose focus: %s" % widget)
 

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py  2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py  2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -141,7 +141,7 @@
   # --------------------------------------------------------------------------
   # On lose of the focus we un-select ComboBox-Entries
   # --------------------------------------------------------------------------
-  def loseFocus(self):
+  def loseFocus(self, index):
     """
     Releases focus from the widget that currently had it.
     Resets the widget's color to normal if focus highlighting is used.

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py        2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py        2006-07-05 
13:45:59 UTC (rev 8524)
@@ -28,6 +28,7 @@
 from gnue.forms.GFForm import *
 from gnue.forms.uidrivers._base.widgets._base import UIWidget
 
+__all__ = ['InvalidBoundingBoxError', 'UIHelper']
 
 # =============================================================================
 # Exceptions
@@ -60,12 +61,14 @@
     # -------------------------------------------------------------------------
 
     def __init__(self, event):
+
         UIWidget.__init__(self, event)
 
         self.label = None
         self.widget = None
         self.growable = False
 
+
     # -------------------------------------------------------------------------
     # Create a new wx widget
     # -------------------------------------------------------------------------
@@ -81,9 +84,9 @@
 
         self.prepare_for_layout(event, spacer)
 
-        newWidget = self._createWidget (event, spacer)
+        newWidget = self._createWidget(event, spacer)
         if event.initialize:
-            self._addToCrossRef (newWidget, self._gfObject, self)
+            self._addToCrossRef(newWidget, self._gfObject, self)
 
         return newWidget
 
@@ -238,7 +241,15 @@
         This function set's the focus to the widget specified by index.
         """
 
-        widget  = self.widgets [index]
+        widget = self.widgets [index]
+        if self.in_grid:
+            label = widget._gnue_label_
+            widget.Show()
+            label.Hide()
+            sizer = widget.GetContainingSizer()
+            if sizer:
+                sizer.Layout()
+
         current = widget.FindFocus ()
 
         if isinstance (widget, wx.ComboBox) and 'wxMac' in wx.PlatformInfo:
@@ -255,10 +266,15 @@
     # On lose of the focus we un-select ComboBox-Entries
     # -------------------------------------------------------------------------
 
-    def loseFocus (self):
-        pass
+    def loseFocus (self, index):
 
+        widget = self.widgets[index]
+        if self.in_grid:
+            widget.Hide()
+            widget._gnue_label_.Show()
+            widget.GetContainingSizer().Layout()
 
+
     # -------------------------------------------------------------------------
     # Set the value of a widget
     # -------------------------------------------------------------------------
@@ -269,7 +285,11 @@
         disables the widget.
         """
 
-        widget = self.widgets [index]
+        widget = self.widgets[index]
+
+        if not widget:
+            return
+
         widget.SetEvtHandlerEnabled (False)
 
         try:
@@ -297,6 +317,9 @@
             widget.Enable (enabled)
 
         finally:
+            if self.in_grid:
+                widget._gnue_label_.SetLabel(value)
+
             widget.SetEvtHandlerEnabled (True)
             widget.Refresh ()
 
@@ -313,7 +336,7 @@
       @param index: index of the widget to be changed (if rows > 0)
       """
 
-      widget = self.widgets [index]
+      widget = self.widgets[index]
 
       if isinstance (widget, wx.ComboBox):
           if 'wxMac' in wx.PlatformInfo:
@@ -338,7 +361,7 @@
         @param index: index of the widget to be changed
         """
     
-        widget = self.widgets [index]
+        widget = self.widgets[index]
 
         if isinstance (widget, wx.ComboBox):
             if 'wxMac' in wx.PlatformInfo:

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -77,7 +77,14 @@
 
         inner = wx.BoxSizer(wx.VERTICAL)
 
-        self.container_sizer = wx.GridBagSizer(2, 0)
+        if 'wxMac' in wx.PlatformInfo:
+            hgap, vgap = 4, 4
+        else:
+            hgap, vgap = 2, 2
+
+        self.container_sizer = wx.GridBagSizer(hgap, vgap)
+        self.container_sizer.SetEmptyCellSize((5, 10))
+
         inner.Add(self.container_sizer, 1, wx.EXPAND | wx.ALL, 2)
 
         stb_sizer.Add(inner, 1, wx.EXPAND)
@@ -93,15 +100,18 @@
     # Add child widgets to the sizer
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget):
+    def add_widgets(self, ui_widget, spacer):
 
+        item = ui_widget.widget
+        flags = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND
+
         if not ui_widget.growable:
-            add = self.add_to_vbox(ui_widget.widget)
-        else:
-            add = ui_widget.widget
+            box = wx.BoxSizer(wx.HORIZONTAL)
+            box.Add(item, 1, wx.ALIGN_CENTER_VERTICAL)
+            item = box
 
-        self.container_sizer.Add(add, ui_widget.chr_pos,
-                ui_widget.chr_span, wx.EXPAND)
+        self.container_sizer.Add(item, ui_widget.chr_pos,
+                ui_widget.chr_span, flags)
 
 
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-07-05 
13:45:59 UTC (rev 8524)
@@ -54,7 +54,7 @@
         self.widget.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
         self.widget.Bind(wx.EVT_CHAR     , self.__on_char)
 
-        self.getParent().add_widgets(self)
+        self.getParent().add_widgets(self, spacer)
 
         return self.widget
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py        2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py        2006-07-05 
13:45:59 UTC (rev 8524)
@@ -1,4 +1,4 @@
-# GNU Enterprise Forms - wx 2.6 UI Driver - Entry widgets
+#y GNU Enterprise Forms - wx 2.6 UI Driver - Entry widgets
 #
 # Copyright 2001-2006 Free Software Foundation
 #
@@ -53,15 +53,22 @@
         """
 
         parent = event.container
+        owner = self.getParent()
 
+        if self.in_grid:
+            parent = owner._get_cell(self, spacer)
+
         style = self._gfObject.style.lower()
         func = getattr(self, "_UIEntry__build_%s" % style)
         (self.label, self.widget) = func(parent)
 
-        self.getParent().add_widgets(self)
+        owner.add_widgets(self, spacer)
 
         # We return the entry object here, since we will bind events to it
         # later
+        if self.in_grid:
+            self.widget._gnue_label_ = self.label
+
         return self.widget
 
 
@@ -186,7 +193,12 @@
 
     def __add_entry_label(self, parent):
 
-        if self._gfObject.label:
+        if self.in_grid:
+            label = wx.StaticText(parent, -1)
+            parent.Bind(wx.EVT_LEFT_UP, self.__on_label_click)
+            label.Bind(wx.EVT_LEFT_UP, self.__on_label_click)
+
+        elif self._gfObject.label:
             label = wx.StaticText(parent, -1, self._gfObject.label)
         else:
             label = None
@@ -195,6 +207,41 @@
 
     # -------------------------------------------------------------------------
 
+    def __on_label_click(self, event):
+
+        label = event.GetEventObject()
+        for item in self.widgets:
+            if isinstance(label, wx.Panel):
+                other = item.GetParent()
+            else:
+                other = item._gnue_label_
+
+            if other == label:
+                do_focus = (self._gfObject._form._currentEntry != 
self._gfObject)
+
+                # adjust the record number if necessary
+                lookup = item
+                if 'wxMac' in wx.PlatformInfo and self._gfObject.style == 
'dropdown':
+                    lookup = lookup.GetParent()
+
+                count  = self.widgets.index(lookup)
+                adjust = count - self._gfObject._visibleIndex
+
+        # Now follows a quite dirty trick.  The current widget does not have an
+        # insertion point set yet, which happens after wx.EVT_SET_FOCUS is
+        # processed.  Calling a requestFOCUS event sets the insertion point to
+        # the end of the display value (via beginEDIT).  So the real insertion
+        # point (of a mouse click for example) always gets lost.  To resolve
+        # that do all the dirty work of synchronizing the focus in GF *after*
+        # setting the initial wx-focus.
+                wx.CallAfter (self.__focus_worker, event.GetEventObject(),
+                        do_focus, adjust)
+
+        event.Skip()
+
+
+    # -------------------------------------------------------------------------
+
     def __add_to_vbox(self, widget):
 
         sizer = wx.BoxSizer(wx.VERTICAL)

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -40,6 +40,11 @@
     Interface implementation of form widgets (forms and dialogs)
     """
 
+    _TAB_STYLE = {'left': wx.NB_LEFT,
+                  'right': wx.NB_RIGHT,
+                  'bottom': wx.NB_BOTTOM,
+                  'top': wx.NB_TOP}
+
     # -------------------------------------------------------------------------
     # Constructor
     # -------------------------------------------------------------------------
@@ -49,25 +54,13 @@
         self.statusBar = None
 
         UIHelper.__init__(self, event)
-        self._inits.extend([self._updateSizers, self.__firstPage])
 
+        self.pages = []
 
-    # -------------------------------------------------------------------------
-    # Make sure to have the first page visible
-    # -------------------------------------------------------------------------
+        self.sizing_enabled = False
+        self._inits.extend([self.__update_sizer])
 
-    def __firstPage (self):
 
-        current = self._form._currentPage
-        pgList  = self._form._layout._pageList
-        if pgList and current in pgList:
-            index = pgList.index(current)
-        else:
-            index = 0
-
-        self._containerToolkitWidget.showPage(index)
-
-
     # -------------------------------------------------------------------------
     # Create a new wx frame widget
     # -------------------------------------------------------------------------
@@ -77,13 +70,13 @@
         if self._form.style != 'dialog':
             self.main_window = self._uiDriver._parentContainer
             if not self.main_window:
-                self.main_window = wx.Frame (None, -1)
+                self.main_window = wx.Frame(None, -1)
         else:
-            self.main_window = wx.Dialog (None, -1)
+            self.main_window = wx.Dialog(None, -1)
 
-        self.main_window.SetTitle (self._form.title)
-        self.main_window.SetIcons (self.__loadIcons ())
-        self.main_window.Bind (wx.EVT_CLOSE, self.__closeTrap, 
self.main_window)
+        self.main_window.SetTitle(self._form.title)
+        self.main_window.SetIcons(self.__load_icons())
+        self.main_window.Bind(wx.EVT_CLOSE, self.__on_close, self.main_window)
 
         self.master_sizer = wx.BoxSizer(wx.VERTICAL)
 
@@ -93,6 +86,8 @@
         self.base_sizer = wx.BoxSizer(wx.VERTICAL)
         self.base_panel.SetSizer(self.base_sizer)
 
+        self.master_sizer.Add(self.base_panel, 1, wx.EXPAND)
+
         # Add Statusbar, Toolbar and Menubar as requested and/or allowed
         if self._form.style != 'dialog':
             if not self._form._features ['GUI:STATUSBAR:SUPPRESS']:
@@ -108,38 +103,41 @@
                 tlb = ToolBar (self._uiDriver, self.base_panel, self._form)
                 self.base_sizer.Add (tlb.toolbar, 0, wx.EXPAND)
 
+        # Now create the page container
         if self._form._layout.tabbed != 'none':
-            wrapper = TabbedWrapper (self, self.base_panel, self.base_sizer)
+            style = self._TAB_STYLE[self._form._layout.tabbed]
+            container = wx.Notebook(self.base_panel, -1, style = style)
         else:
-            wrapper = BaseWrapper (self, self.base_panel, self.base_sizer)
+            container = wx.Panel(self.base_panel, -1)
+            cont_sizer = wx.BoxSizer(wx.VERTICAL)
+            container.SetSizer(cont_sizer)
 
-        self._containerToolkitWidget = wrapper
+        self.base_sizer.Add(container, 1, wx.EXPAND | wx.ALL, 6)
 
-        self.master_sizer.Add(self.base_panel, 1, wx.EXPAND)
-        self.main_window.SetSizer(self.master_sizer)
+        self._containerToolkitWidget = container
 
-        return wrapper
+        return self.main_window
 
 
     # -------------------------------------------------------------------------
     # Load an icon bundle for this form
     # -------------------------------------------------------------------------
 
-    def __loadIcons (self):
+    def __load_icons(self):
 
-      idir = GConfig.getInstalledBase ('forms_images', 'common_images')
-      iconBundle = wx.IconBundle ()
+      idir = GConfig.getInstalledBase('forms_images', 'common_images')
+      iconBundle = wx.IconBundle()
 
       for sz in [16, 32, 64]:
           fn = os.path.join(idir, 'forms', 'default',
                   'gnue-%sx%s.png' % (sz, sz))
-          if os.path.exists (fn):
+          if os.path.exists(fn):
               # On wxMSW loading an icon directly from a file doesn't work, so
               # we need to copy the icons from a bitmap on the fly
-              icon = wx.Icon (fn, wx.BITMAP_TYPE_PNG)
-              icon.CopyFromBitmap (wx.Image (fn).ConvertToBitmap ())
+              icon = wx.Icon(fn, wx.BITMAP_TYPE_PNG)
+              icon.CopyFromBitmap(wx.Image(fn).ConvertToBitmap())
 
-              iconBundle.AddIcon (icon)
+              iconBundle.AddIcon(icon)
 
       return iconBundle
 
@@ -148,11 +146,13 @@
     # Set sizers, specify the size hints and fit all child controls
     # -------------------------------------------------------------------------
 
-    def _updateSizers (self):
+    def __update_sizer (self):
 
-        self.main_window.Fit ()
-        self._containerToolkitWidget.set_scrollrate ()
+        if isinstance(self._containerToolkitWidget, wx.Notebook):
+            self._containerToolkitWidget.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
+                    self.__on_page_changed, self._containerToolkitWidget)
 
+        self.main_window.SetSizerAndFit(self.master_sizer)
         self.main_window.CenterOnScreen ()
 
 
@@ -163,6 +163,8 @@
     def show (self):
 
         self.main_window.Raise ()
+
+        self.sizing_enabled = True
         self.main_window.Show ()
 
 
@@ -173,6 +175,7 @@
     def showModal(self):
 
         self.main_window.Raise()
+        self.sizing_enabled = True
 
         # FIXME: this is a really dirty workaround.  Although the focus is set
         # properly in the GFForm, it is misplaced in the wx.Dialog after
@@ -189,14 +192,38 @@
     # Close the form
     # -------------------------------------------------------------------------
 
-    def __closeTrap (self, event):
+    def __on_close(self, event):
 
-        if event.CanVeto ():
-            self._request ('EXIT')
-            event.Veto ()
+        if event.CanVeto():
+            self._request('EXIT')
+            event.Veto()
+        else:
+            self.sizing_enabled = False
+            event.GetEventObject().Destroy()
 
+    # -------------------------------------------------------------------------
+
+    def __on_page_changed(self, event):
+
+        self._request('PAGE', data=event.GetSelection())
+        event.Skip()
+
+
+    # -------------------------------------------------------------------------
+    # Show the requested page
+    # -------------------------------------------------------------------------
+
+    def show_page(self, page_index):
+
+        container = self._containerToolkitWidget
+        if isinstance (container, wx.Notebook):
+            container.SetSelection(page_index)
         else:
-            event.GetEventObject ().Destroy ()
+            for (index, widget) in enumerate(self.pages):
+                if index != page_index:
+                    widget.Hide()
+                else:
+                    widget.Show()
 
 
     # -------------------------------------------------------------------------
@@ -205,7 +232,7 @@
 
     def gotoPage (self, page):
 
-        self._containerToolkitWidget.showPage (page._pageIndex)
+        self.show_page(page._pageIndex)
 
 
     # -------------------------------------------------------------------------
@@ -252,183 +279,6 @@
 
 
 # =============================================================================
-# Simple scrolled window containing multiple page panels
-# =============================================================================
-
-class BaseWrapper (wx.ScrolledWindow):
-
-  # ---------------------------------------------------------------------------
-  # Constructor
-  # ---------------------------------------------------------------------------
-
-  def __init__ (self, uiForm, parent, sizer):
-
-    self._uiForm   = uiForm
-    self._uiDriver = uiForm._uiDriver
-    self._gfObject = uiForm._gfObject
-    self._pages    = []
-
-    wx.ScrolledWindow.__init__ (self, parent, -1)
-    sizer.Add (self, 1, wx.EXPAND | wx.ALL, 8)
-
-    self.sw_sizer = wx.BoxSizer(wx.VERTICAL)
-    self.SetSizer(self.sw_sizer)
-
-    self.page_container = self._createPageContainer()
-    self.page_sizer     = wx.BoxSizer(wx.VERTICAL)
-    self.page_container.SetSizer(self.page_sizer)
-
-    self.sw_sizer.Add(self.page_container, 1, wx.EXPAND)
-
-
-  # ---------------------------------------------------------------------------
-  # Make sure to set the scrollrate for the scrolled window
-  # ---------------------------------------------------------------------------
-
-  def set_scrollrate (self):
-
-      self.SetScrollRate(self._uiDriver.cellWidth, self._uiDriver.cellHeight)
-
-
-  # ---------------------------------------------------------------------------
-  # Create the container widget for all the wrapped pages
-  # ---------------------------------------------------------------------------
-
-  def _createPageContainer (self):
-
-      return wx.Panel(self, -1)
-
-
-  # ---------------------------------------------------------------------------
-  # 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
-      """
-
-      if self._gfObject._layout.managed:
-          pg_sizer = wx.BoxSizer(wx.VERTICAL)
-      else:
-          pg_sizer = wx.GridBagSizer(2, 0)
-
-      pg_panel = wx.Panel(self.page_container, -1)
-      pg_panel.SetSizer(pg_sizer)
-
-      if not self.pageCount():
-          self.page_sizer.Add(pg_panel, 1, wx.EXPAND)
-
-      self._addToContainer (gfPage, pg_panel)
-
-      return pg_panel
-
-
-  # ---------------------------------------------------------------------------
-  # 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.page_container.SetSelection (page)
-    self.Refresh ()
-
-
-  # ---------------------------------------------------------------------------
-  # Create the container widget for all the wrapped pages
-  # ---------------------------------------------------------------------------
-
-  def _createPageContainer (self):
-
-    notebook = wx.Notebook (self, -1,
-        style = self._TAB_STYLE [self._uiForm._form._layout.tabbed])
-    notebook.Bind (wx.EVT_NOTEBOOK_PAGE_CHANGING, self.__changePage, notebook)
-
-    return notebook
-
-
-  # ---------------------------------------------------------------------------
-  # Add a given page widget to the page container
-  # ---------------------------------------------------------------------------
-
-  def _addToContainer (self, gfPage, pageWidget):
-
-    title = "%s" % (gfPage.caption or gfPage.name)
-    self.page_container.SetEvtHandlerEnabled (False)
-    try:
-      self.page_container.AddPage (pageWidget, title, False)
-      self._pages.append (pageWidget)
-
-    finally:
-      self.page_container.SetEvtHandlerEnabled (True)
-
-
-  # ---------------------------------------------------------------------------
-  # Change a notebook page
-  # ---------------------------------------------------------------------------
-
-  def __changePage (self, event):
-
-    self._uiForm._request ('PAGE', data = event.GetSelection ())
-
-
-
-# =============================================================================
 # Widget configuration
 # =============================================================================
 

Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py 2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py 2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -0,0 +1,233 @@
+# 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, gridline
+
+
+# =============================================================================
+# Interface implementation for a box widget
+# =============================================================================
+
+class UIGrid (_base.UIHelper):
+
+    # -------------------------------------------------------------------------
+    # Create a wx box widget
+    # -------------------------------------------------------------------------
+
+    def _createWidget (self, event, spacer):
+
+        self.growable = True
+        parent = event.container
+        owner  = self.getParent()
+        sizer  = owner.container_sizer
+
+        self.widget = wx.Panel(parent, -1) # , style=wx.SUNKEN_BORDER)
+        self.widget.Bind(wx.EVT_SIZE, self.__on_size)
+
+        outer = wx.BoxSizer(wx.VERTICAL)
+        self.widget.SetSizer(outer)
+
+        self.container_sizer = wx.GridBagSizer()
+        outer.Add(self.container_sizer, 1, wx.EXPAND | wx.ALL, 2)
+
+        self._containerToolkitWidget = self.widget
+
+        self._max = self._gfObject.rows
+        self._visible = self._max
+
+        self._current_records = self._gfObject.rows
+        self.__build_header()
+
+        owner.add_widgets(self, spacer)
+
+        return self.container_sizer
+
+
+    def __build_header(self):
+
+        cols = {}
+        linenum = 0
+        for line in self._gfObject.findChildrenOfType('GFGridLine', True, 
True):
+            index = 0
+            for item in line._children:
+                span = int(getattr(item, 'Sizer__span', 1))
+                cols.setdefault(index, []).append(getattr(item, 'label', None))
+                index += span
+            linenum += 1
+
+        colnum = cols.keys()
+        colnum.sort()
+
+        for clx in colnum:
+            self.container_sizer.AddGrowableCol(clx)
+            pnl = wx.Panel(self.widget, -1, style=wx.RAISED_BORDER)
+            vbx = wx.BoxSizer(wx.VERTICAL)
+            pnl.SetSizer(vbx)
+
+            for label in cols[clx]:
+                stc = wx.StaticText(pnl, -1, label)
+                vbx.Add(stc, 1, wx.EXPAND)
+
+            self.container_sizer.Add(pnl, (0, clx), (1, 1), wx.EXPAND)
+
+
+
+    # -------------------------------------------------------------------------
+    # Add an UI widget to the Grid container
+    # -------------------------------------------------------------------------
+
+    def add_widgets(self, ui_widget, spacer):
+        pass
+
+
+    # -------------------------------------------------------------------------
+    # Get the row-number of a concrete gridline in the GridBagSizer
+    # -------------------------------------------------------------------------
+
+    def _get_row(self, line, record):
+
+        return len(self._children) * record + self._children.index(line) + 1
+
+
+    def __on_size(self, event):
+
+        if not self._uiForm.sizing_enabled:
+            event.Skip()
+            return
+
+        saved = self._uiForm.sizing_enabled
+        self._uiForm.sizing_enabled = False
+
+        try:
+            (width, height) = self.widget.GetContainingSizer().GetSize()
+
+            rech = 0
+            for item in self._children:
+                rech += max([panel.GetBestSize()[1] for panel in 
item._columns[0]])
+
+            (hd_width, hd_height) = self.container_sizer.GetCellSize(0, 0)
+            available = height - hd_height
+            num_recs = int(available / float(rech))
+            num_recs = (height - hd_height) / rech
+
+            # Get the diff
+            refresh = False
+            if num_recs > self._visible:
+                self.__add_new_records(num_recs - self._visible)
+                self.walk(self.__child_rows_walker)
+                self._form.refreshDisplay(self._gfObject)
+
+            elif num_recs < self._visible:
+                self.__hide_records(self._visible - num_recs)
+                self.walk(self.__child_rows_walker)
+
+        finally:
+            self._uiForm.sizing_enabled = saved
+
+        event.Skip()
+
+
+    # -------------------------------------------------------------------------
+    # 
+    # -------------------------------------------------------------------------
+
+    def __add_new_records(self, num_recs):
+
+        for index in range(num_recs):
+            record = self._visible + index
+
+            if record >= self._max:
+                self.walk(self.__child_add_walker, record)
+                self._max += 1
+            else:
+                self.__change_visibility(record, True)
+
+        self._visible += num_recs
+
+        self._uiForm.main_window.Layout()
+
+
+    def __child_add_walker(self, item, spacer):
+
+        if item == self:
+            return
+
+        widget = item.createWidget(item._creationEvent, spacer)
+        item.widgets.append(widget)
+
+
+    # -------------------------------------------------------------------------
+    #
+    # -------------------------------------------------------------------------
+
+    def __change_visibility(self, record, state):
+
+        grid = self.container_sizer
+
+        for item in self._children:
+            row = self._get_row(item, record)
+            for col in range(len(item._children)):
+                item = grid.FindItemAtPosition((row, col))
+                if item:
+                    item.Show(state)
+
+
+    # -------------------------------------------------------------------------
+    # 
+    # -------------------------------------------------------------------------
+
+    def __hide_records(self, num_recs):
+
+        for index in range(num_recs):
+            self.__change_visibility(self._visible-1, False)
+            self._visible -= 1
+
+        if self._uiDriver._uiFocusIndex > self._visible - 1:
+            focus = self._uiDriver._uiFocusWidget
+            focus.loseFocus(self._uiDriver._uiFocusIndex)
+
+            self._uiDriver._uiFocusIndex = self._visible - 1
+            focus.indexedFocus(self._visible - 1)
+
+        self._uiForm.main_window.Layout()
+
+
+    def __child_rows_walker(self, item):
+        
+        if item == self:
+            return
+
+        item._gfObject._rows = self._visible
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIGrid,
+  'provides' : 'GFGrid',
+  'container': 1
+}


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

Added: trunk/gnue-forms/src/uidrivers/wx26/widgets/gridline.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/gridline.py     2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/gridline.py     2006-07-05 
13:45:59 UTC (rev 8524)
@@ -0,0 +1,119 @@
+# 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, hbox, entry, button
+
+__all__ = ['UIGridLine']
+
+# =============================================================================
+# Interface implementation for a box widget
+# =============================================================================
+
+class UIGridLine (_base.UIHelper):
+
+    def __init__(self, event):
+        _base.UIHelper.__init__(self, event)
+        self._columns = {}
+
+    # -------------------------------------------------------------------------
+    # Create a wx box widget
+    # -------------------------------------------------------------------------
+
+    def _createWidget (self, event, spacer):
+
+        owner  = self.getParent()
+
+        parent = event.container
+        sizer  = owner.container_sizer
+
+        self.__prepare_columns(parent, spacer)
+
+        self.container_sizer = sizer
+        self._containerToolkitWidget = parent
+
+        owner.add_widgets(self, spacer)
+
+        return None
+
+    # -------------------------------------------------------------------------
+    # 
+    # -------------------------------------------------------------------------
+
+    def __prepare_columns(self, parent, spacer):
+
+        owner = self.getParent()
+        sizer = owner.container_sizer
+        row = owner._get_row(self, spacer)
+
+        offset = 0
+        for child in self._children:
+            panel = wx.Panel(parent, -1)
+            hbx = wx.BoxSizer(wx.HORIZONTAL)
+            panel.SetSizer(hbx)
+
+            if not spacer % 2:
+                panel.SetBackgroundColour(wx.GREEN)
+            else:
+                panel.SetBackgroundColour(wx.CYAN)
+
+            self._columns.setdefault(spacer, []).append(panel)
+
+            pos = (row, offset)
+            sizer.Add(panel, pos, (1, child.span), wx.EXPAND)
+            offset += child.span
+
+
+
+    # -------------------------------------------------------------------------
+    # Add an UI widget to the Grid container
+    # -------------------------------------------------------------------------
+
+    def add_widgets(self, ui_widget, spacer):
+
+        panel = self._get_cell(ui_widget, spacer)
+        sizer = panel.GetSizer()
+
+        sizer.Add(ui_widget.label, 1, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)
+        sizer.Add(ui_widget.widget, 1, wx.EXPAND)
+        best = ui_widget.widget.GetBestSize()
+        sizer.SetMinSize(best)
+        ui_widget.widget.Hide()
+
+
+    def _get_cell(self, ui_widget, spacer):
+
+        index = self._children.index(ui_widget)
+        return self._columns[spacer][index]
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIGridLine,
+  'provides' : 'GFGridLine',
+  'container': 1
+}


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

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py 2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py 2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -61,7 +61,7 @@
         self.__current_col = 0
 
         self.widget = outer
-        owner.add_widgets(self)
+        owner.add_widgets(self, spacer)
 
         return self.container_sizer
 
@@ -69,7 +69,7 @@
     # Add new widgets for a givin UI* instance to the HBox container
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget):
+    def add_widgets(self, ui_widget, spacer):
 
         pos = (0, self.__current_col)
         span = (1, 1)

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py        2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/image.py        2006-07-05 
13:45:59 UTC (rev 8524)
@@ -78,7 +78,7 @@
 
         sw_sizer.Add(bmp, 1, wx.EXPAND)
 
-        self.getParent().add_widgets(self)
+        self.getParent().add_widgets(self, spacer)
 
         return bmp
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py        2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/label.py        2006-07-05 
13:45:59 UTC (rev 8524)
@@ -47,7 +47,7 @@
     parent = event.container
     self.widget = wx.StaticText(parent, -1, self._gfObject.text, style=flags)
 
-    self.getParent().add_widgets(self)
+    self.getParent().add_widgets(self, spacer)
 
     return self.widget
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -22,13 +22,19 @@
 # $Id$
 
 import wx
+
 from gnue.forms.uidrivers.wx26.widgets import _base
 
+__all__ = ['UIPage']
+
 # =============================================================================
 # Interface implementation of a page
 # =============================================================================
 
 class UIPage(_base.UIHelper):
+    """
+    UI widget for the <page> tag.
+    """
 
     # -------------------------------------------------------------------------
     # Create a new page widget
@@ -36,31 +42,60 @@
 
     def _createWidget(self, event, spacer):
 
-        self._pageIndex = event.container.pageCount()
-        self._containerToolkitWidget = \
-                event.container.createPage(self._gfObject)
-        self.container_sizer = self._containerToolkitWidget.GetSizer()
+        self._pageIndex = len(self._uiForm.pages)
+        parent = event.container
 
-        return self._containerToolkitWidget
+        self.page_panel = wx.Panel(parent, -1)
+        self.page_sizer = wx.BoxSizer(wx.VERTICAL)
+        self.page_panel.SetSizer(self.page_sizer)
 
+        if isinstance(parent, wx.Notebook):
+            title = "%s" % (self._gfObject.caption or self._gfObject.name)
+            parent.AddPage(self.page_panel, title, False)
+        else:
+            parent.GetSizer().Add(self.page_panel, 1, wx.EXPAND)
 
+        self._uiForm.pages.append(self.page_panel)
+
+        # Add the container-sizer depending on the page-management
+        if self.managed:
+            self.container_sizer = wx.BoxSizer(wx.VERTICAL)
+        else:
+            if 'wxMac' in wx.PlatformInfo:
+                hgap, vgap = 4, 4
+            else:
+                hgap, vgap = 2, 2
+
+            self.container_sizer = wx.GridBagSizer(hgap, vgap)
+            self.container_sizer.SetEmptyCellSize((5, 10))
+
+        self.page_sizer.Add(self.container_sizer, 1, wx.EXPAND)
+
+        self._containerToolkitWidget = self.page_panel
+        return self.page_panel
+
+
     # -------------------------------------------------------------------------
     # Add widgets to the page
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget):
+    def add_widgets(self, ui_widget, spacer):
 
+        item = ui_widget.widget
+
         if self.managed:
-            self.container_sizer.Add(ui_widget.widget, 1, wx.EXPAND)
+            self.container_sizer.Add(item, 1, wx.EXPAND)
         else:
-            if ui_widget.growable:
-                add = self.add_to_vbox(ui_widget.widget)
-            else:
-                add = ui_widget.widget
-            self.container_sizer.Add(add, ui_widget.chr_pos,
-                    ui_widget.chr_span, wx.EXPAND)
+            flags = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND
+            if not ui_widget.growable:
+                box = wx.BoxSizer(wx.HORIZONTAL)
+                box.Add(item, 1, wx.ALIGN_CENTER_VERTICAL)
+                item = box
 
+            self.container_sizer.Add(item, ui_widget.chr_pos,
+                    ui_widget.chr_span, flags)
 
+
 # =============================================================================
 # Configuration data
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py    2006-06-29 
21:16:34 UTC (rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/scrollbar.py    2006-07-05 
13:45:59 UTC (rev 8524)
@@ -40,7 +40,7 @@
       parent = event.container
 
       self.widget = wx.ScrollBar(parent, -1, style=wx.SB_VERTICAL)
-      self.getParent().add_widgets(self)
+      self.getParent().add_widgets(self, spacer)
 
       (crec, recs, self.pageSize) = self._gfObject.get_record_and_page_count()
       wx.EVT_COMMAND_SCROLL(self.widget, self.widget.GetId(),

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2006-06-29 21:16:34 UTC 
(rev 8523)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2006-07-05 13:45:59 UTC 
(rev 8524)
@@ -23,7 +23,7 @@
 
 import wx
 
-from gnue.forms.uidrivers.wx26.widgets import _base, hbox, entry, button
+from gnue.forms.uidrivers.wx26.widgets import _base, hbox, entry, button, grid
 
 
 # =============================================================================
@@ -61,7 +61,7 @@
         self.__current_row = 0
 
         self.widget = outer
-        owner.add_widgets(self)
+        owner.add_widgets(self, spacer)
 
         return self.container_sizer
 
@@ -70,13 +70,13 @@
     # Add an UI widget to the VBox container
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget):
+    def add_widgets(self, ui_widget, spacer):
 
         pos = (self.__current_row, 0)
         span = (1, 1)
         add = 0
 
-        span_control = isinstance(ui_widget, (UIVBox, hbox.UIHBox)) or \
+        span_control = isinstance(ui_widget, (UIVBox, hbox.UIHBox, 
grid.UIGrid)) or \
                 isinstance (ui_widget.widget, wx.CheckBox)
 
         if ui_widget.label:





reply via email to

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