ImagerIPImpl.mesa
Edited by:
Doug Wyatt, March 7, 1984 4:02:28 pm PST
DIRECTORY
Font USING [FONT, Name, RequestedTransformation],
Imager USING [Context, Error],
ImagerBasic USING [Color, ConstantColor, IntPair, IntRectangle, Pair, PathMapType, PixelArray, StrokeEnd, Transformation, Visibility],
ImagerPrivate USING [Class, ClassRep, Name, RegisterDevice],
ImagerTransform USING [Contents, TransformationRec],
IPOutput,
RefText USING [TrustTextAsRope],
Rope USING [FromChar, ROPE, Substr];
ImagerIPImpl: CEDAR PROGRAM
IMPORTS Font, Imager, ImagerPrivate, ImagerTransform, IPOutput, RefText, Rope
~ BEGIN OPEN ImagerBasic;
ROPE: TYPE ~ Rope.ROPE;
Context: TYPE ~ Imager.Context;
FONT: TYPE ~ Font.FONT;
Name: TYPE ~ ImagerPrivate.Name;
TransformationRec: TYPE ~ ImagerTransform.TransformationRec;
Master: TYPE ~ IPOutput.Master;
Init: PROC[context: Context, info: REF] ~ {
master: Master ~ IPOutput.Narrow[info];
context.data ← master;
};
GetMaster: PROC[context: Context] RETURNS[Master] ~ INLINE {
RETURN[IPOutput.Narrow[context.data]];
};
ISet: PROC[context: Context, n: Name, x: REF] ~ {
master: Master ~ GetMaster[context];
SELECT n FROM
$T => ERROR Imager.Error[$NotImplementedForThisContext];
$showVec => WITH x SELECT FROM
font: FONT => {
name: ROPE ~ font.Name[];
m: TransformationRec ~ font.RequestedTransformation[].Contents[];
master.FindFont[name];
master.MakeT[m.a, m.b, m.c, m.d, m.e, m.f];
master.ModifyFont[];
master.ISet[$showVec];
};
ENDCASE => ERROR Imager.Error[$WrongType];
$color => WITH x SELECT FROM
color: Color => WITH color SELECT FROM
c: ConstantColor => {
master.SetGray[1.0-(REAL[c.Y]/REAL[CARDINAL.LAST])];
};
ENDCASE => ERROR Imager.Error[$Unimplemented];
ENDCASE => ERROR Imager.Error[$WrongType];
$clipOutline => ERROR Imager.Error[$NotImplementedForThisContext];
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ISetReal: PROC[context: Context, n: Name, x: REAL] ~ {
master: Master ~ GetMaster[context];
SELECT n FROM
DCScpx => ERROR Imager.Error[$NotImplementedForThisContext];
DCScpy => ERROR Imager.Error[$NotImplementedForThisContext];
correctMX => ERROR Imager.Error[$NotImplementedForThisContext];
correctMY => ERROR Imager.Error[$NotImplementedForThisContext];
mediumXSize => ERROR Imager.Error[$NotImplementedForThisContext];
mediumYSize => ERROR Imager.Error[$NotImplementedForThisContext];
fieldXMin => ERROR Imager.Error[$NotImplementedForThisContext];
fieldYMin => ERROR Imager.Error[$NotImplementedForThisContext];
fieldXMax => ERROR Imager.Error[$NotImplementedForThisContext];
fieldYMax => ERROR Imager.Error[$NotImplementedForThisContext];
strokeWidth => { master.PutReal[x]; master.ISet[$strokeWidth] };
underlineStart => ERROR Imager.Error[$NotImplementedForThisContext];
amplifySpace => { master.PutReal[x]; master.ISet[$amplifySpace] };
correctShrink => { master.PutReal[x]; master.ISet[$correctShrink] };
correctTX => ERROR Imager.Error[$NotImplementedForThisContext];
correctTY => ERROR Imager.Error[$NotImplementedForThisContext];
ENDCASE => ERROR Imager.Error[$BadSelector];
};
ISetInt: PROC[context: Context, n: Name, x: INT] ~ {
master: Master ~ GetMaster[context];
SELECT n FROM
priorityImportant => { master.PutInt[x]; master.ISet[$priorityImportant] };
noImage => ERROR Imager.Error[$NotImplementedForThisContext];
strokeEnd => { master.PutInt[x]; master.ISet[$strokeEnd] };
correctPass => ERROR Imager.Error[$NotImplementedForThisContext];
ENDCASE => ERROR Imager.Error[$BadSelector];
};
SetSampledColor: PROC[context: Context, pa: PixelArray, pixelT: Transformation, colorOperator: ATOM] ~ {
ERROR Imager.Error[$Unimplemented];
};
SetSampledBlack: PROC[context: Context, pa: PixelArray, pixelT: Transformation, transparent: BOOLEAN] ~ {
ERROR Imager.Error[$Unimplemented];
};
DoSave: PROC[context: Context, body: PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginDoSaveSimpleBody[];
body[];
master.EndDoSaveSimpleBody[];
};
DoSaveAll: PROC[context: Context, body: PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginMakeSimpleCO[];
body[];
master.EndMakeSimpleCO[];
master.DoSaveAll[];
};
ConcatT: PROC[context: Context, m: Transformation] ~ {
ERROR Imager.Error[$Unimplemented];
};
TranslateT: PROC[context: Context, x, y: REAL] ~ {
master: Master ~ GetMaster[context];
master.Translate[x, y]; master.ConcatT[];
};
RotateT: PROC[context: Context, a: REAL] ~ {
master: Master ~ GetMaster[context];
master.Rotate[a]; master.ConcatT[];
};
ScaleT: PROC[context: Context, s: REAL] ~ {
master: Master ~ GetMaster[context];
master.Scale[s]; master.ConcatT[];
};
Scale2T: PROC[context: Context, sx, sy: REAL] ~ {
master: Master ~ GetMaster[context];
master.Scale2[sx, sy]; master.ConcatT[];
};
Move: PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.Move[];
};
Trans: PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.Trans[];
};
SetXY: PROC[context: Context, p: Pair] ~ {
master: Master ~ GetMaster[context];
master.SetXY[p.x, p.y];
};
IntegerSetXY: PROC[context: Context, x, y: INTEGER] ~ {
master: Master ~ GetMaster[context];
master.SetXY[x, y];
};
SetXYRel: PROC[context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
IF v.y=0 THEN master.SetXRel[v.x]
ELSE IF v.x=0 THEN master.SetYRel[v.y]
ELSE master.SetXYRel[v.x, v.y];
};
IntegerSetXYRel: PROC[context: Context, x, y: INTEGER] ~ {
master: Master ~ GetMaster[context];
IF y=0 THEN master.SetXRel[x]
ELSE IF x=0 THEN master.SetYRel[y]
ELSE master.SetXYRel[x, y];
};
GetCP: PROC [context: Context] RETURNS [cp: Pair] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
GetCPRounded: PROC[context: Context] RETURNS [cp: Pair] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
DoTrajectories: PROC[master: Master, action: PROC[Master],
pathMap: PathMapType, pathData: REF] ~ {
started: BOOLFALSE;
lp: Pair ← [0, 0];
move: PROC[p: Pair] ~ {
IF started THEN action[master] ELSE started ← TRUE;
master.MoveTo[p.x, p.y];
lp ← p;
};
line: PROC[p: Pair] ~ {
IF p.y=lp.y THEN master.LineToX[p.x]
ELSE IF p.x=lp.x THEN master.LineToY[p.y]
ELSE master.LineTo[p.x, p.y];
lp ← p;
};
curve: PROC[p1, p2, p3: Pair] ~ {
master.CurveTo[p1.x, p1.y, p2.x, p2.y, p3.x, p3.y];
lp ← p3;
};
conic: PROC[p1, p2: Pair, r: REAL] ~ {
master.ConicTo[p1.x, p1.y, p2.x, p2.y, r];
lp ← p2;
};
pathMap[pathData, move, line, curve, conic];
IF started THEN action[master];
};
MaskFill: PROC[context: Context, pathMap: PathMapType, pathData: REF] ~ {
master: Master ~ GetMaster[context];
n: INT ← 0;
action: PROC[master: Master] ~ { n ← n+1 };
DoTrajectories[master, action, pathMap, pathData];
master.MakeOutline[n];
master.MaskFill[];
};
MaskStroke: PROC[context: Context, pathMap: PathMapType, pathData: REF,
strokeWidth: REAL, strokeEnd: StrokeEnd] ~ {
master: Master ~ GetMaster[context];
action: PROC[master: Master] ~ { master.MaskStroke[] };
DoTrajectories[master, action, pathMap, pathData];
};
MaskStrokeClosed: PROC[context: Context, pathMap: PathMapType, pathData: REF,
strokeWidth: REAL] ~ {
master: Master ~ GetMaster[context];
action: PROC[master: Master] ~ { master.MaskStrokeClosed[] };
DoTrajectories[master, action, pathMap, pathData];
};
MaskVector: PROC [context: Context, x1, y1, x2, y2: REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskVector[x1, y1, x2, y2];
};
IntegerMaskVector: PROC[context: Context, x1, y1, x2, y2: INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskVector[x1, y1, x2, y2];
};
MaskRectangle: PROC[context: Context, x, y, w, h: REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskRectangle[x, y, w, h];
};
IntegerMaskRectangle: PROC[context: Context, x, y, w, h: INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskRectangle[x, y, w, h];
};
StartUnderline: PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.StartUnderline[];
};
MaskUnderline: PROC[context: Context, dy, h: REAL] ~ {
master: Master ~ GetMaster[context];
master.MaskUnderline[dy, h];
};
IntegerMaskUnderline: PROC[context: Context, dy, h: INTEGER] ~ {
master: Master ~ GetMaster[context];
master.MaskUnderline[dy, h];
};
MaskPixel: PROC[context: Context, pa: PixelArray] ~ {
ERROR Imager.Error[$Unimplemented];
};
ClipOutline: PROC[context: Context, pathMap: PathMapType, pathData: REF] ~ {
ERROR Imager.Error[$Unimplemented];
};
ExcludeOutline: PROC[context: Context, pathMap: PathMapType, pathData: REF] ~ {
ERROR Imager.Error[$Unimplemented];
};
ClipRectangle: PROC[context: Context, x, y, w, h: REAL] ~ {
ERROR Imager.Error[$Unimplemented];
};
ExcludeRectangle: PROC[context: Context, x, y, w, h: REAL] ~ {
ERROR Imager.Error[$Unimplemented];
};
IntegerClipRectangle: PROC[context: Context, x, y, w, h: INTEGER] ~ {
ERROR Imager.Error[$Unimplemented];
};
IntegerExcludeRectangle: PROC[context: Context, x, y, w, h: INTEGER] ~ {
ERROR Imager.Error[$Unimplemented];
};
ShowChar: PROC[context: Context, char: CHAR, font: FONT] ~ {
master: Master ~ GetMaster[context];
master.Show[Rope.FromChar[char]];
};
ShowCharacters: PROC[context: Context, characters: REF, font: FONT, start: INT, length: INT] ~ {
master: Master ~ GetMaster[context];
rope: ROPE ~ WITH characters SELECT FROM
text: REF TEXT => RefText.TrustTextAsRope[text],
ENDCASE => NARROW[characters];
master.Show[rope.Substr[start, length]];
};
CorrectMask: PROC[context: Context] ~ {
master: Master ~ GetMaster[context];
master.CorrectMask[];
};
CorrectSpace: PROC[context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.CorrectSpace[v.x, v.y];
};
SetCorrectMeasure: PROC[context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.SetCorrectMeasure[v.x, v.y];
};
SetCorrectTolerance: PROC [context: Context, v: Pair] ~ {
master: Master ~ GetMaster[context];
master.SetCorrectTolerance[v.x, v.y];
};
Space: PROC [context: Context, x: REAL] ~ {
master: Master ~ GetMaster[context];
master.Space[x];
};
IntegerSpace: PROC [context: Context, x: INTEGER] ~ {
master: Master ~ GetMaster[context];
master.Space[x];
};
Correct: PROC[context: Context, body: PROC] ~ {
master: Master ~ GetMaster[context];
master.BeginCorrect[];
body[];
master.EndCorrect[];
};
DrawBitmap: PROC [context: Context, base: LONG POINTER, raster: CARDINAL, area: IntRectangle] ~ {
ERROR Imager.Error[$NotYetImplemented];
};
MaskBits: PROC [context: Context, base: LONG POINTER, raster: CARDINAL, tile: IntRectangle, area: IntRectangle] ~ {
ERROR Imager.Error[$NotYetImplemented];
};
Reset: PROC [context: Context] ~ {
};
SetViewOrigin: PROC [context: Context, viewOrigin: IntPair] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
GetViewOrigin: PROC [context: Context] RETURNS [viewOrigin: IntPair] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
SetViewBox: PROC [context: Context, viewBox: IntRectangle] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
GetViewBox: PROC [context: Context] RETURNS [IntRectangle] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
ClipView: PROC [context: Context, clipBox: IntRectangle, exclude: BOOLEAN] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
MoveSurfaceRectangle: PROC [context: Context, source: IntRectangle, dest: IntPair] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
TestRectangle: PROC [context: Context, x, y, w, h: REAL] RETURNS [visibility: Visibility] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
GetSurfaceBounds: PROC [context: Context] RETURNS [IntRectangle] ~ {
ERROR Imager.Error[$NotImplementedForThisContext];
};
SpecialOp: PROC [context: Context, op: ATOM, data: REF] RETURNS [REF] ~ {
SELECT op FROM
ENDCASE => ERROR Imager.Error[$UnimplementedSpecialOp];
};
interpressClass: ImagerPrivate.Class ← NEW [ImagerPrivate.ClassRep ← [
deviceType: $Interpress,
Init: Init,
ISet: ISet,
ISetReal: ISetReal,
ISetInt: ISetInt,
SetSampledColor: SetSampledColor,
SetSampledBlack: SetSampledBlack,
DoSave: DoSave,
DoSaveAll: DoSaveAll,
ConcatT: ConcatT,
TranslateT: TranslateT,
RotateT: RotateT,
ScaleT: ScaleT,
Scale2T: Scale2T,
Move: Move,
Trans: Trans,
SetXY: SetXY,
IntegerSetXY: IntegerSetXY,
SetXYRel: SetXYRel,
IntegerSetXYRel: IntegerSetXYRel,
GetCP: GetCP,
GetCPRounded: GetCPRounded,
MaskFill: MaskFill,
MaskStroke: MaskStroke,
MaskStrokeClosed: MaskStrokeClosed,
MaskVector: MaskVector,
IntegerMaskVector: IntegerMaskVector,
MaskRectangle: MaskRectangle,
IntegerMaskRectangle: IntegerMaskRectangle,
StartUnderline: StartUnderline,
MaskUnderline: MaskUnderline,
IntegerMaskUnderline: IntegerMaskUnderline,
MaskPixel: MaskPixel,
ClipOutline: ClipOutline,
ExcludeOutline: ExcludeOutline,
ClipRectangle: ClipRectangle,
ExcludeRectangle: ExcludeRectangle,
IntegerClipRectangle: IntegerClipRectangle,
IntegerExcludeRectangle: IntegerExcludeRectangle,
ShowChar: ShowChar,
ShowCharacters: ShowCharacters,
CorrectMask: CorrectMask,
CorrectSpace: CorrectSpace,
SetCorrectMeasure: SetCorrectMeasure,
SetCorrectTolerance: SetCorrectTolerance,
Space: Space,
IntegerSpace: IntegerSpace,
Correct: Correct,
Reset: Reset,
SetViewOrigin: SetViewOrigin,
GetViewOrigin: GetViewOrigin,
SetViewBox: SetViewBox,
GetViewBox: GetViewBox,
ClipView: ClipView,
MoveSurfaceRectangle: MoveSurfaceRectangle,
TestRectangle: TestRectangle,
GetSurfaceBounds: GetSurfaceBounds,
SpecialOp: SpecialOp
]];
ImagerPrivate.RegisterDevice[interpressClass];
END.