xref: /openbsd/lib/libmenu/m_sub.c (revision 7b36286a)
1 /*	$OpenBSD: m_sub.c,v 1.4 2001/01/22 18:02:06 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30 
31 /****************************************************************************
32  *   Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
33  ****************************************************************************/
34 
35 /***************************************************************************
36 * Module m_sub                                                             *
37 * Menus subwindow association routines                                     *
38 ***************************************************************************/
39 
40 #include "menu.priv.h"
41 
42 MODULE_ID("$From: m_sub.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
43 
44 /*---------------------------------------------------------------------------
45 |   Facility      :  libnmenu
46 |   Function      :  int set_menu_sub(MENU *menu, WINDOW *win)
47 |
48 |   Description   :  Sets the subwindow of the menu.
49 |
50 |   Return Values :  E_OK           - success
51 |                    E_POSTED       - menu is already posted
52 +--------------------------------------------------------------------------*/
53 NCURSES_EXPORT(int)
54 set_menu_sub (MENU *menu, WINDOW *win)
55 {
56   if (menu)
57     {
58       if ( menu->status & _POSTED )
59 	RETURN(E_POSTED);
60       menu->usersub = win;
61       _nc_Calculate_Item_Length_and_Width(menu);
62     }
63   else
64     _nc_Default_Menu.usersub = win;
65 
66   RETURN(E_OK);
67 }
68 
69 /*---------------------------------------------------------------------------
70 |   Facility      :  libnmenu
71 |   Function      :  WINDOW *menu_sub(const MENU *menu)
72 |
73 |   Description   :  Returns a pointer to the subwindow of the menu
74 |
75 |   Return Values :  NULL on error, otherwise a pointer to the window
76 +--------------------------------------------------------------------------*/
77 NCURSES_EXPORT(WINDOW *)
78 menu_sub (const MENU * menu)
79 {
80   const MENU* m = Normalize_Menu(menu);
81   return Get_Menu_Window(m);
82 }
83 
84 /* m_sub.c ends here */
85