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_opt *
25 * Menus item option routines *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_item_opt.c,v 1.4 1997/05/01 16:47:26 juergen Exp $")
32 /*---------------------------------------------------------------------------
34 | Function : int set_item_opts(ITEM *item, Item_Options opts)
36 | Description : Set the options of the item. If there are relevant
37 | changes, the item is connected and the menu is posted,
38 | the menu will be redisplayed.
40 | Return Values : E_OK - success
41 | E_BAD_ARGUMENT - invalid item options
42 +--------------------------------------------------------------------------*/
43 int set_item_opts(ITEM *item, Item_Options opts)
45 if (opts & ~ALL_ITEM_OPTS)
46 RETURN(E_BAD_ARGUMENT);
50 if (item->opt != opts)
52 MENU *menu = item->imenu;
56 if ((!(opts & O_SELECTABLE)) && item->value)
59 if (menu && (menu->status & _POSTED))
61 Move_And_Post_Item( menu, item );
67 _nc_Default_Item.opt = opts;
72 /*---------------------------------------------------------------------------
74 | Function : int item_opts_off(ITEM *item, Item_Options opts)
76 | Description : Switch of the options for this item.
78 | Return Values : E_OK - success
79 | E_BAD_ARGUMENT - invalid options
80 +--------------------------------------------------------------------------*/
81 int item_opts_off(ITEM *item, Item_Options opts)
83 ITEM *citem = item; /* use a copy because set_item_opts must detect
84 NULL item itself to adjust its behaviour */
86 if (opts & ~ALL_ITEM_OPTS)
87 RETURN(E_BAD_ARGUMENT);
90 Normalize_Item(citem);
91 opts = citem->opt & ~opts;
92 return set_item_opts( item, opts );
96 /*---------------------------------------------------------------------------
98 | Function : int item_opts_on(ITEM *item, Item_Options opts)
100 | Description : Switch on the options for this item.
102 | Return Values : E_OK - success
103 | E_BAD_ARGUMENT - invalid options
104 +--------------------------------------------------------------------------*/
105 int item_opts_on(ITEM *item, Item_Options opts)
107 ITEM *citem = item; /* use a copy because set_item_opts must detect
108 NULL item itself to adjust its behaviour */
110 if (opts & ~ALL_ITEM_OPTS)
111 RETURN(E_BAD_ARGUMENT);
114 Normalize_Item(citem);
115 opts = citem->opt | opts;
116 return set_item_opts( item, opts );
120 /*---------------------------------------------------------------------------
121 | Facility : libnmenu
122 | Function : Item_Options item_opts(const ITEM *item)
124 | Description : Switch of the options for this item.
126 | Return Values : Items options
127 +--------------------------------------------------------------------------*/
128 Item_Options item_opts(const ITEM * item)
130 return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
133 /* m_item_opt.c ends here */