CDVSpecialPainters.mesa (part of ChipNDale)
Copyright © 1984, 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi August 29, 1984 4:58:52 pm PDT
Last edited by: Christian Jacobi, March 3, 1987 3:41:47 pm PST
DIRECTORY
Atom USING [GetPName],
CD,
CDBasics,
CDDrawQueue,
CDOps,
CDProperties,
CDViewerBackdoor,
CDVPrivate,
CDViewer,
CDVScale,
Cursors,
Imager,
Rope USING [ROPE],
VFonts,
ViewerClasses USING [Viewer];
CDVSpecialPainters: CEDAR PROGRAM
IMPORTS Atom, CD, CDBasics, CDDrawQueue, CDOps, CDProperties, CDViewerBackdoor, CDVScale, CDViewer, CDVPrivate, Imager, VFonts =
BEGIN
-- CDVSpecialPainters implements some procedures which are called by the (viewers)-draw
-- proc of ChipNDale viewers
VRef: TYPE = CDVPrivate.VRef;
FurtherPaintProc: TYPE = CDViewerBackdoor.FurtherPaintProc;
--PROC [me: CDVPrivate.VRef, whatChanged: REF];
ShowViewers: FurtherPaintProc = {
--PROC [me: CDVPrivate.VRef, key: REF]
--monitored by ProtectedRepaint
OutlineViewer: PROC [me: VRef, other: ViewerClasses.Viewer] = {
otherMe: VRef = 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];
};
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
};
PaintSignalNames: FurtherPaintProc = {
--PROC [me: CDVPrivate.VRef, key: REF]
--monitored by ProtectedRepaint
PaintProperties[me, $SignalName]
};
PaintInstanceNames: FurtherPaintProc = {
--PROC [me: CDVPrivate.VRef, key: REF]
--monitored by ProtectedRepaint
PaintProperties[me, $InstanceName]
};
PaintProperties: PROC [me: CDVPrivate.VRef, key: ATOM] = {
nameDevice: REF NameDevice ← NEW[NameDevice←[propKey: key, vPriv: me]];
internalPr: CD.DrawRef = CD.CreateDrawRef[[
design: me.actualDesign,
interestClip: me.dClip,
devicePrivate: nameDevice,
drawChild: NamedDrawChild,
drawRect: DontDrawRect,
drawContext: DontDrawContext,
stopFlag: me.stoprequest
]];
Imager.SetColor[me.viewContext, Imager.black];
Imager.SetFont[me.viewContext, defaultFont];
CDOps.DrawDesign[me.actualDesign, internalPr];
};
NameDevice: TYPE = RECORD [propKey: ATOM, vPriv: VRef];
defaultFont: Imager.Font = VFonts.DefaultFont[];
NamedDrawChild: CD.DrawProc = {
dev: REF NameDevice = NARROW[pr.devicePrivate];
text: Rope.ROPENIL;
ob.class.drawMe[pr, ob, trans, readOnlyInstProps];
WITH CDProperties.GetListProp[readOnlyInstProps, dev.propKey] SELECT FROM
r: Rope.ROPE => text ← r;
a: ATOM => text ← Atom.GetPName[a];
ENDCASE => NULL;
IF text#NIL THEN {
r: CD.Rect ← CDBasics.MapRect[CD.InterestRect[ob], trans];
p: CD.Position ← CDVScale.DesignToViewerPosition[dev.vPriv.scale, CDBasics.BaseOfRect[r]];
Imager.SetXY[dev.vPriv.viewContext, [p.x+1, p.y+1]];
Imager.SetColor[dev.vPriv.viewContext, Imager.black];
Imager.SetFont[dev.vPriv.viewContext, defaultFont];
Imager.ShowRope[dev.vPriv.viewContext, text];
};
};
DontDrawRect: CD.DrawRectProc = {
};
DontDrawContext: CD.DrawContextProc = {
};
PaintTemporaries: FurtherPaintProc = {
PROC [me: CDVPrivate.VRef, key: REF]
--eg. former paints ticks
--called through ProtectedRepaint only
};
DrawSignalNames: FurtherPaintProc = {
-- PROC [me: CDVPrivate.VRef, key: REF]
-- called from anywhere, not monitored
CDDrawQueue.QueueInsertDrawCommand[me.ct, [$SignalNames, CDBasics.universe]];
};
DrawInstanceNames: FurtherPaintProc = {
-- PROC [me: CDVPrivate.VRef, key: REF]
-- called from anywhere, not monitored
CDDrawQueue.QueueInsertDrawCommand[me.ct, [$InstanceNames, CDBasics.universe]];
};
Init: PROC [] = {
--protected procedures
CDViewerBackdoor.InstallFurtherPaint[keyValue: $ShowViewers, proc: ShowViewers];
CDViewerBackdoor.InstallFurtherPaint[keyValue: $SignalNames, proc: PaintSignalNames];
CDViewerBackdoor.InstallFurtherPaint[keyValue: $InstanceNames, proc: PaintInstanceNames];
CDViewerBackdoor.InstallFurtherPaint[keyValue: $Temporaries, proc: PaintTemporaries];
--unprotected procedures
CDViewerBackdoor.InstallFurtherPaint[keyValue: $DrawSignalNames, proc: DrawSignalNames];
CDViewerBackdoor.InstallFurtherPaint[keyValue: $DrawInstanceNames, proc: DrawInstanceNames];
};
Init[];
END.