<div dir="ltr"><div><div>NOTE: I could have added baselineY: baselineY parameter to font displayString:... like it is in MultiDispalyScanner<br></div>BUT: there is currently a workaround in StrikeFont which is found only in the version without baselineY:<br>
</div>All this stuff is really getting funny...<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/29 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nicolas Cellier uploaded a new version of Graphics to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Graphics-nice.236.mcz" target="_blank">http://source.squeak.org/trunk/Graphics-nice.236.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Graphics-nice.236<br>
Author: nice<br>
Time: 29 September 2013, 3:37:33.253 am<br>
UUID: 38c2e6a3-d9fa-4a5b-b5e1-91a85e4afae6<br>
Ancestors: Graphics-nice.235<br>
<br>
Don't setStopConditions twice in CharacterBlockScanner and DisplayScanner in MVC compatibility methods.<br>
SharedPools are inherited in Squeak, so don't declare TextConstants in CompositionScanner.<br>
<br>
=============== Diff against Graphics-nice.235 ===============<br>
<br>
Item was changed:<br>
----- Method: CharacterBlockScanner>>buildCharacterBlockIn: (in category 'private') -----<br>
buildCharacterBlockIn: para<br>
+ "This method is used by the MVC version only."<br>
+<br>
+ | lineIndex runLength lineStop stopCondition |<br>
- | lineIndex runLength lineStop done stopCondition |<br>
"handle nullText"<br>
(para numberOfLines = 0 or: [text size = 0])<br>
ifTrue: [^ CharacterBlock new stringIndex: 1 "like being off end of string"<br>
text: para text<br>
topLeft: (para leftMarginForDisplayForLine: 1 alignment: (alignment ifNil:[textStyle alignment]))<br>
@ para compositionRectangle top<br>
extent: 0 @ textStyle lineGrid].<br>
"find the line"<br>
lineIndex := para lineIndexOfTop: characterPoint y.<br>
destY := para topAtLineIndex: lineIndex.<br>
line := para lines at: lineIndex.<br>
lastIndex := line first.<br>
-<br>
rightMargin := para rightMarginForDisplay.<br>
+ self setStopConditions. " also loads the font, alignment and all emphasis attributes "<br>
- self setStopConditions. " also loads the font and loads all emphasis attributes "<br>
<br>
-<br>
(lineIndex = para numberOfLines and:<br>
[(destY + line lineHeight) < characterPoint y])<br>
ifTrue: ["if beyond lastLine, force search to last character"<br>
self characterPointSetX: rightMargin]<br>
ifFalse: [characterPoint y < (para compositionRectangle) top<br>
ifTrue: ["force search to first line"<br>
characterPoint := (para compositionRectangle) topLeft].<br>
characterPoint x > rightMargin<br>
ifTrue: [self characterPointSetX: rightMargin]].<br>
+ destX := leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: alignment.<br>
+ nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: alignment.<br>
+ runLength := text runLengthFor: line first.<br>
+ lineStop := characterIndex "scanning for index"<br>
+ ifNil: [ line last ]. "scanning for point"<br>
+ runStopIndex := lastIndex + (runLength - 1) min: lineStop.<br>
- destX := (leftMargin := para leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment])).<br>
- nextLeftMargin:= para leftMarginForDisplayForLine: lineIndex+1 alignment: (alignment ifNil:[textStyle alignment]).<br>
- lastIndex := line first.<br>
-<br>
- self setStopConditions. "also sets font"<br>
- runLength := (text runLengthFor: line first).<br>
- characterIndex == nil<br>
- ifTrue: [lineStop := line last "characterBlockAtPoint"]<br>
- ifFalse: [lineStop := characterIndex "characterBlockForIndex"].<br>
- (runStopIndex := lastIndex + (runLength - 1)) > lineStop<br>
- ifTrue: [runStopIndex := lineStop].<br>
lastCharacterExtent := 0 @ line lineHeight.<br>
+ spaceCount := 0.<br>
- spaceCount := 0. done := false.<br>
self handleIndentation.<br>
<br>
- [done]<br>
- whileFalse:<br>
[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex<br>
in: text string rightX: characterPoint x<br>
stopConditions: stopConditions kern: kern.<br>
+ "see setStopConditions for stopping conditions for character block operations."<br>
-<br>
- "see setStopConditions for stopping conditions for character block operations."<br>
self lastCharacterExtentSetX: (font widthOf: (text at: lastIndex)).<br>
+ self perform: stopCondition] whileFalse.<br>
+<br>
+ ^characterIndex == nil<br>
- (self perform: stopCondition) ifTrue:<br>
- [characterIndex == nil<br>
ifTrue: ["characterBlockAtPoint"<br>
^ CharacterBlock new stringIndex: lastIndex text: text<br>
topLeft: characterPoint + (font descentKern @ 0)<br>
extent: lastCharacterExtent]<br>
ifFalse: ["characterBlockForIndex"<br>
^ CharacterBlock new stringIndex: lastIndex text: text<br>
topLeft: characterPoint + ((font descentKern) - kern @ 0)<br>
+ extent: lastCharacterExtent]!<br>
- extent: lastCharacterExtent]]]!<br>
<br>
Item was changed:<br>
CharacterScanner subclass: #CompositionScanner<br>
instanceVariableNames: 'spaceX spaceIndex lineHeight baseline lineHeightAtSpace baselineAtSpace'<br>
classVariableNames: ''<br>
+ poolDictionaries: ''<br>
- poolDictionaries: 'TextConstants'<br>
category: 'Graphics-Text'!<br>
<br>
!CompositionScanner commentStamp: '<historical>' prior: 0!<br>
CompositionScanners are used to measure text and determine where line breaks and space padding should occur.!<br>
<br>
Item was changed:<br>
----- Method: DisplayScanner>>displayLines:in:clippedBy: (in category 'MVC-compatibility') -----<br>
displayLines: linesInterval in: aParagraph clippedBy: visibleRectangle<br>
"The central display routine. The call on the primitive<br>
(scanCharactersFrom:to:in:rightX:) will be interrupted according to an<br>
array of stop conditions passed to the scanner at which time the code to<br>
handle the stop condition is run and the call on the primitive continued<br>
until a stop condition returns true (which means the line has<br>
terminated)."<br>
| leftInRun |<br>
"leftInRun is the # of characters left to scan in the current run;<br>
when 0, it is time to call 'self setStopConditions'"<br>
morphicOffset := 0@0.<br>
leftInRun := 0.<br>
self initializeFromParagraph: aParagraph clippedBy: visibleRectangle.<br>
ignoreColorChanges := false.<br>
foregroundColor := paragraphColor := aParagraph foregroundColor.<br>
backgroundColor := aParagraph backgroundColor.<br>
aParagraph backgroundColor isTransparent<br>
ifTrue: [fillBlt := nil]<br>
ifFalse: [fillBlt := bitBlt copy. "Blt to fill spaces, tabs, margins"<br>
fillBlt sourceForm: nil; sourceOrigin: 0@0.<br>
fillBlt fillColor: aParagraph backgroundColor].<br>
rightMargin := aParagraph rightMarginForDisplay.<br>
lineY := aParagraph topAtLineIndex: linesInterval first.<br>
bitBlt destForm deferUpdatesIn: visibleRectangle while: [<br>
linesInterval do:<br>
[:lineIndex |<br>
+ | string startIndex lastPos runLength stopCondition baselineY |<br>
- | string startIndex lastPos runLength stopCondition |<br>
line := aParagraph lines at: lineIndex.<br>
lastIndex := line first.<br>
+ leftInRun <= 0<br>
+ ifTrue: [self setStopConditions. "also sets the font, alignment and emphasisCode"<br>
+ leftInRun := text runLengthFor: line first].<br>
+ leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: alignment.<br>
+ destX := runX := leftMargin.<br>
- self setStopConditions. " causes an assignment to inst var. alignment "<br>
-<br>
- leftMargin := aParagraph leftMarginForDisplayForLine: lineIndex alignment: (alignment ifNil:[textStyle alignment]).<br>
- destX := (runX := leftMargin).<br>
- line := aParagraph lines at: lineIndex.<br>
lineHeight := line lineHeight.<br>
fillBlt == nil ifFalse:<br>
[fillBlt destX: visibleRectangle left destY: lineY<br>
width: visibleRectangle width height: lineHeight; copyBits].<br>
+ baselineY := lineY + line baseline.<br>
+ destY := baselineY - font ascent. "Should have happened in setFont"<br>
- lastIndex := line first.<br>
- leftInRun <= 0<br>
- ifTrue: [self setStopConditions. "also sets the font"<br>
- leftInRun := text runLengthFor: line first].<br>
- destY := lineY + line baseline - font ascent. "Should have happened in setFont"<br>
runLength := leftInRun.<br>
runStopIndex := lastIndex + (runLength - 1) min: line last.<br>
leftInRun := leftInRun - (runStopIndex - lastIndex + 1).<br>
spaceCount := 0.<br>
string := text string.<br>
self handleIndentation.<br>
[<br>
startIndex := lastIndex.<br>
lastPos := destX@destY.<br>
stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex<br>
in: string rightX: rightMargin stopConditions: stopConditions<br>
kern: kern.<br>
lastIndex >= startIndex ifTrue:[<br>
font displayString: string on: bitBlt<br>
from: startIndex to: lastIndex at: lastPos kern: kern].<br>
"see setStopConditions for stopping conditions for displaying."<br>
self perform: stopCondition<br>
] whileFalse.<br>
fillBlt == nil ifFalse:<br>
[fillBlt destX: destX destY: lineY width: visibleRectangle right-destX height: lineHeight; copyBits].<br>
lineY := lineY + lineHeight]]!<br>
<br>
<br>
</blockquote></div><br></div>