commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8566 - in branches/forms-0.5/src: GFObjects input/displayHandler


From: johannes
Subject: [gnue] r8566 - in branches/forms-0.5/src: GFObjects input/displayHandlers uidrivers/wx26/widgets
Date: Thu, 17 Aug 2006 09:32:11 -0500 (CDT)

Author: johannes
Date: 2006-08-17 09:32:11 -0500 (Thu, 17 Aug 2006)
New Revision: 8566

Modified:
   branches/forms-0.5/src/GFObjects/GFBlock.py
   branches/forms-0.5/src/GFObjects/GFField.py
   branches/forms-0.5/src/input/displayHandlers/Checkbox.py
   branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py
   branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py
Log:
Added a third state to the checkboxes while in query mode.  This way we
can search for either state of a checkbox.



Modified: branches/forms-0.5/src/GFObjects/GFBlock.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-17 12:00:55 UTC (rev 
8565)
+++ branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-17 14:32:11 UTC (rev 
8566)
@@ -951,20 +951,21 @@
       match = False
       for comparison in baseComparisons.keys():
           
-        if val[:2+len(comparison)].lower() == "%s%s%s" % \
+        if isinstance(val, basestring) and \
+                val[:2+len(comparison)].lower() == "%s%s%s" % \
           (comparisonDelimeter, comparison, comparisonDelimeter):
           value=val[2+len(comparison):]
           
           if baseComparisons[comparison][1]:
-            conditions.append([ baseComparisons[comparison][0], 
-                                ['field', entry.field], 
-                                ['const', value] 
+            conditions.append([ baseComparisons[comparison][0],
+                                ['field', entry.field],
+                                ['const', value]
                               ])
           else:
-            conditions.append([ baseComparisons[comparison][0], 
-                                ['field', entry.field] 
+            conditions.append([ baseComparisons[comparison][0],
+                                ['field', entry.field]
                               ])
-          match = True  
+          match = True
           break
       
       # Falls through to old behaviour if no : condition given or 

Modified: branches/forms-0.5/src/GFObjects/GFField.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFField.py 2006-08-17 12:00:55 UTC (rev 
8565)
+++ branches/forms-0.5/src/GFObjects/GFField.py 2006-08-17 14:32:11 UTC (rev 
8566)
@@ -345,7 +345,11 @@
         pass
 
     if mode == 'query':
-      self._block._queryValues[self] = value
+        if value is None:
+            if self in self._block._queryValues:
+                del self._block._queryValues[self]
+        else:
+            self._block._queryValues[self] = value
 
     elif mode == 'init':
       self._block._initializingRecord [self.field] = value

Modified: branches/forms-0.5/src/input/displayHandlers/Checkbox.py
===================================================================
--- branches/forms-0.5/src/input/displayHandlers/Checkbox.py    2006-08-17 
12:00:55 UTC (rev 8565)
+++ branches/forms-0.5/src/input/displayHandlers/Checkbox.py    2006-08-17 
14:32:11 UTC (rev 8566)
@@ -60,6 +60,9 @@
 
 
   def _sanitizeValue(self, value):
+    if self.field._block.mode == 'query' and (value in [None, '']):
+        return None
+
     if ("%s" % value)[:1] in self.trueValues:
       return True
     elif ("%s" % value)[:1] in self.falseValues:
@@ -88,7 +91,14 @@
 
   # Toggle value of checkbox
   def __toggle (self):
-    self.work = not self.work
+    allowed = [True, False]
+    if self.field._block.mode == 'query':
+        allowed.append(None)
+    next = allowed.index(self.work) + 1
+    if next == len(allowed):
+        next = 0
+
+    self.work = allowed[next]
     self.modified = True
     self._buildDisplay ()
 
@@ -147,4 +157,4 @@
     if event.text != None:
       self.work = self._sanitizeValue(event.data)
       self.modified = True
-      self._buildDisplay()
\ No newline at end of file
+      self._buildDisplay()

Modified: branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py      2006-08-17 
12:00:55 UTC (rev 8565)
+++ branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py      2006-08-17 
14:32:11 UTC (rev 8566)
@@ -194,6 +194,13 @@
         if value:
           widget.SetStringSelection (value, True)
 
+      elif isinstance(widget, wx.CheckBox):
+          if value is None:
+              widget.Set3StateValue(wx.CHK_UNDETERMINED)
+          elif value:
+              widget.Set3StateValue(wx.CHK_CHECKED)
+          else:
+              widget.Set3StateValue(wx.CHK_UNCHECKED)
       else:
         if isinstance (widget, wx.ComboBox):
           # We use SetStringSelection to keep the selected index in sync with

Modified: branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py      2006-08-17 
12:00:55 UTC (rev 8565)
+++ branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py      2006-08-17 
14:32:11 UTC (rev 8566)
@@ -126,8 +126,10 @@
     """
     """
 
-    result = wx.CheckBox (parent, -1, self._gfObject.label, self.__pos)
+    result = wx.CheckBox (parent, -1, self._gfObject.label, self.__pos,
+            style=wx.CHK_3STATE)
     result.Bind (wx.EVT_CHECKBOX, self.__toggleCheckbox)
+    result.Bind (wx.EVT_CHAR, self.__keypress)
     result.Bind (wx.EVT_SET_FOCUS, self.__on_set_focus)
 
     return result





reply via email to

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