PseudoCursorsImpl.mesa
Michael Plass, November 2, 1982 10:48 am
Last Edited by: Beach, May 24, 1983 9:12 am
DIRECTORY
Graphics,
GraphicsOps,
Process,
PseudoCursors,
Terminal,
ViewerOps,
ViewerClasses;
PseudoCursorsImpl: CEDAR MONITOR
IMPORTS Graphics, GraphicsOps, Process, ViewerOps EXPORTS PseudoCursors =
BEGIN
PseudoCursor: TYPE = PseudoCursors.PseudoCursor;
DataRec: TYPE = RECORD [
bits: REF Terminal.BWCursorBitmap,
bitMap: GraphicsOps.BitmapRef,
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];
data.bitMap ← NEW[GraphicsOps.BitmapRep ← [base: data.bits, raster: 1, width: 16, height: 16]];
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
{bits ← NEW[Terminal.BWCursorBitmap ← ALL[0]]};
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
Graphics.SetCP[context, 0, 16];
GraphicsOps.DrawBitmap[context, NARROW[self.data, REF DataRec].bitMap, 16, 16];
END;
psuedoCursor: ViewerClasses.ViewerClass ← NEW[ViewerClasses.ViewerClassRec ← [
paint: PseudoCursorPaint,
tipTable: NIL
]];
TRUSTED{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.