commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8967 - in trunk/gnue-forms/src/uidrivers/wx26: . widgets


From: johannes
Subject: [gnue] r8967 - in trunk/gnue-forms/src/uidrivers/wx26: . widgets
Date: Tue, 31 Oct 2006 09:59:49 -0600 (CST)

Author: johannes
Date: 2006-10-31 09:59:48 -0600 (Tue, 31 Oct 2006)
New Revision: 8967

Modified:
   trunk/gnue-forms/src/uidrivers/wx26/UIdriver.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/page.py
Log:
More work on positioned layout


Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2006-10-31 15:53:27 UTC 
(rev 8966)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2006-10-31 15:59:48 UTC 
(rev 8967)
@@ -117,20 +117,27 @@
       check = wx.CheckBox (frame, wx.ID_ANY)
       result ['checkbox'] = check.GetBestSize () [1]
 
-      button = wx.Button (frame, wx.ID_ANY)
-      result ['button'] = button.GetBestSize () [1]
+      # button = wx.Button (frame, wx.ID_ANY)
+      # result ['button'] = button.GetBestSize () [1]
 
       # Get the height and width of a form-cell for which we use the tallest
       # control and the avarage character width of the application font
-      cellHeight = max (result.values ()) + 1
-      cellWidth  = frame.GetCharWidth ()
+      cellHeight = max (result.values ()) + 2
+      cellWidth  = frame.GetCharWidth () + 1
 
     finally:
       frame.Destroy ()
 
     return (result, cellWidth, cellHeight)
 
+  # ---------------------------------------------------------------------------
+  # Get the border for a given type of control
+  # ---------------------------------------------------------------------------
 
+  def control_border(self, control):
+      return (self.cellHeight - self.controlHeight[control]) / 2
+
+
   # ---------------------------------------------------------------------------
   # Hide the splash screen
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-10-31 15:53:27 UTC 
(rev 8966)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/box.py  2006-10-31 15:59:48 UTC 
(rev 8967)
@@ -80,10 +80,18 @@
         self._sizer.SetEmptyCellSize((self._uiDriver.cellWidth,
                 self._uiDriver.cellHeight))
         # leave some border on top and bottom
+        half = self._uiDriver.control_border('label') / 2
+        box.Add((half, half))
         box.Add(self._sizer, 1, wx.TOP | wx.BOTTOM,
                 self._uiDriver.cellHeight/4)
 
-        self.widget = box
+        # the vertical box which will contain the box
+        outer = wx.BoxSizer(wx.VERTICAL)
+        outer.Add((half, half))
+        outer.Add(box, 1, wx.ALIGN_CENTER_HORIZONTAL)
+        outer.Add((1, self._uiDriver.cellHeight / 2))
+
+        self.widget = outer
         owner.add_widgets(self, 0)
 
         return self._container
@@ -93,7 +101,7 @@
     # Add child widgets to the sizer
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget, spacer):
+    def add_widgets(self, ui_widget, spacer, border=0):
         """
         Add a given UI widget to the page.
 
@@ -109,9 +117,13 @@
             box.Add(item, 1, wx.ALIGN_CENTER_VERTICAL)
             item = box
 
-        self._sizer.Add(item, ui_widget.chr_pos, ui_widget.chr_span, flags)
+        if border:
+            flags |= wx.TOP | wx.BOTTOM
 
+        self._sizer.Add(item, ui_widget.chr_pos, ui_widget.chr_span, flags,
+                border)
 
+
 # =============================================================================
 # Configuration data
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-10-31 
15:53:27 UTC (rev 8966)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-10-31 
15:59:48 UTC (rev 8967)
@@ -57,7 +57,12 @@
         else:
             parent = event.container
 
-        self.widget = wx.Button(parent, -1, self._gfObject.label)
+        if not self.managed:
+            csize = (self.get_default_size()[0], self._uiDriver.cellHeight - 2)
+        else:
+            csize = wx.DefaultSize
+
+        self.widget = wx.Button(parent, -1, self._gfObject.label, size=csize)
         self.widget.Bind(wx.EVT_BUTTON   , self.__on_button)
         self.widget.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
         self.widget.Bind(wx.EVT_CHAR     , self.__on_char)

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py        2006-10-31 
15:53:27 UTC (rev 8966)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py        2006-10-31 
15:59:48 UTC (rev 8967)
@@ -61,6 +61,7 @@
 
         style = self._gfObject.style.lower()
         func = getattr(self, "_UIEntry__build_%s" % style)
+        self.__border = 0
         (self.label, self.widget) = func(parent)
 
         (mins, maxs) = self.get_size_hints()
@@ -70,7 +71,7 @@
             self.widget.SetMaxSize(maxs)
 
 
-        owner.add_widgets(self, spacer)
+        owner.add_widgets(self, spacer, self.__border)
 
         if self.in_grid:
             self.widget._gnue_label_ = self.label
@@ -98,8 +99,18 @@
         # TODO: should we use the container_sizer.GetEmptyCellSize() for
         # setting a minimal control size ?
         csize = self.get_default_size()
+
+        # NOTE: a multiline text control has a native size which is about 60
+        # pixels.  This height might be bigger than for example two grid cells.
+        # In that case those lines in the GridBagSizer would be stretched which
+        # is not what we want!  To avoid that, we set the size of the control
+        # to 1 pixel in height, which will be overriden by the containing
+        # GridBagSizer when it comes to layout.
+        if multiline:
+            csize = (csize[0], 1)
+            self.__border = self._uiDriver.control_border('default')
+
         ctrl = wx.TextCtrl(parent, -1, size=csize, style=xFlags)
-
         ctrl.Bind(wx.EVT_CHAR, self.__on_keypress)
         ctrl.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
 
@@ -186,7 +197,10 @@
     def __build_listbox(self, parent):
 
         self.growable = True
-        csize = self.get_default_size()
+        # NOTE: please have a look at the note on multiline text edits above
+        csize = (self.get_default_size()[0], 1)
+        self.__border = self._uiDriver.control_border('default')
+
         result = wx.ListBox(parent, -1, size=csize, style=wx.LB_SINGLE)
         self.update_choices(result)
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-10-31 15:53:27 UTC 
(rev 8966)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-10-31 15:59:48 UTC 
(rev 8967)
@@ -92,7 +92,7 @@
     # Add widgets to the page
     # -------------------------------------------------------------------------
 
-    def add_widgets(self, ui_widget, spacer):
+    def add_widgets(self, ui_widget, spacer, border=0):
         """
         Add a given UI widget to the page.
 
@@ -106,16 +106,20 @@
         if self.managed:
             sizer.Add(item, ui_widget.stretch, wx.EXPAND | wx.ALL, 4)
         else:
-            flags = wx.ALIGN_CENTER
+            flags = wx.ALIGN_CENTER | wx.EXPAND
             if not ui_widget.growable:
                 box = wx.BoxSizer(wx.HORIZONTAL)
                 box.Add(item, 1, wx.ALIGN_CENTER_VERTICAL)
                 item = box
 
-            sizer.Add(item, ui_widget.chr_pos, ui_widget.chr_span, flags)
+            if border:
+                flags |= wx.TOP | wx.BOTTOM
 
+            sizer.Add(item, ui_widget.chr_pos, ui_widget.chr_span, flags,
+                    border)
 
 
+
 # =============================================================================
 # Configuration data
 # =============================================================================





reply via email to

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