--- a/SelectionInTreeView.st Sat Feb 04 22:21:59 2017 +0100
+++ b/SelectionInTreeView.st Sat Feb 04 22:39:53 2017 +0100
@@ -205,16 +205,18 @@
highlightMode
"get the mode how to draw a selected line:
#line draw whole line selected
- #label draw label selected
- "
+ #label draw label selected"
+
^ highlightMode
+
+ "Modified (comment): / 04-02-2017 / 22:23:07 / cg"
!
highlightMode:aMode
"set the mode how to draw a selected line:
#line draw whole line selected
- #label draw label selected
- "
+ #label draw label selected"
+
|mode|
(mode := aMode) == #label ifFalse:[
@@ -225,19 +227,20 @@
highlightMode := mode.
self invalidate
]
+
+ "Modified (comment): / 04-02-2017 / 22:23:12 / cg"
!
itemClass
- "returns current itemClass used
- "
+ "returns current itemClass used"
+
^ itemClass
-
+ "Modified (comment): / 04-02-2017 / 22:22:56 / cg"
!
itemClass:anItemClass
- "set itemClass to be used
- "
+ "set itemClass to be used"
(anItemClass notNil and:[anItemClass ~~ itemClass]) ifTrue:[
itemClass := anItemClass.
@@ -245,18 +248,20 @@
self refetchDeviceResources.
].
+ "Modified (comment): / 04-02-2017 / 22:23:01 / cg"
!
lineColor
- "returns user configured line color or nil
- "
+ "returns user configured line color or nil"
+
^ lineColor
+ "Modified (comment): / 04-02-2017 / 22:23:18 / cg"
!
lineColor:aColor
- "returns user configured line color or nil
- "
+ "returns user configured line color or nil"
+
|col|
col := aColor = fgColor ifTrue:[nil] ifFalse:[aColor].
@@ -266,39 +271,49 @@
lineColor notNil ifTrue:[lineColor := lineColor onDevice:device].
self invalidate
]
+
+ "Modified (comment): / 04-02-2017 / 22:23:23 / cg"
!
nodeAtIndex:anIndex
- "returns node at an index or nil
- "
+ "returns node at an index or nil"
+
(anIndex notNil and:[anIndex between:1 and:listOfNodes size]) ifTrue:[
^ listOfNodes at:anIndex
].
- ^ nil
+ ^ nil
+
+ "Modified (comment): / 04-02-2017 / 22:23:30 / cg"
!
root
- "gets the root of the model; the first item into list.
- "
+ "gets the root of the model; the first item into list."
+
^ self nodeAtIndex:1
+
+ "Modified (comment): / 04-02-2017 / 22:23:36 / cg"
!
root:aRoot
- "sets the root of the model; the first item into list.
- "
+ "sets the root of the model; the first item into list."
+
aRoot notNil ifTrue:[aRoot expand].
model root:aRoot
+
+ "Modified (comment): / 04-02-2017 / 22:23:40 / cg"
!
textInset
- "get the left inset of the text label
- "
+ "get the left inset of the text label"
+
^ textInset
+
+ "Modified (comment): / 04-02-2017 / 22:23:44 / cg"
!
textInset:anInset
- "set the left inset of the text label
- "
+ "set the left inset of the text label"
+
anInset ~~ textInset ifTrue:[
anInset >= 0 ifTrue:[
textInset := anInset.
@@ -307,29 +322,35 @@
self error
]
].
+
+ "Modified (comment): / 04-02-2017 / 22:23:48 / cg"
! !
!SelectionInTreeView methodsFor:'accessing-behavior'!
drawVLinesFromLevel
"returns the level vertical lines are drawn from;
- starting at 1 up to n
- "
+ starting at 1 up to n"
+
^ drawVLinesFromLevel
+
+ "Modified (comment): / 04-02-2017 / 22:23:55 / cg"
!
drawVLinesFromLevel:aLevel
"set the level vertical lines are drawn from;
- starting at 1 up to n
- "
- |lv|
-
- lv := (aLevel ? 1) max:1.
-
- lv ~~ drawVLinesFromLevel ifTrue:[
- drawVLinesFromLevel := lv.
+ starting at 1 up to n"
+
+ |lvl|
+
+ lvl := (aLevel ? 1) max:1.
+
+ lvl ~~ drawVLinesFromLevel ifTrue:[
+ drawVLinesFromLevel := lvl.
self invalidate
]
+
+ "Modified (format): / 04-02-2017 / 22:24:09 / cg"
!
supportsExpandAll
@@ -344,54 +365,56 @@
validateDoubleClickBlock
"return the conditionBlock; this block is evaluated before a doubleClick action
on a node will be performed. In case of returning false, the doubleClick will
- not be handled.
- "
+ not be handled."
+
^ validateDoubleClickBlock
-
+ "Modified (comment): / 04-02-2017 / 22:24:18 / cg"
!
validateDoubleClickBlock:aOneArgBlock
"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
- not be handled.
- "
+ not be handled."
+
validateDoubleClickBlock := aOneArgBlock
-
+ "Modified (comment): / 04-02-2017 / 22:24:25 / cg"
!
validateExpandabilityBlock
"return the expand conditionBlock; this block is evaluated before an expand due to
a doubleClick on a node will be performed. In case of returning false,
- the node will not be expanded.
- "
+ the node will not be expanded."
+
^ validateExpandabilityBlock
-
+ "Modified (comment): / 04-02-2017 / 22:24:30 / cg"
!
validateExpandabilityBlock:aOneArgBlock
"set the expand conditionBlock; this block is evaluated before an expand due to
a doubleClick on a node will be performed. In case of returning false,
- the node will not be expanded.
- "
+ the node will not be expanded."
+
validateExpandabilityBlock := aOneArgBlock
-
+ "Modified (comment): / 04-02-2017 / 22:24:36 / cg"
! !
!SelectionInTreeView methodsFor:'accessing-channels'!
rootHolder
- "get the holder which keeps the hierarchical list entry or nil
- "
+ "get the holder which keeps the hierarchical list entry or nil"
+
^ rootHolder
+
+ "Modified (comment): / 04-02-2017 / 22:24:41 / cg"
!
rootHolder:aValueHolder
- "set the holder which keeps the hierarchical list entry or nil
- "
+ "set the holder which keeps the hierarchical list entry or nil"
+
rootHolder notNil ifTrue:[
rootHolder removeDependent:self
].
@@ -400,18 +423,21 @@
rootHolder addDependent:self.
self rootFromModel.
].
+
+ "Modified (comment): / 04-02-2017 / 22:24:47 / cg"
!
selectionHolder
- "get the holder which keeps a list of selected items or nil
- "
+ "get the holder which keeps a list of selected items or nil"
+
^ selectionHolder
+ "Modified (comment): / 04-02-2017 / 22:24:51 / cg"
!
selectionHolder:aHolder
- "set the holder which keeps a list of selected items or nil
- "
+ "set the holder which keeps a list of selected items or nil"
+
selectionHolder notNil ifTrue:[
selectionHolder removeDependent:self
].
@@ -421,10 +447,29 @@
self selectionFromModel
].
+ "Modified (comment): / 04-02-2017 / 22:24:57 / cg"
! !
!SelectionInTreeView methodsFor:'accessing-images'!
+closeIndicator
+ "return the bitmap image shown for expandable tree items (a little right arrow)
+ (initialized to a right arrow)"
+
+ ^ closeIndicator
+
+ "Created: / 04-02-2017 / 21:15:24 / cg"
+!
+
+closeIndicator:aBitmapIcon
+ "set the bitmap image shown for expandable tree items
+ (defaults to a right arrow)"
+
+ closeIndicator := aBitmapIcon
+
+ "Created: / 04-02-2017 / 21:15:39 / cg"
+!
+
imageClosed
"return the value of the instance variable 'imageClosed'.
That's the (default) bitmap image shown for closed folders
@@ -435,6 +480,17 @@
"Created: 3.7.1997 / 12:34:31 / cg"
!
+imageClosed:anIconImage
+ "set the instance variable 'imageClosed'.
+ That's the (default) bitmap image shown for closed folders
+ (if nil, a class-specific open file-directory bitmap will be used).
+ Must be set early (before opening the view)"
+
+ imageClosed := anIconImage.
+
+ "Created: / 04-02-2017 / 20:34:01 / cg"
+!
+
imageItem
"return the value of the instance variable 'imageItem'.
That's the (default) bitmap image shown for regular items
@@ -445,6 +501,17 @@
"Created: 3.7.1997 / 12:34:34 / cg"
!
+imageItem:anIconImage
+ "set the instance variable 'imageItem'.
+ That's the (default) bitmap image shown for non-folders
+ (if nil, a class-specific file bitmap will be used).
+ Must be set early (before opening the view)"
+
+ imageItem := anIconImage.
+
+ "Created: / 04-02-2017 / 20:34:33 / cg"
+!
+
imageOnMyDevice:anImage
"associate image to device and returns the new image."
@@ -462,88 +529,135 @@
^ imageOpened
"Created: 3.7.1997 / 12:34:28 / cg"
+!
+
+imageOpened:anIconImage
+ "set the instance variable 'imageOpened'.
+ That's the (default) bitmap image shown for opened folders
+ (if nil, a class-specific open file-directory bitmap will be used).
+ Must be set early (before opening the view)"
+
+ imageOpened := anIconImage.
+
+ "Created: / 04-02-2017 / 20:33:39 / cg"
+!
+
+openIndicator
+ "return the bitmap image shown for expanded tree items (a little down arrow)
+ (initialized to a down arrow)"
+
+ ^ openIndicator
+
+ "Created: / 04-02-2017 / 21:15:06 / cg"
+!
+
+openIndicator:aBitmapIcon
+ "set the bitmap image shown for expanded tree items
+ (defaults to a down arrow)"
+
+ openIndicator := aBitmapIcon
+
+ "Created: / 04-02-2017 / 21:16:01 / cg"
! !
!SelectionInTreeView methodsFor:'accessing-look'!
showDirectoryIndicator
- "returns true if directories has an open/closed indicator
- "
- ^ showDirectoryIndicator
+ "returns true if items with children have an open/closed indicator"
+
+ ^ showDirectoryIndicator
+
+ "Modified (comment): / 04-02-2017 / 22:22:30 / cg"
!
-showDirectoryIndicator:aState
- "set or clear open/closed indicator for directories
- "
- "show or hide lines
- "
- aState ~~ showDirectoryIndicator ifTrue:[
- showDirectoryIndicator := aState.
+showDirectoryIndicator:aBoolean
+ "show or hide open/closed indicators for items with children"
+
+ aBoolean ~~ showDirectoryIndicator ifTrue:[
+ showDirectoryIndicator := aBoolean.
self recomputeDirectoryIndicator.
self invalidate
].
+
+ "Modified (comment): / 04-02-2017 / 21:27:54 / cg"
!
showDirectoryIndicatorForRoot
- "returns true if root directory has an open/closed indicator if
- the common showDirectoryIndicator is enabled
- "
+ "returns true if the root item has an open/closed indicator
+ (showing requires that the general showDirectoryIndicator is also enabled)"
+
^ showDirectoryIndicatorForRoot
+
+ "Modified (comment): / 04-02-2017 / 21:29:29 / cg"
!
-showDirectoryIndicatorForRoot:aState
- "true if root directory has an open/closed indicator if
- the common showDirectoryIndicator is enabled
- "
- aState ~~ showDirectoryIndicatorForRoot ifTrue:[
- showDirectoryIndicatorForRoot := aState.
+showDirectoryIndicatorForRoot:aBoolean
+ "show/hide the root item's open/closed indicator
+ (showing requires that the the common showDirectoryIndicator is also enabled)"
+
+ aBoolean ~~ showDirectoryIndicatorForRoot ifTrue:[
+ showDirectoryIndicatorForRoot := aBoolean.
self recomputeDirectoryIndicator.
self invalidate
].
+
+ "Modified (format): / 04-02-2017 / 21:34:31 / cg"
!
showLines
- "returns true if lines are shown
- "
- ^ showLines
+ "returns true if lines are shown"
+
+ ^ showLines
+
+ "Modified (comment): / 04-02-2017 / 21:29:49 / cg"
!
-showLines:aState
- "show or hide lines
- "
- aState ~~ showLines ifTrue:[
- showLines := aState.
+showLines:aBoolean
+ "show or hide lines"
+
+ aBoolean ~~ showLines ifTrue:[
+ showLines := aBoolean.
self invalidate
].
+
+ "Modified (format): / 04-02-2017 / 21:34:35 / cg"
!
showLinesForRoot
- "returns true if root-lines are shown
- "
- ^ showLinesForRoot
+ "returns true if root-lines are shown"
+
+ ^ showLinesForRoot
+
+ "Modified (format): / 04-02-2017 / 21:30:03 / cg"
!
-showLinesForRoot:aState
- "show or hide lines for root(s)
- "
- aState ~~ showLinesForRoot ifTrue:[
- showLinesForRoot := aState.
+showLinesForRoot:aBoolean
+ "show or hide lines for root(s)"
+
+ aBoolean ~~ showLinesForRoot ifTrue:[
+ showLinesForRoot := aBoolean.
self invalidate
].
+
+ "Modified (format): / 04-02-2017 / 21:30:43 / cg"
!
showRoot
- "list with or without root
- "
- ^ showRoot
+ "show or hide the root item?"
+
+ ^ showRoot
+
+ "Modified (format): / 04-02-2017 / 22:22:40 / cg"
!
-showRoot:aState
- "list with or without root
- "
- showRoot ~~ aState ifTrue:[
- model showRoot:(showRoot := aState).
+showRoot:aBoolean
+ "show or hide the root item"
+
+ showRoot ~~ aBoolean ifTrue:[
+ model showRoot:(showRoot := aBoolean).
].
+
+ "Modified (format): / 04-02-2017 / 21:30:38 / cg"
! !
!SelectionInTreeView methodsFor:'change & update'!
@@ -637,8 +751,8 @@
!
update:something with:aParameter from:aModel
- "one of my models changed its value
- "
+ "one of my models changed its value"
+
|idx|
aModel == rootHolder ifTrue:[
@@ -674,6 +788,7 @@
].
super update:something with:aParameter from:aModel.
+ "Modified (comment): / 04-02-2017 / 22:25:06 / cg"
! !
!SelectionInTreeView methodsFor:'drawing'!
@@ -732,8 +847,8 @@
!
redrawIndicatorLine:aLineNr
- "redraw the directory indicator for a line
- "
+ "redraw the directory indicator for a line"
+
|node ext img visLn
x "{ Class:SmallInteger }"
y "{ Class:SmallInteger }"
@@ -770,6 +885,8 @@
self displayForm:img x:x y:(y - ext y)
].
].
+
+ "Modified (comment): / 04-02-2017 / 22:25:15 / cg"
!
redrawVisibleLine:visLineNr
@@ -783,22 +900,24 @@
!SelectionInTreeView methodsFor:'drawing basics'!
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
- "redraw a visible line range with clearing the background
- "
+ "redraw a visible line range with clearing the background"
+
|y h|
y := self yOfVisibleLine:startVisLineNr.
- h := endVisLineNr - startVisLineNr + 1 * fontHeight.
+ h := (endVisLineNr - startVisLineNr + 1) * fontHeight.
y + h > height ifTrue:[
h := height - y
].
self redrawX:0 y:y width:width height:h.
+
+ "Modified (format): / 04-02-2017 / 22:25:33 / cg"
!
drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop
- "redraw from line to line without clearing the background
- "
+ "redraw from line to line without clearing the background"
+
|node prevNode parent p1 p2 showVLines showHLine lv nxtPrnt
showRootNot isFirst
@@ -822,6 +941,7 @@
limitLvI "{ Class:SmallInteger }"
limitLvX "{ Class:SmallInteger }"
xIcon
+ levelArray
|
yBot := y0.
@@ -833,7 +953,7 @@
parent := 4711. "/ to force a recompute
prevNode := 4711. "/ to force a recomputation of the level
- gc maskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)).
+ gc maskOrigin:((self viewOrigin + (0 @ 1)) \\ (lineMask extent)).
gc paint:lineColor on:bgColor.
gc mask:lineMask.
begHLnY := y0.
@@ -842,7 +962,8 @@
limitLvI := drawVLinesFromLevel + 1.
limitLvX := limitLvI * widthLvl + offsHLnX.
- buildInArray atAllPut:0.
+ levelArray := Array new:50 withAll:0.
+ "/ buildInArray atAllPut:0.
start == 1 ifTrue:[
begHLnY := yCtr + fontHeight.
@@ -894,7 +1015,7 @@
gc displayLineFromX:x y:yTop toX:x y:yBot
]
] ifFalse:[
- buildInArray at:lv put:yBot
+ levelArray at:lv put:yBot
].
].
lv := lv - 1.
@@ -912,12 +1033,15 @@
y := (start ~~ 1) ifTrue:[y0] ifFalse:[y0 + (fontHeight // 2)].
limitLvI to:startLvI do:[:i|
- (yBot := buildInArray at:i) ~~ 0 ifTrue:[
+ (yBot := levelArray at:i) ~~ 0 ifTrue:[
gc displayLineFromX:x y:y toX:x y:yBot
].
x := x + widthLvl.
].
gc mask:nil.
+
+ "Modified: / 04-02-2017 / 21:06:20 / cg"
+ "Modified (format): / 04-02-2017 / 22:25:54 / cg"
!
drawVisibleLineSelected:visLineNr with:fg and:bg
@@ -1022,8 +1146,8 @@
!
redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop
- "redraw from line to line without clearing the background
- "
+ "redraw from line to line without clearing the background"
+
|node prevNode parent icon showIndc showIcon showText nxtPrnt
end "{ Class:SmallInteger }"
@@ -1108,12 +1232,13 @@
prevNode := node.
]
- "Modified: / 22.8.1998 / 12:56:50 / cg"
+ "Modified: / 22-08-1998 / 12:56:50 / cg"
+ "Modified (comment): / 04-02-2017 / 22:26:07 / cg"
!
redrawSelFrameAtX:x0 y:y0 toX:x1
- "redraw selection frame for a line
- "
+ "redraw selection frame for a line"
+
|
w "{ Class: SmallInteger }"
y "{ Class: SmallInteger }"
@@ -1159,6 +1284,8 @@
].
self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel.
]
+
+ "Modified (comment): / 04-02-2017 / 22:26:11 / cg"
!
redrawX:x y:y width:w height:h
@@ -1226,15 +1353,19 @@
detectNode:aOneArgBlock
"evaluate the argument, aBlock for each node in the list until
the block returns true; in this case return the node which caused
- the true evaluation. If none node is detected, nil is returned.
- "
- ^ listOfNodes detect:aOneArgBlock ifNone:nil
+ the true evaluation. If none node is detected, nil is returned."
+
+ ^ listOfNodes detect:aOneArgBlock ifNone:nil
+
+ "Modified (comment): / 04-02-2017 / 22:26:21 / cg"
!
selectedNodesDo:aOneArgBlock
- "evaluate the block on each node selected
- "
+ "evaluate the block on each node selected"
+
self selectionDo:[:i| aOneArgBlock value:(listOfNodes at:i) ]
+
+ "Modified (comment): / 04-02-2017 / 22:26:27 / cg"
! !
!SelectionInTreeView methodsFor:'event handling'!
@@ -1314,8 +1445,8 @@
doubleClicked
"handle a double click; collapse or expand selected entry
- in case of having children
- "
+ in case of having children"
+
|node |
(node := self selectedNode) notNil ifTrue:[
@@ -1331,11 +1462,12 @@
]
]
+ "Modified (comment): / 04-02-2017 / 22:27:09 / cg"
!
handleSelectButtonAtX:x y:y
- "handle a select button click
- "
+ "handle a select button click"
+
|node lineNr sensor isExpd|
lineNr := self indicatiorLineForButton:#select atX:x y:y.
@@ -1368,11 +1500,13 @@
isExpd ifTrue:[model doExpand:node]
ifFalse:[model doCollapse:node].
].
+
+ "Modified (comment): / 04-02-2017 / 22:27:14 / cg"
!
indicatiorLineForButton:aButton atX:x y:y
- "returns linenumber assigned to indicator at x/y or 0
- "
+ "returns linenumber assigned to indicator at x/y or 0"
+
|nr x0 node|
( enabled
@@ -1393,6 +1527,8 @@
]
].
^ 0
+
+ "Modified (comment): / 04-02-2017 / 22:27:18 / cg"
!
isCtrlMetaAltOrShiftPressed
@@ -1404,8 +1540,8 @@
key:key select:index x:x y:y
"select an entry by a keyboard action. This is treated like a doubleClick
on that entry.
- Add on: In case that the entry is not selectable, scroll to the entry
- "
+ Add on: In case that the entry is not selectable, scroll to the entry"
+
(enabled and:[keyActionStyle notNil]) ifFalse:[
^ self
].
@@ -1420,6 +1556,8 @@
].
self gotoLine:index
+
+ "Modified (comment): / 04-02-2017 / 22:27:27 / cg"
!
keyPress:key x:x y:y
@@ -1479,11 +1617,13 @@
!
fetchDefaultImages
- "returns a directory with default keys and images; could be
- redefined by subclass.
- "
+ "returns a directory with default keys and images;
+ could be redefined by subclass."
+
^ itemClass notNil ifTrue:[itemClass keysAndIcons]
ifFalse:[nil]
+
+ "Modified (comment): / 04-02-2017 / 22:27:43 / cg"
!
fetchDeviceResources
@@ -1496,32 +1636,26 @@
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
- "
+ images again and again later;
+ returns the maximum extent of the images used.
+ Could be redefined by subclass"
+
|img x y keysAndIcons|
x := y := 0.
- imageOpened isNil ifTrue:[
- imageOpened := self imageOnMyDevice:(self class imageOpened)
- ].
+
imageOpened notNil ifTrue:[
+ imageOpened := imageOpened onDevice:device.
x := x max:(imageOpened width).
y := y max:(imageOpened height).
].
-
- imageClosed isNil ifTrue:[
- imageClosed := self imageOnMyDevice:(self class imageClosed)
- ].
imageClosed notNil ifTrue:[
+ imageClosed := imageClosed onDevice:device.
x := x max:(imageClosed width).
y := y max:(imageClosed height).
].
-
- imageItem isNil ifTrue:[
- imageItem := self imageOnMyDevice:(self class imageItem)
- ].
imageItem notNil ifTrue:[
+ imageItem := imageItem onDevice:device.
x := x max:(imageItem width).
y := y max:(imageItem height).
].
@@ -1529,7 +1663,7 @@
(keysAndIcons := self fetchDefaultImages) notNil ifTrue:[
keysAndIcons keysAndValuesDo:[:aKey :anIcon|
(anIcon isImage and:[aKey notNil]) ifTrue:[
- registeredImages at:aKey put:(self imageOnMyDevice:anIcon)
+ registeredImages at:aKey put:(anIcon onDevice:device)
]
]
].
@@ -1544,17 +1678,18 @@
].
^ x @ y
- "Modified: / 12.8.1998 / 12:45:53 / cg"
+ "Modified: / 04-02-2017 / 21:04:08 / cg"
+ "Modified (comment): / 04-02-2017 / 22:28:13 / cg"
!
getFontParameters
- "save old computed height derived from images
- "
+ "save old computed height derived from images"
+
|lineHeight|
lineHeight := fontHeight ? 0.
super getFontParameters.
- labelOffsetY := fontAscent - (fontHeight - lineSpacing // 2).
+ labelOffsetY := fontAscent - ((fontHeight - lineSpacing) // 2).
lineHeight > fontHeight ifTrue:[
fontHeight := lineHeight
@@ -1562,6 +1697,8 @@
fontHeight odd ifTrue:[
fontHeight := fontHeight + 1
]
+
+ "Modified (format): / 04-02-2017 / 22:28:27 / cg"
!
initStyle
@@ -1569,12 +1706,20 @@
super initStyle.
highlightMode := DefaultHilightMode ? #label.
-
+
+ openIndicator := self class openIndicator. "/ a little arrow
+ closeIndicator := self class closeIndicator. "/ a little arrow
+
+ imageOpened := self class imageOpened. "/ an open folder
+ imageClosed := self class imageClosed. "/ an closed folder
+ imageItem := self class imageItem. "/ a document icon
+
+ "Modified: / 04-02-2017 / 21:10:55 / cg"
!
initialize
- "setup instance attributes
- "
+ "setup instance attributes"
+
super initialize.
itemClass isNil ifTrue:[
@@ -1583,8 +1728,12 @@
supportsExpandAll := true.
self bitGravity:#NorthWest.
- showRoot := showDirectoryIndicatorForRoot := showLines := computeResources := true.
+ showRoot := showDirectoryIndicatorForRoot := showLines := computeResources := true.
showDirectoryIndicator := discardMotionEvents := showLinesForRoot := false.
+ "/ cg: the above default looks bad to me;
+ "/ why not:
+ "/ showDirectoryIndicator := true.
+ "/ showDirectoryIndicatorForRoot := false.
leftMargin := 2.
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55].
registeredImages := IdentityDictionary new.
@@ -1593,12 +1742,16 @@
imageInset := 0. "/ set during indication enabled
imageWidth := 8. "/ default: will change during startup
- buildInArray := Array new:50. "/ used for temporary calculation
- "/ suppress garbage collection
+ "/ rubbish - a temporary during a method generates less stress
+ "/ than an object in oldSpace...
+ "/ buildInArray := Array new:50. "/ used for temporary calculation
+ "/ suppress garbage collection
self model:nil. "/ creates a default model.
highlightMode := #label.
editValueFgColor := Color blue.
+
+ "Modified (comment): / 04-02-2017 / 22:28:32 / cg"
!
realize
@@ -1607,8 +1760,8 @@
!
recomputeDirectoryIndicator
- "setup attributes used by directory indicator
- "
+ "setup attributes used by directory indicator"
+
|x w|
imageInset := 0.
@@ -1618,17 +1771,12 @@
].
x := 0.
- openIndicator isNil ifTrue:[
- openIndicator := self imageOnMyDevice:(self class openIndicator)
- ].
openIndicator notNil ifTrue:[
+ openIndicator := openIndicator onDevice:device.
x := openIndicator width
].
-
- closeIndicator isNil ifTrue:[
- closeIndicator := self imageOnMyDevice:(self class closeIndicator)
- ].
closeIndicator notNil ifTrue:[
+ closeIndicator := closeIndicator onDevice:device.
x := x max:(closeIndicator width)
].
@@ -1639,13 +1787,14 @@
imageInset := x - w.
].
- "Modified: / 13.8.1998 / 12:02:04 / cg"
+ "Modified: / 04-02-2017 / 21:12:35 / cg"
+ "Modified (comment): / 04-02-2017 / 22:28:38 / cg"
!
refetchDeviceResources
"reinitialize heavily used device resources - to avoid rendering
- images again and again later
- "
+ images again and again later"
+
|extent|
(realized and:[computeResources and:[listOfNodes size ~~ 0]]) ifTrue:[
@@ -1667,11 +1816,13 @@
self recomputeDirectoryIndicator.
self computeNumberOfLinesShown.
]
+
+ "Modified (comment): / 04-02-2017 / 22:28:42 / cg"
!
release
- "remove dependencies
- "
+ "remove dependencies"
+
rootHolder removeDependent:self.
selectionHolder removeDependent:self.
@@ -1679,55 +1830,63 @@
model stopRunningTasks
].
super release.
+
+ "Modified (comment): / 04-02-2017 / 22:28:48 / cg"
! !
!SelectionInTreeView methodsFor:'model'!
getListFromModel
"if I have a model, get my list from it using the listMessage.
- If listMessage is nil, try aspectMessage for backward compatibilty.
- "
+ If listMessage is nil, try aspectMessage for backward compatibilty."
+
super list:(self listFromModel) keepSelection:true
+
+ "Modified (comment): / 04-02-2017 / 22:28:57 / cg"
!
listFromModel
"get list from model and return the new list.
- If listMessage is nil, try aspectMessage for backward compatibilty.
- "
+ If listMessage is nil, try aspectMessage for backward compatibilty."
+
|msg|
widthOfWidestLine := nil.
list := listOfNodes := (msg := listMsg ? aspectMsg) notNil ifTrue:[model perform:msg] ifFalse:[#()].
self refetchDeviceResources.
- ^ listOfNodes
+ ^ listOfNodes
+
+ "Modified (format): / 04-02-2017 / 22:29:03 / cg"
!
model:aModel
- "check whether model is nil; than a default model is created
- "
- |model root|
+ "check whether given new model is nil;
+ then a default model is created"
+
+ |root newModel|
model notNil ifTrue:[
model stopRunningTasks
].
- model := aModel ? (self class defaultModelClass new).
- self itemClass:(model class defaultItemClass).
- root := model root.
-
- model showRoot:showRoot.
+ newModel := aModel ? (self class defaultModelClass new).
+ self itemClass:(newModel class defaultItemClass).
+ root := newModel root.
+
+ newModel showRoot:showRoot.
root notNil ifTrue:[
root expand
].
- super model:model.
+ super model:newModel.
self getListFromModel
+ "Modified (comment): / 04-02-2017 / 22:35:24 / cg"
!
rootFromModel
- "update hierarchical list from root model; 'rootHolder'
- "
+ "update hierarchical list from root model; 'rootHolder'"
+
|root|
root := rootHolder root.
@@ -1736,11 +1895,13 @@
self selection:nil.
self root:root.
].
+
+ "Modified (comment): / 04-02-2017 / 22:30:16 / cg"
!
selectionFromModel
- "set the selection derived from the selectionHolder
- "
+ "set the selection derived from the selectionHolder"
+
|coll value size idx|
(value := selectionHolder value) notNil ifTrue:[
@@ -1769,11 +1930,13 @@
].
].
self setSelection:coll
+
+ "Modified (comment): / 04-02-2017 / 22:30:21 / cg"
!
selectionToModel
- "write selection to selection holder
- "
+ "write selection to selection holder"
+
|newSel oldSel|
oldSel := selectionHolder value.
@@ -1801,36 +1964,40 @@
]
]
]
+
+ "Modified (comment): / 04-02-2017 / 22:30:26 / cg"
! !
!SelectionInTreeView methodsFor:'private'!
closeEditor
- "close the editor
- "
+ "close the editor"
+
editorWidget notNil ifTrue:[
editorWidget destroy.
editorIndex := 0.
editorWidget := nil.
].
+ "Modified (comment): / 04-02-2017 / 22:30:31 / cg"
!
list:aList keepSelection:keepSelection
"setup new list; keep selection dependent on the boolean state
- keepSelection
- "
+ keepSelection"
+
|list|
list := (aList size == 0) ifTrue:[#()] ifFalse:[aList].
super list:list keepSelection:keepSelection.
self refetchDeviceResources.
+ "Modified (comment): / 04-02-2017 / 22:30:38 / cg"
!
openEditor
- "open an editor on selection
- "
+ "open an editor on selection"
+
|node x0 x1 y0|
editorWidget notNil ifTrue:[
@@ -1860,6 +2027,8 @@
gc fillRectangleX:(x0 - SelectionInset) y:y0
width:SelectionInset + SelectionInset + (x1 - x0)
height:fontHeight.
+
+ "Modified (comment): / 04-02-2017 / 22:32:18 / cg"
! !
!SelectionInTreeView methodsFor:'private-drag and drop'!
@@ -1902,36 +2071,38 @@
!
dragObjectForNode:aNode
- "returns the dragable object for a node; could be redefined in subclass
- "
+ "returns the dragable object for a node; could be redefined in subclass"
+
^ DropObject new:aNode.
-
+ "Modified (comment): / 04-02-2017 / 22:32:26 / cg"
!
startDragX:x y:y
- "start drag
- "
+ "start drag"
+
dragIsActive := true.
DragAndDropManager startDrag:(self collectionOfDragObjects)
from:self
atEnd:endDragAction
-
+ "Modified (comment): / 04-02-2017 / 22:32:30 / cg"
! !
!SelectionInTreeView methodsFor:'private-queries'!
lengthOfLongestLineBetween:firstLine and:lastLine
- "return the length (in characters) of the longest line in a line-range
- "
+ "return the length (in characters) of the longest line in a line-range"
+
^ self widthOfContents // fontWidth + 1
+
+ "Modified (comment): / 04-02-2017 / 22:32:36 / cg"
!
smallestLevelOfNodesBetween:start and:stop
- "returns the smallest level of the nodes in a line range
- "
+ "returns the smallest level of the nodes in a line range"
+
|prevNode currParent nextParent
lvl "{ Class:SmallInteger }"
@@ -1969,9 +2140,7 @@
].
^ min
-
-
-
+ "Modified (comment): / 04-02-2017 / 22:32:40 / cg"
!
widthOfContents
@@ -1988,53 +2157,58 @@
!
widthOfLongestLine
- "return the width of the longest line in pixels
- "
+ "return the width of the longest line in pixels"
+
|parent pItem p
startX "{ Class: SmallInteger }"
deltaX "{ Class: SmallInteger }"
level "{ Class: SmallInteger }"
width "{ Class: SmallInteger }"
- maxSz "{ Class: SmallInteger }"|
-
- buildInArray atAllPut:0.
+ maxSz "{ Class: SmallInteger }"
+ levelArray|
+
+ levelArray := Array new:50 withAll:0.
+ "/ buildInArray atAllPut:0.
+
parent := nil.
maxSz := 1.
level := 1.
listOfNodes do:[:anItem|
(p := anItem parent) ~~ parent ifTrue:[
- buildInArray at:level put:maxSz.
+ levelArray at:level put:maxSz.
(parent := p) == pItem ifTrue:[level := level + 1]
ifFalse:[level := anItem level].
- maxSz := buildInArray at:level.
+ maxSz := levelArray at:level.
].
pItem := anItem.
maxSz := maxSz max:(anItem name size).
].
- buildInArray at:level put:maxSz.
+ levelArray at:level put:maxSz.
startX := self xOfStringLevel:1.
deltaX := imageInset + imageWidth.
width := '1' widthOn:self.
maxSz := 0.
- buildInArray do:[:el|
+ levelArray do:[:el|
el == 0 ifTrue:[ ^ maxSz + viewOrigin x ].
maxSz := maxSz max:(el * width + startX).
startX := startX + deltaX.
].
+
+ "Modified: / 04-02-2017 / 21:07:13 / cg"
+ "Modified (comment): / 04-02-2017 / 22:32:49 / cg"
! !
!SelectionInTreeView methodsFor:'private-redefinitions'!
expandTabs
- "nothing to do
- "
-
-
+ "nothing to do"
+
+ "Modified (comment): / 04-02-2017 / 22:32:57 / cg"
!
list:aCollection expandTabs:expand scanForNonStrings:scan
@@ -2081,7 +2255,7 @@
^ img
].
icon isImage ifTrue:[
- img := self imageOnMyDevice:icon.
+ img := icon onDevice:device.
registeredImages at:icon put:img.
^ img
]
@@ -2095,17 +2269,21 @@
].
"/ folder
^ aNode hidden ifTrue:[imageClosed] ifFalse:[imageOpened]
+
+ "Modified: / 04-02-2017 / 22:37:12 / cg"
!
indexOfNode:aNode
- "returns index of a node
- "
+ "returns index of a node"
+
^ listOfNodes identityIndexOf:aNode
+
+ "Modified (comment): / 04-02-2017 / 22:33:08 / cg"
!
xOfFigureLevel:aLevel
- "origin x where to draw the icon
- "
+ "origin x where to draw the icon"
+
|l "{ Class:SmallInteger }"|
l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1].
@@ -2118,31 +2296,37 @@
]
].
^ (l * (imageInset + imageWidth)) + imageInset - viewOrigin x + leftMargin
+
+ "Modified (comment): / 04-02-2017 / 22:33:19 / cg"
!
xOfFigureNode:aNode
- "origin x where to draw the icon
- "
+ "origin x where to draw the icon"
+
^ self xOfFigureLevel:(aNode level)
+
+ "Modified (comment): / 04-02-2017 / 22:33:24 / cg"
!
xOfStringLevel:aLevel
- "origin x where to draw the text( label )
- "
+ "origin x where to draw the text( label )"
+
^ (self xOfFigureLevel:aLevel) + imageWidth + textInset
+ "Modified (comment): / 04-02-2017 / 22:33:28 / cg"
!
xOfStringNode:aNode
- "origin x where to draw the text( label )
- "
+ "origin x where to draw the text( label )"
+
^ self xOfStringLevel:(aNode level)
+ "Modified (comment): / 04-02-2017 / 22:33:32 / cg"
!
xOfValueNode:aNode
- "returns the left x position of the start of the value
- "
+ "returns the left x position of the start of the value"
+
|p x|
p := aNode parent.
@@ -2152,6 +2336,7 @@
^ x + (self xOfStringNode:aNode)
+ "Modified (comment): / 04-02-2017 / 22:33:36 / cg"
! !
!SelectionInTreeView methodsFor:'scrolling'!
@@ -2169,27 +2354,30 @@
!
originChanged:delta
- "sent after scrolling - have to update origin of editor
- "
+ "sent after scrolling - have to update origin of editor"
+
super originChanged:delta.
editorWidget notNil ifTrue:[
editorWidget origin:(editorWidget origin - delta)
]
+ "Modified (comment): / 04-02-2017 / 22:33:43 / cg"
! !
!SelectionInTreeView methodsFor:'selection'!
selectNode:aNode
- "change selection to a node
- "
+ "change selection to a node"
+
^ self selectNode:aNode withNotify:true.
+
+ "Modified (comment): / 04-02-2017 / 22:33:49 / cg"
!
selectNode:aNode withNotify:withNotify
- "change selection to a node
- "
+ "change selection to a node"
+
|index|
(index := aNode) notNil ifTrue:[
@@ -2208,6 +2396,8 @@
] ifTrue:[
self selection:index
].
+
+ "Modified (comment): / 04-02-2017 / 22:33:52 / cg"
!
selectNodes:aCollectionOfNodes
@@ -2239,16 +2429,18 @@
!
selectedIndex
- "get single selected index or 0
- "
+ "get single selected index or 0"
+
selection size == 1 ifTrue:[^ selection first].
selection isNumber ifTrue:[^ selection].
- ^ 0
+ ^ 0
+
+ "Modified (format): / 04-02-2017 / 22:34:01 / cg"
!
selectedNode
- "get the single selected node or nil
- "
+ "get the single selected node or nil"
+
|idx|
(idx := self selectedIndex) ~~ 0 ifTrue:[
@@ -2257,20 +2449,23 @@
^ nil
"Modified: / 19-01-2011 / 18:41:02 / cg"
+ "Modified (comment): / 04-02-2017 / 22:34:06 / cg"
!
selectedNodes
- "get a collection of selected nodes
- "
+ "get a collection of selected nodes"
+
|selIndexCollection|
(selIndexCollection := self selection) size == 0 ifTrue:[^ #() ].
^ selIndexCollection collect:[:eachIndex | listOfNodes at:eachIndex].
+
+ "Modified (comment): / 04-02-2017 / 22:34:10 / cg"
!
selectionChangedFrom:oldSelection
- "update selectionHolder if not nil
- "
+ "update selectionHolder if not nil"
+
self closeEditor.
"/ first change my selectionHolders value ...
@@ -2281,18 +2476,18 @@
"/ ... then make notifications.
super selectionChangedFrom:oldSelection.
-
+ "Modified (comment): / 04-02-2017 / 22:34:13 / cg"
!
setSelection:aSelection
- "if no selection exists, close the editor
- "
+ "if no selection exists, close the editor"
+
(aSelection isNil or:[aSelection == 0]) ifTrue:[
self closeEditor
].
super setSelection:aSelection
-
+ "Modified (comment): / 04-02-2017 / 22:34:17 / cg"
! !
!SelectionInTreeView methodsFor:'selection actions'!