defpup() — Silicon Graphics
NAME
defpup - defines a menu
SPECIFICATION
C
int defpup(str [, args ] ... )
char *str;
long args;
FORTRAN
Note: available only in C
Pascal
Note: available only in C
DESCRIPTION
defpup defines a popup menu by providing str, a string which describes each menu item. Menu items are one of three types: title, submenu, or selectable item. A title item is simply the string displayed at the top of the menu. A submenu item is an item which if rolled off to either side will invoke a submenu with further choices. A selectable item, selected with the right mouse button, may have a numeric value, function, or implied numeric value associated with it. The optional arguments to defpup should provide submenu identifiers as returned by defpup and newpup and/or handling function addresses as dictated by str. str is made up of label/type pairs separated by vertical bars. Each label/type pair is made up of a menu label and an optional typing character which is preceded by a percent sign. The item types are as follows:
%t title string
%F menu function invoked by any item selection
%f item function invoked by buttoning the associated item
%m submenu brought up by rolling off the associated item
%n normal item (default) selected by buttoning the associated item
%x# numeric item selected by buttoning the associated item
The use of the item types is best illustrated by some example.
menu=defpup("foo %t |item 1|item 2 |item 3 |item 4");
defines a popup menu with title foo and four items. A menu of this type could be used as follows:
switch (dopup(menu)) {
case 1 : /* item 1 */
handling code
break;
case 2 : /* item 2 */
handling code
break;
case 3 : /* item 3 */
handling code
break;
case 4 : /* item 4 */
handling code
break;
}
A more complicated example is:
menu=defpup("foobar %t %F|item 1 %n|item 2 %m|item 3 %f|item 4 %x234",
menufunc, submenu, func);
defines a menu with title foobar and four items. Invoked by:
menuval = dopup(menu);
Buttoning menu item 1 causes dopup to return menufunc(1). Rolling off menu item 2 causes submenu to be displayed, providing the user with additional selections. If a selection is made, dopup returns menufunc(dopup(submenu)); otherwise submenu disappears and selections may be made from menu. Buttoning item 3 causes the function func to be executed with 3 as its argument. dopup returns menufunc(func(3)). Buttoning item 4 causes dopup to return menufunc(234). If no item is selected then dopup returns −1. Any function that is invoked from a popup menu is executed out of pupmode and full screen mode. If a menu handling function wishes to use the popup planes and/or regions of the screen beyond the process’s graphics port it must make calls to pupmode and/or fullscrn.
SEE ALSO
newpup, addtopup, dopup, freepup
“Multiple Exposure: The IRIS Window Manager” in the IRIS User’s Guide
NOTE
This command can be used only in immediate mode. This command is not supported in FORTRAN or Pascal; use newpup and addtopup. This command should be used only under the window manager. It cannot be called remotely.
Version 2.4 — May 08, 1986