--- a/HierarchicalListView.st Thu Dec 18 16:13:09 2003 +0100
+++ b/HierarchicalListView.st Fri Dec 19 09:41:11 2003 +0100
@@ -341,31 +341,31 @@
"test whether the list is not a hierarchical item and
retrieve the showRoot attribute from the list
"
- |newList|
-
- newList := aList.
-
aList notNil ifTrue:[
aList isHierarchicalItem ifTrue:[
- list notNil ifTrue:[
- list root:aList.
- ^ self
- ].
- newList := HierarchicalList new.
- newList showRoot:showRoot.
- newList root:aList.
+ self list root:aList.
aList expand.
+ ^ self
].
- showRoot := newList showRoot.
+ showRoot := aList showRoot.
].
- super list:newList
+ super list:aList
+!
+
+newDefaultList
+ "creates and returns a new default list class, on default a HierarchicalList
+ "
+ |list|
+
+ list := HierarchicalList new.
+ list showRoot:(showRoot ? true).
+ ^ list
!
root
"returns the anchor of the list or nil
"
- list notNil ifTrue:[ ^ list root ].
- ^ nil
+ ^ self list root
! !
!HierarchicalListView methodsFor:'accessing-behavior'!
@@ -571,10 +571,7 @@
"
showRoot ~~ aBoolean ifTrue:[
showRoot := aBoolean.
-
- list notNil ifTrue:[
- list showRoot:aBoolean.
- ].
+ self list showRoot:showRoot.
shown ifTrue:[ self invalidate ]
].
!
@@ -814,7 +811,7 @@
update:what with:aPara from:chgObj
"get the status of <showRoot> from the list
"
- chgObj == list ifTrue:[
+ chgObj == self list ifTrue:[
showRoot ~~ chgObj showRoot ifTrue:[
showRoot := chgObj showRoot.
self invalidate.
@@ -1077,8 +1074,8 @@
maxLevel := 1.
- list criticalDo:[
- list do:[:el| maxLevel := maxLevel max:(el level) ].
+ self list criticalDo:[
+ self list do:[:el| maxLevel := maxLevel max:(el level) ].
].
needMore := (width - imageWidth) max:2.
@@ -1595,5 +1592,5 @@
!HierarchicalListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.86 2003-08-19 08:34:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.87 2003-12-19 08:41:04 ca Exp $'
! !
--- a/ListModelView.st Thu Dec 18 16:13:09 2003 +0100
+++ b/ListModelView.st Fri Dec 19 09:41:11 2003 +0100
@@ -192,8 +192,8 @@
list ~~ aList ifTrue:[
list removeDependent:self.
- ].
- (list := aList) notNil ifTrue:[
+ list := aList.
+ list isNil ifTrue:[list := self newDefaultList ].
list addDependent:self
].
preferredExtent := nil.
@@ -219,6 +219,12 @@
self invalidate.
self contentsChanged
+!
+
+newDefaultList
+ "creates and returns a new default list class, on default a List
+ "
+ ^ List new
! !
!ListModelView methodsFor:'accessing-behavior'!
@@ -301,29 +307,20 @@
If the index is invalid, return the result of evaluating
the exceptionblock.
"
- list notNil ifTrue:[
- ^ list at:anIndex ifAbsent:exceptionBlock
- ].
- ^ exceptionBlock value
+ ^ list at:anIndex ifAbsent:exceptionBlock
!
findLast:aOneArgBlock
"find the last list entry, for which evaluation of the argument, aOneArgBlock
returns true; return its index or 0 if none detected.
"
- list notNil ifTrue:[
- ^ list findLast:aOneArgBlock
- ].
- ^ 0
+ ^ list findLast:aOneArgBlock
!
identityIndexOf:anElement
"returns the index of an element or nil
"
- list notNil ifTrue:[
- ^ list identityIndexOf:anElement
- ].
- ^ 0
+ ^ list identityIndexOf:anElement
!
last
@@ -464,7 +461,7 @@
self invalidateLineAt:aLnNr.
^ self
].
- cache := startOfLinesY.
+ cache := self startOfLinesY.
aLnNr + 1 to:cache size do:[:i|
cache at:i put:((cache at:i) + dltHeight)
@@ -680,15 +677,16 @@
"
|a1 a2|
- chgObj ~~ list ifTrue:[
- chgObj == listHolder ifTrue:[
- self list:(listHolder value).
+ chgObj ~~ self list ifTrue:[
+ chgObj == self listHolder ifTrue:[
+ self list:(chgObj value).
] ifFalse:[
super update:what with:aPara from:chgObj
].
^ self
].
-
+ "the list has changed
+ "
aPara isCollection ifFalse:[
what == #at: ifTrue:[self lineChangedAt:aPara with:nil. ^ self].
what == #insert: ifTrue:[self listChangedInsert:aPara nItems:1. ^ self].
@@ -699,8 +697,8 @@
a1 := aPara at:1.
a2 := aPara at:2.
- (a1 == 1 and:[a2 == list size]) ifTrue:[
- self list:list. "/ reload full list
+ (a1 == 1 and:[a2 == self size]) ifTrue:[
+ self list:chgObj. "/ reload list
^ self
].
@@ -811,8 +809,11 @@
stop isNil ifTrue:[
stop := self size.
- ] ifFalse:[
- yAbs == (startOfLinesY at:stop) ifTrue:[
+ ] ifFalse:[ |y0|
+ y0 := self startOfLinesY at:stop ifAbsent:nil.
+ y0 isNil ifTrue:[^ self].
+
+ yAbs == y0 ifTrue:[
stop := (stop - 1) max:start
].
].
@@ -945,12 +946,8 @@
"
super initStyle.
- DefaultForegroundColor isNil ifTrue:[
- self updateStyleCache
- ].
-
DefaultBackgroundColor notNil ifTrue:[
- viewBackground := DefaultBackgroundColor
+ viewBackground := DefaultBackgroundColor
].
lineSpacing := 0.
textStartLeft := 2.
@@ -961,11 +958,11 @@
startOfLinesY add:(2 + margin). "/ top inset of first line
DefaultShadowColor notNil ifTrue:[
- shadowColor := DefaultShadowColor
+ shadowColor := DefaultShadowColor
].
DefaultLightColor notNil ifTrue:[
- lightColor := DefaultLightColor
+ lightColor := DefaultLightColor
].
!
@@ -984,6 +981,7 @@
renderer isNil ifTrue:[
renderer := self class defaultRenderer forView:self.
].
+ self list:(self list).
!
mapped
@@ -1016,8 +1014,8 @@
release
"remove dependencies
"
- listHolder removeDependent:self.
- list removeDependent:self.
+ self listHolder removeDependent:self.
+ self list removeDependent:self.
super release
! !
@@ -1030,20 +1028,27 @@
^ self sensor hasDamageFor:self
!
+startOfLinesY
+ "returns a sequencable list which keeps all the absolute Y-start positions
+ for each line into the list. The first entry is the top Y inset.
+ "
+ ^ startOfLinesY
+!
+
yAbsoluteOfLine:aLineNr
"given a lineNr, return y-coordinate absolute
"
|y y2 y1 cash|
- cash := startOfLinesY.
+ cash := self startOfLinesY.
(y := cash at:aLineNr ifAbsent:nil) notNil ifTrue:[
- ^ y
+ ^ y
].
"/ recompute a y position
- y1 := startOfLinesY at:1 ifAbsent:2.
- y2 := startOfLinesY at:2 ifAbsent:10.
+ y1 := cash at:1 ifAbsent:2.
+ y2 := cash at:2 ifAbsent:10.
^ aLineNr * (y2 - y1) + y1
!
@@ -1064,7 +1069,7 @@
ictr "{ Class: SmallInteger}"
yRun "{ Class: SmallInteger}"
|
- cash := startOfLinesY.
+ cash := self startOfLinesY.
(size := cash size) < 2 ifTrue:[^ nil]. "/ empty list
@@ -1205,11 +1210,9 @@
!
size
- "returns number of raws
+ "returns the number of list entries
"
- ^ list size
-
-
+ ^ self list size
! !
!ListModelView methodsFor:'recomputation'!
@@ -1272,7 +1275,7 @@
heightOfContents
"return the height of the contents in pixels
"
- ^ startOfLinesY last ? 0
+ ^ self startOfLinesY last ? 0
!
heightOfLineAt:aLineNr
@@ -1651,7 +1654,7 @@
!ListModelView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.83 2003-10-08 15:35:03 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.84 2003-12-19 08:41:11 ca Exp $'
! !
ListModelView initialize!