JaMIInterpressImpl.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Tim Diebert: July 23, 1985 5:02:46 pm PDT
Michael Plass, March 13, 1986 11:24:24 am PST
DIRECTORY
Convert,
JaM,
JaMIPrivate,
Imager,
ImagerInterpress,
Rope
;
JaMIInterpressImpl: CEDAR PROGRAM
IMPORTS Convert, Imager, JaM, JaMIPrivate, ImagerInterpress, Rope
EXPORTS JaMIPrivate
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
ApplyDoPage: PUBLIC PROC [self: JaM.State] ~ { OPEN JaM;
info: JaMIPrivate.Info ¬ JaMIPrivate.GetInfo[self];
rope: ROPE ~ PopRope[self];
x: Any ~ Pop[self];
action: PROC [dc: Imager.Context] ~ {
Imager.ScaleT[dc, 0.0254/72];
info.ipenabled¬ TRUE;
info.ipdc¬ dc;
Execute[self, x];
info.ipenabled¬ FALSE;
};
ref: ImagerInterpress.Ref = ImagerInterpress.Create[rope];
IF info = NIL THEN ERROR;
ImagerInterpress.DoPage[ref, action ! UNWIND => info.ipenabled¬ FALSE];
ImagerInterpress.Close[ref];
};
ApplyWriteInterpress: PUBLIC PROC [self: JaM.State] ~ { OPEN JaM;
info: JaMIPrivate.Info ¬ JaMIPrivate.GetInfo[self];
x: Any ¬ Pop[self];
decl: Array ~ PopArray[self];
rope: ROPE ~ PopRope[self];
quit: INT ¬ 0;
pageNumber: INT ¬ 1;
action: PROC [dc: Imager.Context] ~ {
Imager.ScaleT[dc, 0.0254/72];
info.ipenabled¬ TRUE;
info.ipdc¬ dc;
JaM.PushInt[self, pageNumber];
Execute[self, x];
quit ¬ JaM.PopInt[self];
info.ipenabled¬ FALSE;
};
ref: ImagerInterpress.Ref = ImagerInterpress.Create[rope];
IF info = NIL THEN ERROR;
FOR i: NAT IN [decl.start..decl.start+decl.length) DO
d: Any ¬ JaM.AGet[decl, i];
WITH d SELECT FROM
font: Imager.Font => ImagerInterpress.DeclareFont[ref, font];
color: Imager.Color => ImagerInterpress.DeclareColor[ref, color];
pixelArray: Imager.PixelArray => ImagerInterpress.DeclarePixelArray[ref, pixelArray];
colorOperator: Imager.ColorOperator => ImagerInterpress.DeclareColorOperator[ref, colorOperator];
ENDCASE => ERROR JaM.Error[WrongType, Rope.Cat["wrong type: element ", Convert.RopeFromInt[i], " of declaration"]];
ENDLOOP;
UNTIL quit # 0 DO
ImagerInterpress.DoPage[ref, action ! UNWIND => info.ipenabled ¬ FALSE];
pageNumber ¬ pageNumber + 1;
ENDLOOP;
ImagerInterpress.Close[ref];
};
RegisterInterpress: PUBLIC PROC [self: JaM.State] ~ {
JaM.Register[self, ".makeinterpress", ApplyDoPage];
JaM.Register[self, ".writeinterpress", ApplyWriteInterpress];
};
END.