commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r10116 - in trunk/gnue-forms/src: . uidrivers/wx/widgets


From: reinhard
Subject: [gnue] r10116 - in trunk/gnue-forms/src: . uidrivers/wx/widgets
Date: Thu, 10 Dec 2009 03:36:08 -0600 (CST)

Author: reinhard
Date: 2009-12-10 03:36:08 -0600 (Thu, 10 Dec 2009)
New Revision: 10116

Modified:
   trunk/gnue-forms/src/GFConfig.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/button.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py
Log:
Reintroduced the possibility to have a shining background color for the focused
widget.


Modified: trunk/gnue-forms/src/GFConfig.py
===================================================================
--- trunk/gnue-forms/src/GFConfig.py    2009-12-10 07:35:08 UTC (rev 10115)
+++ trunk/gnue-forms/src/GFConfig.py    2009-12-10 09:36:08 UTC (rev 10116)
@@ -185,39 +185,8 @@
     'Typecast'   : GTypecast.whole,
     'Default'    : 10 },
 
-  { 'Name'       : 'fixedWidthFont',
+  { 'Name'       : 'focus_color',
     'Type'       : 'Setting',
-    'Comment'    : 'Set to true if wxWidgets or Win32 clients should use '
-                 + 'a fixed width font.',
-    'Description': 'The next 3 options are only used by the wxPython and the'
-                 + 'Win32 clients.\n'
-                 + 'Normally, default font style and size is used, '
-                 + 'according to the active theme.\n'
-                 + 'Set to true if wxWidgets or Win32 clients should use '
-                 + 'a fixed width font.',
-    'Typecast'   : GTypecast.boolean,
-    'Default'    : False },
-
-  { 'Name'       : 'pointSize',
-    'Type'       : 'Setting',
-    'Comment'    : 'If fixedWidthFont is set to true, then this is the '
-                 + 'point size used for fonts.',
-    'Description': 'If fixedWidthFont is set to true, then this is the '
-                 + 'point size used for fonts.',
-    'Typecast'   : GTypecast.whole,
-    'Default'    : 0 },
-
-  { 'Name'       : 'faceName',
-    'Type'       : 'Setting',
-    'Comment'    : 'If fixedWidthFont is set to true, then this is '
-                 + 'the face name used for fonts.',
-    'Description': 'If fixedWidthFont is set to true, then this is '
-                 + 'the face name used for fonts.',
-    'Typecast'   : GTypecast.text,
-    'Default'    : '' },
-
-  { 'Name'       : 'focusColor',
-    'Type'       : 'Setting',
     'Comment'    : 'The color of a highlighted (ie focused) widget.',
     'Description': 'The color of a highlighted (ie focused) widget. '
                  + 'Leave empty if you don\'t want highlight. '

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/button.py 2009-12-10 07:35:08 UTC 
(rev 10115)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/button.py 2009-12-10 09:36:08 UTC 
(rev 10116)
@@ -63,10 +63,11 @@
             csize = wx.DefaultSize
 
         self.widget = wx.Button(parent, -1, self._gfObject.label, size=csize)
-        self.widget.Bind(wx.EVT_BUTTON   , self.__on_button)
-        self.widget.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
-        self.widget.Bind(wx.EVT_KEY_DOWN , self.__on_key_down)
-        self.widget.Bind(wx.EVT_CHAR     , self.__on_char)
+        self.widget.Bind(wx.EVT_CHAR      , self.__on_char)
+        self.widget.Bind(wx.EVT_KEY_DOWN  , self.__on_key_down)
+        self.widget.Bind(wx.EVT_BUTTON    , self.__on_button)
+        self.widget.Bind(wx.EVT_SET_FOCUS , self.__on_set_focus)
+        self.widget.Bind(wx.EVT_KILL_FOCUS, self.__on_kill_focus)
 
         if self.in_grid:
             self.widget._gnue_label_ = None
@@ -134,11 +135,29 @@
         if self._uiForm.block_focus_events:
             return
 
-        lookup = event.GetEventObject()
-        self._gfObject._event_set_focus(self.widgets.index(lookup))
+        widget = event.GetEventObject()
+
+        # Let the GF focus follow
+        self._gfObject._event_set_focus(self.widgets.index(widget))
+
+        # Change background color of widget if requested.
+        if gConfigForms('focus_color'):
+            self.__old_background = widget.GetBackgroundColour()
+            widget.SetBackgroundColour(gConfigForms('focus_color'))
+
         event.Skip()
 
+    # -------------------------------------------------------------------------
 
+    def __on_kill_focus(self, event):
+
+        widget = event.GetEventObject()
+
+        # Change background color of widget if requested.
+        if gConfigForms('focus_color'):
+            widget.SetBackgroundColour(self.__old_background)
+
+
     # -------------------------------------------------------------------------
     # Enable/disable this button
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py  2009-12-10 07:35:08 UTC 
(rev 10115)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/entry.py  2009-12-10 09:36:08 UTC 
(rev 10116)
@@ -108,6 +108,7 @@
         ctrl.Bind(wx.EVT_CHAR, self.__on_keypress)
         ctrl.Bind(wx.EVT_KEY_DOWN, self.__on_key_down)
         ctrl.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
+        ctrl.Bind(wx.EVT_KILL_FOCUS, self.__on_kill_focus)
 
         # If the control has a block assigned, we bind the mouse wheel event to
         # scroll through the block's records.
@@ -148,6 +149,7 @@
         result.Bind (wx.EVT_CHAR, self.__on_keypress)
         result.Bind (wx.EVT_KEY_DOWN, self.__on_key_down)
         result.Bind (wx.EVT_SET_FOCUS, self.__on_set_focus)
+        result.Bind(wx.EVT_KILL_FOCUS, self.__on_kill_focus)
 
         label = None
 
@@ -178,8 +180,9 @@
         else:
             result.Bind(wx.EVT_TEXT, self.__on_text_changed)
 
+        item.Bind(wx.EVT_KEY_DOWN, self.__on_combo_keydown)
         item.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
-        item.Bind(wx.EVT_KEY_DOWN, self.__on_combo_keydown)
+        item.Bind(wx.EVT_KILL_FOCUS, self.__on_kill_focus)
 
         # Workaround for a bug in wxGTK 2.8 (tested with 2.8.7.1) - ComboBox
         # does not receive EVT_SET_FOCUS when the dropdown button is clicked.
@@ -206,6 +209,7 @@
         result.Bind(wx.EVT_LISTBOX, self.__on_item_selected)
         result.Bind(wx.EVT_KEY_DOWN, self.__on_key_down)
         result.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
+        result.Bind(wx.EVT_KILL_FOCUS, self.__on_kill_focus)
 
         return [self.__add_entry_label(parent), result]
 
@@ -278,15 +282,34 @@
         if self._uiForm.block_focus_events:
             return
 
+        widget = event.GetEventObject()
+        if 'wxMac' in wx.PlatformInfo and self._gfObject.style == 'dropdown':
+            widget = widget.GetParent()
+
         # Let the GF focus follow
-        lookup = event.GetEventObject()
-        if 'wxMac' in wx.PlatformInfo and self._gfObject.style == 'dropdown':
-            lookup = lookup.GetParent()
-        self._gfObject._event_set_focus(self.widgets.index(lookup))
+        self._gfObject._event_set_focus(self.widgets.index(widget))
+
+        # Change background color of widget if requested.
+        if gConfigForms('focus_color'):
+            self.__old_background = widget.GetBackgroundColour()
+            widget.SetBackgroundColour(gConfigForms('focus_color'))
+
         event.Skip()
 
     # -------------------------------------------------------------------------
 
+    def __on_kill_focus(self, event):
+
+        widget = event.GetEventObject()
+        if 'wxMac' in wx.PlatformInfo and self._gfObject.style == 'dropdown':
+            widget = widget.GetParent()
+
+        # Change background color of widget if requested.
+        if gConfigForms('focus_color'):
+            widget.SetBackgroundColour(self.__old_background)
+
+    # -------------------------------------------------------------------------
+
     def __on_mac_choice_clicked(self, event):
 
         lookup = event.GetEventObject().GetParent()





reply via email to

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