# HG changeset patch # User Claus Gittinger # Date 1378471043 -7200 # Node ID 9f4dfdcf92b812d7175b18b8ce72d72e4b0cf4a3 # Parent 3f24bdf8a35588b7885d83df5732a2640654261f class: ListView changed: #widthOfContents tinung for huge collections (widthOfContents computation) diff -r 3f24bdf8a355 -r 9f4dfdcf92b8 ListView.st --- a/ListView.st Fri Sep 06 14:24:32 2013 +0200 +++ b/ListView.st Fri Sep 06 14:37:23 2013 +0200 @@ -3478,7 +3478,12 @@ "return the width of the contents in pixels - used for scrollbar interface" - |max f d lengthOfLongestString lengthOfLongestLine| + |f d + start "{ Class: SmallInteger }" + stop "{ Class: SmallInteger }" + lengthOfLongestString "{ Class: SmallInteger }" + lengthOfLongestLine "{ Class: SmallInteger }" + max "{ Class: SmallInteger }"| list isNil ifTrue:[^ 0]. widthOfWidestLine notNil ifTrue:[^ widthOfWidestLine + (leftMargin * 2)]. @@ -3489,27 +3494,35 @@ ]. f := font := font onDevice:d. + start := 1. + stop := numberOfLinesForWidthOfContentsComputation + isNil + ifTrue:[ list size ] + ifFalse:[ (numberOfLinesForWidthOfContentsComputation max:1) min: list size ]. + 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 := 0. + start to:stop do:[:lineNr | + |entry w| + + entry := list at:lineNr. + entry notNil ifTrue:[ + entry isString ifTrue:[ + w := f widthOf:entry + ] ifFalse:[ + w := entry widthOn:self + ]. + max := max max:w. + ]. + ]. ] ifFalse:[ fontIsFixedWidth ifTrue:[ max := lengthOfLongestString := 0. list notNil ifTrue:[ - list do:[:line | + start to:stop do:[:lineNr | + |line| + + line := list at:lineNr. line notNil ifTrue:[ (line isString and:[line hasChangeOfEmphasis not]) ifTrue:[ line size > lengthOfLongestString ifTrue:[ @@ -3525,9 +3538,10 @@ ] ifFalse:[ max := lengthOfLongestLine := 0. list notNil ifTrue:[ - list do:[:line | - |len| - + start to:stop do:[:lineNr | + |line len| + + line := list at:lineNr. line notNil ifTrue:[ len := line size. "/ consider this a speed hack (not exact, but fast) @@ -5134,10 +5148,10 @@ !ListView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.379 2013-09-06 12:24:18 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.380 2013-09-06 12:37:23 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.379 2013-09-06 12:24:18 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.380 2013-09-06 12:37:23 cg Exp $' ! !