GEditMotionImpl.mesa; Edited by McGregor on December 9, 1982 10:10 am
DIRECTORY
Cursors USING [CursorArray, CursorType, NewCursor, SetCursor],
GEditClasses USING [Class],
GEditMotion,
GEditSelect USING [selection],
GEditViewer,
InputFocus USING [CaptureButtons, ReleaseButtons],
MessageWindow USING [Append, Clear],
TIPUser USING [InstantiateNewTIPTable, TIPScreenCoords, TIPTable],
ViewerClasses USING [NotifyProc, Viewer],
ViewerOps USING [MouseInViewer, PaintViewer],
WindowManager USING [RestoreCursor];
GEditMotionImpl: PROGRAM
IMPORTS Cursors, GEditSelect, InputFocus, MessageWindow, TIPUser, ViewerOps, WindowManager
EXPORTS GEditMotion =
BEGIN OPEN GEditViewer, GEditSelect;
gEditMotionTIP: TIPUser.TIPTable ← TIPUser.InstantiateNewTIPTable["GEditMotion.tip"];
motionCursorBits: Cursors.CursorArray ←
[177777B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 100001B, 177777B];
motionCursor: Cursors.CursorType ← Cursors.NewCursor[motionCursorBits, -7, -7];
initialX, initialY: INTEGER;
Move:
PUBLIC
PROC [x, y:
INTEGER] =
BEGIN
IF selection.viewer=NIL THEN RETURN;
InputFocus.CaptureButtons[MoveCopyNotify, gEditMotionTIP, selection.viewer];
initialX ← selection.caretX;
initialY ← selection.caretY;
Cursors.SetCursor[motionCursor];
ViewerOps.PaintViewer[selection.viewer, client, FALSE, $Selection];
MessageWindow.Append["Select new position...", TRUE];
IF selection.caretX#x OR selection.caretY#y THEN Update[x, y];
END;
MoveCopyNotify: ViewerClasses.NotifyProc =
BEGIN
mouse: TIPUser.TIPScreenCoords;
mousedViewer: ViewerClasses.Viewer;
client: BOOL;
FOR list:
LIST
OF
REF
ANY ← input, list.rest
UNTIL list =
NIL
DO
WITH list.first
SELECT
FROM
x:
ATOM =>
SELECT x
FROM
$Abort => Stop[TRUE];
$Stop => Stop[];
$Update =>
IF client
AND mousedViewer=self
THEN Update[mouse.mouseX, mouse.mouseY]
ELSE
IF mousedViewer.parent=self
THEN
BEGIN
IF client THEN Update[mouse.mouseX+mousedViewer.cx, mouse.mouseY+mousedViewer.cy] ELSE Update[mouse.mouseX+mousedViewer.wx, mouse.mouseY+mousedViewer.wy]
END;
ENDCASE => NULL;
z: TIPUser.TIPScreenCoords => [mousedViewer, client] ← ViewerOps.MouseInViewer[mouse ← z];
ENDCASE => ERROR;
ENDLOOP;
END;
Update:
PROC [newX, newY:
INTEGER] =
BEGIN
dx: INTEGER ~ newX - selection.caretX;
dy: INTEGER ~ newY - selection.caretY;
IF dx=0 AND dy=0 THEN RETURN;
ViewerOps.PaintViewer[selection.viewer, client, FALSE, $XORSelection];
FOR obj: SelectedObject ← selection.objects, obj.nextObject
UNTIL obj=
NIL
DO
class: GEditClasses.Class ~ NARROW[obj.object.class];
IF class#
NIL
AND class.moveProc#
NIL
THEN
class.moveProc[obj.object, selection.viewer, obj.controlPoint, selection.grain, dx, dy];
ENDLOOP;
ViewerOps.PaintViewer[selection.viewer, client, FALSE, $XORSelection];
selection.caretX ← newX;
selection.caretY ← newY;
END;
Stop:
PROC [abort:
BOOL ←
FALSE] =
BEGIN
InputFocus.ReleaseButtons[];
IF abort
THEN
BEGIN
-- restore selected objects to original position
dx: INTEGER ~ initialX - selection.caretX;
dy: INTEGER ~ initialY - selection.caretY;
FOR obj: SelectedObject ← selection.objects, obj.nextObject
UNTIL obj=
NIL
DO
class: GEditClasses.Class ~ NARROW[obj.object.class];
IF class#
NIL
AND class.moveProc#
NIL
THEN
class.moveProc[obj.object, selection.viewer, obj.controlPoint, selection.grain, dx, dy];
ENDLOOP;
END;
WindowManager.RestoreCursor[];
ViewerOps.PaintViewer[selection.viewer, client];
MessageWindow.Clear[];
END;
END.