fixed widthOfContents with variable fonts (win32);
slightly tuned partial line drawing (horiz. scrolling)
--- a/ListView.st Fri Oct 02 19:52:40 1998 +0200
+++ b/ListView.st Sat Oct 03 23:54:14 1998 +0200
@@ -1188,11 +1188,13 @@
y := self yOfVisibleLine:startVisLineNr.
sH := lineSpacing // 2.
- self paint:bg.
- self fillRectangleX:margin
- y:y-sH
- width:(width - (margin * 2))
- height:(endVisLineNr - startVisLineNr + 1) * fontHeight + (lineSpacing - sH).
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ self paint:bg.
+ self fillRectangleX:margin
+ y:y-sH
+ width:(width - (margin * 2))
+ height:(endVisLineNr - startVisLineNr + 1) * fontHeight + (lineSpacing - sH).
+ ].
list isNil ifTrue:[^ self].
y := y + fontAscent.
@@ -1201,28 +1203,28 @@
startLine := startVisLineNr + firstLineShown - 1.
endLine := endVisLineNr + firstLineShown - 1.
(startLine == 0) ifTrue:[
- y := y + fontHeight.
- startLine := startLine + 1
+ y := y + fontHeight.
+ startLine := startLine + 1
].
(endLine > listSize) ifTrue:[
- e := listSize
+ e := listSize
] ifFalse:[
- e := endLine
+ e := endLine
].
(startLine <= e) ifTrue:[
- x := textStartLeft - leftOffset.
- self paint:fg on:bg.
- self from:startLine to:e do:[:line |
- line notNil ifTrue:[
- self displayOpaqueString:line x:x y:y
- ].
- y := y + fontHeight
- ]
+ x := textStartLeft - leftOffset.
+ self paint:fg on:bg.
+ self from:startLine to:e do:[:line |
+ line notNil ifTrue:[
+ self displayOpaqueString:line x:x y:y
+ ].
+ y := y + fontHeight
+ ]
]
- "Modified: 24.2.1996 / 16:41:48 / cg"
+ "Modified: / 3.10.1998 / 23:06:41 / cg"
!
drawLine:line atX:x inVisible:visLineNr with:fg and:bg
@@ -1233,16 +1235,18 @@
|y|
y := self yOfVisibleLine:visLineNr.
- self paint:bg.
- self fillRectangleX:margin y:y - (lineSpacing//2)
- width:(width - (2 * margin))
- height:fontHeight.
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ self paint:bg.
+ self fillRectangleX:margin y:y - (lineSpacing//2)
+ width:(width - (2 * margin))
+ height:fontHeight.
+ ].
line notNil ifTrue:[
- self paint:fg on:bg.
- self displayOpaqueString:line x:x y:(y + fontAscent)
+ self paint:fg on:bg.
+ self displayOpaqueString:line x:x y:(y + fontAscent)
]
- "Modified: 28.2.1996 / 14:46:07 / cg"
+ "Modified: / 3.10.1998 / 23:05:17 / cg"
!
drawLine:line fromX:x inVisible:visLineNr with:fg and:bg
@@ -1315,53 +1319,62 @@
drawVisibleLine:visLineNr from:startCol to:endCol with:fg and:bg
"draw part of a visible line in fg/bg"
- |y yf x lineString len characterString w sCol|
+ |y yf x lineString len characterString w sCol eCol|
(endCol >= startCol) ifTrue:[
- sCol := startCol max:1.
-
- lineString := self visibleAt:visLineNr.
-
- (lineString notNil and:[lineString isString not])
- ifTrue:[
- self drawVisibleLine:visLineNr with:fg and:bg.
- ] ifFalse:[
- x := (self xOfCol:sCol inVisibleLine:visLineNr) - leftOffset.
- y := (self yOfVisibleLine:visLineNr).
- yf := y - (lineSpacing // 2).
- len := lineString size.
- (sCol > len) ifTrue:[
- len := endCol - sCol + 1.
- self paint:bg.
- self fillRectangleX:x y:yf
- width:(fontWidth * len)
- height:fontHeight
- ] ifFalse:[
- (endCol > len) ifTrue:[
- characterString := lineString species new:endCol.
- characterString replaceFrom:1 to:len with:lineString startingAt:1.
- lineString := characterString
- ].
- self paint:bg.
- (lineString isMemberOf:String) ifTrue:[
- fontIsFixedWidth ifTrue:[
- w := (endCol - sCol + 1) * fontWidth
- ] ifFalse:[
- w := font widthOf:lineString from:sCol to:endCol
- ]
- ] ifFalse:[
- w := (lineString copyFrom:sCol to:endCol) widthOn:self
- ].
- self fillRectangleX:x y:yf
- width:w
- height:fontHeight.
- self paint:fg on:bg.
- self displayOpaqueString:lineString from:sCol to:endCol x:x y:(y + fontAscent)
- ]
- ]
+ sCol := startCol max:1.
+
+ lineString := self visibleAt:visLineNr.
+
+ (lineString notNil and:[lineString isString not])
+ ifTrue:[
+ self drawVisibleLine:visLineNr with:fg and:bg.
+ ] ifFalse:[
+ x := (self xOfCol:sCol inVisibleLine:visLineNr) - leftOffset.
+ y := (self yOfVisibleLine:visLineNr).
+ yf := y - (lineSpacing // 2).
+ len := lineString size.
+ (sCol > len) ifTrue:[
+ len := endCol - sCol + 1.
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ self paint:bg.
+ self fillRectangleX:x y:yf
+ width:(fontWidth * len)
+ height:fontHeight
+ ]
+ ] ifFalse:[
+ eCol := endCol.
+ (endCol > len) ifTrue:[
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ characterString := lineString species new:endCol.
+ characterString replaceFrom:1 to:len with:lineString startingAt:1.
+ lineString := characterString.
+ ] ifTrue:[
+ eCol := len.
+ ].
+ ].
+ (lineString isMemberOf:String) ifTrue:[
+ fontIsFixedWidth ifTrue:[
+ w := (eCol - sCol + 1) * fontWidth
+ ] ifFalse:[
+ w := font widthOf:lineString from:sCol to:eCol
+ ]
+ ] ifFalse:[
+ w := (lineString copyFrom:sCol to:eCol) widthOn:self
+ ].
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ self paint:bg.
+ self fillRectangleX:x y:yf
+ width:w
+ height:fontHeight.
+ ].
+ self paint:fg on:bg.
+ self displayOpaqueString:lineString from:sCol to:eCol x:x y:(y + fontAscent)
+ ]
+ ]
]
- "Modified: / 3.9.1998 / 21:54:01 / cg"
+ "Modified: / 3.10.1998 / 22:59:41 / cg"
!
drawVisibleLine:visLineNr from:startCol with:fg and:bg
@@ -1370,32 +1383,33 @@
|y x lineString index1 index2|
(startCol < 1) ifTrue:[
- index1 := 1
+ index1 := 1
] ifFalse:[
- index1 := startCol
+ index1 := startCol
].
y := self yOfVisibleLine:visLineNr.
x := (self xOfCol:index1 inVisibleLine:visLineNr) - leftOffset.
- self paint:bg.
- self fillRectangleX:x y:y - (lineSpacing // 2)
- width:(width + leftOffset - x)
- height:fontHeight.
-
+ backgroundAlreadyClearedColor == bg ifFalse:[
+ self paint:bg.
+ self fillRectangleX:x y:y - (lineSpacing // 2)
+ width:(width + leftOffset - x)
+ height:fontHeight.
+ ].
lineString := self visibleAt:visLineNr.
lineString notNil ifTrue:[
- lineString isString ifFalse:[
- self drawVisibleLine:visLineNr with:fg and:bg.
- ] ifTrue:[
- index2 := lineString size.
- (index2 < index1) ifTrue:[^ self].
- (index1 <= index2) ifTrue:[
- self paint:fg on:bg.
- self displayOpaqueString:lineString from:index1 to:index2 x:x y:(y + fontAscent)
- ]
- ]
+ lineString isString ifFalse:[
+ self drawVisibleLine:visLineNr with:fg and:bg.
+ ] ifTrue:[
+ index2 := lineString size.
+ (index2 < index1) ifTrue:[^ self].
+ (index1 <= index2) ifTrue:[
+ self paint:fg on:bg.
+ self displayOpaqueString:lineString from:index1 to:index2 x:x y:(y + fontAscent)
+ ]
+ ]
]
- "Modified: 12.5.1996 / 12:47:49 / cg"
+ "Modified: / 3.10.1998 / 23:07:56 / cg"
!
drawVisibleLine:visLineNr with:fg and:bg
@@ -2510,47 +2524,47 @@
widthOfWidestLine notNil ifTrue:[^ widthOfWidestLine + (leftMargin * 2)].
device isNil ifTrue:[
- "/ mhmh - really dont know yet
- f := font on:Screen current
+ "/ mhmh - really dont know yet
+ f := font on:Screen current
] ifFalse:[
- f := font := font on:device.
+ f := font := font on:device.
].
includesNonStrings ifTrue:[
- max := list
- inject:0
- into:[:maxSoFar :entry |
- (
- entry isNil ifTrue:[
- 0
- ] ifFalse:[
- entry isString ifTrue:[
- f widthOf:entry
- ] ifFalse:[
- entry widthOn:self
- ]
- ]
- ) max:maxSoFar.
- ]
+ max := list
+ inject:0
+ into:[:maxSoFar :entry |
+ (
+ entry isNil ifTrue:[
+ 0
+ ] ifFalse:[
+ entry isString ifTrue:[
+ f widthOf:entry
+ ] ifFalse:[
+ entry widthOn:self
+ ]
+ ]
+ ) max:maxSoFar.
+ ]
] ifFalse:[
- fontIsFixedWidth ifTrue:[
- max := self lengthOfLongestLine * fontWidth
- ] ifFalse:[
- max := 0.
- list notNil ifTrue:[
- list do:[:line |
- line notNil ifTrue:[
- max := max max:(line widthOn:self)
- ]
- ].
+ 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)
- ].
- ].
+ ].
+ ].
].
widthOfWidestLine := max.
^ max + (leftMargin * 2)
- "Modified: 5.7.1996 / 13:54:01 / cg"
+ "Modified: / 24.9.1998 / 18:21:08 / cg"
!
xOriginOfContents
@@ -3821,5 +3835,5 @@
!ListView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.175 1998-10-02 17:52:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.176 1998-10-03 21:54:14 cg Exp $'
! !