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

Associating windows and subwindows with menus

Two windows are associated with each menu -- the menu window and the menu subwindow. The following functions assign windows and subwindows to menus and fetch those previously assigned to them.

SYNOPSIS

   int set_menu_win (menu, window)
   MENU * menu;
   WINDOW * window;
   

WINDOW * menu_win (menu) MENU * menu;

int set_menu_sub (menu, window) MENU * menu; WINDOW * window;

WINDOW * menu_sub (menu) MENU * menu;

To place a border around your menu or give it a title, you call set_menu_win and write to the associated window.


NOTE: By default, (1) the menu window is NULL, which by convention means that ETI uses stdscr as the menu window; and (2) the menu subwindow is NULL, which means that ETI uses the menu window as the menu subwindow.

If you do not want to use the system defaults, you may create a window and a subwindow for every menu. ETI automatically writes all output of the menu proper on the menu's subwindow. You may write additional output (such as borders, titles, and the like) on the menu's window. The relationship between ETI menu routines, your application program, a menu window, and a menu subwindow is illustrated in ``Menu functions write to subwindow, application to window''.

Menu functions write to subwindow, application to window


NOTE: You should apply all output and refresh operations to the menu window, not its subwindow.

``Creating a menu with a border'' shows how you can create and display a menu with a border of the default characters, ACS_VLINE and ACS_HLINE. (See the box command in the curses(3ocurses) manual pages.)

   MENU * m;
   WINDOW * w;
   int rows, cols;
   

scale_menu (m, &rows, &cols); /* get dimensions of menu */

/* create window 2 characters larger than menu dimensions with top left corner at (0, 0). subwindow is positioned at (1, 1) relative to menu window origin with dimensions equal to the menu dimensions. */

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); /* draw border in w */ }

Creating a menu with a border

Variables rows and cols provide the menu dimensions without the border. The dimensions of the menu subwindow are set to these values. In general, if you want a simple border, you should set the number of rows and columns in the menu's window to be two more than the numbers in its subwindow, as in the example.

Remember that the initial default menu window and subwindow are NULL. (By convention, this means that stdscr is used as the menu window and the menu window is used as the menu subwindow.) If you want to change the current default menu window or subwindow, you can pass functions set_menu_win and set_menu_sub a NULL menu pointer. Thus, the code

   WINDOW * dftwin;
   

set_menu_win ((MENU *) 0, dftwin); /* sets default menu window to dftwin */

changes the current default window to dftwin.

If successful, functions set_menu_win and set_menu_sub return E_OK. If not, they return one of the following:


E_SYSTEM_ERROR
system error

E_POSTED
menu is posted

Next topic: Fetching and changing a menu's display attributes
Previous topic: Querying the menu dimensions

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