[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9302 - in trunk/gnue-forms/src/uidrivers: _base/widgets wx26 wx2
From: |
johannes |
Subject: |
[gnue] r9302 - in trunk/gnue-forms/src/uidrivers: _base/widgets wx26 wx26/widgets |
Date: |
Sat, 13 Jan 2007 09:08:47 -0600 (CST) |
Author: johannes
Date: 2007-01-13 09:08:41 -0600 (Sat, 13 Jan 2007)
New Revision: 9302
Modified:
trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
Log:
Added GNUe:Sizer:defwidth/height so an entry can define a 'default size'
to start with. (still work in progress though)
Modified: trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py 2007-01-12
20:01:00 UTC (rev 9301)
+++ trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py 2007-01-13
15:08:41 UTC (rev 9302)
@@ -117,6 +117,9 @@
self.max_width = int(getattr(self._gfObject, 'Sizer__maxwidth', 0))
self.max_height = int(getattr(self._gfObject, 'Sizer__maxheight',
0))
+ self.def_width = int(getattr(self._gfObject, 'Sizer__defwidth', 0))
+ self.def_height = int(getattr(self._gfObject, 'Sizer__defheight',
+ 0))
self.span = int(getattr(self._gfObject, 'Sizer__span', 1))
else:
Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2007-01-12 20:01:00 UTC
(rev 9301)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2007-01-13 15:08:41 UTC
(rev 9302)
@@ -73,7 +73,7 @@
self.app = wx.GetApp () or wx.App ()
wx.lib.colourdb.updateColourDB()
- (self.controlHeight, self.cellWidth, self.cellHeight) = self.__getSizes
()
+ (self.best_sizes, self.cellWidth, self.cellHeight) = self.__getSizes ()
self.textWidth = self.widgetWidth = self.cellWidth
self.textHeight = self.widgetHeight = self.cellHeight
@@ -97,25 +97,27 @@
try:
# First of all find out the preferred size of all widgets needed
label = wx.StaticText (frame, wx.ID_ANY)
- result ['label'] = label.GetBestSize () [1]
+ result['label'] = label.GetBestSize()
text = wx.TextCtrl (frame, wx.ID_ANY)
- result ['default'] = text.GetBestSize () [1]
+ result['default'] = text.GetBestSize()
combo = wx.ComboBox (frame, wx.ID_ANY)
- result ['dropdown'] = combo.GetBestSize () [1]
+ result['dropdown'] = combo.GetBestSize()
check = wx.CheckBox (frame, wx.ID_ANY)
- result ['checkbox'] = check.GetBestSize () [1]
+ result['checkbox'] = check.GetBestSize()
- # 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 ()) + 2
+ cellHeight = max([i[1] for i in result.values()]) + 2
cellWidth = frame.GetCharWidth () + 1
+ # Add the button after calculating the cellHeight. This is because a
+ # button is too big on GTK.
+ button = wx.Button (frame, wx.ID_ANY)
+ result['button'] = button.GetBestSize()
+
finally:
frame.Destroy ()
@@ -126,7 +128,7 @@
# ---------------------------------------------------------------------------
def control_border(self, control):
- return (self.cellHeight - self.controlHeight[control]) / 2
+ return (self.cellHeight - self.best_sizes[control][1]) / 2
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-01-12
20:01:00 UTC (rev 9301)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-01-13
15:08:41 UTC (rev 9302)
@@ -239,12 +239,24 @@
@returns: tuple with default size
"""
+ cellw = self._uiDriver.cellWidth
+ cellh = self._uiDriver.cellHeight
+ style = self._gfObject.style.lower()
+
if self.managed:
- return (-1, -1)
+ (defw, defh) = self._uiDriver.best_sizes.get(style, (0, 0))
+
+ nc = min(max(self.def_width or 0, self._gfObject._field.length or
+ 0), 64)
+ defw = max(nc * cellw, defw)
+ if self.def_height:
+ defh = max(self.def_height * cellh, defh)
+
+ return (defw, defh)
else:
# We're using the size of an empty GridCell instead of the average
# character width. It returns better looking forms.
- return (self._uiDriver.cellWidth * self.chr_w, -1)
+ return (cellw * self.chr_w, -1)
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2007-01-12
20:01:00 UTC (rev 9301)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2007-01-13
15:08:41 UTC (rev 9302)
@@ -188,6 +188,8 @@
# NOTE: please have a look at the note on multiline text edits above
if not self.managed:
csize = (self.get_default_size()[0], 1)
+ else:
+ csize = (-1, -1)
self.__border = self._uiDriver.control_border('default')
result = wx.ListBox(parent, -1, size=csize, style=wx.LB_SINGLE)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9302 - in trunk/gnue-forms/src/uidrivers: _base/widgets wx26 wx26/widgets,
johannes <=