CDMarkObjectsImpl.mesa   
Copyright © 1984 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, September 13, 1984 5:01:54 pm PDT
DIRECTORY
CDMarkObjects,
CD,
CDOrient,
CDProperties,
Rope USING [ROPE, Equal],
Graphics USING [Context, MoveTo, LineTo, DrawArea, NewPath, Path, Translate];
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;
myLevel: CD.Level ← CD.combined;
objsProcs: REF CD.ObjectProcs;
path: Graphics.Path = CreateAlignmentMarkPath[];
DrawAlignMark: CD.DrawProc =
BEGIN
-- PROC [aptr: ApplicationPtr, pos: DesignPosition, orient: Orientation, pr: REF DrawInformation];
DrawArrowInContext: PROC [context: Graphics.Context] =
BEGIN
context.Translate[pos.x, pos.y];
CDOrient.OrientateContext[context, markOb.size, orient];
context.DrawArea[path: path];
END;
CD.DrawToContext[pr, DrawArrowInContext, myLevel];
END;
WriteMark: CD.InternalWriteProc --PROC [me: ObPtr]-- = {};
ReadMark: CD.InternalReadProc --PROC [] RETURNS [ObPtr]-- = {RETURN [markOb]};
DescribeMark: CD.DescribeProc --PROC [me: ObPtr] RETURNS [Rope.ROPE]-- =
BEGIN
RETURN["alignment mark "];
END;
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.MapPosition[
itemInCell: [x1: 0, y1: 0, x2: 0, y2: 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;
CreateAlignmentMarkPath: 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 ← DrawAlignMark;
objsProcs.internalWrite ← WriteMark;
objsProcs.internalRead ← ReadMark;
objsProcs.describe ← DescribeMark;
markOb ← NEW[CD.ObjectDefinition ← [
p: objsProcs,
size: [4, 4],
level: myLevel,
specificRef: markAtom
]];
END;
Init[];
END.