CDVSpecialPainters.mesa (part of Chipndale)
Copyright © 1984 by Xerox Corporation. All rights reserved.
Ch. Jacobi August 29, 1984 4:58:52 pm PDT
last edited by Christian Jacobi November 5, 1984 10:23:09 am PST
DIRECTORY
Atom USING [GetPName],
CD,
CDApplications,
CDBasics,
CDDraw,
CDProperties,
CDVFurtherPainters,
CDVPrivate,
CDViewer,
CDVScale,
Cursors,
Graphics,
GraphicsOps,
Rope USING [ROPE],
ViewerClasses USING [Viewer];
CDVSpecialPainters: CEDAR PROGRAM
IMPORTS Atom, CDApplications, CDDraw, CDBasics, CDProperties, CDVFurtherPainters, CDVScale, CDViewer, CDVPrivate, Graphics =
BEGIN
-- CDVSpecialPainters implements some procedures which are called by the (viewers)-draw
-- proc of chipndale viewers
MyGraphicRef: TYPE = CDVPrivate.MyGraphicRef;
FurtherPaintProc: TYPE = CDVFurtherPainters.FurtherPaintProc;
--PROC [me: CDVPrivate.MyGraphicRef, whatChanged: REF];
ShowViewers: FurtherPaintProc =
--PROC [me: CDVPrivate.MyGraphicRef, key: REF]
--monitored by ProtectedRepaint
BEGIN
OutlineViewer: PROC [me: MyGraphicRef, other: ViewerClasses.Viewer] =
BEGIN
otherMe: MyGraphicRef = NARROW[other.data];
r: CD.DesignRect = otherMe.deviceDrawRef.worldClip;
p1: CD.Position = CDVScale.DesignToViewerPosition[me.scale, [r.x1, r.y1]];
p2: CD.Position = CDVScale.DesignToViewerPosition[me.scale, [r.x2, r.y2]];
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x+1, p2.y];
CDVPrivate.InvertArea[me, p1.x, p2.y, p2.x, p2.y+1];
CDVPrivate.InvertArea[me, p2.x, p2.y, p2.x+1, p1.y];
CDVPrivate.InvertArea[me, p2.x, p1.y, p1.x, p1.y+1];
END;
FOR l: CDViewer.ViewerList ← CDViewer.ViewersOf[me.actualDesign], l.rest WHILE l#NIL DO
IF ~l.first.iconic AND l.first#me.viewer THEN OutlineViewer[me: me, other: l.first];
ENDLOOP
END;
PaintSignalNames: FurtherPaintProc =
-- PROC [me: CDVPrivate.MyGraphicRef, key: REF]
-- monitored by ProtectedRepaint
BEGIN
DrawCommentForViewers: PROC [pos: CD.DesignPosition, text: Rope.ROPE, me: MyGraphicRef] =
BEGIN
tc: Graphics.Context ~ Graphics.CopyContext[me.viewerContext];
p: CD.Position ~ CDVScale.DesignToViewerPosition[me.scale, pos];
Graphics.SetColor[tc, Graphics.black];
Graphics.SetCP[tc, p.x, p.y];
Graphics.DrawRope[tc, text];
END;
design: CD.Design = me.actualDesign;
FOR w: CD.ApplicationList ← design^.actual.first.specific.contents, w.rest WHILE w#NIL DO
IF CDBasics.Intersect[CDApplications.ARectO[w.first], me.deviceDrawRef.worldClip] THEN
BEGIN
x: REF ← CDProperties.GetPropFromApplication[from: w.first, prop: $SignalName];
IF x=NIL THEN
x ← CDProperties.GetPropFromObject[from: w.first.ob, prop: $SignalName];
IF x#NIL THEN {
IF me.deviceDrawRef.stopFlag^ THEN EXIT;
IF ISTYPE[x, Rope.ROPE] THEN {
signame: Rope.ROPE = NARROW[x];
DrawCommentForViewers[CDBasics.BaseOfRect[CDApplications.ARectI[w.first]], signame, me]
}
ELSE IF ISTYPE[x, ATOM] THEN {
a: ATOM = NARROW[x];
signame: Rope.ROPE = Atom.GetPName[a];
DrawCommentForViewers[CDBasics.BaseOfRect[CDApplications.ARectI[w.first]], signame, me]
}
};
END
ENDLOOP;
END;
PaintTemporaries: FurtherPaintProc =
-- PROC [me: CDVPrivate.MyGraphicRef, key: REF]
--eg. former paints ticks
--called through ProtectedRepaint only
BEGIN
END;
RepaintBackgroundComplete: FurtherPaintProc =
-- PROC [me: CDVPrivate.MyGraphicRef, key: REF]
-- monitored by ProtectedRepaint
BEGIN
CDVPrivate.RepaintBackground[me, CDBasics.universe, FALSE];
END;
DrawSignalNames: FurtherPaintProc =
-- PROC [me: CDVPrivate.MyGraphicRef, key: REF]
-- called from anywhere, not monitored
BEGIN
CDDraw.InsertCommandAll[me.actualDesign,
CDDraw.Comm[cmd: ref, erase: FALSE, rect: CDBasics.universe, ref: $SignalNames]
];
END;
Init: PROC [] =
BEGIN
--protected procedures
CDVFurtherPainters.InstallFurtherPaint[keyValue: $ShowViewers, proc: ShowViewers];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $SignalNames, proc: PaintSignalNames];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $Temporaries, proc: PaintTemporaries];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $BackGround, proc: RepaintBackgroundComplete];
--unprotected procedures
CDVFurtherPainters.InstallFurtherPaint[keyValue: $DrawSignalNames, proc: DrawSignalNames];
END;
Init[];
END.