--- a/SelectionInTreeView.st Thu Jul 31 13:49:24 1997 +0200
+++ b/SelectionInTreeView.st Fri Aug 01 10:52:54 1997 +0200
@@ -12,8 +12,9 @@
SelectionInListView subclass:#SelectionInTreeView
- instanceVariableNames:'figuresWidth leftIndent figuresWidthDiv2 figuresInset showLines
- listOfNodes dblClickEvt imageOpened imageClosed imageItem'
+ instanceVariableNames:'doubleClickSelectionBlock figuresWidth leftIndent
+ figuresWidthDiv2 figuresInset showLines listOfNodes dblClickEvt
+ imageOpened imageClosed imageItem'
classVariableNames:'ImageOpened ImageClosed ImageItem'
poolDictionaries:''
category:'Views-Text'
@@ -209,6 +210,26 @@
!SelectionInTreeView methodsFor:'accessing-behavior'!
+doubleClickSelectionBlock
+ "get the conditionBlock; this block is evaluated before a doubleClick action
+ on a node containg children will be performed. In case of returning false, the
+ doubleClick will not be handled.
+ "
+ ^ doubleClickSelectionBlock
+
+
+!
+
+doubleClickSelectionBlock:aBlock
+ "set the conditionBlock; this block is evaluated before a doubleClick action
+ on a node containg children will be performed. In case of returning false, the
+ doubleClick will not be handled.
+ "
+ doubleClickSelectionBlock := aBlock
+
+
+!
+
showLines
"returns true if lines are shown
"
@@ -356,39 +377,20 @@
images again and again later"
super fetchDeviceResources.
-
- figuresInset := self class figuresInset.
- imageOpened := (self class imageOpened) onDevice:device.
- imageClosed := (self class imageClosed) onDevice:device.
- imageItem := (self class imageItem) onDevice:device.
+ self refetchDeviceResources
!
-getFontParameters
- "get some info of the used font and figures. They are cached since we use them
- often ..
- "
- |extent|
-
- super getFontParameters.
-
- imageClosed isNil ifTrue:[
- self fetchDeviceResources
- ].
- extent := self getMaxFiguresExtent.
-
- extent y > fontHeight ifTrue:[
- fontHeight := extent y
- ].
- figuresWidth := extent x.
- leftIndent := figuresInset + figuresWidth.
- figuresWidthDiv2 := figuresWidth // 2.
-!
-
-getMaxFiguresExtent
- "returns maximum extent of the figures used
+fetchImageResources
+ "initialize heavily used device resources - to avoid rendering
+ images again and again later; returns maximum extent of the images used.
+ Could be redefined by subclass
"
|y x t|
+ imageOpened := (self class imageOpened) onDevice:device.
+ imageClosed := (self class imageClosed) onDevice:device.
+ imageItem := (self class imageItem) onDevice:device.
+
y := imageClosed heightOn:self.
x := imageClosed widthOn:self.
@@ -398,6 +400,7 @@
(t := imageItem widthOn:self) > x ifTrue:[x := t].
^ x @ y
+
!
initialize
@@ -406,6 +409,27 @@
super initialize.
showLines := true.
dblClickEvt := false.
+ figuresWidth := 18. "/ default: will change during startup
+ figuresInset := 2. "/ default: will change during startup
+ leftIndent := figuresWidth + figuresInset. "/ default: will change during startup
+ figuresWidthDiv2 := figuresWidth // 2. "/ default: will change during startup
+!
+
+refetchDeviceResources
+ "reinitialize heavily used device resources - to avoid rendering
+ images again and again later
+ "
+ |extent|
+
+ figuresInset := self class figuresInset.
+ extent := self fetchImageResources.
+
+ extent y > fontHeight ifTrue:[
+ fontHeight := extent y
+ ].
+ figuresWidth := extent x.
+ leftIndent := figuresInset + figuresWidth.
+ figuresWidthDiv2 := figuresWidth // 2.
! !
@@ -558,6 +582,11 @@
node hasChildren ifTrue:[
"/ node is a children container
+ doubleClickSelectionBlock notNil ifTrue:[
+ (doubleClickSelectionBlock value:(self selectedIndex)) ifFalse:[
+ ^ self
+ ]
+ ].
node numberOfChildren == 0 ifTrue:[
"/ but without any children, thus redraw
"/ only selected line; figure may changed
@@ -578,6 +607,7 @@
].
super doubleClicked.
]
+
!
selectNode:aNode
@@ -614,5 +644,5 @@
!SelectionInTreeView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.7 1997-07-23 07:43:16 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.8 1997-08-01 08:52:54 ca Exp $'
! !