1 /****************************************************************************
2 * Copyright (c) 1998 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
31 ****************************************************************************/
33 #define _XOPEN_SOURCE_EXTENDED
35 #include "form.priv.h"
37 #undef _XOPEN_SOURCE_EXTENDED
39 MODULE_ID("$Id: fld_attr.c,v 1.2 2003/03/11 20:25:50 hoffman Exp $")
41 /*----------------------------------------------------------------------------
42 Field-Attribute manipulation routines
43 --------------------------------------------------------------------------*/
44 /* "Template" macro to generate a function to set a fields attribute */
45 #define GEN_FIELD_ATTR_SET_FCT( name ) \
46 int set_field_ ## name (FIELD * field, chtype attr)\
48 int res = E_BAD_ARGUMENT;\
49 if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
51 Normalize_Field( field );\
52 if ((field -> name) != attr)\
54 field -> name = attr;\
55 res = _nc_Synchronize_Attributes( field );\
63 /* "Template" macro to generate a function to get a fields attribute */
64 #define GEN_FIELD_ATTR_GET_FCT( name ) \
65 chtype field_ ## name (const FIELD * field)\
67 return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
70 /*---------------------------------------------------------------------------
72 | Function : int set_field_fore(FIELD *field, chtype attr)
74 | Description : Sets the foreground of the field used to display the
77 | Return Values : E_OK - success
78 | E_BAD_ARGUMENT - invalid attributes
79 | E_SYSTEM_ERROR - system error
80 +--------------------------------------------------------------------------*/
81 GEN_FIELD_ATTR_SET_FCT( fore
)
83 /*---------------------------------------------------------------------------
85 | Function : chtype field_fore(const FIELD *)
87 | Description : Retrieve fields foreground attribute
89 | Return Values : The foreground attribute
90 +--------------------------------------------------------------------------*/
91 GEN_FIELD_ATTR_GET_FCT( fore
)
93 /*---------------------------------------------------------------------------
95 | Function : int set_field_back(FIELD *field, chtype attr)
97 | Description : Sets the background of the field used to display the
100 | Return Values : E_OK - success
101 | E_BAD_ARGUMENT - invalid attributes
102 | E_SYSTEM_ERROR - system error
103 +--------------------------------------------------------------------------*/
104 GEN_FIELD_ATTR_SET_FCT( back
)
106 /*---------------------------------------------------------------------------
107 | Facility : libnform
108 | Function : chtype field_back(const
110 | Description : Retrieve fields background attribute
112 | Return Values : The background attribute
113 +--------------------------------------------------------------------------*/
114 GEN_FIELD_ATTR_GET_FCT( back
)
116 /* fld_attr.c ends here */