150276Speter/****************************************************************************
2262629Sdelphij * Copyright (c) 1998-2004,2010 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/****************************************************************************
30166124Srafan *   Author:  Juergen Pfeifer, 1995,1997                                    *
3150276Speter ****************************************************************************/
32166124Srafan
3350276Speter#include "form.priv.h"
3450276Speter
35262629SdelphijMODULE_ID("$Id: fld_opts.c,v 1.12 2010/01/23 21:14:36 tom Exp $")
3650276Speter
3750276Speter/*----------------------------------------------------------------------------
3850276Speter  Field-Options manipulation routines
3950276Speter  --------------------------------------------------------------------------*/
4050276Speter
4150276Speter/*---------------------------------------------------------------------------
4250276Speter|   Facility      :  libnform
4350276Speter|   Function      :  int set_field_opts(FIELD *field, Field_Options opts)
4450276Speter|
4550276Speter|   Description   :  Turns on the named options for this field and turns
4650276Speter|                    off all the remaining options.
4750276Speter|
4850276Speter|   Return Values :  E_OK            - success
4950276Speter|                    E_CURRENT       - the field is the current field
5050276Speter|                    E_BAD_ARGUMENT  - invalid options
5150276Speter|                    E_SYSTEM_ERROR  - system error
5250276Speter+--------------------------------------------------------------------------*/
5376726SpeterNCURSES_EXPORT(int)
54166124Srafanset_field_opts(FIELD *field, Field_Options opts)
5550276Speter{
5650276Speter  int res = E_BAD_ARGUMENT;
57166124Srafan
58262629Sdelphij  T((T_CALLED("set_field_opts(%p,%d)"), (void *)field, opts));
59166124Srafan
6050276Speter  opts &= ALL_FIELD_OPTS;
6150276Speter  if (!(opts & ~ALL_FIELD_OPTS))
62166124Srafan    res = _nc_Synchronize_Options(Normalize_Field(field), opts);
6350276Speter  RETURN(res);
6450276Speter}
6550276Speter
6650276Speter/*---------------------------------------------------------------------------
6750276Speter|   Facility      :  libnform
6850276Speter|   Function      :  Field_Options field_opts(const FIELD *field)
6950276Speter|
7050276Speter|   Description   :  Retrieve the fields options.
7150276Speter|
7250276Speter|   Return Values :  The options.
7350276Speter+--------------------------------------------------------------------------*/
7476726SpeterNCURSES_EXPORT(Field_Options)
75166124Srafanfield_opts(const FIELD *field)
7650276Speter{
77262629Sdelphij  T((T_CALLED("field_opts(%p)"), (const void *)field));
78166124Srafan
79166124Srafan  returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
8050276Speter}
8150276Speter
8250276Speter/*---------------------------------------------------------------------------
8350276Speter|   Facility      :  libnform
8450276Speter|   Function      :  int field_opts_on(FIELD *field, Field_Options opts)
8550276Speter|
8650276Speter|   Description   :  Turns on the named options for this field and all the
8750276Speter|                    remaining options are unchanged.
8850276Speter|
8950276Speter|   Return Values :  E_OK            - success
9050276Speter|                    E_CURRENT       - the field is the current field
9150276Speter|                    E_BAD_ARGUMENT  - invalid options
9250276Speter|                    E_SYSTEM_ERROR  - system error
9350276Speter+--------------------------------------------------------------------------*/
9476726SpeterNCURSES_EXPORT(int)
95166124Srafanfield_opts_on(FIELD *field, Field_Options opts)
9650276Speter{
9750276Speter  int res = E_BAD_ARGUMENT;
9850276Speter
99262629Sdelphij  T((T_CALLED("field_opts_on(%p,%d)"), (void *)field, opts));
100166124Srafan
10150276Speter  opts &= ALL_FIELD_OPTS;
10250276Speter  if (!(opts & ~ALL_FIELD_OPTS))
10350276Speter    {
104166124Srafan      Normalize_Field(field);
105166124Srafan      res = _nc_Synchronize_Options(field, field->opts | opts);
10650276Speter    }
10750276Speter  RETURN(res);
10850276Speter}
10950276Speter
11050276Speter/*---------------------------------------------------------------------------
11150276Speter|   Facility      :  libnform
11250276Speter|   Function      :  int field_opts_off(FIELD *field, Field_Options opts)
11350276Speter|
11450276Speter|   Description   :  Turns off the named options for this field and all the
11550276Speter|                    remaining options are unchanged.
11650276Speter|
11750276Speter|   Return Values :  E_OK            - success
11850276Speter|                    E_CURRENT       - the field is the current field
11950276Speter|                    E_BAD_ARGUMENT  - invalid options
12050276Speter|                    E_SYSTEM_ERROR  - system error
12150276Speter+--------------------------------------------------------------------------*/
12276726SpeterNCURSES_EXPORT(int)
123166124Srafanfield_opts_off(FIELD *field, Field_Options opts)
12450276Speter{
12550276Speter  int res = E_BAD_ARGUMENT;
12650276Speter
127262629Sdelphij  T((T_CALLED("field_opts_off(%p,%d)"), (void *)field, opts));
128166124Srafan
12950276Speter  opts &= ALL_FIELD_OPTS;
13050276Speter  if (!(opts & ~ALL_FIELD_OPTS))
13150276Speter    {
132166124Srafan      Normalize_Field(field);
133166124Srafan      res = _nc_Synchronize_Options(field, field->opts & ~opts);
13450276Speter    }
13550276Speter  RETURN(res);
136166124Srafan}
13750276Speter
13850276Speter/* fld_opts.c ends here */
139