MenuSystem.mesa
Copyright © 1985, Xerox Corporation. All rights reserved.
Provides a client interface to establish a network of pop-up menus.
by Eric Nickell, March 22, 1985 10:16:38 pm PST
Last edited by Eric Nickell, March 25, 1985 5:18:20 pm PST
DIRECTORY
Rope USING [ROPE];
MenuSystem: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE ~ Rope.ROPE;
MenuSystem: TYPE ~ REF MenuSystemRec; --The actual network of menus, etc.
MenuSystemRec: TYPE;   --Details private, and subject to change.
Menu: TYPE ~ RECORD [
title: ROPE,  --May be NIL for no title, iff not referenced by other menus
options: LIST OF ROPE,
defaultSelection: CARDINAL ← 0, --See PopUpMenu.mesa
sticky: BOOLEANFALSE--See discussion of this bit at Select[].
];
CreateMenuSystem: PROC RETURNS [ms: MenuSystem];
InstallMenu: PROC [ms: MenuSystem, menu: Menu];
Lets the MenuSystem know about the menu. If already existing, then replaces old definition.
InstallRefMenu: PROC [ms: MenuSystem, menu: REF Menu];
Same as above, except that the client can hold onto the REF himself, and fiddle with all the parameters. It becomes the client's responsibility to avoid munching on the data at the same time that the menu system is being used. (See CallUnderLock below.) Changing the title is dangerous.
RemoveMenu: PROC [ms: MenuSystem, title: ROPE];
Also removes Actions.
InstallAction: PROC [ms: MenuSystem, title: ROPE, action: REF];
This provides an association between a terminal branch of a menu network, and some REF of the user's choice. Note that installing an action will overwrite a menu with the same title.
Select: PROC [ms: MenuSystem, title: ROPENIL] RETURNS [action: REF];
Brings up the Pop-up menu whose title is title, and lets the user make a selection. If the user's selection (the ROPE, that is) is the title of another menu, that menu is brought up, and the cycle repeats itself.
If the user's selection (the ROPE) has had an action installed for it, then the action is returned. Otherwise, the ROPE itself is returned.
If no title is passed (i.e., = NIL), then MenuSystem will attempt to guess the best menu to bring up. This will be the most recent menu displayed whose sticky bit is TRUE.
CallUnderLock: PROC [proc: PROC];
Calls the requested procedure under monitor lock.
END.