blob: 4ce6b1c52d6085f18850eda066691d1d61ba2c55 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 1998-2010,2016 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304 * *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
12 * *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
15 * *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
27 * authorization. *
28 ****************************************************************************/
29
30/****************************************************************************
31 * Author: Juergen Pfeifer, 1995,1997 *
32 ****************************************************************************/
33
34#include "form.priv.h"
35
micky3879b9f5e72025-07-08 18:04:53 -040036MODULE_ID("$Id: fld_attr.c,v 1.15 2020/12/11 22:05:24 tom Exp $")
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053037
38/*----------------------------------------------------------------------------
39 Field-Attribute manipulation routines
40 --------------------------------------------------------------------------*/
micky3879b9f5e72025-07-08 18:04:53 -040041/* "Template" macro to generate a function to set a field's attribute */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053042#define GEN_FIELD_ATTR_SET_FCT( name ) \
micky3879b9f5e72025-07-08 18:04:53 -040043FORM_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053044{\
45 int res = E_BAD_ARGUMENT;\
micky3879b9f5e72025-07-08 18:04:53 -040046 T((T_CALLED("set_field_" #name "(%p,%s)"), (void *)field, _traceattr(attr)));\
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047 if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
48 {\
49 Normalize_Field( field );\
50 if (field != 0) \
51 { \
52 if ((field -> name) != attr)\
53 {\
54 field -> name = attr;\
55 res = _nc_Synchronize_Attributes( field );\
56 }\
57 else\
58 {\
59 res = E_OK;\
60 }\
61 }\
62 }\
63 RETURN(res);\
64}
65
micky3879b9f5e72025-07-08 18:04:53 -040066/* "Template" macro to generate a function to get a field's attribute */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067#define GEN_FIELD_ATTR_GET_FCT( name ) \
micky3879b9f5e72025-07-08 18:04:53 -040068FORM_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053069{\
Steve Kondikae271bc2015-11-15 02:50:53 +010070 T((T_CALLED("field_" #name "(%p)"), (const void *) field));\
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053071 returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
72}
73
74/*---------------------------------------------------------------------------
75| Facility : libnform
76| Function : int set_field_fore(FIELD *field, chtype attr)
77|
78| Description : Sets the foreground of the field used to display the
79| field contents.
80|
81| Return Values : E_OK - success
82| E_BAD_ARGUMENT - invalid attributes
83| E_SYSTEM_ERROR - system error
84+--------------------------------------------------------------------------*/
85GEN_FIELD_ATTR_SET_FCT(fore)
86
87/*---------------------------------------------------------------------------
88| Facility : libnform
89| Function : chtype field_fore(const FIELD *)
90|
micky3879b9f5e72025-07-08 18:04:53 -040091| Description : Retrieve field's foreground attribute
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053092|
93| Return Values : The foreground attribute
94+--------------------------------------------------------------------------*/
95GEN_FIELD_ATTR_GET_FCT(fore)
96
97/*---------------------------------------------------------------------------
98| Facility : libnform
99| Function : int set_field_back(FIELD *field, chtype attr)
100|
101| Description : Sets the background of the field used to display the
micky3879b9f5e72025-07-08 18:04:53 -0400102| field's extend.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530103|
104| Return Values : E_OK - success
105| E_BAD_ARGUMENT - invalid attributes
106| E_SYSTEM_ERROR - system error
107+--------------------------------------------------------------------------*/
108GEN_FIELD_ATTR_SET_FCT(back)
109
110/*---------------------------------------------------------------------------
111| Facility : libnform
112| Function : chtype field_back(const
113|
micky3879b9f5e72025-07-08 18:04:53 -0400114| Description : Retrieve field's background attribute
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530115|
116| Return Values : The background attribute
117+--------------------------------------------------------------------------*/
118GEN_FIELD_ATTR_GET_FCT(back)
119
120/* fld_attr.c ends here */