TiogaImager.mesa
Copyright Ó 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved.
Michael Plass, March 10, 1992 2:28 pm PST
Doug Wyatt, October 28, 1991 4:07 pm 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 [Style, StyleKind],
Real USING [LargestNumber],
Rope USING [ROPE],
Tioga 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: BOOL ¬ FALSE,
data: REF,
props: Atom.PropList ¬ NIL
];
Making boxes
FormatLine: PROC [start: Tioga.Location, lineWidth: REAL, style: NodeStyle.Style] RETURNS [Box];
FilterProc: TYPE ~ PROC [node: Tioga.Location, level: INT, position: Imager.VEC] RETURNS [skip: BOOL ¬ FALSE, stop: BOOL ¬ FALSE, 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: Tioga.Location];
FormatNodes: PROC [start: Tioga.Location, bounds: Imager.VEC,
styleKind: NodeStyle.StyleKind ¬ print, filter: FilterProc ¬ NIL, sep: SepProc ¬ NIL] RETURNS [FormattedNodes];
Marks: TYPE ~ Atom.PropList;
FormattedPage: TYPE ~ RECORD [
box: Box,
The box representing the formatted page
nextLoc: Tioga.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: Tioga.Location, filter: FilterProc ¬ NIL, marks: Marks ¬ NIL, styleKind: NodeStyle.StyleKind ¬ print] 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 [Tioga.Location];
Finds the character or node pointed at.
The point p is relative to the box's reference point.
FirstLocWithin: PROC [box: Box] RETURNS [Tioga.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 [Tioga.Location],
FirstLocWithin: PROC [box: Box] RETURNS [Tioga.Location],
Destroy: PROC [box: Box]
];
END.