-\f
-/*----------------------------------------------------------------------------
- Field-Options manipulation routines
- --------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_opts(FIELD *field, Field_Options opts)
-|
-| Description : Turns on the named options for this field and turns
-| off all the remaining options.
-|
-| Return Values : E_OK - success
-| E_CURRENT - the field is the current field
-| E_BAD_ARGUMENT - invalid options
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int set_field_opts(FIELD * field, Field_Options opts)
-{
- int res = E_BAD_ARGUMENT;
- if (!(opts & ~ALL_FIELD_OPTS))
- res = Synchronize_Options( Normalize_Field(field), opts );
- RETURN(res);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : Field_Options field_opts(const FIELD *field)
-|
-| Description : Retrieve the fields options.
-|
-| Return Values : The options.
-+--------------------------------------------------------------------------*/
-Field_Options field_opts(const FIELD * field)
-{
- return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int field_opts_on(FIELD *field, Field_Options opts)
-|
-| Description : Turns on the named options for this field and all the
-| remaining options are unchanged.
-|
-| Return Values : E_OK - success
-| E_CURRENT - the field is the current field
-| E_BAD_ARGUMENT - invalid options
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int field_opts_on(FIELD * field, Field_Options opts)
-{
- int res = E_BAD_ARGUMENT;
-
- if (!(opts & ~ALL_FIELD_OPTS))
- {
- Normalize_Field( field );
- res = Synchronize_Options( field, field->opts | opts );
- }
- RETURN(res);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int field_opts_off(FIELD *field, Field_Options opts)
-|
-| Description : Turns off the named options for this field and all the
-| remaining options are unchanged.
-|
-| Return Values : E_OK - success
-| E_CURRENT - the field is the current field
-| E_BAD_ARGUMENT - invalid options
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int field_opts_off(FIELD * field, Field_Options opts)
-{
- int res = E_BAD_ARGUMENT;
-
- if (!(opts & ~ALL_FIELD_OPTS))
- {
- Normalize_Field( field );
- res = Synchronize_Options( field, field->opts & ~opts );
- }
- RETURN(res);
-}
-\f
-/*----------------------------------------------------------------------------
- Field-Attribute manipulation routines
- --------------------------------------------------------------------------*/
-/* "Template" macro to generate a function to set a fields attribute */
-#define GEN_FIELD_ATTR_SET_FCT( name ) \
-int set_field_ ## name (FIELD * field, chtype attr)\
-{\
- int res = E_BAD_ARGUMENT;\
- if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
- {\
- Normalize_Field( field );\
- if ((field -> name) != attr)\
- {\
- field -> name = attr;\
- res = Synchronize_Attributes( field );\
- }\
- else\
- res = E_OK;\
- }\
- RETURN(res);\
-}
-
-/* "Template" macro to generate a function to get a fields attribute */
-#define GEN_FIELD_ATTR_GET_FCT( name ) \
-chtype field_ ## name (const FIELD * field)\
-{\
- return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_fore(FIELD *field, chtype attr)
-|
-| Description : Sets the foreground of the field used to display the
-| field contents.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid attributes
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( fore )
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : chtype field_fore(const FIELD *)
-|
-| Description : Retrieve fields foreground attribute
-|
-| Return Values : The foreground attribute
-+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( fore )
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_back(FIELD *field, chtype attr)
-|
-| Description : Sets the background of the field used to display the
-| fields extend.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid attributes
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( back )
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : chtype field_back(const
-|
-| Description : Retrieve fields background attribute
-|
-| Return Values : The background attribute
-+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( back )
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_pad(FIELD *field, int ch)
-|
-| Description : Set the pad character used to fill the field. This must
-| be a printable character.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer or pad character
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int set_field_pad(FIELD * field, int ch)
-{
- int res = E_BAD_ARGUMENT;
-
- Normalize_Field( field );
- if (isprint((unsigned char)ch))
- {
- if (field->pad != ch)
- {
- field->pad = ch;
- res = Synchronize_Attributes( field );
- }
- else
- res = E_OK;
- }
- RETURN(res);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int field_pad(const FIELD *field)
-|
-| Description : Retrieve the fields pad character.
-|
-| Return Values : The pad character.
-+--------------------------------------------------------------------------*/
-int field_pad(const FIELD * field)
-{
- return Normalize_Field( field )->pad;
-}
-\f
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_just(FIELD *field, int just)
-|
-| Description : Set the fields type of justification.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - one of the arguments was incorrect
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int set_field_just(FIELD * field, int just)
-{
- int res = E_BAD_ARGUMENT;
-
- if ((just==NO_JUSTIFICATION) ||
- (just==JUSTIFY_LEFT) ||
- (just==JUSTIFY_CENTER) ||
- (just==JUSTIFY_RIGHT) )
- {
- Normalize_Field( field );
- if (field->just != just)
- {
- field->just = just;
- res = Synchronize_Attributes( field );
- }
- else
- res = E_OK;
- }
- RETURN(res);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int field_just( const FIELD *field )
-|
-| Description : Retrieve the fields type of justification
-|
-| Return Values : The justification type.
-+--------------------------------------------------------------------------*/
-int field_just(const FIELD * field)
-{
- return Normalize_Field( field )->just;
-}