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 /***************************************************************************
24 * Module menu_item_val *
25 * Set and get menus item values *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_item_val.c,v 1.4 1997/05/01 16:47:26 juergen Exp $")
32 /*---------------------------------------------------------------------------
34 | Function : int set_item_value(ITEM *item, int value)
36 | Description : Programmatically set the items selection value. This is
37 | only allowed if the item is selectable at all and if
38 | it is not connected to a single-valued menu.
39 | If the item is connected to a posted menu, the menu
40 | will be redisplayed.
42 | Return Values : E_OK - success
43 | E_REQUEST_DENIED - not selectable or single valued menu
44 +--------------------------------------------------------------------------*/
45 int set_item_value(ITEM *item, bool value)
53 if ((!(item->opt & O_SELECTABLE)) ||
54 (menu && (menu->opt & O_ONEVALUE)))
55 RETURN(E_REQUEST_DENIED);
57 if (item->value ^ value)
59 item->value = value ? TRUE : FALSE;
62 if (menu->status & _POSTED)
64 Move_And_Post_Item(menu,item);
71 _nc_Default_Item.value = value;
76 /*---------------------------------------------------------------------------
78 | Function : bool item_value(const ITEM *item)
80 | Description : Return the selection value of the item
82 | Return Values : TRUE - if item is selected
83 | FALSE - if item is not selected
84 +--------------------------------------------------------------------------*/
85 bool item_value(const ITEM *item)
87 return ((Normalize_Item(item)->value) ? TRUE : FALSE);
90 /* m_item_val.c ends here */