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