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