SleepPeekImpl.mesa
Copyright (C) 1984 by Xerox Corporation. All rights reserved.
Michael Plass, April 12, 1984 10:15:30 am PST
Last Edited by: Beach, October 9, 1984 8:51:00 pm PDT
DIRECTORY Idle, ImagerPixelMaps, ImagerFrameBuffer, LFBoundingBox, Buttons;
SleepPeekImpl: CEDAR PROGRAM
IMPORTS Idle, ImagerPixelMaps, ImagerFrameBuffer, LFBoundingBox, Buttons
= BEGIN
sMin, fMin: INTEGER;
sSize, fSize: NAT;
screen: ImagerPixelMaps.PixelMap;
shadow: ImagerPixelMaps.PixelMap;
bitmapRef: Idle.BitmapRef;
Bits: TYPE = RECORD [SEQUENCE COMPUTED CARDINAL OF WORD];
Image: Idle.ImageProc ~ {
shadow ← shadow.refRep.Reshape[0, [sMin, fMin, MIN[sSize, h], MIN[fSize, w]]];
shadow.Transfer[screen];
RETURN [bitmapRef];
};
SleepProc: Buttons.ButtonProc ~ BEGIN
IF mouseButton = red OR sSize = 0 OR fSize = 0 OR shadow.refRep = NIL THEN {
get bounding box of the area
sMin ← -1;
[y: sMin, x: fMin, h: sSize, w: fSize] ← LFBoundingBox.GetArea[!LFBoundingBox.AbortAdjust => CONTINUE];
IF sMin < 0 THEN
shadow.refRep ← NIL
ELSE {
TRUSTED {screen ← ImagerFrameBuffer.LFDisplay[]};
sMin ← screen.sSize - sMin - sSize;
shadow ← ImagerPixelMaps.Create[0, [sMin, fMin, sSize, fSize]];
WHILE shadow.refRep.words > 64000 DO
sSize ← sSize * 7 / 8;
fSize ← fSize * 7 / 8;
shadow ← ImagerPixelMaps.Create[0, [sMin, fMin, sSize, fSize]];
ENDLOOP;
shadow.refRep.pointer ← NIL;
shadow.refRep.ref ← NEW[Bits[shadow.refRep.words]];
TRUSTED {shadow.refRep.pointer ← LOOPHOLE[shadow.refRep.ref]};
bitmapRef ← NEW[Idle.BitmapRep ← [base: shadow.refRep.ref, raster: shadow.refRep.rast, width: shadow.fSize, height: shadow.sSize]];
};
};
IF shadow.refRep # NIL THEN Idle.Sleep[Image];
END;
[] ← Buttons.Create[[name: "Sleep"], SleepProc];
END.