--- a/ListModelView.st Thu Jul 15 14:44:47 1999 +0200
+++ b/ListModelView.st Fri Jul 16 16:59:32 1999 +0200
@@ -177,17 +177,13 @@
list:aList
"set the list of items
"
- |size changed negatedOrg sensor|
+ |size negatedOrg sensor|
(sensor := self sensor) notNil ifTrue:[
sensor flushUserEventsFor:self withType:#syncUpdate:with:.
].
- changed := list size ~~ 0.
-
list ~~ aList ifTrue:[
- changed ifFalse:[changed := aList size ~~ 0].
-
list removeDependent:self.
].
(list := aList) notNil ifTrue:[
@@ -205,10 +201,7 @@
self originChanged:negatedOrg.
].
self invalidate.
-
- changed ifTrue:[
- self contentsChanged
- ]
+ self contentsChanged
!
@@ -388,8 +381,9 @@
listChangedInsert:start nItems:nLines
"list changed; items are added
"
- |sensor
+ |
run "{ Class: SmallInteger }"
+ newSz "{ Class: SmallInteger }"
cpyHg "{ Class: SmallInteger }"
absY0 "{ Class: SmallInteger }"
absY1 "{ Class: SmallInteger }"
@@ -404,9 +398,13 @@
self listSizeChanged:start nLines:nLines.
shown not ifTrue:[^ self].
- (startOfLinesY size + nLines - 1) ~~ list size ifTrue:[
- self recomputeHeightOfContents.
- ^ self invalidate.
+ newSz := startOfLinesY size + nLines.
+
+ (newSz - 1) ~~ list size ifTrue:[
+ "/
+ "/ no longer synchrounous
+ "/
+ ^ self lostSynchronisation
].
startOfLinesY addAll:(Array new:nLines) beforeIndex:start + 1.
@@ -419,9 +417,9 @@
run := run + 1.
startOfLinesY at:run put:absY1.
].
-
dltY := absY1 - absY0.
- run + 1 to:(startOfLinesY size) do:[:i|
+
+ run + 1 to:newSz do:[:i||v|
startOfLinesY at:i put:((startOfLinesY at:i) + dltY)
].
@@ -436,8 +434,10 @@
viewOrigin y:(dltY + orgY).
self originChanged:(0 @ dltY).
].
- ((sensor := self sensor) isNil or:[sensor hasDamageFor:self]) ifTrue:[
- ^ self contentsChanged.
+
+ self hasDamage ifTrue:[
+ self invalidate.
+ ^ self contentsChanged.
].
(visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[
@@ -458,12 +458,15 @@
self waitForExpose
].
- self redrawX:margin y:visY0
- width:width - margin - margin
- height:(visY1 - visY0).
+ self invalidateX:margin
+ y:visY0
+ width:width - margin - margin
+ height:(visY1 - visY0).
+
self contentsChanged.
+
!
listChangedRemove:aStart toIndex:aStop
@@ -482,6 +485,7 @@
maxHg "{ Class: SmallInteger }"
stop "{ Class: SmallInteger }"
start "{ Class: SmallInteger }"
+ newSz "{ Class: SmallInteger }"
|
stop := aStop.
start := aStart.
@@ -493,18 +497,22 @@
self listSizeChanged:start nLines:(size negated).
shown not ifTrue:[^ self].
- (startOfLinesY size - size - 1) ~~ list size ifTrue:[
- self recomputeHeightOfContents.
- ^ self invalidate
+ newSz := startOfLinesY size - size.
+
+ (newSz - 1) ~~ list size ifTrue:[
+ "/
+ "/ no longer synchrounous
+ "/
+ ^ self lostSynchronisation
].
absY0 := self yAbsoluteOfLine:start.
- absY1 := self yAbsoluteOfLine:(stop + 1).
+ absY1 := self yAbsoluteOfLine:stop + 1.
dltY := absY1 - absY0.
- startOfLinesY removeFromIndex:start toIndex:stop.
+ startOfLinesY removeFromIndex:(start + 1) toIndex:(stop + 1).
- start to:(startOfLinesY size) do:[:i|
+ (start + 1) to:newSz do:[:i|
absY0 := startOfLinesY at:i.
startOfLinesY at:i put:(absY0 - dltY).
].
@@ -538,8 +546,12 @@
] ifFalse:[
noRedraw := visY0 >= maxHg
].
+ self hasDamage ifTrue:[
+ self invalidate.
+ noRedraw := true
+ ].
- (noRedraw or:[self sensor hasDamageFor:self]) ifFalse:[
+ noRedraw ifFalse:[
visY0 := visY0 max:margin.
cpyHg := maxHg - visY1.
@@ -551,9 +563,10 @@
visY0 := visY0 + cpyHg.
].
- self redrawX:margin y:visY0
- width:width - margin - margin
- height:(maxHg - visY0).
+ self invalidateX:margin
+ y:visY0
+ width:width - margin - margin
+ height:(maxHg - visY0).
].
self contentsChanged.
!
@@ -877,6 +890,14 @@
!ListModelView methodsFor:'private'!
+hasDamage
+ "return true, if any damage events (i.e. expose or resize) are pending.
+ "
+ |sensor|
+
+ ^ (sensor := self sensor) isNil or:[sensor hasDamageFor:self]
+!
+
yAbsoluteOfLine:aLineNr
"given a lineNr, return y-coordinate absolute
"
@@ -1018,6 +1039,25 @@
computeWidthInRange := start@stop
!
+lostSynchronisation
+ "called when the changes derived from the model are faster than the handling
+ "
+ |sensor|
+
+ shown ifTrue:[
+ (sensor := self sensor) notNil ifTrue:[
+ sensor flushUserEventsFor:self withType:#syncUpdate:with:
+ ].
+ self recomputeHeightOfContents.
+ self invalidate.
+ self contentsChanged
+ ].
+
+
+
+
+!
+
widthOfWidestLineBetween:firstLine and:lastLine
"return the width in pixels of the widest line in a range
"
@@ -1303,6 +1343,6 @@
!ListModelView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.17 1999-07-15 12:44:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.18 1999-07-16 14:59:32 cg Exp $'
! !
ListModelView initialize!