150276Speter/**************************************************************************** 2166124Srafan * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 30166124Srafan * Author: Juergen Pfeifer, 1995,1997 * 3150276Speter ****************************************************************************/ 3250276Speter 3350276Speter/*************************************************************************** 3450276Speter* Module m_attribs * 3550276Speter* Control menus display attributes * 3650276Speter***************************************************************************/ 3750276Speter 3850276Speter#include "menu.priv.h" 3950276Speter 40166124SrafanMODULE_ID("$Id: m_attribs.c,v 1.14 2004/12/11 23:29:12 tom Exp $") 4150276Speter 4250276Speter/* Macro to redraw menu if it is posted and changed */ 4350276Speter#define Refresh_Menu(menu) \ 4450276Speter if ( (menu) && ((menu)->status & _POSTED) )\ 4550276Speter {\ 4650276Speter _nc_Draw_Menu( menu );\ 4750276Speter _nc_Show_Menu( menu );\ 4850276Speter } 4950276Speter 5050276Speter/* "Template" macro to generate a function to set a menus attribute */ 5150276Speter#define GEN_MENU_ATTR_SET_FCT( name ) \ 5276726SpeterNCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\ 5350276Speter{\ 54166124Srafan T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr)));\ 5550276Speter if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\ 5650276Speter RETURN(E_BAD_ARGUMENT);\ 5750276Speter if (menu && ( menu -> name != attr))\ 5850276Speter {\ 5950276Speter (menu -> name) = attr;\ 6050276Speter Refresh_Menu(menu);\ 6150276Speter }\ 6250276Speter Normalize_Menu( menu ) -> name = attr;\ 6350276Speter RETURN(E_OK);\ 6450276Speter} 6550276Speter 66166124Srafan/* "Template" macro to generate a function to get a menu's attribute */ 6750276Speter#define GEN_MENU_ATTR_GET_FCT( name ) \ 6876726SpeterNCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\ 6950276Speter{\ 70166124Srafan T((T_CALLED("menu_" #name "(%p)"), menu));\ 71166124Srafan returnAttr(Normalize_Menu( menu ) -> name);\ 7250276Speter} 7350276Speter 7450276Speter/*--------------------------------------------------------------------------- 7550276Speter| Facility : libnmenu 7650276Speter| Function : int set_menu_fore(MENU *menu, chtype attr) 7750276Speter| 7850276Speter| Description : Set the attribute for selectable items. In single- 79166124Srafan| valued menus this is used to highlight the current 8050276Speter| item ((i.e. where the cursor is), in multi-valued 8150276Speter| menus this is used to highlight the selected items. 8250276Speter| 8350276Speter| Return Values : E_OK - success 8450276Speter| E_BAD_ARGUMENT - an invalid value has been passed 8550276Speter+--------------------------------------------------------------------------*/ 86166124SrafanGEN_MENU_ATTR_SET_FCT(fore) 8750276Speter 8850276Speter/*--------------------------------------------------------------------------- 8950276Speter| Facility : libnmenu 9050276Speter| Function : chtype menu_fore(const MENU* menu) 9150276Speter| 9250276Speter| Description : Return the attribute used for selectable items that 9350276Speter| are current (single-valued menu) or selected (multi- 9450276Speter| valued menu). 9550276Speter| 9650276Speter| Return Values : Attribute value 9750276Speter+--------------------------------------------------------------------------*/ 98166124SrafanGEN_MENU_ATTR_GET_FCT(fore) 9950276Speter 10050276Speter/*--------------------------------------------------------------------------- 10150276Speter| Facility : libnmenu 10250276Speter| Function : int set_menu_back(MENU *menu, chtype attr) 10350276Speter| 10450276Speter| Description : Set the attribute for selectable but not yet selected 10550276Speter| items. 10650276Speter| 10750276Speter| Return Values : E_OK - success 10850276Speter| E_BAD_ARGUMENT - an invalid value has been passed 10950276Speter+--------------------------------------------------------------------------*/ 110166124SrafanGEN_MENU_ATTR_SET_FCT(back) 11150276Speter 11250276Speter/*--------------------------------------------------------------------------- 11350276Speter| Facility : libnmenu 11450276Speter| Function : chtype menu_back(const MENU *menu) 11550276Speter| 11650276Speter| Description : Return the attribute used for selectable but not yet 11750276Speter| selected items. 11850276Speter| 11950276Speter| Return Values : Attribute value 12050276Speter+--------------------------------------------------------------------------*/ 121166124SrafanGEN_MENU_ATTR_GET_FCT(back) 12250276Speter 12350276Speter/*--------------------------------------------------------------------------- 12450276Speter| Facility : libnmenu 12550276Speter| Function : int set_menu_grey(MENU *menu, chtype attr) 12650276Speter| 12750276Speter| Description : Set the attribute for unselectable items. 12850276Speter| 12950276Speter| Return Values : E_OK - success 13050276Speter| E_BAD_ARGUMENT - an invalid value has been passed 13150276Speter+--------------------------------------------------------------------------*/ 132166124SrafanGEN_MENU_ATTR_SET_FCT(grey) 13350276Speter 13450276Speter/*--------------------------------------------------------------------------- 13550276Speter| Facility : libnmenu 13650276Speter| Function : chtype menu_grey(const MENU *menu) 13750276Speter| 13850276Speter| Description : Return the attribute used for non-selectable items 13950276Speter| 14050276Speter| Return Values : Attribute value 14150276Speter+--------------------------------------------------------------------------*/ 142166124SrafanGEN_MENU_ATTR_GET_FCT(grey) 14350276Speter/* m_attribs.c ends here */ 144