File: SVViewerToolImpl.mesa
Last edited by Bier on July 30, 1984 2:18:45 am PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
Created on March 22, 1983 2:29 pm
My very own container-type class for solid viewers
DIRECTORY
Icons,
SV2d,
SVEditUser,
SVInterfaceTypes,
SVViewerTool,
ViewerClasses,
ViewerOps;
SVViewerToolImpl: PROGRAM
IMPORTS Icons, SVEditUser, ViewerOps
SHARES ViewerOps =
BEGIN OPEN ViewerClasses;
Point2d: TYPE = SV2d.Point2d;
ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData;
SolidViewerToolPaint: PRIVATE PaintProc = TRUSTED {
viewerToolData: ViewerToolData ← NARROW[self.data];
v: Viewer;
update: BOOLFALSE;
hdiff, wdiff: INTEGER;
FOR l: LIST OF Viewer ← viewerToolData.xBounded, l.rest UNTIL l=NIL DO
v ← l.first;
IF v.destroyed THEN {update ← TRUE; LOOP};
wdiff ← v.ww-v.cw;
v.ww ← MAX[v.parent.cw-v.wx-1, 5];
v.cw ← v.ww-wdiff;
ENDLOOP;
FOR l: LIST OF Viewer ← viewerToolData.yBounded, l.rest UNTIL l=NIL DO
v ← l.first;
IF v.destroyed THEN {update ← TRUE; LOOP};
hdiff ← v.wh-v.ch;
v.wh ← MAX[v.parent.ch-v.wy-1, 5];
v.ch ← v.wh-hdiff;
ENDLOOP;
IF viewerToolData.xBounded#NIL OR viewerToolData.yBounded#NIL
THEN ViewerOps.ResetPaintCache[self, FALSE];
IF update THEN {
oldx: LIST OF Viewer ← viewerToolData.xBounded;
oldy: LIST OF Viewer ← viewerToolData.yBounded;
viewerToolData.xBounded ← viewerToolData.yBounded ← NIL;
FOR l: LIST OF Viewer ← oldx, l.rest UNTIL l=NIL DO
IF ~l.first.destroyed
THEN viewerToolData.xBounded ← CONS[l.first, viewerToolData.xBounded];
ENDLOOP;
FOR l: LIST OF Viewer ← oldy, l.rest UNTIL l=NIL DO
IF ~l.first.destroyed
THEN viewerToolData.yBounded ← CONS[l.first, viewerToolData.yBounded];
ENDLOOP;
};
};
SolidViewerToolDestroy: PRIVATE DestroyProc = TRUSTED {
SVEditUser.NotifyDestroy[self];
};
SolidViewerToolSet: PRIVATE SetProc = TRUSTED {
viewerToolData: ViewerToolData ← NARROW[self.data];
child: Viewer = NARROW[data];
IF child.parent#self THEN ERROR;
IF op=$YBound THEN viewerToolData.yBounded ← CONS[child, viewerToolData.yBounded]
ELSE IF op=$XBound THEN viewerToolData.xBounded ← CONS[child, viewerToolData.xBounded]
ELSE ERROR;
};
SolidViewerToolInit: PRIVATE InitProc = CHECKED {};
solidViewerToolClass: ViewerClasses.ViewerClass ← NEW[ViewerClasses.ViewerClassRec ← [
init: SolidViewerToolInit,
paint: SolidViewerToolPaint,
destroy: SolidViewerToolDestroy,
set: SolidViewerToolSet,
coordSys: top,
icon: Icons.NewIconFromFile["SolidViews.icons", 0]
]];
ViewerOps.RegisterViewerClass[$SolidViewerTool, solidViewerToolClass];-- plug in to Viewers
END.