--- a/ListView.st Wed Aug 30 12:15:02 2000 +0200
+++ b/ListView.st Wed Aug 30 15:11:35 2000 +0200
@@ -635,6 +635,24 @@
"Modified: 22.10.1996 / 23:18:53 / cg"
!
+addAll:aCollectionOfLines beforeIndex:index
+ "add a line and redisplay"
+
+ list isNil ifTrue:[list := OrderedCollection new].
+ aCollectionOfLines do:[:eachLine |
+ list addAll:aCollectionOfLines beforeIndex:index.
+ ].
+
+ widthOfWidestLine := nil. "/ i.e. unknown
+ self textChanged.
+
+ ((index-1) <= self lastLineShown) ifTrue:[
+ self redrawFromLine:index-1.
+ ].
+
+ self contentsChanged. "recompute scrollbars"
+!
+
at:lineNr
"retrieve a line; return nil if beyond end-of-text.
this allows textViews to be used like collections in some places."
@@ -1215,6 +1233,24 @@
].
"Modified: / 26.7.1998 / 13:00:14 / cg"
+!
+
+xxxaddAll:aCollectionOfLines beforeIndex:index
+ "add a line and redisplay"
+
+ list isNil ifTrue:[list := OrderedCollection new].
+ aCollectionOfLines do:[:eachLine |
+ list addAll:aCollectionOfLines beforeIndex:index.
+ ].
+
+ widthOfWidestLine := nil. "/ i.e. unknown
+ self textChanged.
+
+ ((index-1) <= self lastLineShown) ifTrue:[
+ self redrawFromLine:index-1.
+ ].
+
+ self contentsChanged. "recompute scrollbars"
! !
!ListView methodsFor:'accessing-mvc'!
@@ -2783,7 +2819,7 @@
"return the width of the contents in pixels
- used for scrollbar interface"
- |max f d|
+ |max f d lengthOfLongestString|
list isNil ifTrue:[^ 0].
widthOfWidestLine notNil ifTrue:[^ widthOfWidestLine + (leftMargin * 2)].
@@ -2811,17 +2847,35 @@
) max:maxSoFar.
]
] ifFalse:[
- false "fontIsFixedWidth" ifTrue:[
- max := self lengthOfLongestLine * fontWidth
- ] ifFalse:[
- max := 0.
+ fontIsFixedWidth ifTrue:[
+ max := lengthOfLongestString := 0.
list notNil ifTrue:[
list do:[:line |
line notNil ifTrue:[
- max := max max:(line widthOn:self)
+ (line isString and:[line hasChangeOfEmphasis not]) ifTrue:[
+ line size > lengthOfLongestString ifTrue:[
+ lengthOfLongestString := line size
+ ].
+ ] ifFalse:[
+ max := max max:(line widthOn:self)
+ ]
]
].
-"/ max := max max:(f widthOf:list)
+ max := max max:(lengthOfLongestString * fontWidth)
+ ].
+ ] ifFalse:[
+ false "fontIsFixedWidth" ifTrue:[
+ max := self lengthOfLongestLine * fontWidth
+ ] ifFalse:[
+ max := 0.
+ list notNil ifTrue:[
+ list do:[:line |
+ line notNil ifTrue:[
+ max := max max:(line widthOn:self)
+ ]
+ ].
+ "/ max := max max:(f widthOf:list)
+ ].
].
].
].
@@ -4153,5 +4207,5 @@
!ListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.236 2000-08-23 22:33:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.237 2000-08-30 13:11:24 stefan Exp $'
! !
--- a/SelectionInListView.st Wed Aug 30 12:15:02 2000 +0200
+++ b/SelectionInListView.st Wed Aug 30 15:11:35 2000 +0200
@@ -1683,7 +1683,7 @@
!SelectionInListView methodsFor:'change & update'!
update:something with:aParameter from:changedObject
- |list start stop size idx|
+ |listValue start stop size idx|
changedObject == model ifTrue:[
something == aspectMsg ifTrue:[
@@ -1709,16 +1709,17 @@
changedObject == listChannel ifFalse:[
^ super update:something with:aParameter from:changedObject
].
- list := listChannel value.
+ listValue := listChannel value.
something == #at: ifTrue:[
idx := aParameter isCollection ifTrue:[aParameter at:1]
ifFalse:[aParameter].
- ^ self at:aParameter put:(list at:idx).
+ ^ self at:aParameter put:(listValue at:idx).
].
something == #insert: ifTrue:[
- ^ self add:(list at:aParameter) beforeIndex:aParameter
+ listValue == list ifTrue:[self halt].
+ ^ self add:(listValue at:aParameter) beforeIndex:aParameter
].
something == #remove: ifTrue:[
@@ -1727,13 +1728,14 @@
something == #insertCollection: ifTrue:[
(size := aParameter last) ~~ 0 ifTrue:[
- self size == 0 ifTrue:[
+ (self size == 0 or:[size > 50]) ifTrue:[
self getListFromModel
] ifFalse:[
+ listValue == list ifTrue:[self halt].
start := aParameter first.
-
+ "/ self addAll:(listValue copyFrom:start to:start+size-1) beforeIndex:start.
size timesRepeat:[
- self add:(list at:start) beforeIndex:start.
+ self add:(listValue at:start) beforeIndex:start.
start := start + 1
]
]
@@ -1763,7 +1765,7 @@
stop := aParameter last.
start to:stop do:[:anIndex|
- self at:anIndex put:(list at:anIndex)
+ self at:anIndex put:(listValue at:anIndex)
].
^ self
].
@@ -3793,5 +3795,5 @@
!SelectionInListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.179 2000-08-23 18:01:26 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.180 2000-08-30 13:11:35 stefan Exp $'
! !