fld_opts.c revision 76726
150276Speter/**************************************************************************** 276726Speter * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * 3150276Speter ****************************************************************************/ 3250276Speter#include "form.priv.h" 3350276Speter 3476726SpeterMODULE_ID("$Id: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $") 3550276Speter 3650276Speter/*---------------------------------------------------------------------------- 3750276Speter Field-Options manipulation routines 3850276Speter --------------------------------------------------------------------------*/ 3950276Speter 4050276Speter/*--------------------------------------------------------------------------- 4150276Speter| Facility : libnform 4250276Speter| Function : int set_field_opts(FIELD *field, Field_Options opts) 4350276Speter| 4450276Speter| Description : Turns on the named options for this field and turns 4550276Speter| off all the remaining options. 4650276Speter| 4750276Speter| Return Values : E_OK - success 4850276Speter| E_CURRENT - the field is the current field 4950276Speter| E_BAD_ARGUMENT - invalid options 5050276Speter| E_SYSTEM_ERROR - system error 5150276Speter+--------------------------------------------------------------------------*/ 5276726SpeterNCURSES_EXPORT(int) 5376726Speterset_field_opts (FIELD * field, Field_Options opts) 5450276Speter{ 5550276Speter int res = E_BAD_ARGUMENT; 5650276Speter opts &= ALL_FIELD_OPTS; 5750276Speter if (!(opts & ~ALL_FIELD_OPTS)) 5850276Speter res = _nc_Synchronize_Options( Normalize_Field(field), opts ); 5950276Speter RETURN(res); 6050276Speter} 6150276Speter 6250276Speter/*--------------------------------------------------------------------------- 6350276Speter| Facility : libnform 6450276Speter| Function : Field_Options field_opts(const FIELD *field) 6550276Speter| 6650276Speter| Description : Retrieve the fields options. 6750276Speter| 6850276Speter| Return Values : The options. 6950276Speter+--------------------------------------------------------------------------*/ 7076726SpeterNCURSES_EXPORT(Field_Options) 7176726Speterfield_opts (const FIELD * field) 7250276Speter{ 7350276Speter return ALL_FIELD_OPTS & Normalize_Field( field )->opts; 7450276Speter} 7550276Speter 7650276Speter/*--------------------------------------------------------------------------- 7750276Speter| Facility : libnform 7850276Speter| Function : int field_opts_on(FIELD *field, Field_Options opts) 7950276Speter| 8050276Speter| Description : Turns on the named options for this field and all the 8150276Speter| remaining options are unchanged. 8250276Speter| 8350276Speter| Return Values : E_OK - success 8450276Speter| E_CURRENT - the field is the current field 8550276Speter| E_BAD_ARGUMENT - invalid options 8650276Speter| E_SYSTEM_ERROR - system error 8750276Speter+--------------------------------------------------------------------------*/ 8876726SpeterNCURSES_EXPORT(int) 8976726Speterfield_opts_on (FIELD * field, Field_Options opts) 9050276Speter{ 9150276Speter int res = E_BAD_ARGUMENT; 9250276Speter 9350276Speter opts &= ALL_FIELD_OPTS; 9450276Speter if (!(opts & ~ALL_FIELD_OPTS)) 9550276Speter { 9650276Speter Normalize_Field( field ); 9750276Speter res = _nc_Synchronize_Options( field, field->opts | opts ); 9850276Speter } 9950276Speter RETURN(res); 10050276Speter} 10150276Speter 10250276Speter/*--------------------------------------------------------------------------- 10350276Speter| Facility : libnform 10450276Speter| Function : int field_opts_off(FIELD *field, Field_Options opts) 10550276Speter| 10650276Speter| Description : Turns off the named options for this field and all the 10750276Speter| remaining options are unchanged. 10850276Speter| 10950276Speter| Return Values : E_OK - success 11050276Speter| E_CURRENT - the field is the current field 11150276Speter| E_BAD_ARGUMENT - invalid options 11250276Speter| E_SYSTEM_ERROR - system error 11350276Speter+--------------------------------------------------------------------------*/ 11476726SpeterNCURSES_EXPORT(int) 11576726Speterfield_opts_off (FIELD * field, Field_Options opts) 11650276Speter{ 11750276Speter int res = E_BAD_ARGUMENT; 11850276Speter 11950276Speter opts &= ALL_FIELD_OPTS; 12050276Speter if (!(opts & ~ALL_FIELD_OPTS)) 12150276Speter { 12250276Speter Normalize_Field( field ); 12350276Speter res = _nc_Synchronize_Options( field, field->opts & ~opts ); 12450276Speter } 12550276Speter RETURN(res); 12650276Speter} 12750276Speter 12850276Speter/* fld_opts.c ends here */ 129