CDVSomeCursors.mesa
Copyright © 1983, 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, August 5, 1983 11:07 am
Last edited by: Christian Jacobi, March 3, 1987 3:58:04 pm PST
DIRECTORY
CD,
CDLayers,
CDSequencer,
CDVPrivate,
CDVScale,
Imager,
ImagerBackdoor,
InputFocus,
RuntimeError,
PrincOpsUtils,
Process,
TIPUser,
ViewerClasses;
CDVSomeCursors: CEDAR PROGRAM
IMPORTS CDLayers, CDSequencer, CDVPrivate, CDVScale, Imager, ImagerBackdoor, InputFocus, PrincOpsUtils, Process, RuntimeError, TIPUser =
BEGIN
ViewerPos2: PROC [me: CDVPrivate.VRef] RETURNS [CD.Position] = INLINE {
RETURN [CDVScale.DesignToViewerPosition[me.scale, me.stopVC]];
};
ViewerPos1: PROC [me: CDVPrivate.VRef] RETURNS [CD.Position] = INLINE {
RETURN [CDVScale.DesignToViewerPosition[me.scale, me.startVC]];
};
DefaultCursor: PUBLIC PROC[me: CDVPrivate.VRef] = {
p2: CD.Position = ViewerPos2[me];
CDVPrivate.InvertArea[me, p2.x-8, p2.y, p2.x+8, p2.y];
CDVPrivate.InvertArea[me, p2.x, p2.y-8, p2.x, p2.y+8];
};
ArrowCursor: PUBLIC PROC[me: CDVPrivate.VRef] = {
p1: CD.Position = ViewerPos1[me];
p2: CD.Position = ViewerPos2[me];
Imager.SetColor[me.viewContext, ImagerBackdoor.invert];
Imager.MaskVector[me.viewContext, [p1.x, p1.y], [p2.x, p2.y]];
};
PseudoArrowCursor: PUBLIC PROC[me: CDVPrivate.VRef] = {
ENABLE RuntimeError.UNCAUGHT => {
IF CDVPrivate.ShallContinue[me, TRUE, "cursor"] THEN GOTO oops;
};
p1: CD.Position = ViewerPos1[me];
p2: CD.Position = ViewerPos2[me];
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, p2.y];
CDVPrivate.InvertArea[me, p1.x, p2.y, p2.x, p2.y];
EXITS
oops => NULL;
};
RectCursor: PUBLIC PROC[me: CDVPrivate.VRef] = {
ENABLE RuntimeError.UNCAUGHT => {
IF CDVPrivate.ShallContinue[me, TRUE, "cursor"] THEN GOTO oops;
};
p1: CD.Position = ViewerPos1[me];
p2: CD.Position = ViewerPos2[me];
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, p2.y];
CDVPrivate.InvertArea[me, p1.x, p2.y, p2.x, p2.y];
CDVPrivate.InvertArea[me, p2.x, p2.y, p2.x, p1.y];
CDVPrivate.InvertArea[me, p2.x, p1.y, p1.x, p1.y];
EXITS oops => NULL;
};
LCursor: PUBLIC PROC[me: CDVPrivate.VRef] = {
ENABLE RuntimeError.UNCAUGHT => {
IF CDVPrivate.ShallContinue[me, TRUE, "cursor"] THEN GOTO oops;
};
yi, yo, xi, xo: INT; --i=inner, o=outer, if p1 considered center
wireWidth: CD.Number =
MAX[CDVScale.DesignToViewerScalar[me.scale, me.defaultWidthVC], 1];
p1: CD.Position = ViewerPos1[me];
p2: CD.Position = ViewerPos2[me];
IF me.firstHorizontalVC THEN {
IF p2.x<=p1.x AND p2.x>=p1.x-wireWidth
AND (p2.y<p1.y OR p2.y>p1.y+wireWidth) THEN { -- sorry, only vertical, p2.x ignored
CDVPrivate.InvertArea[me, p1.x, p2.y, p1.x, p1.y];
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x+wireWidth, p1.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p1.y, p1.x+wireWidth, p2.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p2.y, p1.x, p2.y];
RETURN
};
IF p2.x>=p1.x THEN {xi ← p2.x; xo ← xi+wireWidth}
ELSE {xo ← p2.x; xi ← xo+wireWidth};
IF p2.y<p1.y THEN { -- L shaped, down
CDVPrivate.InvertArea[me, p1.x, p1.y, xi, p1.y];
CDVPrivate.InvertArea[me, xi, p1.y, xi, p2.y];
CDVPrivate.InvertArea[me, xi, p2.y, xo, p2.y];
CDVPrivate.InvertArea[me, xo, p2.y, xo, p1.y+wireWidth];
CDVPrivate.InvertArea[me, xo, p1.y+wireWidth, p1.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p1.x, p1.y+wireWidth, p1.x, p1.y];
RETURN
};
IF p2.y>p1.y+wireWidth THEN { -- L shaped, up
CDVPrivate.InvertArea[me, p1.x, p1.y, xo, p1.y];
CDVPrivate.InvertArea[me, xo, p1.y, xo, p2.y];
CDVPrivate.InvertArea[me, xo, p2.y, xi, p2.y];
CDVPrivate.InvertArea[me, xi, p2.y, xi, p1.y+wireWidth];
CDVPrivate.InvertArea[me, xi, p1.y+wireWidth, p1.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p1.x, p1.y+wireWidth, p1.x, p1.y];
RETURN
};
-- only horizontal
CDVPrivate.InvertArea[me, p1.x, p1.y, p2.x, p1.y];
CDVPrivate.InvertArea[me, p2.x, p1.y, p2.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p2.x, p1.y+wireWidth, p1.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p1.x, p1.y+wireWidth, p1.x, p1.y];
}
ELSE -- NOT me.firstHorizontalVC -- {
IF p2.y<=p1.y AND p2.y>=p1.y-wireWidth
AND (p2.x<p1.x OR p2.x>p1.x+wireWidth) THEN { -- sorry, only horizontal, p2.y ignored
CDVPrivate.InvertArea[me, p2.x, p1.y, p1.x, p1.y];
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p1.x, p1.y+wireWidth, p2.x, p1.y+wireWidth];
CDVPrivate.InvertArea[me, p2.x, p1.y+wireWidth, p2.x, p1.y];
RETURN
};
IF p2.y>=p1.y THEN {yi ← p2.y; yo ← yi+wireWidth}
ELSE {yo ← p2.y; yi ← yo+wireWidth};
IF p2.x<p1.x THEN { -- L shaped, left
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, yi];
CDVPrivate.InvertArea[me, p1.x, yi, p2.x, yi];
CDVPrivate.InvertArea[me, p2.x, yi, p2.x, yo];
CDVPrivate.InvertArea[me, p2.x, yo, p1.x+wireWidth, yo];
CDVPrivate.InvertArea[me, p1.x+wireWidth, yo, p1.x+wireWidth, p1.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p1.y, p1.x, p1.y];
RETURN
};
IF p2.x>p1.x+wireWidth THEN { -- L shaped, right
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, yo];
CDVPrivate.InvertArea[me, p1.x, yo, p2.x, yo];
CDVPrivate.InvertArea[me, p2.x, yo, p2.x, yi];
CDVPrivate.InvertArea[me, p2.x, yi, p1.x+wireWidth, yi];
CDVPrivate.InvertArea[me, p1.x+wireWidth, yi, p1.x+wireWidth, p1.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p1.y, p1.x, p1.y];
RETURN
};
-- only vertical
CDVPrivate.InvertArea[me, p1.x, p1.y, p1.x, p2.y];
CDVPrivate.InvertArea[me, p1.x, p2.y, p1.x+wireWidth, p2.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p2.y, p1.x+wireWidth, p1.y];
CDVPrivate.InvertArea[me, p1.x+wireWidth, p1.y, p1.x, p1.y];
};
EXITS oops => NULL;
};
UseWireCursor: CDVPrivate.CursorModeProc = {
l: CD.Layer = CDLayers.CurrentLayer[me.actualDesign];
w: CD.Number = CDLayers.LayerWidth[me.actualDesign, l];
me.designRec.outlineProcLC ← IF w>0 THEN LCursor ELSE RectCursor;
me.designRec.usedCursor ← $wire;
};
UseRectCursor: CDVPrivate.CursorModeProc = {
me.designRec.usedCursor ← mode;
me.designRec.outlineProcLC ← RectCursor
};
UseArrowCursor: CDVPrivate.CursorModeProc = {
me.designRec.usedCursor ← mode;
me.designRec.outlineProcLC ← ArrowCursor
};
UsePseudoArrowCursor: CDVPrivate.CursorModeProc = {
me.designRec.usedCursor ← mode;
me.designRec.outlineProcLC ← PseudoArrowCursor
};
UseDefaultCursor: CDVPrivate.CursorModeProc = {
me.designRec.usedCursor ← NIL;
me.designRec.outlineProcLC ← DefaultCursor
};
DoThePartialAdvance: CDVPrivate.CursorModeProc = {
UseWireCursor[me, $wire];
IF me.designRec.firstHLC THEN me.designRec.startLC.x ← me.designRec.stopLC.x
ELSE me.designRec.startLC.y ← me.designRec.stopLC.y;
me.designRec.firstHLC ← NOT me.designRec.firstHLC;
me.designRec.startLCValid ← TRUE;
};
DoFlipCursor: CDVPrivate.CursorModeProc = {
UseWireCursor[me, $wire];
me.designRec.firstHLC ← NOT me.designRec.firstHLC
};
IsTheCursor: PROC [usedCursor: REF] RETURNS [yes: BOOLFALSE] =
INLINE BEGIN
ENABLE RuntimeError.UNCAUGHT => {--must have not yet been initialized-- GOTO deny};
IF CDVPrivate.cursoredCDViewer#NIL THEN
RETURN [NARROW[CDVPrivate.cursoredCDViewer.data, CDVPrivate.VRef].designRec.usedCursor=usedCursor];
EXITS deny => RETURN [FALSE]
END;
IsWire: PROC RETURNS [BOOL] = {RETURN [IsTheCursor[$wire]]};
IsRect: PROC RETURNS [BOOL] = {RETURN [IsTheCursor[$rect]]};
IsArrow: PROC RETURNS [BOOL] = {RETURN [IsTheCursor[$arrow]]};
IsDefault: PROC RETURNS [BOOL] = {RETURN [IsTheCursor[NIL]]};
NoFocus: PROC RETURNS [BOOLTRUE] = {
--returns true when the cursored viewer is different from the focused viewer
ENABLE RuntimeError.UNCAUGHT => GOTO Oops;
focus: InputFocus.Focus ← InputFocus.GetInputFocus[];
RETURN [focus=NIL OR CDVPrivate.cursoredCDViewer#focus.owner]
EXITS Oops => RETURN
};
SetXModeOn: CDVPrivate.CursorModeProc = {
me.designRec.xMode ← TRUE
};
SetXModeOff: CDVPrivate.CursorModeProc = {
me.designRec.xMode ← FALSE
};
SetMarkOnStart: CDVPrivate.CursorModeProc = {
me.designRec.mark ← me.designRec.startLC
};
SetMarkOnStop: CDVPrivate.CursorModeProc = {
me.designRec.mark ← me.designRec.stopLC
};
SetStartOnMark: CDVPrivate.CursorModeProc = {
me.designRec.startLC ← me.designRec.startLC;
me.designRec.startLCValid ← TRUE;
};
ShowMark: CDVPrivate.CursorModeProc = {
--handled specially because we do not call stoptrack
comm: CDSequencer.Command = NEW[CDSequencer.CommandRec ←
CDSequencer.CommandRec[
design: me.actualDesign,
key: $ShowMark,
pos: me.designRec.mark,
sPos: me.designRec.mark,
l: me.designRec.currentLayer,
ref: me,
n: me.defaultWidthVC,
b: me.designRec.firstHLC
]
];
TRUSTED {Process.Detach[FORK
CDSequencer.ExecuteCommand[design: me.actualDesign, comm: comm]
]}
};
CursoredDesignXMode: PROC [] RETURNS [xmode: BOOLFALSE] = {
ENABLE RuntimeError.UNCAUGHT => {--not yet initialized-- GOTO skip};
IF CDVPrivate.cursoredCDViewer#NIL THEN
WITH CDVPrivate.cursoredCDViewer.data SELECT FROM
gr: CDVPrivate.VRef => xmode ← gr.designRec.xMode
ENDCASE => NULL;
EXITS skip => NULL
};
IsXMode: PROC RETURNS [xMode: BOOL] = {
xMode ← CursoredDesignXMode[]
};
IsNotXMode: PROC RETURNS [notXMode: BOOL] = {
notXMode ← ~ CursoredDesignXMode[]
};
CDVPrivate.ImplementACursor[NIL, UseDefaultCursor]; --overwrites the default
CDVPrivate.ImplementACursor[$wire, UseWireCursor];
CDVPrivate.ImplementACursor[$rect, UseRectCursor];
IF PrincOpsUtils.VERSION[].machineType=dorado THEN
CDVPrivate.ImplementACursor[$arrow, UseArrowCursor]
ELSE
CDVPrivate.ImplementACursor[$arrow, UsePseudoArrowCursor];
CDVPrivate.ImplementACursor[$default, UseDefaultCursor];
CDVPrivate.ImplementACursor[$PartialWireAdvance, DoThePartialAdvance];
CDVPrivate.ImplementACursor[$FlipWire, DoFlipCursor];
TIPUser.RegisterTIPPredicate[key: $ChipndaleWireCursor, p: IsWire];
TIPUser.RegisterTIPPredicate[key: $ChipndaleRectCursor, p: IsRect];
TIPUser.RegisterTIPPredicate[key: $ChipndaleArrowCursor, p: IsArrow];
TIPUser.RegisterTIPPredicate[key: $ChipndaleDefaultCursor, p: IsDefault];
TIPUser.RegisterTIPPredicate[key: $ChipndaleNoFocus, p: NoFocus];
CDVPrivate.ImplementACursor[$SetXModeOn, SetXModeOn];
CDVPrivate.ImplementACursor[$SetXModeOff, SetXModeOff];
CDVPrivate.ImplementACursor[$SetMarkOnStart, SetMarkOnStart];
CDVPrivate.ImplementACursor[$SetMarkOnStop, SetMarkOnStop];
CDVPrivate.ImplementACursor[$SetStartOnMark, SetStartOnMark];
CDVPrivate.ImplementACursor[$ShowMark, ShowMark];
TIPUser.RegisterTIPPredicate[key: $ChipndaleXMode, p: IsXMode];
TIPUser.RegisterTIPPredicate[key: $ChipndaleNXMode, p: IsNotXMode];
END.