1 /**************************************************************************** 2 * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 3 * * 4 * Permission is hereby granted, free of charge, to any person obtaining a * 5 * copy of this software and associated documentation files (the * 6 * "Software"), to deal in the Software without restriction, including * 7 * without limitation the rights to use, copy, modify, merge, publish, * 8 * distribute, distribute with modifications, sublicense, and/or sell * 9 * copies of the Software, and to permit persons to whom the Software is * 10 * furnished to do so, subject to the following conditions: * 11 * * 12 * The above copyright notice and this permission notice shall be included * 13 * in all copies or substantial portions of the Software. * 14 * * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22 * * 23 * Except as contained in this notice, the name(s) of the above copyright * 24 * holders shall not be used in advertising or otherwise to promote the * 25 * sale, use or other dealings in this Software without prior written * 26 * authorization. * 27 ****************************************************************************/ 28 29 /**************************************************************************** 30 * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * 31 ****************************************************************************/ 32 33 /*************************************************************************** 34 * Module m_attribs * 35 * Control menus display attributes * 36 ***************************************************************************/ 37 38 #include "menu.priv.h" 39 40 MODULE_ID("$Id: m_attribs.c,v 1.9 2000/12/10 02:16:48 tom Exp $") 41 42 /* Macro to redraw menu if it is posted and changed */ 43 #define Refresh_Menu(menu) \ 44 if ( (menu) && ((menu)->status & _POSTED) )\ 45 {\ 46 _nc_Draw_Menu( menu );\ 47 _nc_Show_Menu( menu );\ 48 } 49 50 /* "Template" macro to generate a function to set a menus attribute */ 51 #define GEN_MENU_ATTR_SET_FCT( name ) \ 52 NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\ 53 {\ 54 if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\ 55 RETURN(E_BAD_ARGUMENT);\ 56 if (menu && ( menu -> name != attr))\ 57 {\ 58 (menu -> name) = attr;\ 59 Refresh_Menu(menu);\ 60 }\ 61 Normalize_Menu( menu ) -> name = attr;\ 62 RETURN(E_OK);\ 63 } 64 65 /* "Template" macro to generate a function to get a menus attribute */ 66 #define GEN_MENU_ATTR_GET_FCT( name ) \ 67 NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\ 68 {\ 69 return (Normalize_Menu( menu ) -> name);\ 70 } 71 72 /*--------------------------------------------------------------------------- 73 | Facility : libnmenu 74 | Function : int set_menu_fore(MENU *menu, chtype attr) 75 | 76 | Description : Set the attribute for selectable items. In single- 77 | valued menus thiis is used to highlight the current 78 | item ((i.e. where the cursor is), in multi-valued 79 | menus this is used to highlight the selected items. 80 | 81 | Return Values : E_OK - success 82 | E_BAD_ARGUMENT - an invalid value has been passed 83 +--------------------------------------------------------------------------*/ 84 GEN_MENU_ATTR_SET_FCT( fore ) 85 86 /*--------------------------------------------------------------------------- 87 | Facility : libnmenu 88 | Function : chtype menu_fore(const MENU* menu) 89 | 90 | Description : Return the attribute used for selectable items that 91 | are current (single-valued menu) or selected (multi- 92 | valued menu). 93 | 94 | Return Values : Attribute value 95 +--------------------------------------------------------------------------*/ 96 GEN_MENU_ATTR_GET_FCT( fore ) 97 98 /*--------------------------------------------------------------------------- 99 | Facility : libnmenu 100 | Function : int set_menu_back(MENU *menu, chtype attr) 101 | 102 | Description : Set the attribute for selectable but not yet selected 103 | items. 104 | 105 | Return Values : E_OK - success 106 | E_BAD_ARGUMENT - an invalid value has been passed 107 +--------------------------------------------------------------------------*/ 108 GEN_MENU_ATTR_SET_FCT( back ) 109 110 /*--------------------------------------------------------------------------- 111 | Facility : libnmenu 112 | Function : chtype menu_back(const MENU *menu) 113 | 114 | Description : Return the attribute used for selectable but not yet 115 | selected items. 116 | 117 | Return Values : Attribute value 118 +--------------------------------------------------------------------------*/ 119 GEN_MENU_ATTR_GET_FCT( back ) 120 121 /*--------------------------------------------------------------------------- 122 | Facility : libnmenu 123 | Function : int set_menu_grey(MENU *menu, chtype attr) 124 | 125 | Description : Set the attribute for unselectable items. 126 | 127 | Return Values : E_OK - success 128 | E_BAD_ARGUMENT - an invalid value has been passed 129 +--------------------------------------------------------------------------*/ 130 GEN_MENU_ATTR_SET_FCT( grey ) 131 132 /*--------------------------------------------------------------------------- 133 | Facility : libnmenu 134 | Function : chtype menu_grey(const MENU *menu) 135 | 136 | Description : Return the attribute used for non-selectable items 137 | 138 | Return Values : Attribute value 139 +--------------------------------------------------------------------------*/ 140 GEN_MENU_ATTR_GET_FCT( grey ) 141 /* m_attribs.c ends here */ 142