[Pkg] The Trunk: MorphicExtras-nice.125.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Oct 11 23:43:36 UTC 2013


Nicolas Cellier uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-nice.125.mcz

==================== Summary ====================

Name: MorphicExtras-nice.125
Author: nice
Time: 12 October 2013, 1:42:40.518 am
UUID: 8c46c27b-8589-438e-8ecb-a1d593fd2b89
Ancestors: MorphicExtras-nice.124

Make DisplayScanner abstract - Part 3:
Hook the concrete CanvasCharacterScanner subclass

=============== Diff against MorphicExtras-nice.124 ===============

Item was changed:
+ DisplayScanner subclass: #CanvasCharacterScanner
+ 	instanceVariableNames: 'canvas'
- CharacterScanner subclass: #CanvasCharacterScanner
- 	instanceVariableNames: 'canvas foregroundColor lineY defaultTextColor'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'MorphicExtras-Support'!
  
+ !CanvasCharacterScanner commentStamp: 'nice 10/12/2013 01:37' prior: 0!
- !CanvasCharacterScanner commentStamp: 'nice 10/6/2013 23:07' prior: 0!
  A CanvasCharacterScanner is displaying characters onto a Morphic canvas.
  
  Instance Variables
  	canvas:		<Canvas>
- 	defaultTextColor:		<Color>
- 	foregroundColor:		<Color>
- 	lineY:		<Number>
  
  canvas
  	- the canvas on which characters are displayed
  
- defaultTextColor
- 	- the default foreground color for displaying text in absence of other text attributes specification
- 
- foregroundColor
- 	- the foreground color for displaying text, taking TextColor attributes being into account
- 
- lineY
- 	- the distance between destination canvas top and current line top
  !

Item was removed:
- ----- Method: CanvasCharacterScanner>>cr (in category 'stop conditions') -----
- cr
- 	"When a carriage return is encountered, simply increment the pointer 
- 	into the paragraph."
- 
- 	pendingKernX := 0.
- 	(lastIndex < text size and: [(text at: lastIndex) = CR and: [(text at: lastIndex+1) = Character lf]])
- 		ifTrue: [lastIndex := lastIndex + 2]
- 		ifFalse: [lastIndex := lastIndex + 1].
- 	^false!

Item was removed:
- ----- Method: CanvasCharacterScanner>>crossedX (in category 'stop conditions') -----
- crossedX
- 	"This condition will sometimes be reached 'legally' during display, when, 
- 	for instance the space that caused the line to wrap actually extends over 
- 	the right boundary. This character is allowed to display, even though it 
- 	is technically outside or straddling the clipping ectangle since it is in 
- 	the normal case not visible and is in any case appropriately clipped by 
- 	the scanner."
- 
- 	"self fillLeading."
- 	^ true !

Item was removed:
- ----- Method: CanvasCharacterScanner>>defaultTextColor (in category 'private') -----
- defaultTextColor
- 	defaultTextColor ifNil:[defaultTextColor := Color black].
- 	^defaultTextColor!

Item was removed:
- ----- Method: CanvasCharacterScanner>>defaultTextColor: (in category 'private') -----
- defaultTextColor: color
- 	"This defaultTextColor inst var is equivalent to paragraphColor of DisplayScanner."
- 	defaultTextColor := color.
- !

Item was added:
+ ----- Method: CanvasCharacterScanner>>displayAnchoredMorph: (in category 'displaying') -----
+ displayAnchoredMorph: aMorph
+ 	"Yet to be defined with appropriate positionning and clipping"!

Item was removed:
- ----- Method: CanvasCharacterScanner>>displayLine:offset:leftInRun: (in category 'scanning') -----
- displayLine: textLine offset: offset leftInRun: leftInRun 
- 	"largely copied from DisplayScanner's routine"
- 
- 	| nowLeftInRun startLoc startIndex stopCondition |
- 	line := textLine.
- 	foregroundColor ifNil: [foregroundColor := Color black].
- 	leftMargin := (line leftMarginForAlignment: alignment) + offset x.
- 	rightMargin := line rightMargin + offset x.
- 	lineY := line top + offset y.
- 	lastIndex := textLine first.
- 	nowLeftInRun := leftInRun <= 0 
- 				ifTrue: 
- 					[self setStopConditions.	"also sets the font"
- 					text runLengthFor: lastIndex]
- 				ifFalse: [leftInRun]. 
- 	destX := leftMargin.
- 	runStopIndex := lastIndex + (nowLeftInRun - 1) min: line last.
- 	spaceCount := 0.
- 	[
- 			"remember where this portion of the line starts"
- 			startLoc := destX @ destY.
- 			startIndex := lastIndex.
- 
- 			"find the end of this portion of the line"
- 			stopCondition := self 
- 						scanCharactersFrom: lastIndex
- 						to: runStopIndex
- 						in: text string
- 						rightX: rightMargin
- 						stopConditions: stopConditions
- 						kern: kern.	"displaying: false"
- 
- 			"display that portion of the line"
- 			canvas 
- 				drawString: text string
- 				from: startIndex
- 				to: lastIndex
- 				at: startLoc
- 				font: font
- 				color: foregroundColor.
- 
- 			"handle the stop condition"
- 			self perform: stopCondition
- 	] whileFalse.
- 	^runStopIndex - lastIndex!

Item was added:
+ ----- Method: CanvasCharacterScanner>>displayString:from:to:at: (in category 'displaying') -----
+ displayString: string from: startIndex  to: stopIndex at: aPoint
+ 	canvas 
+ 		drawString: string
+ 		from: startIndex
+ 		to: stopIndex
+ 		at: aPoint
+ 		font: font
+ 		color: foregroundColor.!

Item was removed:
- ----- Method: CanvasCharacterScanner>>endOfRun (in category 'stop conditions') -----
- endOfRun
- 	"The end of a run in the display case either means that there is actually 
- 	a change in the style (run code) to be associated with the string or the 
- 	end of this line has been reached."
- 	| runLength |
- 
- 	lastIndex = line last ifTrue: [^true].
- 	runLength := text runLengthFor: (lastIndex := lastIndex + 1).
- 	runStopIndex := lastIndex + (runLength - 1) min: line last.
- 	self setStopConditions.
- 	^ false!

Item was added:
+ ----- Method: CanvasCharacterScanner>>fillTextBackground (in category 'displaying') -----
+ fillTextBackground
+ 	"do nothing"!

Item was removed:
- ----- Method: CanvasCharacterScanner>>paddedSpace (in category 'stop conditions') -----
- paddedSpace
- 	"Each space is a stop condition when the alignment is right justified. 
- 	Padding must be added to the base width of the space according to 
- 	which space in the line this space is and according to the amount of 
- 	space that remained at the end of the line when it was composed."
- 
- 	destX := destX + spaceWidth + kern + (line justifiedPadFor: spaceCount font: font).
- 	lastIndex := lastIndex + 1.
- 	pendingKernX := 0.
- 	^ false!

Item was removed:
- ----- Method: CanvasCharacterScanner>>setFont (in category 'private') -----
- setFont
- 	foregroundColor := self defaultTextColor.
- 	super setFont.
- 	destY := lineY + line baseline - font ascent!

Item was removed:
- ----- Method: CanvasCharacterScanner>>tab (in category 'stop conditions') -----
- tab
- 
- 	destX := (alignment = Justified and: [self leadingTab not])
- 		ifTrue:		"imbedded tabs in justified text are weird"
- 			[destX + (textStyle tabWidth - (line justifiedTabDeltaFor: spaceCount)) max: destX]
- 		ifFalse: 
- 			[textStyle nextTabXFrom: destX
- 				leftMargin: leftMargin
- 				rightMargin: rightMargin].
- 	lastIndex := lastIndex + 1.
- 	pendingKernX := 0.
- 	^ false!

Item was removed:
- ----- Method: CanvasCharacterScanner>>textColor: (in category 'text attributes') -----
- textColor: color
- 	foregroundColor := color!



More information about the Packages mailing list