CDVSpecialPainters.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Ch. Jacobi August 29, 1984 4:58:52 pm PDT
last edited by Christian Jacobi, May 29, 1985 10:36:39 am PDT
DIRECTORY
Atom USING [GetPName],
CD,
CDBasics,
CDDraw,
CDOps,
CDProperties,
CDVFurtherPainters,
CDVPrivate,
CDViewer,
CDVScale,
Cursors,
Imager,
Rope USING [ROPE],
VFonts,
ViewerClasses USING [Viewer];
CDVSpecialPainters:
CEDAR
PROGRAM
IMPORTS Atom, CD, CDDraw, CDOps, CDProperties, CDVFurtherPainters, CDVScale, CDViewer, CDVPrivate, Imager, VFonts =
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.Rect = otherMe.dClip;
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
PaintProperties[me, $SignalName]
END;
PaintInstanceNames: FurtherPaintProc =
--PROC [me: CDVPrivate.MyGraphicRef, key: REF]
--monitored by ProtectedRepaint
BEGIN
PaintProperties[me, $InstanceName]
END;
PaintProperties:
PROC [me: CDVPrivate.MyGraphicRef, key:
ATOM] =
BEGIN
nameDevice: REF NameDevice ← NEW[NameDevice←[propKey: key, vPriv: me]];
internalPr: CD.DrawRef = CD.CreateDrawRef[me.actualDesign];
internalPr.interestClip ← me.deviceDrawRef.interestClip;
internalPr.devicePrivate ← nameDevice;
internalPr.drawChild ← NamedDrawChild;
internalPr.drawRect ← DontDrawRect;
internalPr.drawContext ← DontDrawContext;
internalPr.stopFlag ← me.stoprequest;
Imager.SetColor[me.viewContext, Imager.black];
CDOps.DrawDesign[design: me.actualDesign, pr: internalPr];
END;
NameDevice: TYPE = RECORD [propKey: ATOM, vPriv: MyGraphicRef];
defaultFont: Imager.Font = VFonts.DefaultFont[];
NamedDrawChild:
PROC [inst:
CD.Instance, pos:
CD.Position, orient:
CD.Orientation,
pr: CD.DrawRef] =
BEGIN
dev: REF NameDevice = NARROW[pr.devicePrivate];
text: Rope.ROPE ← NIL;
inst.ob.class.drawMe[inst, pos, orient, pr];
WITH CDProperties.GetPropFromInstance[from: inst, prop: dev.propKey]
SELECT
FROM
r: Rope.ROPE => text ← r;
a: ATOM => text ← Atom.GetPName[a];
ENDCASE => NULL;
IF text#
NIL
THEN {
vpos: CD.Position = CDVScale.DesignToViewerPosition[dev.vPriv.scale, pos];
Imager.SetXY[dev.vPriv.viewContext, [vpos.x+1, vpos.y+1]];
Imager.SetColor[dev.vPriv.viewContext, Imager.black];
Imager.SetFont[dev.vPriv.viewContext, defaultFont];
Imager.ShowRope[dev.vPriv.viewContext, text];
};
END;
DontDrawRect:
PROC [r:
CD.Rect, l:
CD.Layer, pr:
CD.DrawRef] =
BEGIN
END;
DontDrawContext:
PROC [pr:
CD.DrawRef, proc:
CD.DrawContextLayerProc, ob:
CD.Object, pos:
CD.Position, orient:
CD.Orientation, layer:
CD.Layer] =
BEGIN
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;
DrawInstanceNames: 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: $InstanceNames]
];
END;
Init:
PROC [] =
BEGIN
--protected procedures
CDVFurtherPainters.InstallFurtherPaint[keyValue: $ShowViewers, proc: ShowViewers];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $SignalNames, proc: PaintSignalNames];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $InstanceNames, proc: PaintInstanceNames];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $Temporaries, proc: PaintTemporaries];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $BackGround, proc: RepaintBackgroundComplete];
--unprotected procedures
CDVFurtherPainters.InstallFurtherPaint[keyValue: $DrawSignalNames, proc: DrawSignalNames];
CDVFurtherPainters.InstallFurtherPaint[keyValue: $DrawInstanceNames, proc: DrawInstanceNames];
END;
Init[];
END.