PopUpMenus.mesa
Copyright Ó 1986, 1991 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, August 22, 1986 11:00:59 am PDT
Last Edited by: Christian Jacobi, December 23, 1986 12:02:55 pm PST
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: REF¬NIL, callData: REF¬NIL] RETURNS [REF¬NIL];
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: ROPE¬NIL, doc: ROPE¬NIL, 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: ROPE¬NIL, proc: EntryProc¬NIL, entryData: REF¬NIL, doc: ROPE¬NIL] 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¬0, proc: EntryProc¬NIL, entryData: REF¬NIL] 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: REF¬NIL] 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
ReLabel: PROC [menu: Menu, header: ROPE¬NIL, doc: ROPE¬NIL] RETURNS [sameMenu: Menu];
Redefines header and doc for a menu
header:  header line of popup menu
doc:  documentation for header line and outside
sameMenu: for conveniance returns menu again
Call: PROC [menu: Menu, callData: REF¬NIL, position: REF¬NIL, default: REF¬NIL] 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.