--- a/SelectionInTreeView.st Fri Apr 03 10:39:40 1998 +0200
+++ b/SelectionInTreeView.st Fri Apr 03 10:41:09 1998 +0200
@@ -17,7 +17,7 @@
lineColor computeResources showRoot showDirectoryIndicator
closeIndicator openIndicator showDirectoryIndicatorForRoot
imageOpened imageClosed imageItem discardMotionEvents
- registeredImages'
+ registeredImages supportsExpandAll'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
@@ -314,6 +314,15 @@
].
!
+supportsExpandAll
+ ^ supportsExpandAll
+!
+
+supportsExpandAll:aBool
+
+ supportsExpandAll := aBool
+!
+
validateDoubleClickBlock
"set the conditionBlock; this block is evaluated before a doubleClick action
on a node will be performed. In case of returning false, the doubleClick will
@@ -805,7 +814,7 @@
buttonPress:button x:x y:y
"check for indicator
"
- |expand node lineNr|
+ |expand node lineNr oldSize isExpandable|
lineNr := self indicatiorLineForButton:button atX:x y:y.
@@ -814,11 +823,10 @@
].
node := listOfNodes at:lineNr.
-"/ ( validateDoubleClickBlock isNil
-"/ or:[(validateDoubleClickBlock value:node) ~~ false]
-"/ ) ifFalse:[
-"/ ^ super buttonPress:button x:x y:y
-"/ ].
+ node hasChildren ifFalse:[ "/ no children exists
+ ^ super buttonPress:button x:x y:y
+ ].
+
discardMotionEvents := true.
dragIsActive := false.
clickPosition := nil.
@@ -830,7 +838,48 @@
self selection:nil
]
].
- self nodeAt:lineNr expand:(node isExpandable).
+ isExpandable := node isExpandable.
+
+ self isCtrlMetaAltOrShiftPressed ifFalse:[
+ ^ self nodeAt:lineNr expand:isExpandable
+ ].
+
+ isExpandable ifTrue:[
+ supportsExpandAll ifFalse:[
+ ^ self nodeAt:lineNr expand:isExpandable
+ ].
+ node expandAll
+ ] ifFalse:[
+ (node hasExpandedChildren) ifTrue:[
+ node hasChildrenWithSubChildren ifFalse:[
+ ^ self nodeAt:lineNr expand:isExpandable
+ ].
+ node collapseAllChildren
+ ] ifFalse:[
+ supportsExpandAll ifFalse:[
+ ^ self nodeAt:lineNr expand:isExpandable
+ ].
+ node expandAllChildren
+ ]
+ ].
+
+ node children isEmpty ifTrue:[
+ "/ no children; redraw selected line (image might change)
+ self redrawLine:lineNr.
+ ] ifFalse:[
+ "/ with children; update list and redraw to end.
+ oldSize := list size.
+ model removeDependent:self.
+ model recomputeList.
+ model addDependent:self.
+ list := self listFromModel.
+
+ oldSize ~~ list size ifTrue:[
+ self redrawFromLine:lineNr.
+ self contentsChanged.
+ ]
+ ]
+
!
@@ -865,25 +914,21 @@
indicatiorLineForButton:aButton atX:x y:y
"returns linenumber assigned to indicator at x/y or 0
"
- |sensor nr x0 node|
+ |nr x0 node|
( enabled
and:[showDirectoryIndicator
and:[aButton == 1 or:[aButton == #select]]]
) ifTrue:[
- sensor := self sensor.
-
- (sensor ctrlDown or:[sensor shiftDown]) ifFalse:[
- nr := self visibleLineToListLine:(self visibleLineOfY:y).
+ nr := self visibleLineToListLine:(self visibleLineOfY:y).
- nr notNil ifTrue:[
- node := listOfNodes at:nr.
- node hasChildren ifTrue:[
- x0 := self xOfFigureLevel:(node level - 1).
+ nr notNil ifTrue:[
+ node := listOfNodes at:nr.
+ node hasChildren ifTrue:[
+ x0 := self xOfFigureLevel:(node level - 1).
- (x > x0 and:[(x0 + imageWidth) > x and:[node children notEmpty]]) ifTrue:[
- ^ nr
- ]
+ (x > x0 and:[(x0 + imageWidth) > x and:[node children notEmpty]]) ifTrue:[
+ ^ nr
]
]
]
@@ -892,6 +937,21 @@
!
+isCtrlMetaAltOrShiftPressed
+ "returns true if CTRL, META, ALT or SHIFT is pressed
+ "
+ |sensor|
+
+ (sensor := self sensor) notNil ifTrue:[
+ ^ ( sensor ctrlDown
+ or:[sensor altDown
+ or:[sensor shiftDown
+ or:[sensor metaDown]]]
+ )
+ ].
+ ^ false
+!
+
key:key select:index x:x y:y
"select an entry by a keyboard action. This is treated like a doubleClick
on that entry.
@@ -1111,6 +1171,7 @@
"setup instance attributes
"
super initialize.
+ supportsExpandAll := true.
self bitGravity:#NorthWest.
showRoot := showDirectoryIndicatorForRoot := showLines := computeResources := true.
showDirectoryIndicator := discardMotionEvents := false.
@@ -1325,12 +1386,11 @@
node hasChildren ifFalse:[ "/ no children exists
^ self
].
-
node isExpandable ifTrue:[
- doExpand ifFalse:[^ self]. "/ already collapsed
+ doExpand ifFalse:[^ self]. "/ already expanded
node expand
] ifFalse:[
- doExpand ifTrue:[^ self]. "/ already expanded
+ doExpand ifTrue:[^ self]. "/ already collapsed
node collapse
].
@@ -1347,6 +1407,7 @@
self contentsChanged.
]
+
! !
!SelectionInTreeView methodsFor:'private - drag and drop'!
@@ -1750,5 +1811,5 @@
!SelectionInTreeView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.51 1998-03-30 12:07:50 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.52 1998-04-03 08:41:09 ca Exp $'
! !