# HG changeset patch # User Stefan Vogel # Date 1470739275 -7200 # Node ID 303a3073eb6869f6ff647e89aecb2feaf007d498 # Parent fd5acaa8e4741e41b4b6309639695699f1cef449 #REFACTORING by stefan class: ListView changed:5 methods use #deviceFont instead of #createFontOnDevice diff -r fd5acaa8e474 -r 303a3073eb68 ListView.st --- a/ListView.st Tue Aug 09 12:40:50 2016 +0200 +++ b/ListView.st Tue Aug 09 12:41:15 2016 +0200 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - " COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved @@ -2860,24 +2858,24 @@ |hMax newDeviceFont| - newDeviceFont := gc createFontOnDevice. + newDeviceFont := gc deviceFont. hMax := newDeviceFont height. includesNonStrings == true ifTrue:[ - "/ - "/ find maximum height of lines - "/ - hMax := list inject:hMax into:[:maxSoFar :thisLine | - thisLine isNil ifTrue:[ - maxSoFar - ] ifFalse:[ - (thisLine isSingleByteString) ifTrue:[ - maxSoFar - ] ifFalse:[ - maxSoFar max:(thisLine heightOn:self) - ] - ] - ]. + "/ + "/ find maximum height of lines + "/ + hMax := list inject:hMax into:[:maxSoFar :thisLine | + thisLine isNil ifTrue:[ + maxSoFar + ] ifFalse:[ + (thisLine isSingleByteString) ifTrue:[ + maxSoFar + ] ifFalse:[ + maxSoFar max:(thisLine heightOn:self) + ] + ] + ]. ]. fontHeight := newDeviceFont maxHeight. @@ -3454,11 +3452,7 @@ heightForLines:numberOfLines "return the height of the receiver, if numberOfLines are to be displayed" - |font| - - "need a device font for query" - font := gc createFontOnDevice. - ^ numberOfLines * fontHeight + topMargin + font descent + lineSpacing + (margin * 2) + ^ numberOfLines * fontHeight + topMargin + gc deviceFont descent + lineSpacing + (margin * 2) "Created: 27.1.1996 / 16:55:39 / cg" ! @@ -3467,7 +3461,7 @@ "return the height of the contents in pixels - used for scrollbar interface" - |numLines font| + |numLines| numLines := self numberOfLines. numLines == 0 ifTrue:[^ 0]. @@ -3478,14 +3472,10 @@ "/ nFullLinesShown ~~ nLinesShown ifTrue:[ "/ numLines := numLines + 1 "/ ]. - " - need device-font for query - " - font := gc createFontOnDevice. ^ numLines * fontHeight "dont take font height here - think of LabelAndIcons" "/ + textStartTop - (lineSpacing // 2) - + (font descent) + + (gc deviceFont descent) "/ + (font descent * 2) "makes it look better" . @@ -3644,7 +3634,7 @@ ^ widthOfWidestLine + (leftMargin * 2) ]. - font := gc createFontOnDevice. + font := gc deviceFont. checkedLinesForWidthOfContentsComputation isNil ifTrue:[ start := 1. stop := list size @@ -3721,16 +3711,15 @@ widthOfLine:lineNr "return the width of a line in pixels" - |line font| + |line| list isNil ifTrue:[^ 0]. lineNr > list size ifTrue:[^ 0]. line := list at:lineNr. list isNil ifTrue:[^ 0]. - font := gc createFontOnDevice. (line isSingleByteString) ifTrue:[ - ^ font widthOf:line + ^ gc deviceFont widthOf:line ]. ^ line widthOn:self