CDMarkObjectsImpl.mesa   
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Created by: Bob Mayo, June 8, 1984 12:28:34 pm PDT
Redesigned by: Jacobi, September 10, 1984 5:04:14 pm PDT
Last Edited: Jacobi, May 9, 1985 12:53:10 pm PDT
DIRECTORY
CDMarkObjects,
CD,
CDOrient,
CDProperties,
Rope USING [ROPE, Equal],
Graphics USING [Context, MoveTo, LineTo, DrawArea, NewPath, Path];
CDMarkObjectsImpl: CEDAR PROGRAM    
IMPORTS CD, CDProperties, Rope, CDOrient, Graphics
EXPORTS CDMarkObjects =
BEGIN
MarkEnumerator: TYPE = CDMarkObjects.MarkEnumerator;
--PROC [markApp: CD.ApplicationPtr] RETURNS [quit: BOOL�LSE]
markAtom: PUBLIC ATOM ← $AlignmentMarkOb;
markOb: PUBLIC CD.ObPtr;
markNameProperty: PUBLIC ATOM ← $SignalName;
myLayer: CD.Layer ← CD.combined;
objsProcs: REF CD.ObjectProcs;
path: Graphics.Path = CreateMarkPath[];
DrawMark: CD.DrawProc =
BEGIN
DrawPath: PROC [context: Graphics.Context, ob: CD.ObPtr, layer: CD.Layer] =
BEGIN
context.DrawArea[path: path];
END;
IF pr.symbolics THEN {
pr.drawContext[pr, DrawPath, markOb, pos, orient, myLayer]
}
END;
WriteMark: CD.InternalWriteProc --PROC [me: ObPtr]-- = {};
ReadMark: CD.InternalReadProc --PROC [] RETURNS [ObPtr]-- = {RETURN [markOb]};
SetMarkName: PUBLIC PROC [markApp: CD.ApplicationPtr, name: Rope.ROPE] =
BEGIN
CDProperties.PutPropOnApplication[onto: markApp, prop: markNameProperty, val: name]
END;
GetMarkName: PUBLIC PROC [markApp: CD.ApplicationPtr] RETURNS [name: Rope.ROPE] =
BEGIN
WITH CDProperties.GetPropFromApplication[from: markApp, prop: markNameProperty] SELECT FROM
r: Rope.ROPE => name ← r;
ENDCASE => name ← "* bad name *";
END;
FindMark: PUBLIC PROC [cellOb: CD.ObPtr←NIL, design: CD.Design←NIL, name: Rope.ROPE] RETURNS [app: CD.ApplicationPtr←NIL] =
BEGIN
Enumerate: MarkEnumerator = {
IF Rope.Equal[GetMarkName[markApp], name] THEN {app ← markApp; quit←TRUE}
};
[] ← EnumerateMarks[cellOb: cellOb, design: design, proc: Enumerate];
END;
GetMarkPosition: PUBLIC PROC [markApp: CD.ApplicationPtr] RETURNS [CD.DesignPosition] =
--actually finds any position of a real origin
BEGIN
RETURN [CDOrient.MapPoint[
pointInCell: [x: 0, y: 0],
cellInstPos: markApp.location,
cellSize: markApp.ob.size,
cellInstOrient: markApp.orientation
]]
END;
EnumerateMarks: PUBLIC PROC [cellOb: CD.ObPtr←NIL, design: CD.Design←NIL, proc: MarkEnumerator] RETURNS [quit: BOOLFALSE] =
BEGIN
cp: CD.CellPtr;
IF cellOb#NIL THEN cp ← NARROW[cellOb.specificRef]
ELSE IF design#NIL THEN cp ← design^.actual.first.specific
ELSE ERROR;
FOR list: CD.ApplicationList ← cp.contents, list.rest WHILE (list#NIL AND ~quit) DO
IF list.first.ob=markOb THEN {
quit ← proc[list.first]; -- do NOT catch errors
};
ENDLOOP;
END;
CreateMarkPath: PROC [] RETURNS [path: Graphics.Path] =
BEGIN
path ← Graphics.NewPath[size: 8];
Graphics.MoveTo[path, 0, 0, TRUE];
Graphics.LineTo[path, 0, 3];
Graphics.LineTo[path, 1, 2];
Graphics.LineTo[path, 3, 4];
Graphics.LineTo[path, 4, 3];
Graphics.LineTo[path, 2, 1];
Graphics.LineTo[path, 3, 0];
Graphics.LineTo[path, 0, 0];
END;
Init: PROC[] =
BEGIN
objsProcs ← CD.RegisterObjectType[markAtom];
objsProcs.drawMe ← DrawMark;
objsProcs.internalWrite ← WriteMark;
objsProcs.internalRead ← ReadMark;
objsProcs.description ← "mark";
objsProcs.symbolic ← TRUE;
markOb ← NEW[CD.ObjectDefinition ← [
p: objsProcs,
size: [4, 4],
layer: myLayer,
specificRef: markAtom
]];
END;
Init[];
END.