support focus highlighting
authorca
Wed, 28 Feb 2007 16:50:46 +0100
changeset 3176 4785f8b58e64
parent 3175 d82c95049597
child 3177 36121bb5ae31
support focus highlighting
SelectionInTreeView.st
--- a/SelectionInTreeView.st	Wed Feb 28 16:20:16 2007 +0100
+++ b/SelectionInTreeView.st	Wed Feb 28 16:50:46 2007 +0100
@@ -9,8 +9,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-
-
 "{ Package: 'stx:libwidg2' }"
 
 SelectionInListView subclass:#SelectionInTreeView
@@ -789,16 +787,12 @@
         dX  := ext x.
 
         (x + dX > 0 and:[(x := x - dX) < (width - margin)]) ifTrue:[
-            (self isInSelection:aLineNr) ifTrue:[ self paint:hilightFgColor on:hilightBgColor ]
-                                        ifFalse:[ self paint:fgColor on:bgColor ].
+            self paintOnIsSelected:(self isInSelection:aLineNr).
 
             y := (self yOfVisibleLine:visLn) + (fontHeight // 2) - 1.
             self displayForm:img x:x y:(y - ext y)
         ].
     ].
-
-
-
 !
 
 redrawVisibleLine:visLineNr
@@ -959,6 +953,18 @@
           height:fontHeight
 !
 
+paintOnIsSelected:isSelected
+    isSelected ifTrue:[
+        self hasFocus ifTrue:[
+            self paint:hilightFgColor on:hilightBgColor
+        ] ifFalse:[
+            self paint:hilightFgColorNoFocus on:hilightBgColorNoFocus
+        ]
+    ] ifFalse:[
+        self paint:fgColor on:bgColor.
+    ].
+!
+
 redrawElement:anIndex
 
     |vln x0 xT y|
@@ -1000,7 +1006,12 @@
 
         isSel ifTrue:[
             w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
-            self paint:hilightBgColor.
+
+            self hasFocus ifTrue:[
+                self paint:hilightBgColor.
+            ] ifFalse:[
+                self paint:hilightBgColorNoFocus.
+            ].                
             self fillRectangleX:x y:yTop width:w height:fontHeight.
 
             (value notNil and:[(editorWidget isNil or:[editorIndex ~~ anIndex])]) ifTrue:[
@@ -1013,9 +1024,7 @@
     ].
 
     label notNil ifTrue:[
-        isSel ifTrue:[self paint:hilightFgColor on:hilightBgColor]
-             ifFalse:[self paint:fgColor on:bgColor].
-
+        self paintOnIsSelected:isSel.
         self displayOpaqueString:label x:x0 y:y0.
 
         value notNil ifTrue:[
@@ -1032,10 +1041,8 @@
 
         wV ~~ 0 ifTrue:[
             self redrawSelFrameAtX:xV y:yTop toX:(xV + wV)
-        ]
+        ].
     ].
-
-
 !
 
 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
@@ -1140,14 +1147,16 @@
     hilightFrameColor notNil ifTrue:[
         hilightLevel == 0 ifTrue:[
             self paint:hilightFrameColor.
+
             highlightMode == #line ifTrue:[
                 self displayLineFromX:x0 y:y0 toX:x1 y:y0.
                 y := y0 + fontHeight - 1.
-                ^self displayLineFromX:x0 y:y toX:x1 y:y.
+                self displayLineFromX:x0 y:y toX:x1 y:y.
             ] ifFalse:[
-                ^self displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight
-            ]
-        ]
+                self displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight.
+            ].
+            ^ self
+        ].
     ] ifFalse:[
         hilightStyle == #motif ifTrue:[
             self paint:bgColor.
@@ -2488,5 +2497,5 @@
 !SelectionInTreeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.106 2004-03-26 11:35:58 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.107 2007-02-28 15:50:46 ca Exp $'
 ! !