[gnue] r9491 - trunk/gnue-forms/src/uidrivers/wx26/widgets

[email protected]
Newsgroups gmane.comp.cms.gnue.cvs
Message-ID <[email protected]>
Author: reinhard
Date: 2007-04-11 08:48:05 -0500 (Wed, 11 Apr 2007)
New Revision: 9491

Modified:
   trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py
Log:
Fixed header for multiline grids.


Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py	2007-04-11 12:53:16 UTC (rev 9490)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/grid.py	2007-04-11 13:48:05 UTC (rev 9491)
@@ -105,34 +105,28 @@
 
     def __build_header(self):
 
-        cols = {}
+        sizer = self._container.GetSizer()
+        num_cols = 0
         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))
+                panel = wx.Panel(self._container, -1, style=wx.RAISED_BORDER)
+                box = wx.BoxSizer(wx.HORIZONTAL)
+                panel.SetSizer(box)
+                static = wx.StaticText(panel, -1, getattr(item, 'label') or u"")
+                box.Add(static, 1, wx.EXPAND)
+                sizer.Add(panel, (linenum, index), (1, span), wx.EXPAND)
                 index += span
+            num_cols = max(num_cols, index)
             linenum += 1
 
-        colnum = cols.keys()
-        colnum.sort()
+        # For now, make all columns growable:
+        for col in range(0, num_cols):
+            sizer.AddGrowableCol(col)
 
-        sizer = self._container.GetSizer()
 
-        for clx in colnum:
-            sizer.AddGrowableCol(clx)
-            pnl = wx.Panel(self._container, -1, style=wx.RAISED_BORDER)
-            vbx = wx.BoxSizer(wx.VERTICAL)
-            pnl.SetSizer(vbx)
-
-            for label in cols[clx]:
-                stc = wx.StaticText(pnl, -1, label or u"")
-                vbx.Add(stc, 1, wx.EXPAND)
-
-            sizer.Add(pnl, (0, clx), (1, 1), wx.EXPAND)
-
-
     # -------------------------------------------------------------------------
     # Get the row-number of a concrete gridline in the GridBagSizer
     # -------------------------------------------------------------------------
@@ -145,7 +139,7 @@
         @returns: the row within the GridBagSizer
         """
 
-        return len(self._children) * record + self._children.index(line) + 1
+        return len(self._children) * (record + 1) + self._children.index(line)
 
 
     # -------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.