support hightlightMode
authorca
Thu, 28 May 1998 13:17:22 +0200
changeset 900 cd74dcab7e3f
parent 899 68770c9d162d
child 901 0e090a691095
support hightlightMode #line draw whole line selected #label draw label selected
SelTreeV.st
SelectionInTreeView.st
--- a/SelTreeV.st	Fri May 22 14:09:01 1998 +0200
+++ b/SelTreeV.st	Thu May 28 13:17:22 1998 +0200
@@ -18,8 +18,8 @@
 		closeIndicator openIndicator showDirectoryIndicatorForRoot
 		imageOpened imageClosed imageItem discardMotionEvents
 		registeredImages supportsExpandAll buildInArray
-		drawVLinesFromLevel'
-	classVariableNames:''
+		drawVLinesFromLevel highlightMode'
+	classVariableNames:'DefaultHilightMode'
 	poolDictionaries:''
 	category:'Views-Text'
 !
@@ -124,6 +124,21 @@
 
 ! !
 
+!SelectionInTreeView class methodsFor:'defaults'!
+
+updateStyleCache
+    "extract values from the styleSheet and cache them in class variables"
+
+    <resource: #style (#'selection.highlightMode')>
+
+    DefaultHilightMode := StyleSheet at:'selection.highlightMode' default:#line.
+    "
+     self updateStyleCache
+    "
+
+
+! !
+
 !SelectionInTreeView class methodsFor:'resources'!
 
 closeIndicator
@@ -183,6 +198,34 @@
 
 !SelectionInTreeView methodsFor:'accessing'!
 
+highlightMode
+    "get the mode how to draw a selected line:
+        #line           draw whole line selected
+        #label          draw label selected
+    "
+    ^ highlightMode
+!
+
+highlightMode:aMode
+    "set the mode how to draw a selected line:
+        #line           draw whole line selected
+        #label          draw label selected
+    "
+    |mode|
+
+    (mode := aMode) == #label ifFalse:[
+        mode := #line
+    ].
+
+    mode ~~ highlightMode ifTrue:[
+        highlightMode := mode.
+
+        shown ifTrue:[
+            self invalidate
+        ]
+    ]
+!
+
 lineColor
     "returns user configured line color or nil
     "
@@ -579,27 +622,6 @@
 
 !SelectionInTreeView methodsFor:'drawing'!
 
-drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
-    "redraw a visible line range with clearing the background
-    "
-    |y0 y1 sz|
-
-    shown ifTrue:[
-        y0  := self yOfVisibleLine:startVisLineNr.
-        y0  := y0 - 1.
-        sz  := endVisLineNr - startVisLineNr + 1.
-        y1  := sz * fontHeight.
-
-    "/  clear rectangle line and set background color
-        self paint:bg.
-        self fillRectangleX:0 y:y0 width:width height:y1.
-
-        (y1 := self visibleLineToAbsoluteLine:startVisLineNr) notNil ifTrue:[
-            self redrawLinesX:0 y:y0 toX:width start:y1 stop:(y1 + sz)
-        ]
-    ]
-!
-
 drawLine:line atX:atX inVisible:visLineNr with:fg and:bg
     self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
 
@@ -700,19 +722,30 @@
 
 
 
+!
+
+redrawVisibleLine:visLineNr
+    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
+!
+
+redrawVisibleLine:visLineNr from:startCol to:endCol
+    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
 ! !
 
 !SelectionInTreeView methodsFor:'drawing basics'!
 
-drawLabelIndex:anIndex atX:x y:yCenter
-    "draw text label at x and y centered
+drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
+    "redraw a visible line range with clearing the background
     "
-    |lbl y|
+    |y h|
 
-    (lbl := (listOfNodes at:anIndex) name) notNil ifTrue:[
-        y := yCenter + labelOffsetY.
-        self displayOpaqueString:lbl x:x y:y.
-    ]    
+    y := self yOfVisibleLine:startVisLineNr.
+    h := endVisLineNr - startVisLineNr + 1 * fontHeight.
+
+    y + h > height ifTrue:[
+        h := height - y
+    ].
+    self redrawX:0 y:y width:width height:h.
 !
 
 drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop
@@ -835,6 +868,50 @@
 
 !
 
+drawVisibleLineSelected:visLineNr with:fg and:bg
+    "redraw a single line as selected."
+    |y|
+
+    (self visibleLineToListLine:visLineNr) isNil ifTrue:[
+        ^ super drawVisibleLine:visLineNr with:fg and:bg
+    ].
+    self redrawX:0
+               y:(self yOfVisibleLine:visLineNr)
+           width:width
+          height:fontHeight
+!
+
+redrawLabelAt:x y:yTop index:anIndex
+    |isSelected y0 x0 x1 maxX w label i|
+
+    label       := (listOfNodes at:anIndex) name.
+    isSelected  := self isInSelection:anIndex.
+
+    highlightMode == #label ifTrue:[
+        x0 := x + 4.
+
+        isSelected ifTrue:[
+            w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
+            self paint:hilightBgColor.
+            self fillRectangleX:x y:yTop width:w height:fontHeight.
+        ]
+    ] ifFalse:[
+        x0 := x
+    ].
+
+    label notNil ifTrue:[
+        isSelected ifTrue:[self paint:hilightFgColor on:hilightBgColor]
+                  ifFalse:[self paint:fgColor on:bgColor].
+
+        self displayOpaqueString:label x:x0 y:yTop + (fontHeight // 2) + labelOffsetY.
+    ].
+
+    (isSelected and:[highlightMode == #label]) ifTrue:[
+        self redrawSelFrameAtX:x y:yTop toX:(x + w)
+    ].
+
+!
+
 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
     "redraw from line to line without clearing the background
     "
@@ -911,12 +988,7 @@
         ].
 
         showText ifTrue:[
-            (self isInSelection:anIndex) ifFalse:[
-                self paint:fgColor on:bgColor
-            ] ifTrue:[
-                self paint:hilightFgColor on:hilightBgColor
-            ].
-            self drawLabelIndex:anIndex atX:xText y:yCtr .
+            self redrawLabelAt:xText y:(yBot - fontHeight) index:anIndex
         ].
         (showIndc and:[node showIndicator]) ifTrue:[
             icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator].
@@ -926,63 +998,108 @@
     ]
 !
 
-redrawSelFrameForYs:aList fromX:x0 toX:x1
-    "redraw selection frames for each line starting at an absolute 
-     y derived from the argument a list.
+redrawSelFrameAtX:x0 y:y0 toX:x1
+    "redraw selection frame for a line
     "
-    | 
-     spc "{ Class: SmallInteger }"
-     dY  "{ Class: SmallInteger }"
+    |
      w   "{ Class: SmallInteger }"
      y   "{ Class: SmallInteger }" 
      x   "{ Class: SmallInteger }" 
     |
-    aList isNil ifTrue:[
-        ^ self
-    ].
-    strikeOut ifTrue:[
-        y := fontHeight // 2.
-        self paint:bgColor.
-        aList do:[:sY| self displayLineFromX:x0 y:(sY + y) toX:x1 y:(sY + y) ].
-        ^ self
-    ].
-    spc := lineSpacing // 2.
 
     hilightFrameColor notNil ifTrue:[
         hilightLevel == 0 ifTrue:[
-            dY := fontHeight - 1.
             self paint:hilightFrameColor.
-
-            aList do:[:sY|
-                y := sY - spc. self displayLineFromX:x0 y:y toX:x1 y:y.
-                y := y  + dY.  self displayLineFromX:x0 y:y toX:x1 y:y.
-            ].
+            self displayLineFromX:x0 y:y0 toX:x1 y:y0.
+            y := y0 + fontHeight - 1.
+          ^ self displayLineFromX:x0 y:y toX:x1 y:y.
         ]
     ] ifFalse:[
         hilightStyle == #motif ifTrue:[
-            dY := fontHeight - spc - 2.
             self paint:bgColor.
 
-            aList do:[:sY|
-                y := sY - spc + 1. self displayLineFromX:x0 y:y toX:x1 y:y.
-                y := sY + dY.      self displayLineFromX:x0 y:y toX:x1 y:y.
-            ]
+            y := y0 + 1.
+            self displayLineFromX:x0 y:y toX:x1 y:y.
+            y := y0 + fontHeight - 2.
+            self displayLineFromX:x0 y:y toX:x1 y:y.
         ]
     ].
 
     hilightLevel ~~ 0 ifTrue:[
         "/ draw edge
 
-        w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset.
-        x := margin - leftOffset.
-
-        aList do:[:sY|
-            self drawEdgesForX:x y:(sY - spc) width:w height:fontHeight level:hilightLevel.
-        ]
+        highlightMode == #line ifTrue:[
+            w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset.
+            x := margin - leftOffset.
+        ] ifFalse:[
+            w := x1 - x0.
+            x := x0.
+        ].
+        self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel.
     ]
 
 
 
+!
+
+redrawX:x y:y width:w height:h
+    "a region must be redrawn"
+
+    |savClip startLn sel
+     y0       "{ Class:SmallInteger }"
+     y1       "{ Class:SmallInteger }"
+     visStart "{ Class:SmallInteger }"
+     visEnd   "{ Class:SmallInteger }"
+     stopLn   "{ Class:SmallInteger }"
+     maxY     "{ Class:SmallInteger }"
+     maxX     "{ Class:SmallInteger }"
+     dltLine  "{ Class:SmallInteger }"
+     startY   "{ Class:SmallInteger }"|
+
+    shown ifFalse:[^ self].
+
+    visStart := self visibleLineOfY:(y + 1).
+    startLn  := self visibleLineToAbsoluteLine:visStart.
+
+    self paint:bgColor.
+    self fillRectangleX:x y:y width:w height:h.
+    startLn isNil ifTrue:[ ^ self ].
+
+    sel     := nil.
+    maxX    := x + w.
+    maxY    := y + h.
+    visEnd  := self visibleLineOfY:maxY.
+    startY  := self yOfVisibleLine:visStart.
+    dltLine := startLn - visStart.
+    stopLn  := dltLine + visEnd.
+    savClip := clipRect.
+
+    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
+
+    (highlightMode == #line and:[self hasSelection]) ifTrue:[
+        "/ redraw the background for all selected lines in the invalid range
+
+        self selectionDo:[:lnNr|
+            (lnNr between:startLn and:stopLn) ifTrue:[
+                sel isNil ifTrue:[
+                    sel := OrderedCollection new.
+                    self paint:hilightBgColor.
+                ].
+                sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)).
+                y1 := y0 + fontHeight min:maxY.
+                y0 := y0 max:y.
+                self fillRectangleX:x y:y0 width:w height:y1 - y0.
+            ]
+        ]
+    ].
+    self redrawLinesX:x y:startY toX:maxX start:startLn stop:stopLn.
+
+    "/ draw selection frames
+    sel notNil ifTrue:[
+        sel do:[:y0| self redrawSelFrameAtX:x y:y0 toX:maxX]
+    ].
+
+    self clippingRectangle:savClip.
 ! !
 
 !SelectionInTreeView methodsFor:'enumerating'!
@@ -1178,68 +1295,6 @@
 
 
 
-!
-
-redrawX:x y:y width:w height:h
-    "a region must be redrawn"
-
-    |savClip startLn sel
-     lnSpace  "{ Class:SmallInteger }"
-     y0       "{ Class:SmallInteger }"
-     y1       "{ Class:SmallInteger }"
-     visStart "{ Class:SmallInteger }"
-     visEnd   "{ Class:SmallInteger }"
-     stopLn   "{ Class:SmallInteger }"
-     maxY     "{ Class:SmallInteger }"
-     maxX     "{ Class:SmallInteger }"
-     dltLine  "{ Class:SmallInteger }"
-     startY   "{ Class:SmallInteger }"|
-
-    shown ifFalse:[^ self].
-
-    visStart := self visibleLineOfY:(y + 1).
-    startLn  := self visibleLineToAbsoluteLine:visStart.
-
-    self paint:bgColor.
-    self fillRectangleX:x y:y width:w height:h.
-    startLn isNil ifTrue:[ ^ self ].
-
-    sel     := nil.
-    maxX    := x + w.
-    maxY    := y + h.
-    lnSpace := lineSpacing // 2.
-    visEnd  := self visibleLineOfY:maxY.
-    startY  := self yOfVisibleLine:visStart.
-    dltLine := startLn - visStart.
-    stopLn  := dltLine + visEnd.
-    savClip := clipRect.
-
-    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
-
-    self hasSelection ifTrue:[
-        "/ redraw the background for all selected lines in the invalid range
-
-        self selectionDo:[:lnNr|
-            (lnNr between:startLn and:stopLn) ifTrue:[
-                sel isNil ifTrue:[
-                    sel := OrderedCollection new.
-                    self paint:hilightBgColor.
-                ].
-                sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)).
-                y0 := y0 - lnSpace.
-                y1 := y0 + fontHeight min:maxY.
-                y0 := y0 max:y.
-                self fillRectangleX:x y:y0 width:w height:y1 - y0.
-            ]
-        ]
-    ].
-
-    self redrawLinesX:x y:startY - lnSpace toX:maxX start:startLn stop:stopLn.
-
-    "/ draw selection frames
-    self redrawSelFrameForYs:sel fromX:x toX:maxX.
-
-    self clippingRectangle:savClip.
 ! !
 
 !SelectionInTreeView methodsFor:'initialization'!
@@ -1341,6 +1396,14 @@
     ]
 !
 
+initStyle
+    "setup viewStyle specifics"
+
+    super initStyle.
+    highlightMode := DefaultHilightMode ? #line.
+
+!
+
 initialize
     "setup instance attributes
     "
@@ -1360,7 +1423,7 @@
                                         "/ suppress garbage collection
 
     self model:nil.     "/ creates a default model.
-
+    highlightMode := #line.
 !
 
 realize
@@ -2000,5 +2063,5 @@
 !SelectionInTreeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelTreeV.st,v 1.59 1998-04-16 10:59:40 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/Attic/SelTreeV.st,v 1.60 1998-05-28 11:17:22 ca Exp $'
 ! !
--- a/SelectionInTreeView.st	Fri May 22 14:09:01 1998 +0200
+++ b/SelectionInTreeView.st	Thu May 28 13:17:22 1998 +0200
@@ -18,8 +18,8 @@
 		closeIndicator openIndicator showDirectoryIndicatorForRoot
 		imageOpened imageClosed imageItem discardMotionEvents
 		registeredImages supportsExpandAll buildInArray
-		drawVLinesFromLevel'
-	classVariableNames:''
+		drawVLinesFromLevel highlightMode'
+	classVariableNames:'DefaultHilightMode'
 	poolDictionaries:''
 	category:'Views-Text'
 !
@@ -124,6 +124,21 @@
 
 ! !
 
+!SelectionInTreeView class methodsFor:'defaults'!
+
+updateStyleCache
+    "extract values from the styleSheet and cache them in class variables"
+
+    <resource: #style (#'selection.highlightMode')>
+
+    DefaultHilightMode := StyleSheet at:'selection.highlightMode' default:#line.
+    "
+     self updateStyleCache
+    "
+
+
+! !
+
 !SelectionInTreeView class methodsFor:'resources'!
 
 closeIndicator
@@ -183,6 +198,34 @@
 
 !SelectionInTreeView methodsFor:'accessing'!
 
+highlightMode
+    "get the mode how to draw a selected line:
+        #line           draw whole line selected
+        #label          draw label selected
+    "
+    ^ highlightMode
+!
+
+highlightMode:aMode
+    "set the mode how to draw a selected line:
+        #line           draw whole line selected
+        #label          draw label selected
+    "
+    |mode|
+
+    (mode := aMode) == #label ifFalse:[
+        mode := #line
+    ].
+
+    mode ~~ highlightMode ifTrue:[
+        highlightMode := mode.
+
+        shown ifTrue:[
+            self invalidate
+        ]
+    ]
+!
+
 lineColor
     "returns user configured line color or nil
     "
@@ -579,27 +622,6 @@
 
 !SelectionInTreeView methodsFor:'drawing'!
 
-drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
-    "redraw a visible line range with clearing the background
-    "
-    |y0 y1 sz|
-
-    shown ifTrue:[
-        y0  := self yOfVisibleLine:startVisLineNr.
-        y0  := y0 - 1.
-        sz  := endVisLineNr - startVisLineNr + 1.
-        y1  := sz * fontHeight.
-
-    "/  clear rectangle line and set background color
-        self paint:bg.
-        self fillRectangleX:0 y:y0 width:width height:y1.
-
-        (y1 := self visibleLineToAbsoluteLine:startVisLineNr) notNil ifTrue:[
-            self redrawLinesX:0 y:y0 toX:width start:y1 stop:(y1 + sz)
-        ]
-    ]
-!
-
 drawLine:line atX:atX inVisible:visLineNr with:fg and:bg
     self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg
 
@@ -700,19 +722,30 @@
 
 
 
+!
+
+redrawVisibleLine:visLineNr
+    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
+!
+
+redrawVisibleLine:visLineNr from:startCol to:endCol
+    self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor
 ! !
 
 !SelectionInTreeView methodsFor:'drawing basics'!
 
-drawLabelIndex:anIndex atX:x y:yCenter
-    "draw text label at x and y centered
+drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
+    "redraw a visible line range with clearing the background
     "
-    |lbl y|
+    |y h|
 
-    (lbl := (listOfNodes at:anIndex) name) notNil ifTrue:[
-        y := yCenter + labelOffsetY.
-        self displayOpaqueString:lbl x:x y:y.
-    ]    
+    y := self yOfVisibleLine:startVisLineNr.
+    h := endVisLineNr - startVisLineNr + 1 * fontHeight.
+
+    y + h > height ifTrue:[
+        h := height - y
+    ].
+    self redrawX:0 y:y width:width height:h.
 !
 
 drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop
@@ -835,6 +868,50 @@
 
 !
 
+drawVisibleLineSelected:visLineNr with:fg and:bg
+    "redraw a single line as selected."
+    |y|
+
+    (self visibleLineToListLine:visLineNr) isNil ifTrue:[
+        ^ super drawVisibleLine:visLineNr with:fg and:bg
+    ].
+    self redrawX:0
+               y:(self yOfVisibleLine:visLineNr)
+           width:width
+          height:fontHeight
+!
+
+redrawLabelAt:x y:yTop index:anIndex
+    |isSelected y0 x0 x1 maxX w label i|
+
+    label       := (listOfNodes at:anIndex) name.
+    isSelected  := self isInSelection:anIndex.
+
+    highlightMode == #label ifTrue:[
+        x0 := x + 4.
+
+        isSelected ifTrue:[
+            w  := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8.
+            self paint:hilightBgColor.
+            self fillRectangleX:x y:yTop width:w height:fontHeight.
+        ]
+    ] ifFalse:[
+        x0 := x
+    ].
+
+    label notNil ifTrue:[
+        isSelected ifTrue:[self paint:hilightFgColor on:hilightBgColor]
+                  ifFalse:[self paint:fgColor on:bgColor].
+
+        self displayOpaqueString:label x:x0 y:yTop + (fontHeight // 2) + labelOffsetY.
+    ].
+
+    (isSelected and:[highlightMode == #label]) ifTrue:[
+        self redrawSelFrameAtX:x y:yTop toX:(x + w)
+    ].
+
+!
+
 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
     "redraw from line to line without clearing the background
     "
@@ -911,12 +988,7 @@
         ].
 
         showText ifTrue:[
-            (self isInSelection:anIndex) ifFalse:[
-                self paint:fgColor on:bgColor
-            ] ifTrue:[
-                self paint:hilightFgColor on:hilightBgColor
-            ].
-            self drawLabelIndex:anIndex atX:xText y:yCtr .
+            self redrawLabelAt:xText y:(yBot - fontHeight) index:anIndex
         ].
         (showIndc and:[node showIndicator]) ifTrue:[
             icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator].
@@ -926,63 +998,108 @@
     ]
 !
 
-redrawSelFrameForYs:aList fromX:x0 toX:x1
-    "redraw selection frames for each line starting at an absolute 
-     y derived from the argument a list.
+redrawSelFrameAtX:x0 y:y0 toX:x1
+    "redraw selection frame for a line
     "
-    | 
-     spc "{ Class: SmallInteger }"
-     dY  "{ Class: SmallInteger }"
+    |
      w   "{ Class: SmallInteger }"
      y   "{ Class: SmallInteger }" 
      x   "{ Class: SmallInteger }" 
     |
-    aList isNil ifTrue:[
-        ^ self
-    ].
-    strikeOut ifTrue:[
-        y := fontHeight // 2.
-        self paint:bgColor.
-        aList do:[:sY| self displayLineFromX:x0 y:(sY + y) toX:x1 y:(sY + y) ].
-        ^ self
-    ].
-    spc := lineSpacing // 2.
 
     hilightFrameColor notNil ifTrue:[
         hilightLevel == 0 ifTrue:[
-            dY := fontHeight - 1.
             self paint:hilightFrameColor.
-
-            aList do:[:sY|
-                y := sY - spc. self displayLineFromX:x0 y:y toX:x1 y:y.
-                y := y  + dY.  self displayLineFromX:x0 y:y toX:x1 y:y.
-            ].
+            self displayLineFromX:x0 y:y0 toX:x1 y:y0.
+            y := y0 + fontHeight - 1.
+          ^ self displayLineFromX:x0 y:y toX:x1 y:y.
         ]
     ] ifFalse:[
         hilightStyle == #motif ifTrue:[
-            dY := fontHeight - spc - 2.
             self paint:bgColor.
 
-            aList do:[:sY|
-                y := sY - spc + 1. self displayLineFromX:x0 y:y toX:x1 y:y.
-                y := sY + dY.      self displayLineFromX:x0 y:y toX:x1 y:y.
-            ]
+            y := y0 + 1.
+            self displayLineFromX:x0 y:y toX:x1 y:y.
+            y := y0 + fontHeight - 2.
+            self displayLineFromX:x0 y:y toX:x1 y:y.
         ]
     ].
 
     hilightLevel ~~ 0 ifTrue:[
         "/ draw edge
 
-        w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset.
-        x := margin - leftOffset.
-
-        aList do:[:sY|
-            self drawEdgesForX:x y:(sY - spc) width:w height:fontHeight level:hilightLevel.
-        ]
+        highlightMode == #line ifTrue:[
+            w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset.
+            x := margin - leftOffset.
+        ] ifFalse:[
+            w := x1 - x0.
+            x := x0.
+        ].
+        self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel.
     ]
 
 
 
+!
+
+redrawX:x y:y width:w height:h
+    "a region must be redrawn"
+
+    |savClip startLn sel
+     y0       "{ Class:SmallInteger }"
+     y1       "{ Class:SmallInteger }"
+     visStart "{ Class:SmallInteger }"
+     visEnd   "{ Class:SmallInteger }"
+     stopLn   "{ Class:SmallInteger }"
+     maxY     "{ Class:SmallInteger }"
+     maxX     "{ Class:SmallInteger }"
+     dltLine  "{ Class:SmallInteger }"
+     startY   "{ Class:SmallInteger }"|
+
+    shown ifFalse:[^ self].
+
+    visStart := self visibleLineOfY:(y + 1).
+    startLn  := self visibleLineToAbsoluteLine:visStart.
+
+    self paint:bgColor.
+    self fillRectangleX:x y:y width:w height:h.
+    startLn isNil ifTrue:[ ^ self ].
+
+    sel     := nil.
+    maxX    := x + w.
+    maxY    := y + h.
+    visEnd  := self visibleLineOfY:maxY.
+    startY  := self yOfVisibleLine:visStart.
+    dltLine := startLn - visStart.
+    stopLn  := dltLine + visEnd.
+    savClip := clipRect.
+
+    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
+
+    (highlightMode == #line and:[self hasSelection]) ifTrue:[
+        "/ redraw the background for all selected lines in the invalid range
+
+        self selectionDo:[:lnNr|
+            (lnNr between:startLn and:stopLn) ifTrue:[
+                sel isNil ifTrue:[
+                    sel := OrderedCollection new.
+                    self paint:hilightBgColor.
+                ].
+                sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)).
+                y1 := y0 + fontHeight min:maxY.
+                y0 := y0 max:y.
+                self fillRectangleX:x y:y0 width:w height:y1 - y0.
+            ]
+        ]
+    ].
+    self redrawLinesX:x y:startY toX:maxX start:startLn stop:stopLn.
+
+    "/ draw selection frames
+    sel notNil ifTrue:[
+        sel do:[:y0| self redrawSelFrameAtX:x y:y0 toX:maxX]
+    ].
+
+    self clippingRectangle:savClip.
 ! !
 
 !SelectionInTreeView methodsFor:'enumerating'!
@@ -1178,68 +1295,6 @@
 
 
 
-!
-
-redrawX:x y:y width:w height:h
-    "a region must be redrawn"
-
-    |savClip startLn sel
-     lnSpace  "{ Class:SmallInteger }"
-     y0       "{ Class:SmallInteger }"
-     y1       "{ Class:SmallInteger }"
-     visStart "{ Class:SmallInteger }"
-     visEnd   "{ Class:SmallInteger }"
-     stopLn   "{ Class:SmallInteger }"
-     maxY     "{ Class:SmallInteger }"
-     maxX     "{ Class:SmallInteger }"
-     dltLine  "{ Class:SmallInteger }"
-     startY   "{ Class:SmallInteger }"|
-
-    shown ifFalse:[^ self].
-
-    visStart := self visibleLineOfY:(y + 1).
-    startLn  := self visibleLineToAbsoluteLine:visStart.
-
-    self paint:bgColor.
-    self fillRectangleX:x y:y width:w height:h.
-    startLn isNil ifTrue:[ ^ self ].
-
-    sel     := nil.
-    maxX    := x + w.
-    maxY    := y + h.
-    lnSpace := lineSpacing // 2.
-    visEnd  := self visibleLineOfY:maxY.
-    startY  := self yOfVisibleLine:visStart.
-    dltLine := startLn - visStart.
-    stopLn  := dltLine + visEnd.
-    savClip := clipRect.
-
-    self clippingRectangle:(Rectangle left:x top:y width:w height:h).
-
-    self hasSelection ifTrue:[
-        "/ redraw the background for all selected lines in the invalid range
-
-        self selectionDo:[:lnNr|
-            (lnNr between:startLn and:stopLn) ifTrue:[
-                sel isNil ifTrue:[
-                    sel := OrderedCollection new.
-                    self paint:hilightBgColor.
-                ].
-                sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)).
-                y0 := y0 - lnSpace.
-                y1 := y0 + fontHeight min:maxY.
-                y0 := y0 max:y.
-                self fillRectangleX:x y:y0 width:w height:y1 - y0.
-            ]
-        ]
-    ].
-
-    self redrawLinesX:x y:startY - lnSpace toX:maxX start:startLn stop:stopLn.
-
-    "/ draw selection frames
-    self redrawSelFrameForYs:sel fromX:x toX:maxX.
-
-    self clippingRectangle:savClip.
 ! !
 
 !SelectionInTreeView methodsFor:'initialization'!
@@ -1341,6 +1396,14 @@
     ]
 !
 
+initStyle
+    "setup viewStyle specifics"
+
+    super initStyle.
+    highlightMode := DefaultHilightMode ? #line.
+
+!
+
 initialize
     "setup instance attributes
     "
@@ -1360,7 +1423,7 @@
                                         "/ suppress garbage collection
 
     self model:nil.     "/ creates a default model.
-
+    highlightMode := #line.
 !
 
 realize
@@ -2000,5 +2063,5 @@
 !SelectionInTreeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.59 1998-04-16 10:59:40 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.60 1998-05-28 11:17:22 ca Exp $'
 ! !