1 /*-----------------------------------------------------------------------------+
2 | The ncurses menu library is Copyright (C) 1995-1997 |
3 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
4 | All Rights Reserved. |
6 | Permission to use, copy, modify, and distribute this software and its |
7 | documentation for any purpose and without fee is hereby granted, provided |
8 | that the above copyright notice appear in all copies and that both that |
9 | copyright notice and this permission notice appear in supporting |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the |
12 | software without specific, written prior permission. |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 +-----------------------------------------------------------------------------*/
23 /***************************************************************************
25 * Menus window and subwindow association routines *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_win.c,v 1.5 1997/05/01 16:47:26 juergen Exp $")
32 /*---------------------------------------------------------------------------
34 | Function : int set_menu_win(MENU *menu, WINDOW *win)
36 | Description : Sets the window of the menu.
38 | Return Values : E_OK - success
39 | E_POSTED - menu is already posted
40 +--------------------------------------------------------------------------*/
41 int set_menu_win(MENU *menu, WINDOW *win)
45 if ( menu->status & _POSTED )
48 _nc_Calculate_Item_Length_and_Width(menu);
51 _nc_Default_Menu.userwin = win;
56 /*---------------------------------------------------------------------------
58 | Function : WINDOW *menu_win(const MENU *)
60 | Description : Returns pointer to the window of the menu
62 | Return Values : NULL on error, otherwise pointer to window
63 +--------------------------------------------------------------------------*/
64 WINDOW *menu_win(const MENU *menu)
66 const MENU* m = Normalize_Menu(menu);
67 return (m->userwin ? m->userwin : stdscr);
70 /*---------------------------------------------------------------------------
72 | Function : int set_menu_sub(MENU *menu, WINDOW *win)
74 | Description : Sets the subwindow of the menu.
76 | Return Values : E_OK - success
77 | E_POSTED - menu is already posted
78 +--------------------------------------------------------------------------*/
79 int set_menu_sub(MENU *menu, WINDOW *win)
83 if ( menu->status & _POSTED )
86 _nc_Calculate_Item_Length_and_Width(menu);
89 _nc_Default_Menu.usersub = win;
94 /*---------------------------------------------------------------------------
96 | Function : WINDOW *menu_sub(const MENU *menu)
98 | Description : Returns a pointer to the subwindow of the menu
100 | Return Values : NULL on error, otherwise a pointer to the window
101 +--------------------------------------------------------------------------*/
102 WINDOW *menu_sub(const MENU * menu)
104 const MENU* m = Normalize_Menu(menu);
105 return Get_Menu_Window(m);
108 /*---------------------------------------------------------------------------
109 | Facility : libnmenu
110 | Function : int scale_menu(const MENU *menu)
112 | Description : Returns the minimum window size necessary for the
115 | Return Values : E_OK - success
116 | E_BAD_ARGUMENT - invalid menu pointer
117 | E_NOT_CONNECTED - no items are connected to menu
118 +--------------------------------------------------------------------------*/
119 int scale_menu(const MENU *menu, int *rows, int *cols)
122 RETURN( E_BAD_ARGUMENT );
124 if (menu->items && *(menu->items))
127 *rows = menu->height;
133 RETURN( E_NOT_CONNECTED );
136 /* m_win.c ends here */