BoxTreeImpl.mesa
Mcisaac, June 30, 1987 5:56:57 pm PDT
Implementation for Displaying Mathematical Expressions
DIRECTORY
BoxTree,
InternalExpr,
ImagerFont;

BoxTreeImpl: CEDAR PROGRAM
~ BEGIN
Type Definitions
EXPR: TYPE ~ InternalExpr.EXPR;
BoxTreeRep: TYPE ~
RECORD [
boundbox: ImagerFont.Extents, -- size of bounding box( what type should this be)
offset: Vector.VEC; -- offset from origin of parent box
subBoxes: LIST OF BoxTree.BOXTREE, -- list of boxes bound by this box
parentBox: BoxTree.BOXTREE, -- parent bounding box
style: BoxTree.STYLE,
expression: EXPR -- pointer to expression bound by this box
];
Display & Formatting
Format: PUBLIC PROC [expr: InternalExpr.EXPR, style: STYLE] RETURNS [BOXTREE] ~ {
returns a boxed expression formatted in user space
box : BoxTree ← NewBox[expr, style]; --create a new scaled box with pointer to expr
box.subBoxes ← GetFormat[expr]; --get formating information for expr from data base.
FOR l: LIST OF BoxTree.BOXTREE ← box.subBox, l.next DO
{
l.first.style.scale ← l.first.style.scale*box.style.scale;
l.first.parentBox ← box;
l.first.subBoxes ← Format[l.first.expression, l.first.style];
};
ENDLOOP;
IF box.subBox
THEN box.boundBox ← ComputeBox[box.subBox]
ELSE box.boundBox ←
;
};
Paint: PUBLIC PROC [boxTree: BOXTREE, context: Imager.Context, selections: LIST OF Selection];
paints a boxed expression in the imager space given by context
NewBox: PROC [expr: InternalExpr.EXPR, style: STYLE] RETURNS [BOXTREE] ~ {
create a new scaled box with pointer to expr
Return[NEW[BoxTreeRep ← [style: style, expression: expr]]];
};
GetFormat: PROC [expr: InternalExpr.EXPR] RETURNS [LIST OF BOXTREE] ~ {
returns a boxTree with expr, scale and looks field's determined from the data base
};
END.