PseudoCursorsImpl.mesa
Copyright © 1982, 1983, 1984 Xerox Corporation. All rights reserved.
Michael Plass, November 2, 1982 10:48 am
Last Edited by: Beach, May 24, 1983 9:12 am
Doug Wyatt, September 5, 1984 4:40:40 pm PDT
DIRECTORY
Imager USING [Context],
ImagerOps USING [Bitmap, BitmapRep, ImagerFromGraphics, MaskBitmap],
Process USING [Detach, InitializeCondition, MsecToTicks, Ticks],
PseudoCursors USING [PseudoCursor],
Terminal USING [BWCursorBitmap],
ViewerClasses USING [PaintProc, Viewer, ViewerClass, ViewerClassRec],
ViewerOps USING [CreateViewer, PaintViewer, RegisterViewerClass];
PseudoCursorsImpl: CEDAR MONITOR
IMPORTS ImagerOps, Process, ViewerOps EXPORTS PseudoCursors =
BEGIN
PseudoCursor: TYPE = PseudoCursors.PseudoCursor;
DataRec: TYPE = RECORD [
bits: REF Terminal.BWCursorBitmap,
bitMap: ImagerOps.Bitmap,
newData: BOOLEANFALSE,
paint: PROCESSNIL,
timeout: CONDITION
];
waitTime: Process.Ticks ← Process.MsecToTicks[100];
Create: PUBLIC PROC [parent: ViewerClasses.Viewer, x, y: INTEGER ← 0]
RETURNS [pseudoCursor: PseudoCursor] = TRUSTED {
data: REF DataRec ← NEW[DataRec];
data.bits ← NEW[Terminal.BWCursorBitmap];
TRUSTED { data.bitMap ← NEW[ImagerOps.BitmapRep ← [ref: data.bits, base: LOOPHOLE[data.bits], wordsPerLine: 1, w: 16, h: 16, x: 0, y: 0, ox: 0, oy: 0]] };
Process.InitializeCondition[@data.timeout, waitTime];
pseudoCursor ← ViewerOps.CreateViewer[flavor: $PsuedoCursor, info: [parent: parent, wx: x, wy: y, ww: 16, wh: 16, data: data, border: FALSE], paint: FALSE];
};
Set: PUBLIC ENTRY PROC [pseudoCursor: PseudoCursor, bits: REF Terminal.BWCursorBitmap] =
BEGIN ENABLE UNWIND => {};
d: REF DataRec ← NARROW[pseudoCursor.data];
IF bits=NIL THEN d.bits^ ← ALL[0] ELSE d.bits^ ← bits^;
d.newData ← TRUE;
IF d.paint = NIL THEN TRUSTED{Process.Detach[d.paint ← FORK PaintProcess[pseudoCursor]]};
END;
PaintProcess: ENTRY PROCEDURE [pseudoCursor: PseudoCursor] =
BEGIN ENABLE UNWIND => {};
d: REF DataRec ← NARROW[pseudoCursor.data];
WHILE d.newData DO
d.newData ← FALSE;
TRUSTED{ViewerOps.PaintViewer[pseudoCursor, client, FALSE, $Update]};
WAIT d.timeout;
ENDLOOP;
d.paint ← NIL;
END;
PseudoCursorPaint: ViewerClasses.PaintProc =
BEGIN
imager: Imager.Context ~ ImagerOps.ImagerFromGraphics[context];
data: REF DataRec ~ NARROW[self.data];
ImagerOps.MaskBitmap[imager, 0, 16, data.bitMap];
END;
psuedoCursor: ViewerClasses.ViewerClass ← NEW[ViewerClasses.ViewerClassRec ← [
paint: PseudoCursorPaint,
tipTable: NIL
]];
ViewerOps.RegisterViewerClass[$PsuedoCursor, psuedoCursor]; -- plug in to Viewers
END.
Michael Plass, September 15, 1982 12:15 pm: Increased waitTime from 50ms to 100 ms.
Michael Plass, November 2, 1982 10:48 am. CEDARized.