PopUpMenus.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, August 22, 1986 11:00:59 am PDT
Last Edited by: Christian Jacobi, August 25, 1986 5:50:57 pm PDT
DIRECTORY
Rope USING [ROPE];
PopUpMenus: CEDAR DEFINITIONS =
BEGIN
Package which supports composition and invocation of popup menus.
ROPE: TYPE = Rope.ROPE;
Menu: TYPE = REF MenuRep; --handle representing a popup menu
MenuRep: TYPE = PRIVATE RECORD [impl: REF];
EntryProc: TYPE = PROC [menu: Menu←NIL, entryData: REFNIL, callData: REFNIL] RETURNS [REFNIL];
Type of procedure called on menu selection
menu:  popup menu used
entryData:  as defined for the menu entry
callData:  as given by call
returned value is passed to caller of menu
The NIL initializations are only of use for clients to call procedure directly
Create: PROC [header: ROPENIL, doc: ROPENIL, clientData: REF←NIL] RETURNS [Menu];
Creates a new popup menu (class)
(creates the handle, but does not invoke the created popup menu yet)
header:  header line of popup menu
doc:  documentation for header line and outside
clientData: stored for the client
Entry: PROC [menu: Menu, entry: ROPENIL, proc: EntryProc←NIL, entryData: REFNIL, doc: ROPENIL] RETURNS [sameMenu: Menu];
Makes an entry line for a popup menu
Replaces existing line if entry rope is already used
entry:  text for menu line
proc:  will be called on selection
entryData:  passed to proc on call
a NIL proc and a NIL entryData: removes entry from menu
a NIL proc: on call returns entryData
doc:  documentation for this line
sameMenu: for conveniance returns menu again
Timeout: PROC [menu: Menu, time: INT𡤀, proc: EntryProc←NIL, entryData: REFNIL] RETURNS [sameMenu: Menu];
Defines behaviour of popup menu on timeout
time:  in seconds; 0 for no timeout
proc:  will be called on timeout when menu is called
entryData:  passed to proc on timeout call
a NIL proc and a NIL entryData: no-op on time out (Normal case!)
a NIL proc: on timeout returns entryData
sameMenu: for conveniance returns menu again
Skipped: PROC [menu: Menu, proc: EntryProc←NIL, entryData: REFNIL] RETURNS [sameMenu: Menu];
Defines behaviour of popup menu when called and skipped (no entry selected, no timeout)
proc:  will be called on timeout when menu is called
entryData:  passed to proc on timeout call, or returned if proc=NIL
sameMenu: for conveniance returns menu again
Most menus do NOT define a skipped behaviour
Call: PROC [menu: Menu, callData: REFNIL, position: REFNIL, default: REFNIL] RETURNS [REF];
Calls a popup menu
(draws the menu, accepts interactive selection and calls the EntryProc)
returns data returned from called EntryProc
or entryData if EntryProc was NIL
menu: popup menu to be used
callData: passed to the EntryProc
position: position of popup menu (see documentation)
 defaults to: the current mouse position
default: entry line to select at the beginning; hint only! (see documentation)
 defaults to: no line selected at the beginning
ClientData: PROC [menu: Menu] RETURNS [REF];
returns clientData as given on Create
END.