commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9466 - trunk/gnue-forms/src/uidrivers/curses/widgets


From: reinhard
Subject: [gnue] r9466 - trunk/gnue-forms/src/uidrivers/curses/widgets
Date: Sat, 7 Apr 2007 13:22:30 -0500 (CDT)

Author: reinhard
Date: 2007-04-07 13:22:30 -0500 (Sat, 07 Apr 2007)
New Revision: 9466

Modified:
   trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py
Log:
Implemented left-label style hbox in curses.


Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2007-04-07 
17:40:15 UTC (rev 9465)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py      2007-04-07 
18:22:30 UTC (rev 9466)
@@ -314,25 +314,33 @@
 
         hints = self._hints_.values()
 
-        minh = sum([i[1] for i in hints])
         prop = sum([i[3] for i in hints])
 
         if self.vertical:
             mx_label = max([i[2] for i in hints])
             # min. width: space + widest label + space + widest widget + space
             minw = mx_label + max([i[0] for i in hints]) + 3
+            # min. height: widget + widget + widget + ...
+            minh = sum([i[1] for i in hints])
         else:
             # min. width: space + max(widget/label) + space + ... + space
             minw = sum([max(i[0], i[2]) for i in hints]) + len(hints) + 1
+            # min. height: highest widget
+            minh = max([i[1] for i in hints])
 
         # If a box has a label we have to add the border to the minimum space
         (decw, dech) = self._decoration_size_()
         minw += decw
         minh += dech
 
-        return (minw, minh, 0, prop)
+        if self._gfObject.has_label:
+            label_width = len(self._gfObject.label)
+        else:
+            label_width = 0
 
+        return (minw, minh, label_width, prop)
 
+
     # -------------------------------------------------------------------------
     # Set the size of a box and arrange it's children
     # -------------------------------------------------------------------------
@@ -474,13 +482,14 @@
         max_label= max([i[2] for i in self._hints_.values()])
 
         if self.vertical:
-            add = max_label <> 0 and (max_label + 1) or 0
+            add = max_label != 0 and (max_label + 1) or 0
             child.left = self.left + self._horizontal_offset_() + add
             child.top = last_y + self._vertical_offset_()
 
             result = (0, cheight)
         else:
-            child.top = self.top + self._vertical_offset_() + 1
+            add = max_label != 0 and 1 or 0
+            child.top = self.top + self._vertical_offset_() + add
             child.left = last_x + self._horizontal_offset_()
 
             result = (cwidth + 1, 0)

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2007-04-07 
17:40:15 UTC (rev 9465)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2007-04-07 
18:22:30 UTC (rev 9466)
@@ -219,7 +219,7 @@
     def get_size_hints(self, vertical=None):
 
         label = ''
-        if self._gfObject.style != 'checkbox':
+        if self._gfObject.has_label:
             label = getattr(self._gfObject, 'label', '')
 
         # Only stretch entries if they're in a horizontal container or if they

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py       2007-04-07 
17:40:15 UTC (rev 9465)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py       2007-04-07 
18:22:30 UTC (rev 9466)
@@ -48,7 +48,7 @@
 
     def _decoration_size_(self):
 
-        if self._gfObject.label:
+        if self._gfObject.label and not self._gfObject.has_label:
             return (2, 2)
         else:
             return (0, 0)
@@ -57,7 +57,7 @@
 
     def _add_decoration_(self):
 
-        if self._gfObject.label:
+        if self._gfObject.label and not self._gfObject.has_label:
             attr = self._uiDriver.attr['background']
             box(self._parent, attr, self.left, self.top, self.right,
                     self.bottom, self._gfObject.label)
@@ -66,7 +66,7 @@
 
     def _vertical_offset_(self):
 
-        if self._gfObject.label:
+        if self._gfObject.label and not self._gfObject.has_label:
             return 1
         else:
             return 0
@@ -75,7 +75,7 @@
 
     def _horizontal_offset_(self):
 
-        if self._gfObject.label:
+        if self._gfObject.label and not self._gfObject.has_label:
             return 2
         else:
             return 0





reply via email to

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