-- File: Misc.mesa
-- Last Edited by: CSChow, February 1, 1985 0:42:39 am PST
DIRECTORY
Graphics USING[Context];
Misc: CEDAR DEFINITIONS = BEGIN
MiscOneOf: TYPE = {empty, point, interval, rect};
--Intro: This interface was initially created to solve the problem of defining/constructing
-- channels for a set of components (ie. mapping into topological domain.)
--NB: All (unless stated otherwise) operations in this package return a copy of the object that is
-- TOTALLY independent (doesn't share) of their inputs (objects.) This is costly but
-- avoids a lot of possible obscure bugs from the confusion of objects sharing common subparts
--This is the window abstraction
Window: TYPE = REF WindowRep;
WindowRep: TYPE = RECORD[span: Interval, curtains: LIST OF Interval];
WindCreate: PROC[min, max: INT] RETURNS [Window];
WindAddCurtain: PROC[w: Window, curtain: Interval];
WindIsClosed: PROC[w: Window] RETURNS [BOOL];
WindPassesIntl: PROC[w: Window, intl: Interval] RETURNS [BOOL];
WindCurtainsCoverIntl: PROC[w: Window, intl: Interval] RETURNS [BOOL];
--This is the rectangle abstractions:
Rect: TYPE = REF RectRep;
RectRep: TYPE = RECORD[x, y: Interval];
RectSubtractFailure: ERROR [r1, r2: Rect];
RectCreate: PROC[xMin, yMin, xMax, yMax: INT] RETURNS[Rect];
RectCopy: PROC [r: Rect] RETURNS [Rect];
RectOneOf: PROC[r: Rect] RETURNS[MiscOneOf];
RectIntersect: PROC[r1, r2: Rect] RETURNS[Rect];
RectContainp: PROC[r1, r2: Rect] RETURNS[BOOL];
RectContainPt: PROC[r: Rect, xCoord, yCoord: INT] RETURNS [BOOL];
RectArea: PROC[r: Rect] RETURNS[NAT];
RectMakeBRect: PROC[r1, r2: Rect] RETURNS[Rect];
RectSubtract: PROC[r1, r2: Rect] RETURNS[Rect];
-- ! ERROR RectSubtractFailure if result is not a Rectangle --
RectPaint: PROC[r: Rect, context: Graphics.Context, xOffset, yOffset: REAL, scaleFactor: REAL ← 1.0, stipple: CARDINAL, noFill: BOOLFALSE];
x: PROC[r: Rect] RETURNS [Misc.Interval];
-- = {RETURN [IF r = NIL THEN NIL ELSE r.x]}
y: PROC[r: Rect] RETURNS [Misc.Interval];
-- = {RETURN [IF r = NIL THEN NIL ELSE r.y]};
xMin: PROC[r: Rect] RETURNS[INT];
yMin: PROC[r: Rect] RETURNS[INT];
xMax: PROC[r: Rect] RETURNS[INT];
yMax: PROC[r: Rect] RETURNS[INT];
--This is the interval abstractions
Interval: TYPE = REF IntervalRep;
IntervalRep: TYPE = RECORD[min, max: INT];
IntlSubtractFailure: ERROR[i1, i2: Interval];
IntlCreate: PROC[min, max: INT] RETURNS[Interval];
IntlCopy: PROC[i: Interval] RETURNS[Interval];
IntlOneOf: PROC[i: Interval] RETURNS[MiscOneOf];
IntlMakeBIntl: PROC[i1, i2: Interval] RETURNS[Interval];
IntlContainp: PROC[i1, i2: Interval] RETURNS[BOOL];
IntlContainPt: PROC[i: Interval, p: INT] RETURNS[BOOL];
IntlIntersect: PROC[i1, i2: Interval] RETURNS[Interval];
IntlLength: PROC[i: Interval] RETURNS[NAT];
IntlSubtract: PROC[i1, i2: Interval] RETURNS[Interval];
--! ERROR IntlSubtractFailure if the result is not an Interval-
min: PROC [i: Interval] RETURNS [INT];
max: PROC[i: Interval] RETURNS [INT];
END.