DIRECTORY MathExpr USING [EXPR, AtomEXPR, CompoundEXPR, AtomClass, CompoundClass, MatrixClass], MathBox USING [BOX], MathTypes USING [Style], MathRules USING [Size], Rope USING [ROPE], Imager USING [Context, Color]; MathBoxTrees: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; BoxTree: TYPE ~ Object; BoxTreeData: TYPE ~ REF BoxTreeDataRep; -- external abstract type BoxTreeDataRep: TYPE; -- internal concrete rep ObjectDisplay: TYPE ~ REF ObjectDisplayRep; -- external abstract type ObjectDisplayRep: TYPE; -- internal concrete rep Object: PROC[o: ObjectDisplay] RETURNS[Object]; Pack: PROC[o: ObjectDisplay, levels: CARDINAL] RETURNS[ObjectDisplay]; Unpack: PROC[o: ObjectDisplay, levels: CARDINAL] RETURNS[ObjectDisplay]; EltToExpr: PROC[o: ObjectDisplay, levels: CARDINAL] RETURNS[ObjectDisplay]; Selection: TYPE ~ RECORD[expr: BoxTree, color: Imager.Color, borderOnly: BOOL _ FALSE]; MakeAtomicBoxTree: PROC[tag: ATOM, class: AtomClass, value: ROPE, relBox, absBox: BOX, parent: BoxTree _ NIL] RETURNS[BoxTree]; MakeCompoundBoxTree: PROC[tag: ATOM, class: CompoundClass, subExprs: LIST OF BoxTree, relBox, absBox: BOX, parent: BoxTree _ NIL] RETURNS[BoxTree]; MakeMatrixBoxTree: PROC[tag: ATOM, class: MatrixClass, nRows, nCols: INT, elements: LIST OF BoxTree, relBox, absBox: BOX, openSym, closeSym, space: BoxTree, parent: BoxTree _ NIL] RETURNS[BoxTree]; ASRopeFromBoxTree: PROC[expr: BoxTree, flavor: ATOM _ $AS] RETURNS[ROPE]; BoxTreeFromExpr: PROC[expr: EXPR] RETURNS[BoxTree]; ExprFromBoxTree: PROC[expr: BoxTree] RETURNS[EXPR]; Copy: PROC[expr: BoxTree] RETURNS[BoxTree]; Tag: PROC[expr: BoxTree] RETURNS[ATOM]; Class: PROC[expr: BoxTree] RETURNS[ATOM]; GetSubExprs: PROC[expr: BoxTree] RETURNS[LIST OF BoxTree]; AbsBox: PROC[expr: BoxTree] RETURNS[BOX]; GetBoxTree: PROC[tag: ATOM, exprs: LIST OF BoxTree] RETURNS[BoxTree]; Format: PROC[expr: BoxTree, size: Size] RETURNS[BOX]; Paint: PROC[expr: BoxTree, context: Imager.Context, absBox: BOX, selections: LIST OF Selection]; BoxTreeFromCoords: PROC[expr: BoxTree, x, y: REAL] RETURNS[BoxTree]; Selectable: PROC[expr: BoxTree] RETURNS[BOOL]; SelectableParent: PROC[expr: BoxTree] RETURNS[BoxTree]; SelectableChild: PROC[expr: BoxTree] RETURNS[BoxTree]; SelectableSibling: PROC[expr: BoxTree] RETURNS[BoxTree]; Replace: PROC[expr, old, new: BoxTree] RETURNS[BoxTree]; ReplacePair: TYPE ~ RECORD[old, new: BoxTree]; ReplaceN: PROC[expr: BoxTree, replacements: LIST OF ReplacePair] RETURNS[BoxTree]; unable: ERROR[reason: ATOM]; noSelection: ERROR; END. > MathBoxTrees.mesa Arnon, September 7, 1989 10:20:18 am PDT Definitions for Two-Dimensional Displays of Mathematical Expressions Type Abbreviations from Imported Interfaces EXPR: TYPE ~ MathExpr.EXPR; AtomEXPR: TYPE ~ MathExpr.AtomEXPR; CompoundEXPR: TYPE ~ MathExpr.CompoundEXPR; BOX: TYPE ~ MathBox.BOX; Style: TYPE ~ MathTypes.Style; Size: TYPE ~ MathRules.Size; AtomClass: TYPE ~ MathExpr.AtomClass; CompoundClass: TYPE ~ MathExpr.CompoundClass; MatrixClass: TYPE ~ MathExpr.MatrixClass; Element Type Definitions Element Operations Extracts the Object "imbedded" in an ObjectDisplay. Trivial for an AtomDisplayObject. For a CompoundDisplayObject, descends to its "leaves" (AtomDisplayObject's), then reascends and builds the Object by applying the (constructor) method of each internal node. Pack up "depth n leaf subtrees" of a CompoundDisplayObject Unpack the leaves of a CompoundDisplayObject "to n levels" Convert a BoxTree to general expression representation Domain Operations The editor for this domain, either implicitly or explicitly, views an element as a pureBoxTree, in which all subBoxes are selectable. Direct manipulation of a displayed BoxTree may be supported, or in the worst case you can EltToExpr a BoxTree, edit it as a string, and parse it back in. Selection Type Definitions Display Expression Constructors effects: Constructs and returns a new atomic display expression. effects: Constructs and returns a new compound display expression. effects: Constructs and returns a new matrix display expression. Parse/UnParse Routines effects: Returns a ROPE in selected format effects: Constructs and returns a new display expression from expr. All Display formatting information is set to default values. effects: Constructs and returns a new EXPR from expr. effects: Returns a distinct copy of expr. Selectors effects: Returns tag associated with expr. effects: Returns class of expr. effects: Returns subexpressions for expr. Returns NIL if no subexpressions exist. List Operations effects: Returns the BoxTree in exprs associated with tag. SIGNALS exprNotFound if no association exists. Format and Paint modifies: expr effects: expr is updated into a "paintable" form. Returns a bounding box for expr. SIGNALS unable[reason: ATOM] if Formatting can not be completed. modifies: expr effects: Displays expr in context, bounded by absBox. Updates absolute bounding boxes (viewer coords). SIGNALS unable[reason: ATOM] if Painting cannot be completed. Selection Operations effects: Returns the subexpression associated with coordinates [x, y] in expression expr. SIGNALS noSelection if no association exists. effects: Returns TRUE iff expr is selectable. effects: Returns the parent (enclosing expression) of expr. SIGNALS noSelection if no selectable parent exists. effects: Returns a child expressions (subexpression) for expr. SIGNALS noSelection if no selectable child exists. effects: Returns the "next" sibling expression from expr. SIGNALS noSelection if no selectable sibling exists. effects: Returns a copy of display expression expr with new substituted for old. caveats: Return value must be reformatted before Paint[]'ing. Note that new is used (not a copy). effects: Returns a copy of display expression expr with new substitured for old for each pair in replacements. caveats: Return value must be reformatted before Paint[]'ing. Note that the "new" components of replace pairs are used (not copies). Signals & Errors Κ#•NewlineDelimiter ™Jšœ™J™(J˜JšΟnD™DJ˜šΟk ˜ Jšœ žœžœA˜UJšœžœžœ˜Jšœ žœ ˜Jšœ žœ˜Jšœžœžœ˜Jšœžœ˜—J˜š œžœž œ˜!J˜Jšž˜J˜—headš+™+Jšžœžœžœ˜J˜Jšžœžœ žœ™Jšœ žœ™#Jšœžœ™+Jšžœžœ žœ™Jšœžœ™Jšœžœ™J™Jšœ žœ™%Jšœžœ™-Jšœ žœ™)J˜—š™Icodešœ žœ ˜L˜Lšœ žœžœΟc˜BLšœžœŸ˜/L˜LšœžœžœŸ˜FLšœžœŸ˜1—š™šœžœžœ ˜/Lšœ…™…L™—šœžœžœžœ˜FLšœ:™:L™—šœžœžœžœ˜HLšœ:™:L™—š œžœžœžœ˜KL™6——šœ ™Lšœ ™ —K™K™K™K™K™š™Lš œ žœžœ1žœžœ˜W—š™šœžœžœžœžœžœžœ ˜€LšœA™AL˜—šœžœžœ"žœžœžœžœžœ ˜“LšœC™CL™—šœžœžœ$žœ žœžœžœ7žœžœ ˜ΖLšœA™AL™——š™š œžœžœžœžœ˜ILšœ+™+L™—šœžœžœžœ ˜3LšœD™D—™IL™—šœžœžœžœ˜3Lšœ6™6L˜—šœžœžœ ˜+Lšœ*™*—L™—š ™ šœžœžœžœ˜'Lšœ+™+L™—šœžœžœžœ˜)Lšœ ™ L™—Lš  œžœžœžœžœ ˜:šœžœžœžœ˜)Lšœ*™*Lšœ1™1——š™š  œžœžœ žœžœ žœ ˜ELšœ:™:Lšœ7™7L˜——š™šœžœžœžœ˜5Lšœ™Lšœ3™3Lšœ*™*LšœJ™J—š œžœ1žœžœžœ ˜aLšœ™Lšœ6™6Lšœ:™:LšœG™GL™——š™šœžœžœžœ ˜DLšœ\™\L™7L™—š œžœžœžœ˜.Lšœ-™-L™—šœžœžœ ˜7Lšœ;™;Lšœ<™™>L™—šœžœžœ ˜8LšœR™RL™=Lšœ-™-L™—Lšœ žœžœ˜.š œžœžœžœžœ ˜RLšœ9™9LšœA™AL™=LšœP™P——š™Lšœžœ žœ˜šœ žœ˜L˜——šžœ˜L˜˜L˜J˜J˜——J˜—…— πQ