| 1 | /****************************************************************************
|
|---|
| 2 | * Copyright (c) 1998-2003,2004 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, 1995,1997 *
|
|---|
| 31 | ****************************************************************************/
|
|---|
| 32 |
|
|---|
| 33 | #include "form.priv.h"
|
|---|
| 34 |
|
|---|
| 35 | MODULE_ID("$Id: fld_opts.c,v 1.11 2004/12/11 21:55:46 tom Exp $")
|
|---|
| 36 |
|
|---|
| 37 | /*----------------------------------------------------------------------------
|
|---|
| 38 | Field-Options manipulation routines
|
|---|
| 39 | --------------------------------------------------------------------------*/
|
|---|
| 40 |
|
|---|
| 41 | /*---------------------------------------------------------------------------
|
|---|
| 42 | | Facility : libnform
|
|---|
| 43 | | Function : int set_field_opts(FIELD *field, Field_Options opts)
|
|---|
| 44 | |
|
|---|
| 45 | | Description : Turns on the named options for this field and turns
|
|---|
| 46 | | off all the remaining options.
|
|---|
| 47 | |
|
|---|
| 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 | +--------------------------------------------------------------------------*/
|
|---|
| 53 | NCURSES_EXPORT(int)
|
|---|
| 54 | set_field_opts(FIELD *field, Field_Options opts)
|
|---|
| 55 | {
|
|---|
| 56 | int res = E_BAD_ARGUMENT;
|
|---|
| 57 |
|
|---|
| 58 | T((T_CALLED("set_field_opts(%p,%d)"), field, opts));
|
|---|
| 59 |
|
|---|
| 60 | opts &= ALL_FIELD_OPTS;
|
|---|
| 61 | if (!(opts & ~ALL_FIELD_OPTS))
|
|---|
| 62 | res = _nc_Synchronize_Options(Normalize_Field(field), opts);
|
|---|
| 63 | RETURN(res);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | /*---------------------------------------------------------------------------
|
|---|
| 67 | | Facility : libnform
|
|---|
| 68 | | Function : Field_Options field_opts(const FIELD *field)
|
|---|
| 69 | |
|
|---|
| 70 | | Description : Retrieve the fields options.
|
|---|
| 71 | |
|
|---|
| 72 | | Return Values : The options.
|
|---|
| 73 | +--------------------------------------------------------------------------*/
|
|---|
| 74 | NCURSES_EXPORT(Field_Options)
|
|---|
| 75 | field_opts(const FIELD *field)
|
|---|
| 76 | {
|
|---|
| 77 | T((T_CALLED("field_opts(%p)"), field));
|
|---|
| 78 |
|
|---|
| 79 | returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | /*---------------------------------------------------------------------------
|
|---|
| 83 | | Facility : libnform
|
|---|
| 84 | | Function : int field_opts_on(FIELD *field, Field_Options opts)
|
|---|
| 85 | |
|
|---|
| 86 | | Description : Turns on the named options for this field and all the
|
|---|
| 87 | | remaining options are unchanged.
|
|---|
| 88 | |
|
|---|
| 89 | | Return Values : E_OK - success
|
|---|
| 90 | | E_CURRENT - the field is the current field
|
|---|
| 91 | | E_BAD_ARGUMENT - invalid options
|
|---|
| 92 | | E_SYSTEM_ERROR - system error
|
|---|
| 93 | +--------------------------------------------------------------------------*/
|
|---|
| 94 | NCURSES_EXPORT(int)
|
|---|
| 95 | field_opts_on(FIELD *field, Field_Options opts)
|
|---|
| 96 | {
|
|---|
| 97 | int res = E_BAD_ARGUMENT;
|
|---|
| 98 |
|
|---|
| 99 | T((T_CALLED("field_opts_on(%p,%d)"), field, opts));
|
|---|
| 100 |
|
|---|
| 101 | opts &= ALL_FIELD_OPTS;
|
|---|
| 102 | if (!(opts & ~ALL_FIELD_OPTS))
|
|---|
| 103 | {
|
|---|
| 104 | Normalize_Field(field);
|
|---|
| 105 | res = _nc_Synchronize_Options(field, field->opts | opts);
|
|---|
| 106 | }
|
|---|
| 107 | RETURN(res);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | /*---------------------------------------------------------------------------
|
|---|
| 111 | | Facility : libnform
|
|---|
| 112 | | Function : int field_opts_off(FIELD *field, Field_Options opts)
|
|---|
| 113 | |
|
|---|
| 114 | | Description : Turns off the named options for this field and all the
|
|---|
| 115 | | remaining options are unchanged.
|
|---|
| 116 | |
|
|---|
| 117 | | Return Values : E_OK - success
|
|---|
| 118 | | E_CURRENT - the field is the current field
|
|---|
| 119 | | E_BAD_ARGUMENT - invalid options
|
|---|
| 120 | | E_SYSTEM_ERROR - system error
|
|---|
| 121 | +--------------------------------------------------------------------------*/
|
|---|
| 122 | NCURSES_EXPORT(int)
|
|---|
| 123 | field_opts_off(FIELD *field, Field_Options opts)
|
|---|
| 124 | {
|
|---|
| 125 | int res = E_BAD_ARGUMENT;
|
|---|
| 126 |
|
|---|
| 127 | T((T_CALLED("field_opts_off(%p,%d)"), field, opts));
|
|---|
| 128 |
|
|---|
| 129 | opts &= ALL_FIELD_OPTS;
|
|---|
| 130 | if (!(opts & ~ALL_FIELD_OPTS))
|
|---|
| 131 | {
|
|---|
| 132 | Normalize_Field(field);
|
|---|
| 133 | res = _nc_Synchronize_Options(field, field->opts & ~opts);
|
|---|
| 134 | }
|
|---|
| 135 | RETURN(res);
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | /* fld_opts.c ends here */
|
|---|