m_item_opt.c revision 166124
10Sstevel@tonic-gate/**************************************************************************** 20Sstevel@tonic-gate * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * 30Sstevel@tonic-gate * * 40Sstevel@tonic-gate * Permission is hereby granted, free of charge, to any person obtaining a * 513093SRoger.Faulkner@Oracle.COM * copy of this software and associated documentation files (the * 613093SRoger.Faulkner@Oracle.COM * "Software"), to deal in the Software without restriction, including * 70Sstevel@tonic-gate * without limitation the rights to use, copy, modify, merge, publish, * 80Sstevel@tonic-gate * distribute, distribute with modifications, sublicense, and/or sell * 90Sstevel@tonic-gate * copies of the Software, and to permit persons to whom the Software is * 100Sstevel@tonic-gate * furnished to do so, subject to the following conditions: * 110Sstevel@tonic-gate * * 120Sstevel@tonic-gate * The above copyright notice and this permission notice shall be included * 130Sstevel@tonic-gate * in all copies or substantial portions of the Software. * 140Sstevel@tonic-gate * * 150Sstevel@tonic-gate * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 160Sstevel@tonic-gate * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 170Sstevel@tonic-gate * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 180Sstevel@tonic-gate * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 190Sstevel@tonic-gate * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 200Sstevel@tonic-gate * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2113093SRoger.Faulkner@Oracle.COM * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 220Sstevel@tonic-gate * * 2313093SRoger.Faulkner@Oracle.COM * Except as contained in this notice, the name(s) of the above copyright * 240Sstevel@tonic-gate * holders shall not be used in advertising or otherwise to promote the * 250Sstevel@tonic-gate * sale, use or other dealings in this Software without prior written * 260Sstevel@tonic-gate * authorization. * 270Sstevel@tonic-gate ****************************************************************************/ 280Sstevel@tonic-gate 290Sstevel@tonic-gate/**************************************************************************** 300Sstevel@tonic-gate * Author: Juergen Pfeifer, 1995,1997 * 310Sstevel@tonic-gate ****************************************************************************/ 320Sstevel@tonic-gate 330Sstevel@tonic-gate/*************************************************************************** 340Sstevel@tonic-gate* Module m_item_opt * 350Sstevel@tonic-gate* Menus item option routines * 360Sstevel@tonic-gate***************************************************************************/ 370Sstevel@tonic-gate 380Sstevel@tonic-gate#include "menu.priv.h" 390Sstevel@tonic-gate 400Sstevel@tonic-gateMODULE_ID("$Id: m_item_opt.c,v 1.17 2004/12/25 21:32:54 tom Exp $") 410Sstevel@tonic-gate 420Sstevel@tonic-gate/*--------------------------------------------------------------------------- 430Sstevel@tonic-gate| Facility : libnmenu 440Sstevel@tonic-gate| Function : int set_item_opts(ITEM *item, Item_Options opts) 450Sstevel@tonic-gate| 460Sstevel@tonic-gate| Description : Set the options of the item. If there are relevant 470Sstevel@tonic-gate| changes, the item is connected and the menu is posted, 480Sstevel@tonic-gate| the menu will be redisplayed. 490Sstevel@tonic-gate| 500Sstevel@tonic-gate| Return Values : E_OK - success 510Sstevel@tonic-gate| E_BAD_ARGUMENT - invalid item options 520Sstevel@tonic-gate+--------------------------------------------------------------------------*/ 530Sstevel@tonic-gateNCURSES_EXPORT(int) 540Sstevel@tonic-gateset_item_opts(ITEM * item, Item_Options opts) 550Sstevel@tonic-gate{ 560Sstevel@tonic-gate T((T_CALLED("set_menu_opts(%p,%d)"), item, opts)); 570Sstevel@tonic-gate 580Sstevel@tonic-gate opts &= ALL_ITEM_OPTS; 590Sstevel@tonic-gate 600Sstevel@tonic-gate if (opts & ~ALL_ITEM_OPTS) 610Sstevel@tonic-gate RETURN(E_BAD_ARGUMENT); 620Sstevel@tonic-gate 630Sstevel@tonic-gate if (item) 640Sstevel@tonic-gate { 650Sstevel@tonic-gate if (item->opt != opts) 660Sstevel@tonic-gate { 670Sstevel@tonic-gate MENU *menu = item->imenu; 680Sstevel@tonic-gate 690Sstevel@tonic-gate item->opt = opts; 700Sstevel@tonic-gate 710Sstevel@tonic-gate if ((!(opts & O_SELECTABLE)) && item->value) 720Sstevel@tonic-gate item->value = FALSE; 730Sstevel@tonic-gate 740Sstevel@tonic-gate if (menu && (menu->status & _POSTED)) 750Sstevel@tonic-gate { 760Sstevel@tonic-gate Move_And_Post_Item(menu, item); 770Sstevel@tonic-gate _nc_Show_Menu(menu); 780Sstevel@tonic-gate } 790Sstevel@tonic-gate } 800Sstevel@tonic-gate } 810Sstevel@tonic-gate else 820Sstevel@tonic-gate _nc_Default_Item.opt = opts; 830Sstevel@tonic-gate 840Sstevel@tonic-gate RETURN(E_OK); 850Sstevel@tonic-gate} 860Sstevel@tonic-gate 870Sstevel@tonic-gate/*--------------------------------------------------------------------------- 880Sstevel@tonic-gate| Facility : libnmenu 890Sstevel@tonic-gate| Function : int item_opts_off(ITEM *item, Item_Options opts) 900Sstevel@tonic-gate| 910Sstevel@tonic-gate| Description : Switch of the options for this item. 920Sstevel@tonic-gate| 930Sstevel@tonic-gate| Return Values : E_OK - success 940Sstevel@tonic-gate| E_BAD_ARGUMENT - invalid options 950Sstevel@tonic-gate+--------------------------------------------------------------------------*/ 960Sstevel@tonic-gateNCURSES_EXPORT(int) 970Sstevel@tonic-gateitem_opts_off(ITEM * item, Item_Options opts) 980Sstevel@tonic-gate{ 990Sstevel@tonic-gate ITEM *citem = item; /* use a copy because set_item_opts must detect 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate NULL item itself to adjust its behavior */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate T((T_CALLED("item_opts_off(%p,%d)"), item, opts)); 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate if (opts & ~ALL_ITEM_OPTS) 1060Sstevel@tonic-gate RETURN(E_BAD_ARGUMENT); 1070Sstevel@tonic-gate else 1080Sstevel@tonic-gate { 1090Sstevel@tonic-gate Normalize_Item(citem); 1100Sstevel@tonic-gate opts = citem->opt & ~(opts & ALL_ITEM_OPTS); 1110Sstevel@tonic-gate returnCode(set_item_opts(item, opts)); 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate} 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate/*--------------------------------------------------------------------------- 1160Sstevel@tonic-gate| Facility : libnmenu 1170Sstevel@tonic-gate| Function : int item_opts_on(ITEM *item, Item_Options opts) 1180Sstevel@tonic-gate| 1190Sstevel@tonic-gate| Description : Switch on the options for this item. 1200Sstevel@tonic-gate| 1210Sstevel@tonic-gate| Return Values : E_OK - success 1220Sstevel@tonic-gate| E_BAD_ARGUMENT - invalid options 1230Sstevel@tonic-gate+--------------------------------------------------------------------------*/ 1240Sstevel@tonic-gateNCURSES_EXPORT(int) 1250Sstevel@tonic-gateitem_opts_on(ITEM * item, Item_Options opts) 1260Sstevel@tonic-gate{ 1270Sstevel@tonic-gate ITEM *citem = item; /* use a copy because set_item_opts must detect 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate NULL item itself to adjust its behavior */ 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate T((T_CALLED("item_opts_on(%p,%d)"), item, opts)); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate opts &= ALL_ITEM_OPTS; 1340Sstevel@tonic-gate if (opts & ~ALL_ITEM_OPTS) 1350Sstevel@tonic-gate RETURN(E_BAD_ARGUMENT); 1360Sstevel@tonic-gate else 1370Sstevel@tonic-gate { 1380Sstevel@tonic-gate Normalize_Item(citem); 1390Sstevel@tonic-gate opts = citem->opt | opts; 1400Sstevel@tonic-gate returnCode(set_item_opts(item, opts)); 1410Sstevel@tonic-gate } 1420Sstevel@tonic-gate} 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate/*--------------------------------------------------------------------------- 1450Sstevel@tonic-gate| Facility : libnmenu 1460Sstevel@tonic-gate| Function : Item_Options item_opts(const ITEM *item) 1470Sstevel@tonic-gate| 1480Sstevel@tonic-gate| Description : Switch of the options for this item. 1490Sstevel@tonic-gate| 1500Sstevel@tonic-gate| Return Values : Items options 1510Sstevel@tonic-gate+--------------------------------------------------------------------------*/ 1520Sstevel@tonic-gateNCURSES_EXPORT(Item_Options) 1530Sstevel@tonic-gateitem_opts(const ITEM * item) 1540Sstevel@tonic-gate{ 1550Sstevel@tonic-gate T((T_CALLED("item_opts(%p)"), item)); 1560Sstevel@tonic-gate returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt); 1570Sstevel@tonic-gate} 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate/* m_item_opt.c ends here */ 1600Sstevel@tonic-gate