Author: johannes
Date: 2007-01-16 09:52:00 -0600 (Tue, 16 Jan 2007)
New Revision: 9318
Modified:
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
Log:
Use a default length for date-related fields
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-01-16
14:57:03 UTC (rev 9317)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-01-16
15:52:00 UTC (rev 9318)
@@ -98,7 +98,29 @@
"""
return wx.DefaultSize
+ # -------------------------------------------------------------------------
+ # Get the length of a widget according to it's GFField
+ # -------------------------------------------------------------------------
+ def get_field_length(self):
+ """
+ Returns the lenght of the bound GFField
+ """
+
+ datatype = self._gfObject._field.datatype
+
+ if datatype == 'datetime':
+ result = 19
+ elif datatype == 'date':
+ result = 10
+ elif datatype == 'time':
+ result = 8
+ else:
+ result = self._gfObject._field.length or 0
+
+ return result
+
+
# -------------------------------------------------------------------------
# Update the size hints of a widget
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2007-01-16
14:57:03 UTC (rev 9317)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2007-01-16
15:52:00 UTC (rev 9318)
@@ -581,13 +581,16 @@
bw, bh = self._uiDriver.best_sizes.get(style, (-1, -1))
+ deffield = self.get_field_length()
# Do not exceed either the maximum allowed or 64 characters
- if (self.def_width or self._gfObject._field.length or 0) == 0:
+ if (self.def_width or deffield) == 0:
defw = bw
else:
- maxw = min(self.max_width or 64, 64)
- flength = min(self._gfObject._field.length or maxw, maxw)
- defw = (min(self.def_width or flength, flength) * cellw) or bw
+ if self.def_width:
+ defw = self.def_width * cellw
+ else:
+ maxw = min(self.max_width or 64, 64)
+ defw = min(deffield, maxw) * cellw
if not self.def_height:
defh = -1
@@ -616,7 +619,7 @@
cellw = self._uiDriver.cellWidth
cellh = self._uiDriver.cellHeight
- length = self._gfObject._field.length or 0
+ length = self.get_field_length()
if (self.max_width or length) == 0:
maxw = -1
else:
_______________________________________________
commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue