JunoCursorMenu.mesa
Excised from JunoTop by Stolfi, March 29, 1984 8:49:34 am PST
Last Edited by: Jorge Stolfi June 2, 1984 9:04:25 am PDT
This module provides a cursor menu sub-viewer for Juno.
Calling CreateCursorMenu will create a new viewer M as a child of some parent viewer V. The viewer M displays a menu of cursors, arranged in a rectangular array with client-specified dimensions. Procedure AddCursor is used to define the bit pattern, the position (row and column), and and the "name" of each cursor.
When the mouse is clicked over one of the cursors displayed in M, two things happen: (1) the cursor pattern of V (the parent viewer) is replaced by the selected one, and (2) a list of the form ($Cursor, <cursor name>) is sent to V's NotifyProc.
Note: to be precise, item (1) affects not only V but all viewers with the same class as V. The reason is that the cursor pattern is currently a property of the Viewer's class rather than of the Viewer itself. Since only V itself is notified of the cursor change, V should be the only instance of its class.
DIRECTORY
ViewerClasses USING [Viewer],
Rope USING [ROPE],
Terminal USING [BWCursorBitmap];
BEGIN
Viewer: TYPE = ViewerClasses.Viewer;
Index: TYPE = INTEGER[1..254]; -- so that an row*nCols + col fits in 16 bits
CreateCursorMenu:
PROC
[parent: Viewer, x, y:
INTEGER, rows, cols: Index, showCurrent:
BOOL ←
TRUE]
RETURNS [menu: Viewer];
Creates a cursor menu with the given number of rows and columns, as a children of the specified parent.
The upper left corner of the menu will be placed at the point [x, y] relative to the parent's frame.
If ShowCurrent, the currently selected cursor will be framed on the menu.
AddCursor:
PROC
[menu: Viewer,
name:
ATOM,
help: Rope.
ROPE,
bits: Terminal.BWCursorBitmap,
row, col: Index,
hotX, hotY:
INTEGER ← 0,
setFocus:
BOOL ←
TRUE];
Adds (or replaces) a cursor entry on the specified row and column of the given cursor menu.
The name must not be NIL.
The hotX, hotY parameters specify the cursor's hot spot. [0,0] means the upper left corner, [-8,-8] means the center, etc.
If setFocus is true (default), picking up this cursor will automatically set the InputFocus to the parent's viewer, thus diverting all subsequent keyboard events to its NotifyProc.
This procedure will allocate a new CursorType; since there are only 37 CursorType available to clients in the whole universe, it should be used with moderation.
The help rope is displayed on the herald window when the cursor is selected.
RemoveCursor:
PROC [menu: Viewer, name:
ATOM];
Removes the cursor of the given name from the given menu.
Will not de-allocate the corresponding CursorType.
Will raise an error if there is no cursor with the given name.
PickUpCursor:
PROC [menu: Viewer, name:
ATOM, notify:
BOOL ←
TRUE];
A call to this procedure has essentially the same effect as a user click over the menu entry with the given name.
It will change the cursor of the parent viewer, set the latter as the keyboard input focus (if the cursor's setFocus bit is set), and ship the list [$Cursor <cursor name>] to the parent's notifier (unless notify=FALSE).
Will raise an error if there is no cursor with the given name.
HighlightCursor:
PROC [menu: Viewer, name:
ATOM, grayIt:
BOOL ←
TRUE];
Highligfhts the specified cursor by covering it with a gray mask.
If grayIt=FALSE, removes the gray mask from that cursor.
Does not notify parent.
Will raise an error if there is no cursor with the given name.