commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src PropertyEditor.py


From: Jason Cater
Subject: gnue/designer/src PropertyEditor.py
Date: Wed, 27 Jun 2001 22:38:06 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/06/27 22:38:06

Modified files:
        designer/src   : PropertyEditor.py 

Log message:
        Fixed display of true/false property fields

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/PropertyEditor.py.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: gnue/designer/src/PropertyEditor.py
diff -u gnue/designer/src/PropertyEditor.py:1.8 
gnue/designer/src/PropertyEditor.py:1.9
--- gnue/designer/src/PropertyEditor.py:1.8     Wed Jun 27 22:04:18 2001
+++ gnue/designer/src/PropertyEditor.py Wed Jun 27 22:38:06 2001
@@ -91,6 +91,8 @@
               self.grid.SetCellValue(i,0,"TRUE")
             else: 
               self.grid.SetCellValue(i,0,"FALSE")
+          else: 
+            self.grid.SetCellValue(i,0, "%s" % object.__dict__[key])
         i = i + 1
       self.onSize(None)
       EVT_GRID_CELL_CHANGE(self.grid, self.OnCellChange)
@@ -304,15 +306,66 @@
       evt.Skip()
 
 
-class BoolCellEditor (RestrictedCellEditor):
+class BoolCellEditor (CharCellEditor):
   def __init__(self, attributes): 
-    if attributes.has_key('Default'): 
-       default = attributes['Default'] 
+    CharCellEditor.__init__(self, attributes)
+      
+    self.selectionList = ['FALSE','TRUE']
+
+  def Create(self, parent, id, evtHandler):
+    self._tc = wxComboBox(parent, id, "", style=wxCB_READONLY, 
+                          choices=self.selectionList)
+    self.SetControl(self._tc)
+    if evtHandler:
+      self._tc.PushEventHandler(evtHandler)
+
+  def BeginEdit(self, row, col, grid):
+    self.startValue = grid.GetTable().GetValue(row, col)
+    
+    self._tc.SetValue(self.startValue)
+    self._tc.SetFocus()
+
+  def EndEdit(self, row, col, grid):
+    changed = false
+
+    if self._tc.GetSelection(): 
+      val = 'TRUE' 
     else: 
-       default = 0
-    RestrictedCellEditor.__init__(self, {'ValueSet': {'TRUE':{}, 'FALSE':{}}, 
-                                         'Required': 1, 
-                                         'Default': default} )
+      val = 'FALSE' 
+    if val != self.startValue:
+       changed = true
+       grid.GetTable().SetValue(row, col, "%s" % val) # update the table
+
+    self.startValue = ''
+    self._tc.SetSelection(0)
+    return changed
+
+
+  def Reset(self):
+    self._tc.SetValue(self.startValue)
+    #self._tc.SetInsertionPointEnd()
+
+
+  def StartingKey(self, evt):
+    key = evt.GetKeyCode()
+    ch = None
+    if key in [WXK_NUMPAD0, WXK_NUMPAD1, WXK_NUMPAD2, WXK_NUMPAD3, WXK_NUMPAD4,
+               WXK_NUMPAD5, WXK_NUMPAD6, WXK_NUMPAD7, WXK_NUMPAD8, 
WXK_NUMPAD9]:
+        ch = ch = chr(ord('0') + key - WXK_NUMPAD0)
+
+    elif key < 256 and key >= 0 and chr(key):
+      ch = chr(key)
+      if not evt.ShiftDown():
+        ch = string.lower(ch)
+
+    if ch is not None:
+      # For this example, replace the text.  Normally we would append it.
+      #self._tc.AppendText(ch)
+      pass
+#      self._tc.SetValue(ch)
+#      self._tc.SetInsertionPointEnd()
+    else:
+      evt.Skip()
 
 
 #



reply via email to

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