1 /****************************************************************************
2 * Copyright (c) 1998-2002,2003 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, 1995,1997 *
31 ****************************************************************************/
33 #include "form.priv.h"
35 MODULE_ID("$Id: fld_opts.c,v 1.9 2003/10/25 15:17:08 tom Exp $")
37 /*----------------------------------------------------------------------------
38 Field-Options manipulation routines
39 --------------------------------------------------------------------------*/
41 /*---------------------------------------------------------------------------
43 | Function : int set_field_opts(FIELD *field, Field_Options opts)
45 | Description : Turns on the named options for this field and turns
46 | off all the remaining options.
48 | Return Values : E_OK - success
49 | E_CURRENT - the field is the current field
50 | E_BAD_ARGUMENT - invalid options
51 | E_SYSTEM_ERROR - system error
52 +--------------------------------------------------------------------------*/
54 set_field_opts (FIELD
* field
, Field_Options opts
)
56 int res
= E_BAD_ARGUMENT
;
57 opts
&= ALL_FIELD_OPTS
;
58 if (!(opts
& ~ALL_FIELD_OPTS
))
59 res
= _nc_Synchronize_Options( Normalize_Field(field
), opts
);
63 /*---------------------------------------------------------------------------
65 | Function : Field_Options field_opts(const FIELD *field)
67 | Description : Retrieve the fields options.
69 | Return Values : The options.
70 +--------------------------------------------------------------------------*/
71 NCURSES_EXPORT(Field_Options
)
72 field_opts (const FIELD
* field
)
74 return ALL_FIELD_OPTS
& Normalize_Field( field
)->opts
;
77 /*---------------------------------------------------------------------------
79 | Function : int field_opts_on(FIELD *field, Field_Options opts)
81 | Description : Turns on the named options for this field and all the
82 | remaining options are unchanged.
84 | Return Values : E_OK - success
85 | E_CURRENT - the field is the current field
86 | E_BAD_ARGUMENT - invalid options
87 | E_SYSTEM_ERROR - system error
88 +--------------------------------------------------------------------------*/
90 field_opts_on (FIELD
* field
, Field_Options opts
)
92 int res
= E_BAD_ARGUMENT
;
94 opts
&= ALL_FIELD_OPTS
;
95 if (!(opts
& ~ALL_FIELD_OPTS
))
97 Normalize_Field( field
);
98 res
= _nc_Synchronize_Options( field
, field
->opts
| opts
);
103 /*---------------------------------------------------------------------------
104 | Facility : libnform
105 | Function : int field_opts_off(FIELD *field, Field_Options opts)
107 | Description : Turns off the named options for this field and all the
108 | remaining options are unchanged.
110 | Return Values : E_OK - success
111 | E_CURRENT - the field is the current field
112 | E_BAD_ARGUMENT - invalid options
113 | E_SYSTEM_ERROR - system error
114 +--------------------------------------------------------------------------*/
116 field_opts_off (FIELD
* field
, Field_Options opts
)
118 int res
= E_BAD_ARGUMENT
;
120 opts
&= ALL_FIELD_OPTS
;
121 if (!(opts
& ~ALL_FIELD_OPTS
))
123 Normalize_Field( field
);
124 res
= _nc_Synchronize_Options( field
, field
->opts
& ~opts
);
129 /* fld_opts.c ends here */