TAPrivateImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Rick Beach, July 6, 1982 8:15 pm
Maureen Stone April 21, 1983 10:09 am
Rick Beach, February 11, 1985 12:15:55 pm PST
DIRECTORY
FS USING [Error],
JaM USING [State, PushReal, Push, ExecuteRope],
JaMTS USING [CreateJaMTS, GetLastHandle, JaMData],
PutGet USING [FromFile],
ReadEvalPrint USING [Handle],
Rope,
TACallig,
TAGraphicsHacks,
TAPrivate,
TEditDocument USING [TEditDocumentData],
TextEdit USING [GetRope],
TextNode USING [NarrowToTextNode, Ref],
ViewerClasses,
ViewerOps;
TAPrivateImpl: CEDAR PROGRAM
IMPORTS FS, JaM, JaMTS, PutGet, Rope, TACallig, TAGraphicsHacks, TextEdit, TextNode, ViewerOps
EXPORTS TAPrivate = {
OPEN TAPrivate;
ROPE: TYPE = Rope.ROPE;
FileNotFound: PUBLIC SIGNAL = CODE;
GetDocument: PUBLIC PROCEDURE[fileName: ROPE] RETURNS[node: TextNode.Ref, fromFile: BOOLEAN] = {
viewer: ViewerClasses.Viewer;
viewer ← IF Rope.Size[fileName]=0 THEN NIL ELSE ViewerOps.FindViewer[fileName];
IF viewer # NIL THEN {
node ← NARROW[viewer.data, TEditDocument.TEditDocumentData].text;
fromFile ← FALSE; }
ELSE {
node ← PutGet.FromFile[fileName ! FS.Error => TRUSTED {SIGNAL FileNotFound}]; -- catch directory error by caller
fromFile ← TRUE; }
};
FixFileName: PUBLIC PROCEDURE[oldname, extension: ROPE] RETURNS [newname:ROPE] = {
dotPosition: INTEGER ← Rope.Find[oldname, "."];
IF dotPosition < 0 THEN
newname ← Rope.Cat[oldname, extension]
ELSE
newname ← Rope.Cat[Rope.Substr[oldname, 0, dotPosition], extension];
};
getViewer: ROPE ← ".getviewer";
loadBCD: ROPE ← ".loadbcd";
pushDC: ROPE ← ".pushdc";
popDC: ROPE ← ".popdc";
setCP: ROPE ← ".setpos";
translate: ROPE ← ".translate";
drawArea: ROPE ← ".drawarea";
drawPath: ROPE ← ".drawpath";
drawBox: ROPE ← ".drawbox";
outlinePath: ROPE ← ".calligoutlinepath";
calligRoundPen: ROPE ← ".calligroundpen";
calligRectangularPen: ROPE ← ".calligrectangularpen";
calligItalicPen: ROPE ← ".calligitalicpen";
calligEllipticalPen: ROPE ← ".calligellipticalpen";
calligShadowPen: ROPE ← ".calligshadowpen";
calligShadowPath: ROPE ← ".calligshadowpath";
drawImage: ROPE ← ".drawimage";
drawText: ROPE ← ".drawtext";
setHSVColor: ROPE ← "hsvcolor";
calligDefined: BOOLEANFALSE;
NoJaMGraphicsViewer: PUBLIC SIGNAL = CODE;
state: PUBLIC JaM.State;
InitJaMGraphics: PUBLIC PROCEDURE = {
jaMViewer: ViewerClasses.Viewer ← ViewerOps.FindViewer["JaM"];
handle: ReadEvalPrint.Handle ← IF jaMViewer=NIL
THEN JaMTS.CreateJaMTS["JaM", NIL, NIL]
ELSE JaMTS.GetLastHandle[];
IF ~calligDefined THEN {
Define the Calligraphy graphics functions which reside in TACallig.bcd
state ← NARROW[handle.clientData, JaMTS.JaMData].state;
TACallig.RegisterCallig[state];
TAGraphicsHacks.RegisterGraphicsHacks[state];
JaM.ExecuteRope[state, "(artwork) .dup 50 .dict .def .load .begin"];
JaM.ExecuteRope[state, "(.moveto) (.calligmoveto).cvx .def"];
JaM.ExecuteRope[state, "(.lineto) (.calliglineto).cvx .def"];
JaM.ExecuteRope[state, "(.curveto) (.calligcurveto).cvx .def"];
JaM.ExecuteRope[state, "(.drawpath) (.calligdrawpath).cvx .def"];
JaM.ExecuteRope[state, "(.drawarea) (.calligdrawarea).cvx .def"];
JaM.ExecuteRope[state, "(hsvcolor) (.callighsvcolor) .cvx .def"];
calligDefined ← TRUE};
};
PushDC: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, pushDC] };
PopDC: PUBLIC PROCEDURE= {
JaM.ExecuteRope[state, popDC] };
PushReal: PUBLIC PROCEDURE[r: REAL] = {
JaM.PushReal[state, r] };
DrawArea: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, drawArea] };
DrawPath: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, drawPath] };
OutlinePath: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, outlinePath] };
DrawBox: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, drawBox] };
SetCP: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, setCP] };
Translate: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, translate] };
RoundPen: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligRoundPen] };
ItalicPen: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligItalicPen] };
RectangularPen: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligRectangularPen] };
EllipticalPen: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligEllipticalPen] };
ShadowPen: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligShadowPen] };
ShadowPath: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, calligShadowPath] };
DrawImage: PUBLIC PROCEDURE[imageFileName: Rope.ROPE] = {
JaM.Push[state, imageFileName];
JaM.ExecuteRope[state, drawImage];
};
PushString: PUBLIC PROCEDURE[node: TextNode.Ref] = {
rope: ROPE ← TextEdit.GetRope[TextNode.NarrowToTextNode[node]];
IF rope#NIL THEN
JaM.Push[state, rope] };
DrawText: PUBLIC PROCEDURE = {
JaM.ExecuteRope[state, drawText] };
ExecuteNode: PUBLIC PROCEDURE[node: TextNode.Ref] = {
rope: ROPE ← TextEdit.GetRope[TextNode.NarrowToTextNode[node]];
IF rope#NIL THEN
JaM.ExecuteRope[state, rope];
};
SetHSV: PUBLIC PROCEDURE[h, s, v: REAL] = {
JaM.PushReal[state, h];
JaM.PushReal[state, s];
JaM.PushReal[state, v];
JaM.ExecuteRope[state, setHSVColor];
};
}.
Beach, February 11, 1985 8:54:02 am PST
Changes to use Cedar5.0 version of JaM and TJaMGraphics