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 * Connect and disconnect items to and from menus *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_items.c,v 1.4 1997/05/01 16:47:26 juergen Exp $")
32 /*---------------------------------------------------------------------------
34 | Function : int set_menu_items(MENU *menu, ITEM **items)
36 | Description : Sets the item pointer array connected to menu.
38 | Return Values : E_OK - success
39 | E_POSTED - menu is already posted
40 | E_CONNECTED - one or more items are already connected
42 | E_BAD_ARGUMENT - An incorrect menu or item array was
43 | passed to the function
44 +--------------------------------------------------------------------------*/
45 int set_menu_items(MENU * menu, ITEM ** items)
47 if (!menu || (items && !(*items)))
48 RETURN(E_BAD_ARGUMENT);
50 if ( menu->status & _POSTED )
54 _nc_Disconnect_Items(menu);
58 if(!_nc_Connect_Items( menu, items ))
66 /*---------------------------------------------------------------------------
68 | Function : ITEM **menu_items(const MENU *menu)
70 | Description : Returns a pointer to the item pointer arry of the menu
72 | Return Values : NULL on error
73 +--------------------------------------------------------------------------*/
74 ITEM **menu_items(const MENU *menu)
76 return(menu ? menu->items : (ITEM **)0);
79 /*---------------------------------------------------------------------------
81 | Function : int item_count(const MENU *menu)
83 | Description : Get the number of items connected to the menu. If the
84 | menu pointer is NULL we return -1.
86 | Return Values : Number of items or -1 to indicate error.
87 +--------------------------------------------------------------------------*/
88 int item_count(const MENU *menu)
90 return(menu ? menu->nitems : -1);
93 /* m_items.c ends here */