MULTIMENU 27-Aug-82 MULTIMENU is a package which allows you to create a number of menus or windows to be associated with a main window. For example, consider an editor whose commands (menu driven) are a function of the item selected in the editor window. It is nice to have those menus which are contextually inappropriate to disappear, and to have the only appropriate menu (or menus) be highlighted in some way. (MAKEMENUS WINDOW MENULST WIDTH) WINDOW is the window to associate the menus with. MENULST is a list of menus of windows to associate. Each item in the list can be one of: - An instance of the record MENULSTENTRY (see below); - An already created MENU; - An already created WINDOW; - A LITATOM which resolves to a MENU or WINDOW. For each item which is a MENULSTENTRY, a menu will be created in a standard form: centered items and a 2 pixel border. If MENUSCROLLFLG is a number, and MENUITEMS is a list or a MENU, if the height of the menu is greater than MENUSCROLLFLG, the menu is placed in a scrolling window, limited to MENUSCROLLFLG pixels high. If WIDTH is specified, all menus are created with ITEMWIDTH=WIDTH. If not specified, MAKEMENUS calls the function \FIND-WIDEST- MENU, to determine the width for created menus. The main window gets several properties for bookkeeping; CLOSEFN and MOVEFN are set so that its subsidiary windows are also closed or moved, and RESHAPEFN becomes DON'T. The new property ITEMMENU is a list of subsidiary windows of the form (TITLE . WINDOW) where WINDOW is either a window from MENULST or the window containing a MENU from MENULST. The new property MINMENUHEIGHT keeps track of the bottom of the column of menus. (DELETEALLMENUS MAINW) Deletes all menus associated with MAINW. (CREATEWINDOWFROMBOX WIDTH HEIGHT TITLE) Uses GETBOXPOSITION to ghost a region WIDTH by HEIGHT, returning a window created at the final position, having title TITLE. (GRAYMENU MAINWINDOW MENUID #ITEMSTOGRAY) Grays out the menu. If #ITEMSTOGRAY is NIL, The window's BUTTONEVENTFN is stored away as another property so the menu is deactivated, and the menu is completely grayed over. If #ITEMSTOGRAY is a number, that number of menu items, counting from the bottom of the menu, going up, is grayed over. Grayed over items in such a partially grayed menus will not respond to selection. If #ITEMSTOGRAY is 0, UNGRAYMENU is called, instead. (UNGRAYMENU MAINWINDOW MENUID) Reactivates a (partially) grayed the menu, restoring both its appearance and original behavior. (ADDMULTIMENU MAINW NEWMENULSTENTRY WHERE) Adds a new menu to the menucolumn. WHERE is a list of form (FIRST), (LAST), (BEFORE <MENUID>), or (AFTER <MENUID>). If NIL, WHERE defaults to (LAST). (DELMULTIMENU MAINW MENUID) Deletes the menu with MENUID; all menus beneath the deleted one move up to fill up the blank space. (CHANGEMULTIMENU MAINW OLDMENUID NEWMENUID) Deletes the oldmenu and replaces it with the new one. (MENUEXISTS MAINW MENUID) Returns T if there is a menu with MENUID associated with MAINW. (MAKETTYWINDOW MAINW TTYH) Makes a TTY window associated with window MAINW. This window will be as wide as MAINW plus the WIDTH of the menucolumn associated with MAINW, and will be TTYH (default \TTYHEIGHT) high. The window is located directly below MAINW. (WINDOWDOFUN WINDOW FN) An NLAMBDA. Resets the TTYDISPLAYSTREAM to WINDOW (if NIL, creates one with MAKETTYWINDOW) and evaluates FN. (\MAKEMENU WINDOW MENULSTENTRY WIDTH) Puts up the individual menus or windows. (\FIND-WIDEST-MENU MENULST) Scans MENULST to determine the widest menu or window. (\FIND-MENUCOLUMN-HEIGHT MENULST) Like above, only returns the height of the column of menus to be created from MENULST. (\MENUCLOSEFN WINDOW) The function put on the main window's CLOSEFN property, to close the subsidiary menus/windows. (\MENUMOVEFN WINDOW) Like above, but for the MOVEFN property. Uses RELMOVEW to retain the same relative position between the main window and subsidiary windows after the move. The record template MENULSTENTRY is defined as (RECORD MENULSTENTRY (MENUITEMS MENUTITLE SELECTEDFN MENUID MENUSCROLLFLG)). If MENUID is NIL, it receives the value of MENUTITLE. MENUSCROLLFLG is either NIL: Never scroll; a NUMBER: Limit the menu to NUMBER pixels high, and make it scroll. If menu is shorter than NUMBER pixels, a standard (non-scrolling) menu is created. Eric Schoen SDR