]> ncurses.scripts.mit.edu Git - ncurses.git/blob - form/fld_opts.c
98af32f57099c41c8f668a3756887884656119ea
[ncurses.git] / form / fld_opts.c
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
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:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
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.                               *
22  *                                                                          *
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       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *   Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997        *
31  ****************************************************************************/
32 #include "form.priv.h"
33
34 MODULE_ID("$Id: fld_opts.c,v 1.2 1998/02/11 12:13:44 tom Exp $")
35
36 /*----------------------------------------------------------------------------
37   Field-Options manipulation routines
38   --------------------------------------------------------------------------*/
39
40 /*---------------------------------------------------------------------------
41 |   Facility      :  libnform  
42 |   Function      :  int set_field_opts(FIELD *field, Field_Options opts)
43 |   
44 |   Description   :  Turns on the named options for this field and turns
45 |                    off all the remaining options.
46 |
47 |   Return Values :  E_OK            - success
48 |                    E_CURRENT       - the field is the current field
49 |                    E_BAD_ARGUMENT  - invalid options
50 |                    E_SYSTEM_ERROR  - system error
51 +--------------------------------------------------------------------------*/
52 int set_field_opts(FIELD * field, Field_Options opts)
53 {
54   int res = E_BAD_ARGUMENT;
55   if (!(opts & ~ALL_FIELD_OPTS))
56     res = _nc_Synchronize_Options( Normalize_Field(field), opts );
57   RETURN(res);
58 }
59
60 /*---------------------------------------------------------------------------
61 |   Facility      :  libnform  
62 |   Function      :  Field_Options field_opts(const FIELD *field)
63 |   
64 |   Description   :  Retrieve the fields options.
65 |
66 |   Return Values :  The options.
67 +--------------------------------------------------------------------------*/
68 Field_Options field_opts(const FIELD * field)
69 {
70   return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
71 }
72
73 /*---------------------------------------------------------------------------
74 |   Facility      :  libnform  
75 |   Function      :  int field_opts_on(FIELD *field, Field_Options opts)
76 |   
77 |   Description   :  Turns on the named options for this field and all the 
78 |                    remaining options are unchanged.
79 |
80 |   Return Values :  E_OK            - success
81 |                    E_CURRENT       - the field is the current field
82 |                    E_BAD_ARGUMENT  - invalid options
83 |                    E_SYSTEM_ERROR  - system error
84 +--------------------------------------------------------------------------*/
85 int field_opts_on(FIELD * field, Field_Options opts)
86 {
87   int res = E_BAD_ARGUMENT;
88
89   if (!(opts & ~ALL_FIELD_OPTS))
90     {
91       Normalize_Field( field );
92       res = _nc_Synchronize_Options( field, field->opts | opts );
93     }
94   RETURN(res);
95 }
96
97 /*---------------------------------------------------------------------------
98 |   Facility      :  libnform  
99 |   Function      :  int field_opts_off(FIELD *field, Field_Options opts)
100 |   
101 |   Description   :  Turns off the named options for this field and all the 
102 |                    remaining options are unchanged.
103 |
104 |   Return Values :  E_OK            - success
105 |                    E_CURRENT       - the field is the current field
106 |                    E_BAD_ARGUMENT  - invalid options
107 |                    E_SYSTEM_ERROR  - system error
108 +--------------------------------------------------------------------------*/
109 int field_opts_off(FIELD  * field, Field_Options opts)
110 {
111   int res = E_BAD_ARGUMENT;
112
113   if (!(opts & ~ALL_FIELD_OPTS))
114     {
115       Normalize_Field( field );
116       res = _nc_Synchronize_Options( field, field->opts & ~opts );
117     }
118   RETURN(res);
119 }       
120
121 /* fld_opts.c ends here */