LFUtilImpl.mesa
Michael Plass, July 5, 1983 9:31 am
DIRECTORY
Cursors,
InputFocus,
LFUtil,
TIPUser,
ViewerClasses,
WindowManager,
UserTerminal
;
LFUtilImpl:
CEDAR
MONITOR
IMPORTS Cursors, InputFocus, TIPUser, WindowManager
EXPORTS LFUtil
~ BEGIN
topY, leftX, sourceBottom, sourceHeight, sourceLeft, sourceWidth: INTEGER;
mode: {waitingForUpperLeft, waitingForLowerRight, done} ← done;
ready: CONDITION;
GetArea:
PUBLIC
ENTRY
PROC
RETURNS [sMin, fMin:
INTEGER, sSize, fSize:
NAT] = {
ENABLE UNWIND => NULL;
mode ← waitingForUpperLeft;
InputFocus.CaptureButtons[BoxAdjustNotify, vaTIP];
Cursors.SetCursor[blank];
Cursors.AddCursorCorner[upperLeft];
UNTIL mode = done DO WAIT ready ENDLOOP;
sMin ← 808 - (sourceBottom + sourceHeight);
sSize ← sourceHeight;
fMin ← sourceLeft;
fSize ← sourceWidth;
};
Clip:
PROC [position: TIPUser.TIPScreenCoords]
RETURNS [x, y:
INTEGER] =
BEGIN
x ← position.mouseX;
y ← position.mouseY;
END;
BoxAdjustNotify:
ENTRY ViewerClasses.NotifyProc ~ {
ENABLE UNWIND => {InputFocus.ReleaseButtons[]; WindowManager.RestoreCursor[]};
mouseX, mouseY: INTEGER ← 0;
FOR list:
LIST
OF
REF
ANY ← input, list.rest
UNTIL list =
NIL
DO
WITH list.first
SELECT
FROM
x:
ATOM =>
SELECT x
FROM
$Abort =>
BEGIN
InputFocus.ReleaseButtons[];
WindowManager.RestoreCursor[];
END;
$End =>
BEGIN
IF mode = waitingForUpperLeft
THEN {
mode ← waitingForLowerRight;
Cursors.SetCursor[blank];
Cursors.AddCursorCorner[lowerRight];
topY ← mouseY;
leftX ← mouseX;
}
ELSE
IF mode = waitingForLowerRight
THEN {
mode ← done;
IF topY < mouseY THEN {t: NAT ← topY; topY ← mouseY; mouseY ← t};
IF leftX > mouseX THEN {t: NAT ← leftX; leftX ← mouseX; mouseX ← t};
sourceBottom ← mouseY;
sourceHeight ← topY - mouseY + 1;
sourceLeft ← leftX;
sourceWidth ← mouseX - leftX + 1;
InputFocus.ReleaseButtons[];
WindowManager.RestoreCursor[];
NOTIFY ready;
};
END;
ENDCASE => NULL;
z: TIPUser.TIPScreenCoords => [mouseX, mouseY] ← Clip[z];
ENDCASE => ERROR;
ENDLOOP;
};
vaTIP: TIPUser.TIPTable ←
TIPUser.InstantiateNewTIPTable["/Indigo/CedarViewers/Viewers/ViewerAdjust.tip"];
END.