TiogaImager.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
Michael Plass, March 21, 1986 10:39:44 am PST
Facility for rendering portions of a tioga document via the Imager.
The procedures you probably want are FormatPage, Render, and Destroy.
DIRECTORY
Atom USING [PropList],
Imager USING [Box, Context, Font, Transformation, VEC, XChar],
NodeStyle USING [Ref],
Real USING [LargestNumber],
Rope USING [ROPE],
TextNode USING [Location];
TiogaImager: CEDAR DEFINITIONS
~ BEGIN
General comments
This interface provides a typesetting abstraction that combines some of the features of TEX's boxes-and-glue model with the Interpress notion of what a character operator is.
Box: TYPE ~ REF BoxRep;
BoxRep: TYPE ~ RECORD [
nChars: INT,
bounds: Imager.Box,
expansion: Imager.VEC, -- factor applied to stretch or shrink of component boxes
escapement: Imager.VEC,
stretch: Imager.VEC,
shrink: Imager.VEC,
class: Class,
duplicate: BOOLFALSE,
data: REF,
props: Atom.PropList ← NIL
];
Making boxes
FormatLine: PROC [start: TextNode.Location, lineWidth: REAL, style: NodeStyle.Ref, screenStyle: BOOLFALSE] RETURNS [Box];
FilterProc: TYPE ~ PROC [node: TextNode.Location, level: INT, position: Imager.VEC] RETURNS [skip: BOOLFALSE, stop: BOOLFALSE, maxLineLength: REAL ← Real.LargestNumber];
InsertID: TYPE ~ {nil, head, top, normal, bottom, foot};
SepProc: TYPE ~ PROC [InsertID] RETURNS [LIST OF Box];
FormattedNodes: TYPE ~ RECORD [box: Box, resume: TextNode.Location];
FormatNodes: PROC [start: TextNode.Location, bounds: Imager.VEC, screenStyle: BOOLFALSE, filter: FilterProc ← NIL, sep: SepProc ← NIL] RETURNS [FormattedNodes];
Marks: TYPE ~ Atom.PropList;
FormattedPage: TYPE ~ RECORD [
box: Box,
The box representing the formatted page
nextLoc: TextNode.Location,
The location at which to resume formatting
marks: Marks,
The formatting information accumulated from previous pages.
pageFigure: INT
The number assigned to the page after taking style information into account
];
FormatPage: PROC [pageCounter: INT, startLoc: TextNode.Location, filter: FilterProc ← NIL, marks: Marks ← NIL, screenStyle: BOOLFALSE] RETURNS [FormattedPage];
Initially, pageCounter = 0, marks = NIL
EmptyBox: PROC [escapement: Imager.VEC ← [0,0], stretch: Imager.VEC ← [0,0], shrink: Imager.VEC ← [0,0]] RETURNS [Box];
BoxFromChar: PROC [font: Imager.Font, char: CHAR] RETURNS [Box];
BoxFromXChar: PROC [font: Imager.Font, xchar: Imager.XChar] RETURNS [Box];
BoxFromRope: PROC [font: Imager.Font, rope: Rope.ROPE] RETURNS [Box];
BoxFromList: PROC [list: LIST OF Box, xFix, yFix: Fix ← []] RETURNS [Box];
Fix: TYPE ~ RECORD [
what: {expansion, size} ← expansion,
value: REAL ← 0.0
];
Overlay: PROC [base, new: Box, offset: Imager.VEC] RETURNS [Box];
Makes a box by overlaying two boxes, possibly offset from each other.
escapement, stretch, shrink are inherited from base.
offset is from reference point of base to reference point of new
Basic operations
Composite: PROC [box: Box] RETURNS [BOOL];
Returns TRUE if UnBox operation is meaningful.
UnBox: PROC [box: Box] RETURNS [LIST OF Box];
ModifyBox: PROC [box: Box, m: Imager.Transformation] RETURNS [Box];
Render: PROC [box: Box, context: Imager.Context, position: Imager.VEC];
Renders the box into the context. The reference point of the box will be placed at the specified position.
Resolve: PROC [box: Box, p: Imager.VEC] RETURNS [TextNode.Location];
Finds the character or node pointed at.
The point p is relative to the box's reference point.
FirstLocWithin: PROC [box: Box] RETURNS [TextNode.Location];
Destroy: PROC [box: Box];
Asserts that box is no longer needed, so storage may be re-used.
Duplicate: PROC [box: Box];
Ensures that the box will not be destroyed, since there are multiple ref to it.
List manipulation
Boxes: TYPE ~ RECORD [
list: LIST OF Box ← NIL,
last: LIST OF Box ← NIL
];
AppendList: PROC [boxes: Boxes, list: LIST OF Box] RETURNS [Boxes];
Destructive list concatenation.
AppendBox: PROC [boxes: Boxes, box: Box] RETURNS [Boxes];
Destructive append.
Class record
Class: TYPE ~ REF ClassRep;
ClassRep: TYPE ~ RECORD [
Composite: PROC [box: Box] RETURNS [BOOL],
UnBox: PROC [box: Box] RETURNS [LIST OF Box],
Render: PROC [box: Box, context: Imager.Context, position: Imager.VEC],
Resolve: PROC [box: Box, p: Imager.VEC] RETURNS [TextNode.Location],
FirstLocWithin: PROC [box: Box] RETURNS [TextNode.Location],
Destroy: PROC [box: Box]
];
END.