Rev 1700 of the trunk adds support for changing the background color
of the body pane,
depending on whether the pane has focus or not.  All unit tests pass,
except for the expected failure.

The following option settings now control the background color of the
body pane.  The usual settings apply if one or the other of these do
not exist.

  @string selected-background-color
  @string unselected-background-color

**Important**: the new code provides a template for intermixing Leo-
style settings with Qt stylesheets.  The trick is that we can set a
stylesheet of the body pane that just specifies the background color,
and we can get the color from a normal Leo-style setting, as shown
above.  Here is the code::

badFocusColors = []

def onFocusIn (self):
    self.onFocusHelper(self.selectedBackgroundColor)

def onFocusOut (self):
    self.onFocusHelper(self.unselectedBackgroundColor)

def onFocusHelper(self,name):

    if QtGui.QColor(name).isValid():
        s = 'QTextEdit#richTextEdit { background-color: %s; }' % name
        self.widget.widget.setStyleSheet(s)
    elif name not in self.badFocusColors:
        self.badFocusColors.append(name)
        g.es_print('invalid body background color: %s' %
(name),color='blue')

The selectedBackgroundColor and unselectedBackgroundColor ivars come
from the settings.

Apparently, setting the stylesheet like this has no ill effects on the
global stylesheet.

Thus, it appears we can, for the first time ever, intermix stylesheet
settings and Leo settings.  This is a big step forward.  For example,
I spent several hours this morning trying to set the background color
programatically by setting the body widget's palette.  No joy.  In
contrast, this method, once I thought of it, produced only happy
surprises.

Edward

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to