commit-gnue
[Top][All Lists]
Advanced

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

r6639 - in trunk/gnue-forms/src/uidrivers/wx: . widgets


From: kilo
Subject: r6639 - in trunk/gnue-forms/src/uidrivers/wx: . widgets
Date: Sat, 6 Nov 2004 16:49:06 -0600 (CST)

Author: kilo
Date: 2004-11-06 16:49:05 -0600 (Sat, 06 Nov 2004)
New Revision: 6639

Modified:
   trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
Log:
Highlight currently focused entry in WX too.
Can be switched off via gnue.conf

Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2004-11-05 23:27:24 UTC 
(rev 6638)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2004-11-06 22:49:05 UTC 
(rev 6639)
@@ -18,14 +18,13 @@
 #
 # Copyright 2000-2004 Free Software Foundation
 #
-# FILE:
-# UIwxpython.py
-#
 # DESCRIPTION:
 # A wxPython based user interface driver for GNUe forms.
 #
 # NOTES:
 #
+# $Id$
+
 import sys, os
 import string
 
@@ -102,8 +101,16 @@
 
     panel = wxPanel(dummyWindow, -1)
     self._disabledColour = panel.GetBackgroundColour()
-    self._focusColour = wxColour(255,255,236) # TODO: Make settable
 
+    if gConfigForms('focusColor'):
+      colorStr = gConfigForms('focusColor')
+      rgbR = int(colorStr[:2], 16)
+      rgbG = int(colorStr[2:4], 16)
+      rgbB = int(colorStr[4:6], 16)
+      self._focusColour = wxColour(rgbR, rgbG, rgbB)
+    else:
+      self._focusColour = None
+
     #
     # Find the max size of printable characters
     #  used to setup the grid


Property changes on: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py  2004-11-05 23:27:24 UTC 
(rev 6638)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py  2004-11-06 22:49:05 UTC 
(rev 6639)
@@ -18,14 +18,13 @@
 #
 # Copyright 2000-2004 Free Software Foundation
 #
-# FILE:
-# UIwxpython.py
-#
 # DESCRIPTION:
 # A wxPython based user interface driver for GNUe forms.
 #
 # NOTES:
 #
+# $Id$
+
 from wxPython.wx import *
 
 from gnue.common import events
@@ -95,22 +94,52 @@
     for widget in self.widgets:
       self.Destroy()
 
+
+  # --------------------------------------------------------------------------
+  # Set the focus to a given widget
+  # --------------------------------------------------------------------------
   def indexedFocus(self, index):
+    """
+    Sets the focus to the wx widget specified by index.
+    The focused widget will have a highlight color if it is set in gnue.conf.
+    """
     widget = self.widgets[index]
     widget.__focused = True
-    try:
-      widget.__color
-    except:
-      widget.__color = widget.GetBackgroundColour()
+
+    #Make the focused widget's color different
+    #if focus color is set in gnue.conf.
+    #We store the widget's original color so we can set it back to normal
+    #when it loses focus.
+    #TODO: CheckButtons don't get colored...
+    if self._uiDriver._focusColour:
+      try:
+        widget.__color
+      except:
+        widget.__color = widget.GetBackgroundColour()
+      widget.SetBackgroundColour(self._uiDriver._focusColour)
     widget.SetFocus()
-    widget.SetBackgroundColour(self._uiDriver._focusColour)
 
+
+  # --------------------------------------------------------------------------
+  # On lose of the focus we un-select ComboBox-Entries
+  # --------------------------------------------------------------------------
   def loseFocus(self):
     widget = self.widgets[self._uiDriver._uiFocusIndex]
     widget.__focused = False
-    widget.SetBackgroundColour(widget.__color)
+    try:
+      widget.__color
+      widget.SetBackgroundColour(widget.__color)
+    except:
+      pass
 
-  def setValue(self, value, index=0, enabled=1):
+
+  # --------------------------------------------------------------------------
+  # Set the value of a widget
+  # --------------------------------------------------------------------------
+  def setValue(self, value, index=0, enabled=True):
+    """
+    Sets the value of a widget and optionally enables or disables the widget.
+    """
     # These must be here or dropdown style controls
     # will get events they shouldn't and break.
     widget = self.widgets[index]
@@ -146,7 +175,7 @@
     if enabled:
       widget.__color = color = widget.__origBackgroundColor
       try:
-        if widget.__focused:
+        if widget.__focused and self._uiDriver._focusColour:
           color = self._uiDriver._focusColour
       except AttributeError:
         pass
@@ -156,6 +185,7 @@
     widget.SetBackgroundColour(color)
     widget.Refresh()
 
+
   def setCursorPosition(self, position, index=0):
     try:
       self.widgets[index].SetInsertionPoint(position)


Property changes on: trunk/gnue-forms/src/uidrivers/wx/widgets/_base.py
___________________________________________________________________
Name: svn:keywords
   + Id





reply via email to

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