--- a/SelectionInTreeView.st Mon Jan 26 19:59:54 1998 +0100
+++ b/SelectionInTreeView.st Tue Jan 27 10:50:54 1998 +0100
@@ -13,8 +13,8 @@
SelectionInListView subclass:#SelectionInTreeView
instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth
- showLines listOfNodes imageInset textInset labelOffsetY
- openIndicator computeResources closeIndicator showRoot
+ showLines listOfNodes imageInset textInset labelOffsetY lineMask
+ lineColor openIndicator computeResources closeIndicator showRoot
extentOpenIndicator extentCloseIndicator showDirectoryIndicator
showDirectoryIndicatorForRoot indicatorExtentDiv2 imageOpened
imageClosed imageItem discardMotionEvents'
@@ -87,7 +87,7 @@
sel := SelectionInTreeView new.
sel root:(TreeItem newAsTreeFromSmalltalkClass:nil).
sel action:[:nr | Transcript show:'selected:'; showCR:nr].
-
+ sel lineColor:(Color red).
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
top open.
[exEnd]
@@ -199,6 +199,30 @@
!SelectionInTreeView methodsFor:'accessing'!
+lineColor
+ "returns user configured line color or nil
+ "
+ ^ lineColor
+
+!
+
+lineColor:aColor
+ "returns user configured line color or nil
+ "
+ |col|
+
+ col := aColor = fgColor ifTrue:[nil] ifFalse:[aColor].
+
+ col = lineColor ifFalse:[
+ lineColor := col.
+
+ shown ifTrue:[
+ lineColor notNil ifTrue:[lineColor := lineColor on:device].
+ self invalidate
+ ]
+ ]
+!
+
nodeAtIndex:anIndex
"returns node at an index or nil
"
@@ -484,6 +508,7 @@
index isNil ifTrue:[^ self].
figWidthDiv2 := imageWidth // 2.
+ figWidthDiv2 odd ifTrue:[figWidthDiv2 := figWidthDiv2 + 1].
yCtr := yTop - (fontHeight // 2).
self paint:fg on:bg.
@@ -502,6 +527,12 @@
].
showLines ifTrue:[
+ (lineColor isNil or:[(self isInSelection:index)]) ifFalse:[
+ self paint:lineColor.
+ ].
+ self mask:lineMask.
+ self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)).
+
(node isCollapsable and:[node numberOfChildren ~~ 0]) ifTrue:[
x := xFig + figWidthDiv2.
self displayLineFromX:x y:yCtr toX:x y:yBot
@@ -523,7 +554,9 @@
x := (self xOfFigureLevel:lv) + figWidthDiv2.
self displayLineFromX:x y:yTop - 1 toX:x y:yBot.
]
- ]
+ ].
+ self mask:nil.
+ self paint:fg.
].
"/ draw image
@@ -700,6 +733,15 @@
!SelectionInTreeView methodsFor:'initialization'!
+create
+ super create.
+ lineMask := lineMask on:device.
+
+ lineColor notNil ifTrue:[
+ lineColor := lineColor on:device
+ ]
+!
+
destroy
"remove dependencies
"
@@ -756,6 +798,9 @@
lineHeight > fontHeight ifTrue:[
fontHeight := lineHeight
].
+ fontHeight odd ifTrue:[
+ fontHeight := fontHeight + 1
+ ]
!
initialize
@@ -769,6 +814,7 @@
showDirectoryIndicator := false.
showDirectoryIndicatorForRoot := true.
discardMotionEvents := false.
+ lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
textInset := 4.
imageInset := 0. "/ set during indication enabled
@@ -795,6 +841,10 @@
extent y >= fontHeight ifTrue:[
fontHeight := 1 + extent y.
].
+ fontHeight odd ifTrue:[
+ fontHeight := fontHeight + 1
+ ].
+
imageWidth := extent x.
self recomputeDirectoryIndicator.
self computeNumberOfLinesShown.
@@ -1355,5 +1405,5 @@
!SelectionInTreeView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.33 1998-01-15 18:03:54 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.34 1998-01-27 09:50:54 ca Exp $'
! !