CDMakeProcSomeImpl.mesa (module for ChipNDale)
Copyright © 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 9, 1985 1:58:40 pm PDT
last edited Christian Jacobi, October 4, 1985 11:08:16 pm PDT
DIRECTORY
CD,
CDPolygons,
CDTexts,
CDMakeProcPrivate,
IO,
Rope;
CDMakeProcSomeImpl:
CEDAR
PROGRAM
IMPORTS CDMakeProcPrivate, IO, Rope =
BEGIN
MakePolygon: CDMakeProcPrivate.ExpressionProc =
BEGIN
r: Rope.ROPE ← "CDPolygons.CreatePolygon[points: ";
list: Rope.ROPE ← NIL;
ob: CD.Object ← NARROW[x];
pp: CDPolygons.PolygonPtr ← NARROW[ob.specificRef];
n: INT ← 0;
CDMakeProcPrivate.IncludeDirectory[env, "CDPolygons"];
FOR pl:
LIST
OF
CD.Position ← pp.points, pl.rest
WHILE pl#
NIL
DO
n ← n+1;
IF n=1 THEN list ← "LIST[" ELSE list ← Rope.Cat[list, ", "];
list ← Rope.Cat[list, CDMakeProcPrivate.PosToRope[pl.first]];
ENDLOOP;
list ← Rope.Cat[list, "]"];
r ← Rope.Cat[r, list, ", lev: ", CDMakeProcPrivate.LayerIdent[env, ob.layer], "].ob"];
RETURN [r];
END;
MakeText: CDMakeProcPrivate.ExpressionProc =
BEGIN
SupportFont:
PROC [env: CDMakeProcPrivate.Environment, font: CDTexts.CDFont]
RETURNS [r: Rope.
ROPE] =
BEGIN
x: REF;
TRUSTED { x ← LOOPHOLE[font] };
r ← CDMakeProcPrivate.GlobalIdent[env, x];
IF r=
NIL
THEN {
decl: Rope.ROPE;
r ← CDMakeProcPrivate.RequestGlobalIdent[env, "font", x];
decl ← Rope.Cat[r, ": CDTexts.CDFont ← CDTexts.MakeFont[name: "];
decl ← Rope.Cat[decl, CDMakeProcPrivate.RopeToRope[tp.cdFont.supposedName], ", scale: ", IO.PutFR1["%g", IO.int[tp.cdFont.scaleI]]];
decl ← Rope.Cat[decl, "];"];
CDMakeProcPrivate.GlobalDeclaration1[env, decl];
};
END;
r: Rope.ROPE ← "CDTexts.CreateText[text: ";
fontIdent: Rope.ROPE;
ob: CD.Object ← NARROW[x];
tp: CDTexts.TextPtr ← NARROW[ob.specificRef];
fontIdent ← SupportFont[env, tp.cdFont];
CDMakeProcPrivate.IncludeDirectory[env, "CDTexts"];
r ← Rope.Cat[r, CDMakeProcPrivate.RopeToRope[tp.text], ", font: ", fontIdent];
r ← Rope.Cat[r, ", layer: ", CDMakeProcPrivate.LayerIdent[env, ob.layer], "]"];
RETURN [r];
END;
CDMakeProcPrivate.RegisterExpressionProc[$Polygon, MakePolygon];
CDMakeProcPrivate.RegisterExpressionProc[$Text, MakeText];
END.