[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9122 - trunk/gnue-forms/src/uidrivers/curses/widgets
From: |
johannes |
Subject: |
[gnue] r9122 - trunk/gnue-forms/src/uidrivers/curses/widgets |
Date: |
Thu, 7 Dec 2006 08:47:08 -0600 (CST) |
Author: johannes
Date: 2006-12-07 08:47:07 -0600 (Thu, 07 Dec 2006)
New Revision: 9122
Modified:
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py
trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
trunk/gnue-forms/src/uidrivers/curses/widgets/vbox.py
Log:
Further cleanup of box-code, right/bottom available via property
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -150,7 +150,20 @@
self.width = width
self.height = height
+ # -------------------------------------------------------------------------
+ # Properties
+ # -------------------------------------------------------------------------
+ def __get_right(self):
+ return self.left + self.width - 1
+
+ def __get_bottom(self):
+ return self.top + self.height - 1
+
+ right = property(__get_right, None, None)
+ bottom = property(__get_bottom, None, None)
+
+
# =============================================================================
# Draw a box on a given parent
# =============================================================================
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -41,12 +41,10 @@
self.width = width
self.height = height
- right = self.left + width - 1
- bottom = self.top + height - 1
attr = self._uiDriver.attr['background']
- box(self._parent, attr, self.left, self.top, right, bottom,
+ box(self._parent, attr, self.left, self.top, self.right, self.bottom,
self._gfObject.label)
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -291,8 +291,11 @@
# The children of a form are pages which can have all the available
# space
+ (left, top, right, bottom) = self.get_canvas()
for child in self._children:
- child.set_size_and_fit(x, y)
+ child.left = left
+ child.top = top
+ child.set_size_and_fit(right-left, bottom-top)
gDebug(2, "creating windows for form-widget")
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/hbox.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -42,18 +42,19 @@
def set_size_and_fit(self, width, height):
- right, bottom = self.left + width - 1, self.top + height - 1
- gDebug(2, "Size for hbox: %s/%s %s/%s %s/%s" % (width, height,
- self.left,
- self.top, right, bottom))
+ self.width = width
+ self.height = height
+ gDebug(2, "Size for hbox: %s/%s %s/%s %s/%s" % (self.width,
+ self.height, self.left, self.top, self.right, self.bottom))
+
attr = self._uiDriver.attr['background']
if self._gfObject.label:
- box(self._parent, attr, self.left, self.top, right, bottom,
- self._gfObject.label)
- width -= 2
- height -= 2
+ box(self._parent, attr, self.left, self.top, self.right,
+ self.bottom, self._gfObject.label)
+ self.width -= 2
+ self.height -= 2
hints = {}
for (index, child) in enumerate(self._children):
@@ -74,9 +75,9 @@
# Now let's have a look how much space is left if all children have
# used up their minimum width
- available = width - needed
+ available = self.width - needed
- gDebug(2, "Ordered: w=%s n=%s a=%s o=%s" % (width, needed, available,
+ gDebug(2, "Ordered: w=%s n=%s a=%s o=%s" % (self.width, needed,
available,
ordered))
# First assign the minimum space required to each child
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -64,12 +64,9 @@
def set_size_and_fit(self, width, height):
- gDebug(2, "Parent: %s" % self._parent._gfObject.name)
- (self.left, self.top, self.right, self.bottom) = \
- self._parent.get_canvas()
+ self.width = width
+ self.height = height
- width, height = self.right - self.left, self.bottom - self.top
-
gDebug(2, "Size of Page: %s/%s at %s/%s %s/%s" % \
(width, height, self.left, self.top, self.right, self.bottom))
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/vbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/vbox.py 2006-12-07
14:32:31 UTC (rev 9121)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/vbox.py 2006-12-07
14:47:07 UTC (rev 9122)
@@ -32,7 +32,14 @@
# =============================================================================
class UIVBox(UIHelper):
+ """
+ A vertical box container
+ """
+ # -------------------------------------------------------------------------
+ # Create the widget
+ # -------------------------------------------------------------------------
+
def _create_widget_(self, event, spacer):
UIHelper._create_widget_(self, event, spacer)
@@ -40,20 +47,25 @@
self._container = self._parent
+ # -------------------------------------------------------------------------
+ # Set the widget size and fit all it's children
+ # -------------------------------------------------------------------------
+
def set_size_and_fit(self, width, height):
- right, bottom = self.left + width - 1, self.top + height - 1
- gDebug(2, "Size for vbox: %s/%s %s/%s %s/%s" % (width, height,
- self.left,
- self.top, right, bottom))
+ self.width = width
+ self.height = height
+ gDebug(2, "Size for vbox: %s/%s %s/%s %s/%s" % (self.width,
+ self.height, self.left, self.top, self.right, self.bottom))
+
attr = self._uiDriver.attr['background']
if self._gfObject.label:
- box(self._parent, attr, self.left, self.top, right, bottom,
- self._gfObject.label)
- width -= 2
- height -= 2
+ box(self._parent, attr, self.left, self.top, self.right,
+ self.bottom, self._gfObject.label)
+ self.width -= 2
+ self.height -= 2
hints = {}
for (index, child) in enumerate(self._children):
@@ -77,7 +89,7 @@
# Now let's have a look how much space is left if all children have
# used up their minimum height
- available = height - needed
+ available = self.height - needed
gDebug(2, "Ordered: %s/%s: %s" % (needed, available, ordered))
@@ -88,7 +100,7 @@
(minw, minh, label, propy) = hints[index]
- current_w = width - widest_label - 2
+ current_w = self.width - widest_label - 2
current_h = minh
if propy and available:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9122 - trunk/gnue-forms/src/uidrivers/curses/widgets,
johannes <=