TreeGrapherViewer.mx
Copyright Ó 1990, 1991 by Xerox Corporation. All rights reserved.
Michael Plass, July 13, 1990 5:17 pm PDT
Documentation
Put documentation here
Cedar Primitives
(cedar-imports "TreeGrapherViewer" "TreeGrapher" "ViewerOps")
add strings to DIRECTORY and IMPORT clauses
(cedar-directory "Ascii" "ViewerClasses")
add strings to DIRECTORY clause only
(cedar-require "Install TreeGrapherViewer")
add lines to the generated require file
(define-ref-type "ViewerClasses" "Viewer")
Defines TheFoo procedure for narrowing a "Foo"
(define-ref-type "TreeGrapher" "Node")
Defines TheFoo procedure for narrowing a "Foo"
(define-ref-type "TreeGrapherViewer" "ViewerData")
Defines TheFoo procedure for narrowing a "Foo"
(define-ref-type "Scheme" "Symbol")
Defines TheFoo procedure for narrowing a "Foo"
(define-proc (make-tree-grapher)
Defines a primitive procedure that takes the specified arguments. Parenthesized argument names are optional.
"Make a new tree grapher handle"
result ← TreeGrapherViewer.NewViewerData[];
)
(define-proc (make-tree-grapher-node grapher content format fill-sizes client-data children)
"Make a new tree-grapher-node (not hooked in)"
data: TreeGrapherViewer.ViewerData ~ TheViewerData[grapher];
textFormat: TreeGrapherViewer.TextFormat ~ TreeGrapherViewer.FindFormat[data, TheSymbol[format]];
head: LIST OF ROPE ~ LIST[NIL];
last: LIST OF ROPE ← head;
node: TreeGrapher.Node;
WITH content SELECT FROM
string: String => { last ← last.rest ← LIST[RopeFromString[string]] };
pair: Pair => {
FOR tail: Any ← pair, Cdr[tail] UNTIL tail = NIL DO
last ← last.rest ← LIST[RopeFromString[TheString[Car[tail]]]];
ENDLOOP;
};
ENDCASE => Complain[content, "not a string or list of strings"];
node ← TreeGrapherViewer.NodeFromText[lines: head.rest, textFormat: textFormat, fillSizes: TheREALS[fillSizes], clientData: clientData];
FOR tail: Any ← children, Cdr[tail] UNTIL tail = NIL DO
node.children ← CONS[TheNode[Car[tail]], node.children];
ENDLOOP;
result ← node;
)
(define-proc (make-tree-grapher-viewer name grapher)
"Make a tree-grapher viewer"
data: TreeGrapherViewer.ViewerData ~ TheViewerData[grapher];
rope: ROPE ~ RopeFromString[TheString[name]];
TreeGrapher.DoLayout[data.tree, data.lp];
data.origin ← [1.0-data.tree.layout.treeBox.xmin, 1.0-data.tree.layout.treeBox.ymin];
result ← ViewerOps.CreateViewer[flavor: $TreeGrapher, info: [name: rope, hscrollable: TRUE, data: data]];
)
(define-proc (tree-grapher-set! viewer grapher)
"Set a grapher into a viewer"
data: TreeGrapherViewer.ViewerData ~ TheViewerData[grapher];
v: ViewerClasses.Viewer ~ TheViewer[viewer];
TreeGrapher.DoLayout[data.tree, data.lp];
ViewerOps.SetViewer[v, data, TRUE, $ViewerData];
)
ROPE: TYPE ~ Rope.ROPE;
TheREALS: PROC [any: Any] RETURNS [ans: LIST OF REALNIL] ~ {
last: LIST OF REALNIL;
FOR tail: Any ← any, Cdr[tail] UNTIL tail = NIL DO
new: LIST OF REAL ~ LIST[TheREAL[Car[tail]]];
IF ans = NIL THEN ans ← last ← new ELSE last ← last.rest ← new;
ENDLOOP;
};
Scheme Code