|
|
As it does for panels and forms, ETI provides user pointers for each menu. You can use these pointers to reference menu messages, titles, and the like.
SYNOPSIS
int set_menu_userptr (menu, userptr) MENU menu; char userptr;By default, the menu user pointer (what menu_userptr returns) is NULL.char menu_userptr (menu) MENU menu;
If successful, set_menu_userptr returns
E_OK
.
If an error occurs, it returns
the following:
static void display_menu (m) /* create menu windows and post */ MENU * m; { char * title = menu_userptr (m); /* fetch menu title */WINDOW * w; int rows; int cols;
scale_menu (m, &rows, &cols); /* get dimensions of menu */
/* create menu window and subwindow */
if (w = newwin (rows+2, cols+2, 0, 0)) { set_menu_win (m, w); set_menu_sub (m, derwin (w, rows, cols, 1, 1)); box (w, 0, 0); keypad (w, 1); } else error ("error return from newwin", NULL);
if (post_menu (m) != E_OK) error ("error return from post_menu", NULL); if (title) /* if title set */ { size = strlen (title); wmove (w, 0, (cols-size)/2+1); /* position cursor */ waddstr (w, title); /* write title */ } } main () { MENU * m; char * menutitle; /* initialize menutitle to desired string */
set_menu_userptr (m, menutitle); /* set user pointer to point to title */ display_menu (m); }
Example setting and using a menu user pointer
If function set_menu_userptr is passed a NULL menu pointer,
like all ETI functions,
it assigns a new current default menu user pointer.
In the following,
the new default is the string Default Menu Title
.
MENU * m;char * userprtr = "Default Menu Title";
set_menu_userptr( (MENU *) 0, userptr); /* sets new default userptr */