DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ETI menus

Manipulating the menu user pointer

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;
   

char * menu_userptr (menu) MENU * menu;

By default, the menu user pointer (what menu_userptr returns) is NULL.

If successful, set_menu_userptr returns E_OK. If an error occurs, it returns the following:


E_SYSTEM_ERROR
system error
The code in ``Example setting and using a menu user pointer'' illustrates how you can use these two functions to display a title for your menu. Function main sets the menu user pointer to point to the title of the menu. Later, function display_menu initializes the title with the value returned by menu_userptr. We have previously seen a version of display_menu in ``Sample routines displaying and erasing menus''.
   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 */


Next topic: Setting and fetching menu options
Previous topic: Changing and fetching the pattern buffer

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004