m_items.c revision 1.1
1 2/*************************************************************************** 3* COPYRIGHT NOTICE * 4**************************************************************************** 5* ncurses is copyright (C) 1992-1995 * 6* Zeyd M. Ben-Halim * 7* zmbenhal@netcom.com * 8* Eric S. Raymond * 9* esr@snark.thyrsus.com * 10* * 11* Permission is hereby granted to reproduce and distribute ncurses * 12* by any means and for any fee, whether alone or as part of a * 13* larger distribution, in source or in binary form, PROVIDED * 14* this notice is included with any such distribution, and is not * 15* removed from any of its header files. Mention of ncurses in any * 16* applications linked with it is highly appreciated. * 17* * 18* ncurses comes AS IS with no warranty, implied or expressed. * 19* * 20***************************************************************************/ 21 22/*************************************************************************** 23* Module menu_items * 24* Connect and disconnect items to and from menus * 25***************************************************************************/ 26 27#include "menu.priv.h" 28 29/*--------------------------------------------------------------------------- 30| Facility : libnmenu 31| Function : int set_menu_items(MENU *menu, ITEM **items) 32| 33| Description : Sets the item pointer array connected to menu. 34| 35| Return Values : E_OK - success 36| E_POSTED - menu is already posted 37| E_CONNECTED - one or more items are already connected 38| to another menu. 39| E_BAD_ARGUMENT - An incorrect menu or item array was 40| passed to the function 41+--------------------------------------------------------------------------*/ 42int set_menu_items(MENU * menu, ITEM ** items) 43{ 44 if (!menu || (items && !(*items))) 45 RETURN(E_BAD_ARGUMENT); 46 47 if ( menu->status & _POSTED ) 48 RETURN(E_POSTED); 49 50 if (menu->items) 51 _nc_Disconnect_Items(menu); 52 53 if (items) 54 { 55 if(!_nc_Connect_Items( menu, items )) 56 RETURN(E_CONNECTED); 57 } 58 59 menu->items = items; 60 RETURN(E_OK); 61} 62 63/*--------------------------------------------------------------------------- 64| Facility : libnmenu 65| Function : ITEM **menu_items(const MENU *menu) 66| 67| Description : Returns a pointer to the item pointer arry of the menu 68| 69| Return Values : NULL on error 70+--------------------------------------------------------------------------*/ 71ITEM **menu_items(const MENU *menu) 72{ 73 return(menu ? menu->items : (ITEM **)0); 74} 75 76/*--------------------------------------------------------------------------- 77| Facility : libnmenu 78| Function : int item_count(const MENU *menu) 79| 80| Description : Get the number of items connected to the menu. If the 81| menu pointer is NULL we return -1. 82| 83| Return Values : Number of items or -1 to indicate error. 84+--------------------------------------------------------------------------*/ 85int item_count(const MENU *menu) 86{ 87 return(menu ? menu->nitems : -1); 88} 89 90/* m_items.c ends here */ 91