-- ImagerMaskContextImpl.mesa
-- Mik Lamming - July 30, 1986 5:34:19 pm PDT
Last edited by: Mik Lamming - July 31, 1986 12:16:56 pm PDT
DIRECTORY Atom, ImagerBackdoorPrivate, ImagerColor, ImagerMaskContext, Rope, ImagerDevice, ImagerBackdoor, ImagerScanConverter, ImagerPixelMap, ImagerFont, ImagerManhattan, ImagerPath, ImagerTransformation, Vector2, Imager, ImagerFontPrivate, ImagerPrivate;
ImagerMaskContextImpl: CEDAR PROGRAM
IMPORTS Atom, ImagerBackdoor, ImagerColor
EXPORTS Imager, ImagerFont, ImagerMaskContext
~ BEGIN
Class: TYPE ~ ImagerPrivate.Class;
ClassRep: PUBLIC TYPE ~ ImagerPrivate.ClassRep; -- export to Imager.ClassRep
CharMask: TYPE ~ ImagerDevice.CharMask;
Clipper: TYPE ~ ImagerBackdoor.Clipper;
Color: TYPE ~ Imager.Color;
ColorOperator: TYPE ~ Imager.ColorOperator;
Context: TYPE ~ Imager.Context;
Device: TYPE ~ ImagerDevice.Device;
DeviceBox: TYPE ~ ImagerDevice.DeviceBox;
RunProc: TYPE ~ ImagerDevice.RunProc;
DevicePath: TYPE ~ ImagerScanConverter.DevicePath;
DeviceRectangle: TYPE ~ ImagerPixelMap.DeviceRectangle;
Font: TYPE ~ ImagerFont.Font;
ManhattanPolygon: TYPE ~ ImagerManhattan.Polygon;
PathProc: TYPE ~ ImagerPath.PathProc;
PixelArray: TYPE ~ Imager.PixelArray;
Rectangle: TYPE ~ ImagerTransformation.Rectangle;
Transformation: TYPE ~ ImagerTransformation.Transformation;
TransformationRep: TYPE ~ ImagerTransformation.TransformationRep;
VEC: TYPE ~ Vector2.VEC;
XChar: TYPE ~ ImagerFont.XChar;
XStringProc: TYPE ~ ImagerFont.XStringProc;
FontImpl: TYPE ~ ImagerFontPrivate.FontImpl;
FontImplRep: PUBLIC TYPE ~ ImagerFontPrivate.FontImplRep;
IntKey: TYPE ~ ImagerBackdoor.IntKey;
RealKey: TYPE ~ ImagerBackdoor.RealKey;
-- Clipper: TYPE ~ ImagerBackdoor.Clipper;
Data: TYPE ~ REF DataRec;
DataRec:
TYPE ~
RECORD [
context: Imager.Context ← ,
lastColorRequested: Imager.Color,
maskColor: Imager.Color ← ,
active:BOOLEAN ←
];
forkViewClass: ImagerBackdoorPrivate.Class ~
NEW[ImagerBackdoorPrivate.ClassRep ← [
type: $fork,
ViewReset: ViewReset,
ViewTranslateI: ViewTranslateI,
ViewClip: ViewClip,
ViewClipRectangleI: ViewClipRectangleI,
ViewFromClient: ViewFromClient,
ClientFromView: ClientFromView,
DeviceFromView: DeviceFromView,
ViewFromDevice: ViewFromDevice,
DeviceFromClient: DeviceFromClient,
ClientFromDevice: ClientFromDevice,
MoveViewRectangle: MoveViewRectangle,
TestViewRectangle: TestViewRectangle
]];
forkClass: Class ~
NEW[ClassRep ← [
type: $MaskContext,
DoSave: MaskDoSave,
SetInt: MaskSetInt,
SetReal: MaskSetReal,
SetT: MaskSetT,
SetFont: MaskSetFont,
SetColor: MaskSetColor,
SetClipper: MaskSetClipper,
GetInt: MaskGetInt,
GetReal: MaskGetReal,
GetT: MaskGetT,
GetFont: MaskGetFont,
GetColor: MaskGetColor,
GetClipper: MaskGetClipper,
ConcatT: MaskConcatT,
Scale2T: MaskScale2T,
RotateT: MaskRotateT,
TranslateT: MaskTranslateT,
Move: MaskMove,
SetXY: MaskSetXY,
SetXYRel: MaskSetXYRel,
Show: MaskShow,
ShowText: MaskShowText,
StartUnderline: MaskStartUnderline,
MaskUnderline: MaskMaskUnderline,
CorrectMask: MaskCorrectMask,
CorrectSpace: MaskCorrectSpace,
Space: MaskSpace,
SetCorrectMeasure: MaskSetCorrectMeasure,
SetCorrectTolerance: MaskSetCorrectTolerance,
Correct: MaskCorrect,
DontCorrect: MaskDontCorrect,
SetGray: MaskSetGray,
SetSampledColor: MaskSetSampledColor,
SetSampledBlack: MaskSetSampledBlack,
MaskFill: MaskMaskFill,
MaskStroke: MaskMaskStroke,
MaskDashedStroke: MaskMaskDashedStroke,
MaskRectangle: MaskMaskRectangle,
MaskRectangleI: MaskMaskRectangleI,
MaskVector: MaskMaskVector,
MaskPixel: MaskMaskPixel,
MaskBits: MaskMaskBits,
DrawBits: MaskDrawBits,
Clip: MaskClip,
ClipRectangle: MaskClipRectangle,
ClipRectangleI: MaskClipRectangleI,
GetCP: MaskGetCP,
GetBoundingRectangle: MaskGetBoundingRectangle,
propList: Atom.PutPropOnList[NIL, $viewOperations, forkViewClass]
]];
Create:
PUBLIC PROC [context: Imager.Context, maskColor: Imager.Color, active:
BOOLEAN ←
TRUE]
RETURNS [maskContext: Imager.Context] ~ {
data: Data ← NEW[DataRec ← [context, maskColor, maskColor, active]];
RETURN[NEW[Imager.ContextRep ← [class: forkClass, state: NIL, data: data]]];
};
GetChildContext:
PUBLIC PROC [context: Imager.Context]
RETURNS [child: Imager.Context ←
NIL] ~ {
WITH context.data
SELECT
FROM
data: Data => {
child ← data.context;
};
ENDCASE;
};
SetMaskColor:
PUBLIC PROC [context: Imager.Context, maskColor: Imager.Color] ~ {
WITH context.data
SELECT
FROM
data: Data => {
data.maskColor ← maskColor;
};
ENDCASE;
};
Activated:
PUBLIC PROC [context: Imager.Context, active:
BOOLEAN ←
TRUE] ~ {
WITH context.data
SELECT
FROM
data: Data => {
class: Class ← data.context.class;
data.active ← active;
IF data.active
THEN
class.SetColor[context: data.context, color: data.maskColor]
ELSE
class.SetColor[context: data.context, color: data.lastColorRequested];
};
ENDCASE;
};
MaskDoSave:
PROC[context: Context, action:
PROC, all:
BOOL] ~ {
data: Data ← NARROW[context.data];
active: BOOLEAN ← data.active;
lastColorRequested: Imager.Color ← data.lastColorRequested;
maskColor: Imager.Color ← data.maskColor;
class: Class ← data.context.class;
class.DoSave[context: data.context, action: action, all: all];
data.maskColor ← maskColor;
data.lastColorRequested ← lastColorRequested;
data.active ← active;
};
MaskSetInt:
PROC[context: Context, key: IntKey, val:
INT] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetInt[context: data.context, key: key, val: val];
};
MaskSetReal:
PROC[context: Context, key: RealKey, val:
REAL]
~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetReal[context: data.context, key: key, val: val];
};
MaskSetT:
PROC[context: Context, m: Transformation] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetT[context: data.context, m: m];
};
MaskSetFont:
PROC[context: Context, font: Font] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetFont[context: data.context, font: font];
};
MaskSetColor:
PROC[context: Context, color: Color] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
data.lastColorRequested ← color;
IF data.active
THEN
class.SetColor[context: data.context, color: data.maskColor]
ELSE
class.SetColor[context: data.context, color: color];
};
MaskSetClipper:
PROC[context: Context, clipper: Clipper] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetClipper[context: data.context, clipper: clipper];
};
MaskGetInt:
PROC[context: Context, key: IntKey]
RETURNS[
INT] ~ {
data: Data ← NARROW[context.data];
result: INT;
class: Class ← data.context.class;
result ← class.GetInt[context: data.context, key: key];
RETURN [result]
};
MaskGetReal:
PROC[context: Context, key: RealKey]
RETURNS[
REAL] ~ {
data: Data ← NARROW[context.data];
result: REAL;
class: Class ← data.context.class;
result ← class.GetReal[context: data.context, key: key];
RETURN [result]
};
MaskGetT:
PROC[context: Context]
RETURNS[Transformation] ~ {
data: Data ← NARROW[context.data];
result: Transformation;
class: Class ← data.context.class;
result ← class.GetT[context: data.context];
RETURN [result]
};
MaskGetFont:
PROC[context: Context]
RETURNS[Font] ~ {
data: Data ← NARROW[context.data];
result: Font;
class: Class ← data.context.class;
result ← class.GetFont[context: data.context];
RETURN [result]
};
MaskGetColor:
PROC[context: Context]
RETURNS[Color] ~ {
data: Data ← NARROW[context.data];
result: Color;
class: Class ← data.context.class;
result ← class.GetColor[context: data.context];
RETURN [result]
};
MaskGetClipper:
PROC[context: Context]
RETURNS[Clipper] ~ {
data: Data ← NARROW[context.data];
result: Clipper;
class: Class ← data.context.class;
result ← class.GetClipper[context: data.context];
RETURN [result]
};
MaskConcatT:
PROC[context: Context, m: Transformation] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.ConcatT[context: data.context, m: m];
};
MaskScale2T:
PROC[context: Context, s:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Scale2T[context: data.context, s: s];
};
MaskRotateT:
PROC[context: Context, a:
REAL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.RotateT[context: data.context, a: a];
};
MaskTranslateT:
PROC[context: Context, t:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.TranslateT[context: data.context, t: t];
};
MaskMove:
PROC[context: Context, rounded:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Move[context: data.context, rounded: rounded];
};
MaskSetXY:
PROC[context: Context, p:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetXY[context: data.context, p: p];
};
MaskSetXYRel:
PROC[context: Context, v:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetXYRel[context: data.context, v: v];
};
MaskGetCP:
PROC[context: Context, rounded:
BOOL]
RETURNS[
VEC] ~ {
data: Data ← NARROW[context.data];
result: VEC;
class: Class ← data.context.class;
result ← class.GetCP[context: data.context, rounded: rounded];
RETURN [result]
};
MaskStartUnderline:
PROC[context: Context] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.StartUnderline[context: data.context];
};
MaskMaskUnderline:
PROC[context: Context, dy, h:
REAL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskUnderline[context: data.context, dy: dy, h: h];
};
MaskCorrectMask:
PROC[context: Context] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.CorrectMask[context: data.context];
};
MaskCorrectSpace:
PROC[context: Context, v:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.CorrectSpace[context: data.context, v: v];
};
MaskSpace:
PROC[context: Context, x:
REAL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Space[context: data.context, x: x];
};
MaskSetCorrectMeasure:
PROC[context: Context, v:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetCorrectMeasure[context: data.context, v: v];
};
MaskSetCorrectTolerance:
PROC[context: Context, v:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.SetCorrectTolerance[context: data.context, v: v];
};
MaskCorrect:
PROC[context: Context, action:
PROC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Correct[context: data.context, action: action];
};
MaskDontCorrect:
PROC[context: Context, action:
PROC, saveCP:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.DontCorrect[context: data.context, action: action, saveCP: saveCP];
};
MaskSetGray:
PROC[context: Context, f:
REAL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
data.lastColorRequested ← ImagerColor.ColorFromGray[f];
IF data.active
THEN
class.SetColor[context: data.context, color: data.maskColor]
ELSE
class.SetGray[context: data.context, f: f];
};
MaskSetSampledColor:
PROC[context: Context, pa: PixelArray, m: Transformation, colorOperator: ColorOperator] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
data.lastColorRequested ← ImagerColor.MakeSampledColor[pa, m, colorOperator];
IF data.active
THEN
class.SetColor[context: data.context, color: data.maskColor]
ELSE
class.SetSampledColor[context: data.context, pa: pa, m: m, colorOperator: colorOperator];
};
MaskSetSampledBlack:
PROC[context: Context, pa: PixelArray, m: Transformation, clear:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
data.lastColorRequested ← ImagerColor.MakeSampledBlack[pa, m, clear];
IF data.active
THEN
class.SetColor[context: data.context, color: data.maskColor]
ELSE
class.SetSampledBlack[context: data.context, pa: pa, m: m, clear: clear];
};
MaskClip:
PROC[context: Context, path: PathProc, oddWrap:
BOOL, exclude:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Clip[context: data.context, path: path, oddWrap: oddWrap, exclude: exclude];
};
MaskClipRectangle:
PROC[context: Context, r: Rectangle, exclude:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.ClipRectangle[context: data.context, r: r, exclude: exclude];
};
MaskClipRectangleI:
PROC[context: Context, x, y, w, h:
INTEGER, exclude:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.ClipRectangleI[context: data.context, x: x, y: y, w: w, h: h, exclude: exclude];
};
MaskShow:
PROC [context: Context, string: XStringProc, xrel:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.Show[context: data.context, string: string, xrel: xrel];
};
MaskShowText:
PROC [context: Context, text:
REF
READONLY
TEXT, start, len:
NAT, xrel:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.ShowText[context: data.context, text: text, start: start, len: len, xrel: xrel];
};
MaskMaskFill:
PROC [context: Context, path: PathProc, oddWrap:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskFill[context: data.context, path: path, oddWrap: oddWrap];
};
MaskMaskRectangle:
PROC [context: Context, r: Rectangle] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskRectangle[context: data.context, r: r];
};
MaskMaskRectangleI:
PROC [context: Context, x, y, w, h:
INTEGER] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskRectangleI[context: data.context, x: x, y: y, w: w, h: h];
};
MaskMaskStroke:
PROC [context: Context, path: PathProc, closed:
BOOL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskStroke[context: data.context, path: path, closed: closed];
};
MaskMaskVector:
PROC [context: Context, p1, p2:
VEC] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskVector[context: data.context, p1: p1, p2: p2];
};
MaskMaskDashedStroke:
PROC [context: Context, path: PathProc,
patternLen:
NAT, pattern:
PROC [i:
NAT]
RETURNS [
REAL], offset, length:
REAL] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskDashedStroke[context: data.context, path: path,
patternLen: patternLen, pattern: pattern, offset: offset, length: length];
};
MaskMaskPixel:
PROC [context: Context, pa: PixelArray] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskPixel[context: data.context, pa: pa];
};
MaskMaskBits:
PROC [context: Context, base:
LONG
POINTER, wordsPerLine:
NAT,
sMin, fMin:
NAT ← 0, sSize, fSize:
NAT, tx, ty:
INTEGER] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.MaskBits[context: data.context, base: base, wordsPerLine: wordsPerLine,
sMin: sMin, fMin: fMin, sSize: sSize, fSize: fSize, tx: tx, ty: ty];
};
MaskDrawBits:
PROC [context: Context, base:
LONG
POINTER, wordsPerLine:
NAT,
sMin, fMin:
NAT ← 0, sSize, fSize:
NAT, tx, ty:
INTEGER] ~ {
data: Data ← NARROW[context.data];
class: Class ← data.context.class;
class.DrawBits[context: data.context, base: base, wordsPerLine: wordsPerLine,
sMin: sMin, fMin: fMin, sSize: sSize, fSize: fSize, tx: tx, ty: ty];
};
MaskGetBoundingRectangle:
PROC [context: Context]
RETURNS [Rectangle] ~ {
data: Data ← NARROW[context.data];
result: Rectangle;
class: Class ← data.context.class;
result ← class.GetBoundingRectangle[context: data.context];
RETURN [result]
};
ViewReset:
PROC [context: Context] ~ {
data: Data ← NARROW[context.data];
ImagerBackdoor.ViewReset[context: data.context];
};
ViewTranslateI:
PROC [context: Context, x, y:
INTEGER] ~ {
data: Data ← NARROW[context.data];
ImagerBackdoor.ViewTranslateI[context: data.context, x:x, y:y];
};
ViewClip:
PROC [context: Context, path: PathProc, parity:
BOOL, exclude:
BOOL] ~ {
data: Data ← NARROW[context.data];
ImagerBackdoor.ViewClip[context: data.context, path: path, parity: parity, exclude: exclude];
};
ViewClipRectangleI:
PROC [context: Context, x, y, w, h:
INTEGER, exclude:
BOOL] ~ {
data: Data ← NARROW[context.data];
ImagerBackdoor.ViewClipRectangleI[context: data.context, x:x, y:y, w:w, h:h, exclude:exclude];
};
ViewFromClient:
PROC [context: Context, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.ViewFromClient[context: data.context, p:p];
};
ClientFromView:
PROC [context: Context, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.ClientFromView[context: data.context, p:p];
};
DeviceFromView:
PROC [context: Context
, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.DeviceFromView[context: data.context, p:p];
};
ViewFromDevice:
PROC [context: Context
, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.ViewFromDevice[context: data.context, p:p];
};
DeviceFromClient:
PROC [context: Context
, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.DeviceFromClient[context: data.context, p:p];
};
ClientFromDevice:
PROC [context: Context
, p:
VEC]
RETURNS [
v: VEC] ~ {
data: Data ← NARROW[context.data];
v ← ImagerBackdoor.ClientFromDevice[context: data.context, p:p];
};
MoveViewRectangle:
PROC [context: Context
, width, height, fromX, fromY, toX, toY:
INTEGER] ~ {
data: Data ← NARROW[context.data];
ImagerBackdoor.MoveViewRectangle[context: data.context, width:width, height:height, fromX:fromX, fromY:fromY, toX:toX, toY:toY];
};
TestViewRectangle:
PROC [context: Context
, x, y, w, h:
INTEGER]
RETURNS [vis: ImagerBackdoor.Visibility] ~ {
data: Data ← NARROW[context.data];
vis ← ImagerBackdoor.TestViewRectangle[context: data.context, x:x, y:y, w:w, h:h];
};
END.