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_attribs *
25 * Control menus display attributes *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_attribs.c,v 1.4 1997/05/01 16:47:26 juergen Exp $")
32 /* Macro to redraw menu if it is posted and changed */
33 #define Refresh_Menu(menu) \
34 if ( (menu) && ((menu)->status & _POSTED) )\
36 _nc_Draw_Menu( menu );\
37 _nc_Show_Menu( menu );\
40 /* "Template" macro to generate a function to set a menus attribute */
41 #define GEN_MENU_ATTR_SET_FCT( name ) \
42 int set_menu_ ## name (MENU * menu, chtype attr)\
44 if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
45 RETURN(E_BAD_ARGUMENT);\
46 if (menu && ( menu -> name != attr))\
48 (menu -> name) = attr;\
51 Normalize_Menu( menu ) -> name = attr;\
55 /* "Template" macro to generate a function to get a menus attribute */
56 #define GEN_MENU_ATTR_GET_FCT( name ) \
57 chtype menu_ ## name (const MENU * menu)\
59 return (Normalize_Menu( menu ) -> name);\
62 /*---------------------------------------------------------------------------
64 | Function : int set_menu_fore(MENU *menu, chtype attr)
66 | Description : Set the attribute for selectable items. In single-
67 | valued menus thiis is used to highlight the current
68 | item ((i.e. where the cursor is), in multi-valued
69 | menus this is used to highlight the selected items.
71 | Return Values : E_OK - success
72 | E_BAD_ARGUMENT - an invalid value has been passed
73 +--------------------------------------------------------------------------*/
74 GEN_MENU_ATTR_SET_FCT( fore )
76 /*---------------------------------------------------------------------------
78 | Function : chtype menu_fore(const MENU* menu)
80 | Description : Return the attribute used for selectable items that
81 | are current (single-valued menu) or selected (multi-
84 | Return Values : Attribute value
85 +--------------------------------------------------------------------------*/
86 GEN_MENU_ATTR_GET_FCT( fore )
88 /*---------------------------------------------------------------------------
90 | Function : int set_menu_back(MENU *menu, chtype attr)
92 | Description : Set the attribute for selectable but not yet selected
95 | Return Values : E_OK - success
96 | E_BAD_ARGUMENT - an invalid value has been passed
97 +--------------------------------------------------------------------------*/
98 GEN_MENU_ATTR_SET_FCT( back )
100 /*---------------------------------------------------------------------------
101 | Facility : libnmenu
102 | Function : chtype menu_back(const MENU *menu)
104 | Description : Return the attribute used for selectable but not yet
107 | Return Values : Attribute value
108 +--------------------------------------------------------------------------*/
109 GEN_MENU_ATTR_GET_FCT( back )
111 /*---------------------------------------------------------------------------
112 | Facility : libnmenu
113 | Function : int set_menu_grey(MENU *menu, chtype attr)
115 | Description : Set the attribute for unselectable items.
117 | Return Values : E_OK - success
118 | E_BAD_ARGUMENT - an invalid value has been passed
119 +--------------------------------------------------------------------------*/
120 GEN_MENU_ATTR_SET_FCT( grey )
122 /*---------------------------------------------------------------------------
123 | Facility : libnmenu
124 | Function : chtype menu_grey(const MENU *menu)
126 | Description : Return the attribute used for non-selectable items
128 | Return Values : Attribute value
129 +--------------------------------------------------------------------------*/
130 GEN_MENU_ATTR_GET_FCT( grey )
132 /*---------------------------------------------------------------------------
133 | Facility : libnmenu
134 | Function : int set_menu_pad(MENU *menu, int pad)
136 | Description : Set the character to be used to separate the item name
137 | from its description. This must be a printable
140 | Return Values : E_OK - success
141 | E_BAD_ARGUMENT - an invalid value has been passed
142 +--------------------------------------------------------------------------*/
143 int set_menu_pad(MENU *menu, int pad)
145 bool do_refresh = !(menu);
147 if (!isprint((unsigned char)pad))
148 RETURN(E_BAD_ARGUMENT);
150 Normalize_Menu( menu );
154 Refresh_Menu( menu );
159 /*---------------------------------------------------------------------------
160 | Facility : libnmenu
161 | Function : int menu_pad(const MENU *menu)
163 | Description : Return the value of the padding character
165 | Return Values : The pad character
166 +--------------------------------------------------------------------------*/
167 int menu_pad(const MENU * menu)
169 return (Normalize_Menu( menu ) -> pad);
172 /* m_attribs.c ends here */