--- a/ListView.st Sat Jul 25 12:15:35 1998 +0200
+++ b/ListView.st Mon Jul 27 09:56:03 1998 +0200
@@ -591,12 +591,25 @@
at:index put:aString
"change a line and redisplay"
- |visibleLine y|
-
+ |visibleLine y fontHeightBefore|
+
+ fontHeightBefore := fontHeight.
self withoutRedrawAt:index put:aString.
+
shown ifTrue:[
- "/ synchronous:
- self redrawLine:index
+ "/ synchronous drawing:
+
+ "/ this could have changed the font height;
+ "/ must clear all below last line, if it became smaller
+ fontHeightBefore > fontHeight ifTrue:[
+ (self listLineIsVisible:(self size)) ifTrue:[
+ self clearRectangle:(margin @ (self yOfVisibleLine:nLinesShown+1))
+ corner:(width-margin) @ (height-margin).
+ ].
+ self redrawFromLine:index
+ ] ifFalse:[
+ self redrawLine:index
+ ].
"/ asynchronous:
"/ visibleLine := self listLineToVisibleLine:index.
@@ -606,7 +619,7 @@
"/ ].
]
- "Modified: 18.4.1997 / 14:52:28 / cg"
+ "Modified: / 26.7.1998 / 13:36:33 / cg"
!
characterAtLine:lineNr col:colNr
@@ -725,7 +738,7 @@
otherwise, take the information from the nonStrings arg.
(the nonStrings information is remembered to optimize later redraws & height computations)."
- |oldFirst oldLeft nonStringsBefore|
+ |oldFirst oldLeft nonStringsBefore fontHeightBefore|
(aCollection isNil and:[list isNil]) ifTrue:[
"no change"
@@ -736,6 +749,7 @@
list := aCollection.
nonStringsBefore := includesNonStrings.
+ fontHeightBefore := fontHeight.
includesNonStrings := false.
list notNil ifTrue:[
@@ -749,7 +763,9 @@
]
].
].
- (includesNonStrings ~~ nonStringsBefore) ifTrue:[self getFontParameters].
+ (includesNonStrings ~~ nonStringsBefore) ifTrue:[
+ self getFontParameters.
+ ].
widthOfWidestLine := nil. "/ i.e. unknown
oldFirst := firstLineShown.
@@ -758,10 +774,12 @@
leftOffset := 0.
realized ifTrue:[
- self computeNumberOfLinesShown.
+ (includesNonStrings ~~ nonStringsBefore) ifTrue:[
+ self computeNumberOfLinesShown.
+ ].
self contentsChanged.
"
- dont use scroll here to avoid the redraw
+ dont use scroll here to avoid double redraw
"
viewOrigin := 0 @ 0.
@@ -769,13 +787,20 @@
self originChanged:0 @ ((oldFirst - 1) * fontHeight negated).
].
shown ifTrue:[
- self redrawFromVisibleLine:1 to:nLinesShown
+ self redrawFromVisibleLine:1 to:nLinesShown.
+
+ fontHeightBefore > fontHeight ifTrue:[
+ (self listLineIsVisible:(self size)) ifTrue:[
+"/ self clearRectangle:((margin @ (self yOfVisibleLine:nLinesShown+1))
+"/ corner:(width-margin) @ (height-margin)).
+ ].
+ ]
]
]
- "Modified: 30.8.1995 / 19:07:13 / claus"
- "Modified: 5.6.1997 / 11:09:56 / cg"
- "Created: 5.6.1997 / 12:40:06 / cg"
+ "Modified: / 30.8.1995 / 19:07:13 / claus"
+ "Created: / 5.6.1997 / 12:40:06 / cg"
+ "Modified: / 26.7.1998 / 13:47:35 / cg"
!
removeIndex:lineNr
@@ -913,7 +938,10 @@
includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0.
].
].
- (includesNonStrings ~~ nonStringsBefore) ifTrue:[self getFontParameters].
+ (includesNonStrings ~~ nonStringsBefore) ifTrue:[
+ self getFontParameters.
+ self computeNumberOfLinesShown.
+ ].
"/ new - reposition horizontally if too big
widthOfWidestLine := nil. "/ i.e. unknown
@@ -963,8 +991,8 @@
]
"Modified: / 18.12.1995 / 23:27:54 / stefan"
- "Modified: / 6.3.1997 / 15:23:37 / cg"
"Created: / 22.4.1998 / 11:11:51 / cg"
+ "Modified: / 26.7.1998 / 13:46:49 / cg"
!
size
@@ -1004,10 +1032,11 @@
withoutRedrawAt:index put:aString
"change a line without redisplay"
- |w|
+ |w didIncludeNonStrings|
self checkForExistingLine:index.
list at:index put:aString.
+ didIncludeNonStrings := includesNonStrings.
includesNonStrings ifFalse:[
includesNonStrings := (aString notNil and:[aString isString not]).
] ifTrue:[
@@ -1016,6 +1045,11 @@
]
].
+ includesNonStrings ~~ didIncludeNonStrings ifTrue:[
+ self getFontParameters.
+ self computeNumberOfLinesShown
+ ].
+
widthOfWidestLine notNil ifTrue:[
aString isString ifTrue:[
w := font widthOf:aString
@@ -1029,7 +1063,7 @@
].
]
- "Modified: 22.10.1996 / 23:19:29 / cg"
+ "Modified: / 26.7.1998 / 13:00:14 / cg"
! !
!ListView methodsFor:'accessing-mvc'!
@@ -2068,6 +2102,19 @@
^ line copyTo:stop
!
+listLineIsVisible:listLineNr
+ "return true, if a particular line is visible"
+
+ |visibleLineNr "{ Class: SmallInteger }"|
+
+ shown ifFalse:[^ false].
+ listLineNr isNil ifTrue:[^ false].
+ visibleLineNr := listLineNr + 1 - firstLineShown.
+ ^ (visibleLineNr between:1 and:nLinesShown)
+
+ "Created: / 26.7.1998 / 13:24:16 / cg"
+!
+
listLineToVisibleLine:listLineNr
"given a list line (1..) return visible linenr or nil"
@@ -2246,6 +2293,15 @@
"Modified: 19.7.1996 / 20:38:54 / cg"
!
+yOfLine:lineNr
+ "given a physical lineNr, return y-coordinate in view
+ - works for fix-height fonts only"
+
+ ^ self yOfVisibleLine:(self listLineToVisibleLine:lineNr)
+
+ "Created: / 26.7.1998 / 13:23:16 / cg"
+!
+
yOfVisibleLine:visLineNr
"given a visible lineNr, return y-coordinate in view
- works for fix-height fonts only"
@@ -3704,5 +3760,5 @@
!ListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.169 1998-06-18 17:07:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.170 1998-07-27 07:56:03 cg Exp $'
! !