PipalInteractiveEditImpl.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Louis Monier January 31, 1988 3:11:31 am PST
Bertrand Serlet January 31, 1988 8:17:27 pm PST
Barth, February 4, 1988 12:55:42 pm PST
DIRECTORY BasicTime, BiScrollers, Cursors, Geom2D, Imager, IO, Pipal, PipalInteractiveEdit, PipalEdit, PipalPaint, PipalReal, Process, Real, RefTab, TIPUser, ViewerClasses;
PipalInteractiveEditImpl: CEDAR PROGRAM
IMPORTS BasicTime, BiScrollers, Geom2D, Imager, PipalPaint, PipalReal, Process, TIPUser
EXPORTS PipalInteractiveEdit =
BEGIN OPEN PipalInteractiveEdit;
Operations
lastBiscrollerPaintTime: BasicTime.Pulses;
Create: PUBLIC PROC [editor: PipalEdit.Editor, tipTable: Pipal.ROPE, notify: ViewerClasses.NotifyProc, data: REFNIL] RETURNS [viewerData: ViewerData] ~ {
style: BiScrollers.BiScrollerStyle ← BiScrollers.GetStyle["Buttonned"];
class: BiScrollers.BiScrollerClass ← style.NewBiScrollerClass[[
flavor: $PipalInteractiveEdit,
extrema: Extrema,
paint: BiscrollerPaint,
notify: notify,
bsUserAction: ForkAndDo,
finish: LIST [$Exit],
menu: BiScrollers.bsMenu,
icon: fileCabinet,
tipTable: TIPUser.InstantiateNewTIPTable[tipTable],
cursor: textPointer,
mayStretch: FALSE,
offsetsMustBeIntegers: TRUE,
preferIntegerCoefficients: FALSE
]];
info: ViewerClasses.ViewerRec ← [name: "Pipal",
iconic: FALSE,
data: NEW [ViewerDataRec ← [editor: editor, data: data]]];
bs: BiScrollers.BiScroller ← class.style.CreateBiScroller[class: class, info: info];
viewerData ← NARROW[BiScrollers.ClientDataOf[bs]];
};
Extrema: BiScrollers.ExtremaProc = {
viewerData: ViewerData ← NARROW[clientData];
size: PipalReal.Size ← PipalReal.ObjectSize[viewerData.editor.object];
[min, max] ← Geom2D.ExtremaOfRect[[0.0, 0.0, size.x, size.y], direction];
};
BiscrollerPaint: ViewerClasses.PaintProc = {
clipArea, outlines: LIST OF PipalReal.Rectangle ← NIL;
viewerData: ViewerData ← NARROW [BiScrollers.ClientDataOfViewer[self]];
editor: PipalEdit.Editor = viewerData.editor;
lastBiscrollerPaintTime ← BasicTime.GetClockPulses[];
Coordinate axis
Imager.SetColor[context, Imager.black];
Imager.MaskVector[context, [-1000, 0], [1000, 0]];
Imager.MaskVector[context, [0, -1000], [0, 1000]];
Object
PipalPaint.Paint[editor, context];
lastBiscrollerPaintTime ← BasicTime.GetClockPulses[]-lastBiscrollerPaintTime;
};
ForkAndDo: BiScrollers.BSUserActionProc
~ TRUSTED {Process.Detach[FORK BiScrollers.DoBSUserAction[bs, input]]};
Commands
Notify: ViewerClasses.NotifyProc = {
viewerData: ViewerData ← NARROW [BiScrollers.ClientDataOfViewer[self]];
atom: ATOM = NARROW [input.first];
result: REF;
resultType: PipalEdit.ResultType;
SELECT atom FROM
$MouseDown => viewerData.mouseDown ← NARROW [input.rest.first, BiScrollers.ClientCoords]^;
$TrackSelected => {
area: LIST OF PipalReal.Rectangle;
viewerData.mouseNow ← NARROW [input.rest.first, BiScrollers.ClientCoords]^;
[resultType, result] ← PipalEdit.ApplyCommand[viewerData.editor, $SelectedOutlines];
IF resultType#selectionArea THEN ERROR;
area ← NARROW [result];
area ← TranslateArea[area, PipalReal.Sub[viewerData.mouseNow, viewerData.mouseDown]];
ViewerOps.PaintViewer[self, client, FALSE, NEW [WhatChangedRec ← [
clipArea: area,
outlines: area
]]];
viewerData.previousTrackingArea ← area;
};
$Exit => NULL;
ENDCASE => {
arguments: LIST OF REFNIL;
FOR list: LIST OF REF ← input.rest, list.rest WHILE list#NIL DO
WITH list.first SELECT FROM
cc: BiScrollers.ClientCoords => {
viewerData.mouseNow ← cc^;
arguments ← CONS [cc, arguments];
};
atom: ATOM => SELECT atom FROM
$DownCoords => arguments ← CONS [NEW [PipalReal.Size ← viewerData.mouseDown], arguments];
ENDCASE => arguments ← CONS [atom, arguments];
ENDCASE => arguments ← CONS [atom, arguments];
ENDLOOP;
[resultType, result] ← PipalEdit.ApplyCommand[viewerData.editor, atom, List.Reverse[arguments]];
SELECT resultType FROM
none => ViewerOps.PaintViewer[self, client]; -- until the day we have commands which change menus
changedArea => ViewerOps.PaintViewer[self, client, FALSE, NEW [WhatChangedRec ← [clipArea: NARROW [result]]]];
ENDCASE => ERROR; -- including object
};
};
END.