1 /* $OpenBSD: fld_attr.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998,2000 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 <juergen.pfeifer@gmx.net> 1995,1997 * 33 ****************************************************************************/ 34 #include "form.priv.h" 35 36 MODULE_ID("$From: fld_attr.c,v 1.5 2000/12/10 02:09:38 tom Exp $") 37 38 /*---------------------------------------------------------------------------- 39 Field-Attribute manipulation routines 40 --------------------------------------------------------------------------*/ 41 /* "Template" macro to generate a function to set a fields attribute */ 42 #define GEN_FIELD_ATTR_SET_FCT( name ) \ 43 NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\ 44 {\ 45 int res = E_BAD_ARGUMENT;\ 46 if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\ 47 {\ 48 Normalize_Field( field );\ 49 if ((field -> name) != attr)\ 50 {\ 51 field -> name = attr;\ 52 res = _nc_Synchronize_Attributes( field );\ 53 }\ 54 else\ 55 res = E_OK;\ 56 }\ 57 RETURN(res);\ 58 } 59 60 /* "Template" macro to generate a function to get a fields attribute */ 61 #define GEN_FIELD_ATTR_GET_FCT( name ) \ 62 NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\ 63 {\ 64 return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\ 65 } 66 67 /*--------------------------------------------------------------------------- 68 | Facility : libnform 69 | Function : int set_field_fore(FIELD *field, chtype attr) 70 | 71 | Description : Sets the foreground of the field used to display the 72 | field contents. 73 | 74 | Return Values : E_OK - success 75 | E_BAD_ARGUMENT - invalid attributes 76 | E_SYSTEM_ERROR - system error 77 +--------------------------------------------------------------------------*/ 78 GEN_FIELD_ATTR_SET_FCT( fore ) 79 80 /*--------------------------------------------------------------------------- 81 | Facility : libnform 82 | Function : chtype field_fore(const FIELD *) 83 | 84 | Description : Retrieve fields foreground attribute 85 | 86 | Return Values : The foreground attribute 87 +--------------------------------------------------------------------------*/ 88 GEN_FIELD_ATTR_GET_FCT( fore ) 89 90 /*--------------------------------------------------------------------------- 91 | Facility : libnform 92 | Function : int set_field_back(FIELD *field, chtype attr) 93 | 94 | Description : Sets the background of the field used to display the 95 | fields extend. 96 | 97 | Return Values : E_OK - success 98 | E_BAD_ARGUMENT - invalid attributes 99 | E_SYSTEM_ERROR - system error 100 +--------------------------------------------------------------------------*/ 101 GEN_FIELD_ATTR_SET_FCT( back ) 102 103 /*--------------------------------------------------------------------------- 104 | Facility : libnform 105 | Function : chtype field_back(const 106 | 107 | Description : Retrieve fields background attribute 108 | 109 | Return Values : The background attribute 110 +--------------------------------------------------------------------------*/ 111 GEN_FIELD_ATTR_GET_FCT( back ) 112 113 /* fld_attr.c ends here */ 114