1*c7ef0cfcSnicm /* $OpenBSD: fld_attr.c,v 1.7 2023/10/17 09:52:10 nicm Exp $ */ 202f2426aSmillert /**************************************************************************** 3*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey * 4*c7ef0cfcSnicm * Copyright 1998-2010,2016 Free Software Foundation, Inc. * 502f2426aSmillert * * 602f2426aSmillert * Permission is hereby granted, free of charge, to any person obtaining a * 702f2426aSmillert * copy of this software and associated documentation files (the * 802f2426aSmillert * "Software"), to deal in the Software without restriction, including * 902f2426aSmillert * without limitation the rights to use, copy, modify, merge, publish, * 1002f2426aSmillert * distribute, distribute with modifications, sublicense, and/or sell * 1102f2426aSmillert * copies of the Software, and to permit persons to whom the Software is * 1202f2426aSmillert * furnished to do so, subject to the following conditions: * 1302f2426aSmillert * * 1402f2426aSmillert * The above copyright notice and this permission notice shall be included * 1502f2426aSmillert * in all copies or substantial portions of the Software. * 1602f2426aSmillert * * 1702f2426aSmillert * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1802f2426aSmillert * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1902f2426aSmillert * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 2002f2426aSmillert * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 2102f2426aSmillert * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2202f2426aSmillert * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2302f2426aSmillert * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2402f2426aSmillert * * 2502f2426aSmillert * Except as contained in this notice, the name(s) of the above copyright * 2602f2426aSmillert * holders shall not be used in advertising or otherwise to promote the * 2702f2426aSmillert * sale, use or other dealings in this Software without prior written * 2802f2426aSmillert * authorization. * 2902f2426aSmillert ****************************************************************************/ 3002f2426aSmillert 3102f2426aSmillert /**************************************************************************** 3281d8c4e1Snicm * Author: Juergen Pfeifer, 1995,1997 * 3302f2426aSmillert ****************************************************************************/ 3481d8c4e1Snicm 358d0fca71Smillert #include "form.priv.h" 368d0fca71Smillert 37*c7ef0cfcSnicm MODULE_ID("$Id: fld_attr.c,v 1.7 2023/10/17 09:52:10 nicm Exp $") 388d0fca71Smillert 398d0fca71Smillert /*---------------------------------------------------------------------------- 408d0fca71Smillert Field-Attribute manipulation routines 418d0fca71Smillert --------------------------------------------------------------------------*/ 42*c7ef0cfcSnicm /* "Template" macro to generate a function to set a field's attribute */ 438d0fca71Smillert #define GEN_FIELD_ATTR_SET_FCT( name ) \ 44*c7ef0cfcSnicm FORM_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\ 458d0fca71Smillert {\ 468d0fca71Smillert int res = E_BAD_ARGUMENT;\ 47*c7ef0cfcSnicm T((T_CALLED("set_field_" #name "(%p,%s)"), (void *)field, _traceattr(attr)));\ 488d0fca71Smillert if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\ 498d0fca71Smillert {\ 508d0fca71Smillert Normalize_Field( field );\ 5181d8c4e1Snicm if (field != 0) \ 5281d8c4e1Snicm { \ 538d0fca71Smillert if ((field -> name) != attr)\ 548d0fca71Smillert {\ 558d0fca71Smillert field -> name = attr;\ 568d0fca71Smillert res = _nc_Synchronize_Attributes( field );\ 578d0fca71Smillert }\ 588d0fca71Smillert else\ 5981d8c4e1Snicm {\ 608d0fca71Smillert res = E_OK;\ 618d0fca71Smillert }\ 6281d8c4e1Snicm }\ 6381d8c4e1Snicm }\ 648d0fca71Smillert RETURN(res);\ 658d0fca71Smillert } 668d0fca71Smillert 67*c7ef0cfcSnicm /* "Template" macro to generate a function to get a field's attribute */ 688d0fca71Smillert #define GEN_FIELD_ATTR_GET_FCT( name ) \ 69*c7ef0cfcSnicm FORM_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\ 708d0fca71Smillert {\ 71*c7ef0cfcSnicm T((T_CALLED("field_" #name "(%p)"), (const void *) field));\ 7281d8c4e1Snicm returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\ 738d0fca71Smillert } 748d0fca71Smillert 758d0fca71Smillert /*--------------------------------------------------------------------------- 768d0fca71Smillert | Facility : libnform 778d0fca71Smillert | Function : int set_field_fore(FIELD *field, chtype attr) 788d0fca71Smillert | 798d0fca71Smillert | Description : Sets the foreground of the field used to display the 808d0fca71Smillert | field contents. 818d0fca71Smillert | 828d0fca71Smillert | Return Values : E_OK - success 838d0fca71Smillert | E_BAD_ARGUMENT - invalid attributes 848d0fca71Smillert | E_SYSTEM_ERROR - system error 858d0fca71Smillert +--------------------------------------------------------------------------*/ 868d0fca71Smillert GEN_FIELD_ATTR_SET_FCT(fore) 878d0fca71Smillert 888d0fca71Smillert /*--------------------------------------------------------------------------- 898d0fca71Smillert | Facility : libnform 908d0fca71Smillert | Function : chtype field_fore(const FIELD *) 918d0fca71Smillert | 92*c7ef0cfcSnicm | Description : Retrieve field's foreground attribute 938d0fca71Smillert | 948d0fca71Smillert | Return Values : The foreground attribute 958d0fca71Smillert +--------------------------------------------------------------------------*/ 968d0fca71Smillert GEN_FIELD_ATTR_GET_FCT(fore) 978d0fca71Smillert 988d0fca71Smillert /*--------------------------------------------------------------------------- 998d0fca71Smillert | Facility : libnform 1008d0fca71Smillert | Function : int set_field_back(FIELD *field, chtype attr) 1018d0fca71Smillert | 1028d0fca71Smillert | Description : Sets the background of the field used to display the 103*c7ef0cfcSnicm | field's extend. 1048d0fca71Smillert | 1058d0fca71Smillert | Return Values : E_OK - success 1068d0fca71Smillert | E_BAD_ARGUMENT - invalid attributes 1078d0fca71Smillert | E_SYSTEM_ERROR - system error 1088d0fca71Smillert +--------------------------------------------------------------------------*/ 1098d0fca71Smillert GEN_FIELD_ATTR_SET_FCT(back) 1108d0fca71Smillert 1118d0fca71Smillert /*--------------------------------------------------------------------------- 1128d0fca71Smillert | Facility : libnform 1138d0fca71Smillert | Function : chtype field_back(const 1148d0fca71Smillert | 115*c7ef0cfcSnicm | Description : Retrieve field's background attribute 1168d0fca71Smillert | 1178d0fca71Smillert | Return Values : The background attribute 1188d0fca71Smillert +--------------------------------------------------------------------------*/ 1198d0fca71Smillert GEN_FIELD_ATTR_GET_FCT(back) 1208d0fca71Smillert 1218d0fca71Smillert /* fld_attr.c ends here */ 122