-- NodeStyle.mesa
-- Written by Bill Paxton, January 1981
-- Last changed by Bill Paxton, 12-Jun-81  9:15:29

DIRECTORY
	TextNode,
	TextLooks,
	NameSymbolTable;

NodeStyle: DEFINITIONS =
BEGIN OPEN nodeI:TextNode, looksI:TextLooks, nsI:NameSymbolTable;

Ref: TYPE = REF Body;
Body: TYPE = RECORD [
	fontFace: FontFace ← Regular,
	fontAlphabets: FontAlphabets ← CapsAndLower,
	underlining: FontUnderlining ← None,
	lineFormatting: LineFormatting ← FlushLeft,
	styleName: nodeI.StyleName ← nodeI.nullStyleName, -- such as "TechicalNote"
	fontFamily: nsI.Name ← nsI.nullName, -- such as "TimesRoman"
	fontSize: Dist, -- in points
	leftIndent: Dist, -- all lines indent at least this much on left
	rightIndent: Dist, -- all lines indent at least this much on right
	firstIndent: Dist, -- first line indent this much more on left
	bodyIndent: Dist, -- other lines indent this much more on left
	topIndent: Dist, -- top line at least this much down from top
	bottomIndent: Dist, -- bottom baseline at least this up from bottom
	leading: Dist, -- distance between baselines
	topLeading: Dist, -- min distance from first baseline to previous
	bottomLeading: Dist, -- min distance from last baseline to next
	vshift: Dist, -- distance to raise text above baseline
	minGaps: Dist, -- min distance between tops&bottoms of lines
	minTabWidth: Dist, -- min width of space allowed for tab
	tabs: ARRAY [1..numTabs] OF Dist -- array of tab stops
	];

FontFace: TYPE = {Regular, Bold, Italic, BoldItalic};
FontAlphabets: TYPE = {CapsAndLower, CapsAndSmallCaps, LowerOnly, CapsOnly};
FontUnderlining: TYPE = {None, LettersAndDigits, Visible, All};
LineFormatting: TYPE = {FlushLeft, FlushRight, Justified, Centered};
numTabs: NAT = 20;
Dist: TYPE = REAL ← 0.0;

style: Ref; -- the current ref while executing style ops

-- ***** Operations

LoadStyle: PROC [name: nodeI.StyleName]; -- fast return if already loaded
ReloadStyle: PROC [name: nodeI.StyleName]; -- forces rereading of definition
CurrentStyle: PROC RETURNS [nodeI.StyleName];
SetStyle: PROC [name: nodeI.StyleName]; -- fast return if already current
	-- otherwise ends top dict, begins dict for named style
	-- use this to change style

Apply: PROC [ref: Ref, name, alt: nodeI.TypeName ← nodeI.nullTypeName];
	-- does SetRef[ref]
	-- does SetStyle[ref.styleName]
	-- then executes the name
		-- if name is not known and alt # nullTypeName, try it instead

ApplyLooks: PROC [ref: Ref, looks: looksI.Looks];
	-- does SetRef[ref]
	-- does SetStyle[ref.styleName]
	-- then executes the looks

StyleError: ERROR; -- can be generated by Do or in loading a style

-- ***** Initialization

Start: PROC; -- for initialization only

END.