'From Cuis 1.0 of 28 July 2009 [latest update: #242] on 30 July 2009 at 3:35:51 pm'!

!TextStyle commentStamp: '<historical>' prior: 0!
A TextStyle comprises the formatting information for composing and displaying a unit (usually a paragraph) of text.
TextStyle instances are shared. They are not modified often, and any change will affect the style's many users.
They should not be copied, but new instances might be created.

Each of my instances consists of...
	name				If available for general use in the AvailableTextStyles dictionary, it is also the key for access
	font				The default font to use
	alignment			An integer; text alignment, see TextStyle alignment:
	tabsArray			An array of integers giving tab offsets in pixels

For a concrete example, look at TextStyle default inspect!


!BalloonMorph class methodsFor: 'private' stamp: 'jmv 7/30/2009 15:16'!
getTextMorph: aStringOrMorph for: balloonOwner
	"Construct text morph."
	| m text fontToUse |
	aStringOrMorph isMorph
		ifTrue: [ m _ aStringOrMorph ]
		ifFalse: [
			text _ Text string: aStringOrMorph attribute: TextAlignment centered.
			(fontToUse _ balloonOwner balloonFont)
				ifNotNil: [
					text addAttribute: (TextFontReference toFont: fontToUse) ].
			m _ TextMorph new contents: text].
	m setToAdhereToEdge: #adjustedCenter.
	^ m! !


!FileList2 class methodsFor: 'utility' stamp: 'jmv 7/30/2009 15:18'!
textRow: aString 

	| text |
	text _ Text string: aString attribute: TextAlignment centered.
	^AlignmentMorph proportional
		addMorph:
			((TextMorph new contents: text)
				color: Color blue; 
				lock; 
				autoFitOnOff; 
				wrapFlag: true)
		fullFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1))! !


!PopUpMenu class methodsFor: 'class initialization' stamp: 'jmv 7/30/2009 15:05'!
initialize  "PopUpMenu initialize"
	MenuStyle _ TextStyle default.
	PopUpMenu allSubInstancesDo: [:m | m rescan]! !

!PopUpMenu class methodsFor: 'class initialization' stamp: 'jmv 7/30/2009 15:06'!
setMenuFontTo: aFont
	"Set the menu font as indicated"

	MenuStyle _ TextStyle withFont: aFont.
	self allSubInstancesDo: [:m | m rescan]! !


!TextStyle methodsFor: 'initialization' stamp: 'jmv 7/30/2009 14:45'!
privateName: aString
	"Only to be used from TextStyle instance creation methods"
	
	name _ aString! !

!TextStyle methodsFor: 'initialization' stamp: 'jmv 7/30/2009 14:34'!
privateName: aString font: aFont
	"Only to be used from TextStyle instance creation methods"
	
	name _ aString.
	font _ aFont.
	alignment _ 0.
	tabsArray _ TextStyle defaultTabsArray! !

!TextStyle methodsFor: 'initialization' stamp: 'jmv 7/30/2009 14:34'!
privateName: aString font: aFont alignment: code
	"Only to be used from TextStyle instance creation methods"
	
	name _ aString.
	font _ aFont.
	alignment _ code.
	tabsArray _ TextStyle defaultTabsArray! !


!TextStyle class methodsFor: 'instance creation' stamp: 'jmv 7/30/2009 14:38'!
withFont: aFont

	^self new
		privateName: aFont name font: aFont alignment: 0! !

!TextStyle class methodsFor: 'instance creation' stamp: 'jmv 7/30/2009 14:39'!
withFont: aFont name: aString alignment: code

	^self new
		privateName: aString font: aFont alignment: code! !

!TextStyle class methodsFor: 'instance accessing' stamp: 'jmv 7/30/2009 14:45'!
default: aTextStyle
	"Answer the system default text style."
	
	aTextStyle privateName: 'Default'.
	DefaultTextStyle _ aTextStyle.
	self makeAvailable: DefaultTextStyle! !

!TextStyle class methodsFor: 'examples' stamp: 'jmv 7/30/2009 14:43'!
createExamples
	"
	TextStyle createExamples
	"
	| dejaVu18 dejaVu14 dejaVu11 dejaVu10 heading1 heading2 heading3 emphasized normal |

	dejaVu18 _ AbstractFont familyName: 'DejaVu' pointSize: 18.
	dejaVu14 _ AbstractFont familyName: 'DejaVu' pointSize: 14.
	dejaVu11 _ AbstractFont familyName: 'DejaVu' pointSize: 11.
	dejaVu10 _ AbstractFont familyName: 'DejaVu' pointSize: 10.
	
	heading1 _ TextStyle withFont: dejaVu18 bold name: 'Heading 1' alignment: CharacterScanner centeredCode.
	self makeAvailable: heading1.

	heading2 _ TextStyle withFont: dejaVu18 italic name: 'Heading 2' alignment: CharacterScanner leftFlushCode.
	self makeAvailable: heading2.

	heading3 _ TextStyle withFont: dejaVu14 name: 'Heading 3' alignment: CharacterScanner leftFlushCode.
	self makeAvailable: heading3.

	emphasized _ TextStyle withFont: dejaVu10 bold name: 'Emphasized' alignment: CharacterScanner leftFlushCode.
	self makeAvailable: emphasized.
	
	normal _ TextStyle withFont: dejaVu11 name: 'Normal' alignment: CharacterScanner justifiedCode.
	self makeAvailable: normal.! !

TextStyle class removeSelector: #centeredWithFont:!
TextStyle removeSelector: #alignment:!
TextStyle removeSelector: #centered!
TextStyle removeSelector: #font:!
TextStyle removeSelector: #justified!
TextStyle removeSelector: #leftFlush!
TextStyle removeSelector: #name:!
TextStyle removeSelector: #rightFlush!

!TextStyle reorganize!
('accessing' alignment font initialLineGrid name printOn:)
('tabs and margins' nextTabXFrom:leftMargin:rightMargin: tabWidth)
('initialization' privateName: privateName:font: privateName:font:alignment:)
!

TextMorph removeSelector: #centered!
TextMorph removeSelector: #justified!
TextMorph removeSelector: #leftFlush!
TextMorph removeSelector: #rightFlush!
PopUpMenu class removeSelector: #alignment!
PopUpMenu class removeSelector: #alignment:!
PopUpMenu initialize!
PopUpMenu class removeSelector: #leftFlush!
NewParagraph removeSelector: #centered!
NewParagraph removeSelector: #justified!
NewParagraph removeSelector: #leftFlush!
NewParagraph removeSelector: #rightFlush!
"Postscript:
Leave the line above, and replace the rest of this comment by a useful one.
Executable statements should follow this comment, and should
be separated by periods, with no exclamation points (!!).
Be sure to put any further comments in double-quotes, like this one."
TextStyle initialize.
TextStyle default: StrikeFont default defaultTextStyle.
TextStyle createExamples.
PopUpMenu initialize!

