-- File: IPCoVerifier.mesa
-- Last Edited by: CSChow, February 2, 1985 1:59:31 am PST
DIRECTORY
IPCoTab USING [Component],
Graphics USING[Context],
Misc USING [Rect],
IPConstants USING[Gray],
OrderedSymbolTableRef USING[Table];
IPCoVerifier: CEDAR DEFINITIONS = BEGIN
-- Intro: This interface takes a set of components on a place and verifiy if they intersects
-- or not. During the process it also determines the `proper outline' of the components,
-- ie. one that actually contains the component without intersecting other 'outlines'
Ref: TYPE = REF Rep;
CompItem: TYPE = REF CompItemRep;
CompItemRep: TYPE = RECORD[comp: IPCoTab.Component, hint: RECORD[sw, se, ne, nw: BOOLFALSE]];
Rep: TYPE = RECORD[yOrdered: BOOL, comps: Comps, bRect: Misc.Rect ← NIL];
Comps: TYPE = REF CompsRep;
CompsRep: TYPE = RECORD[tab: OrderedSymbolTableRef.Table];
EachCompItemAction: TYPE = PROC[cI: CompItem] RETURNS[quit: BOOLFALSE];
Create: PROC[yOrdered: BOOLTRUE] RETURNS[Ref];
--If yOrdered is true then the components will ordered by their lower y-coordinates
-- else their lower x-coordinates.
Destroy: PROC [r: Ref];
--Invalidates r and frees up the space
InsertComponent: PROC[r: Ref, co: IPCoTab.Component];
--Add the component to r.
CompItems: PROC[r: Ref, p: EachCompItemAction];
--Enumerate the Component Items of r in increasing order until p returns true
-- or all Component Items are enumerated.
GetBRect: PROC[r: Ref] RETURNS [Misc.Rect];
--Return the rectangle that just contains all the inserted components
Verify: PROC [r: Ref] RETURNS[overlaps: LIST OF Misc.Rect];
--Compute any overlappings between the components if any. Also decide on the
-- outline for the components, eg. if se in the hint of the component item is true this
-- indicates that corner of the component should be retracted. The hints are decided so
-- that there are no overlaps between the outline of the components and that the
-- componets take on the maximum possible space. (NB: The outline always contains
-- the component, but the converse is not true)
PaintSelf: PROC[r: Ref, context: Graphics.Context, xOffset, yOffset: REAL, scaleFactor: REAL ← 1.0, stipple: CARDINAL ← IPConstants.Gray, drawOutline: BOOLTRUE, drawComp:BOOLFALSE, showCompName: BOOLTRUE];
--if drawOutline is true then the outline (based on the hint) will be drawn;
-- if drawComp is true then the shape of the actual component will be drawn.
END.