CDMakeProcSomeImpl.mesa (module for ChipNDale)
Copyright © 1985, 1986 by Xerox Corporation. All rights reserved.
by Christian Jacobi, May 9, 1985 1:58:40 pm PDT
Last Edited by: Jacobi June 20, 1986 3:36:13 pm PDT
DIRECTORY
CD,
CDCurves,
CDTexts,
CDMakeProcPrivate,
IO,
Rope;
CDMakeProcSomeImpl:
CEDAR
PROGRAM
IMPORTS CDMakeProcPrivate, IO, Rope =
BEGIN
MakeCurves:
PROC [env: CDMakeProcPrivate.Environment, ob:
CD.Object, useW:
BOOL, key: Rope.
ROPE]
RETURNS [Rope.
ROPE] =
BEGIN
r: Rope.ROPE ← Rope.Cat["CDCurves.", key, "[points: "];
list: Rope.ROPE ← NIL;
pp: CDCurves.CurvePtr ← NARROW[ob.specificRef];
n: INT ← 0;
CDMakeProcPrivate.IncludeDirectory[env, "CDCurves"];
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;
r ← Rope.Cat[r, list, "]"];
IF useW THEN r ← Rope.Cat[r, IO.PutFR[", w: %g", [integer[pp.w]]]];
r ← Rope.Cat[r, ", layer: ", CDMakeProcPrivate.LayerIdent[env, ob.layer], "].ob"];
RETURN [r];
END;
MakeSplines: CDMakeProcPrivate.ExpressionProc =
BEGIN
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateSpline"] ];
END;
MakeLines: CDMakeProcPrivate.ExpressionProc =
BEGIN
RETURN [ MakeCurves[env, NARROW[x], TRUE, "CreateLine"] ];
END;
MakePolygon: CDMakeProcPrivate.ExpressionProc =
BEGIN
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreatePolygon"] ];
END;
MakeFilledCurve: CDMakeProcPrivate.ExpressionProc =
BEGIN
RETURN [ MakeCurves[env, NARROW[x], FALSE, "CreateFilledCurve"] ];
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[$Polygon0, MakePolygon];
CDMakeProcPrivate.RegisterExpressionProc[$FilledCurve0, MakeFilledCurve];
CDMakeProcPrivate.RegisterExpressionProc[$Line0, MakeLines];
CDMakeProcPrivate.RegisterExpressionProc[$Spline0, MakeSplines];
CDMakeProcPrivate.RegisterExpressionProc[$Text, MakeText];
END.