CDMenus.mesa  (a ChipNDale module)
Copyright © 1984, 1986 by Xerox Corporation. All rights reserved.
Created by: Ch. Jacobi, September 18, 1984 3:24:53 pm PDT
Last Edited by: Ch. Jacobi, March 14, 1986 10:11:52 am PST
DIRECTORY
CD USING [Technology],
CDSequencer USING [Command, CommandProc, QueueMethod],
Rope USING [ROPE];
CDMenus: CEDAR DEFINITIONS =
BEGIN
Implements pop up menus.
CreateMenu: PROC [label: Rope.ROPENIL, globalKey: ATOM NIL] RETURNS [menu: REF];
--Creates a new menu
--label: its header line
--globalKey: If not NIL, the menu may be fetched (GetMenu) using this atom
GetMenu: PROC [globalKey: ATOM] RETURNS [menu: REF];
--Fetches a menu which had been created with a globalKey
--NIL if not found
CreateEntry: PROC [menu: REF, entry: Rope.ROPE NIL, key: REF];
--Makes an entry line in a menu (overwrite if ropes are equal, remove if NIL)
--menu: a menu => use this menu
-- an ATOM => fetch for menu with globalKey
--key: a menu => use the key menu recursively
-- an ATOM => return this as result (does NOT search for a menu) /
--  use CDSequencer
-- others => return as result / error message
CallMenu: PROC [menu: REF] RETURNS [key: REF];
--Calls a menu and return the selected key
--(recursively, until returned key is not of type menu)
CallMenuAndExecute: PROC [menu: REF, comm: CDSequencer.Command];
--Calls a menu and replace the "comm" key with the selected key
--then "comm" is executed
ImplementCommandToCallMenu: PROC[key: ATOM, menu: REF, technology: CD.Technology ← NIL];
--Implements a CDSequencer command "key" which shows the "menu" and after
--selection executes the selected entry
ImplementEntryCommand: PROC [menu: REF, entry: Rope.ROPENIL, p: CDSequencer.CommandProc, key: ATOMNIL, queue: CDSequencer.QueueMethod ← doQueue, technology: CD.Technology ← NIL];
--For conveniance only; Entry appears in all technologies.
--Creates an entry line into the menu and sets it up to call the command p.
--key: key of the command; is made up if NIL.
END.