'From Cuis 2.4 of 17 June 2010 [latest update: #509] on 2 August 2010 at 5:55:24 pm'!

!Morph methodsFor: 'geometry' stamp: 'jmv 8/2/2010 16:23'!
basicExtent: aPoint

	bounds extent = aPoint ifTrue: [^ self].
	self changed.
	bounds _ bounds topLeft extent: aPoint.
	self layoutChanged.
	self changed.
! !

!Morph methodsFor: 'geometry' stamp: 'jmv 8/2/2010 16:23'!
extent: aPoint

	self basicExtent: aPoint! !


!ImageMorph methodsFor: 'accessing' stamp: 'jmv 8/2/2010 16:23'!
borderWidth: bw
	| newExtent |
	newExtent _ 2 * bw + image extent.
	bounds extent = newExtent ifFalse: [ self basicExtent: newExtent ].
	super borderWidth: bw! !

!ImageMorph methodsFor: 'accessing' stamp: 'jmv 8/2/2010 16:23'!
image: anImage 
	self changed.
	image := anImage depth = 1 
				ifTrue: [ColorForm mappingWhiteToTransparentFrom: anImage]
				ifFalse: [anImage]. 
	self basicExtent: image extent! !


!TextEditor methodsFor: 'accessing' stamp: 'jmv 8/2/2010 17:54'!
currentParagraphStyle
	"Answer the TextStyle for the current selection or cursor location if any"
	
	| i t |
	i _ self startIndex.
	t _ paragraph text.
	^i > t size
		ifTrue: [ t styleIfApplying: emphasisHere ]
		ifFalse: [ t textStyleAt: i ]! !


!TextMorph methodsFor: 'accessing' stamp: 'jmv 8/2/2010 17:53'!
contents: stringOrText wrappedTo: width
	"Accept new text contents.  Lay it out, wrapping to width.
	Then fit my height to the result."
	self newContents: ''.
	wrapFlag _ true.
	self basicExtent: width truncated@self height.
	self newContents: stringOrText! !

!TextMorph methodsFor: 'private' stamp: 'jmv 8/2/2010 16:24'!
fit
	"Adjust my bounds to fit the text.  Should be a no-op if autoFit is not specified.
	Required after the text changes,
	or if wrapFlag is true and the user attempts to change the extent."

	| newExtent para |
	self isAutoFit 
		ifTrue: [
			newExtent := (self paragraph extent max: 9 @ text initialStyle initialLineGrid) + (0 @ 2).
			newExtent := newExtent + (2 * borderWidth).
			newExtent ~= bounds extent 
				ifTrue: [
					para := paragraph.	"Save para (layoutChanged smashes it)"
					self basicExtent: newExtent.
					paragraph := para].
			].

	"These statements should be pushed back into senders"
	self paragraph positionWhenComposed: self position.
	self changed	"Too conservative: only paragraph composition
					should cause invalidation."! !

