-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int field_info(const FIELD *field,
-| int *rows, int *cols,
-| int *frow, int *fcol,
-| int *nrow, int *nbuf)
-|
-| Description : Retrieve infos about the fields creation parameters.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
-+--------------------------------------------------------------------------*/
-int field_info(const FIELD *field,
- int *rows, int *cols,
- int *frow, int *fcol,
- int *nrow, int *nbuf)
-{
- if (!field)
- RETURN(E_BAD_ARGUMENT);
-
- if (rows) *rows = field->rows;
- if (cols) *cols = field->cols;
- if (frow) *frow = field->frow;
- if (fcol) *fcol = field->fcol;
- if (nrow) *nrow = field->nrow;
- if (nbuf) *nbuf = field->nbuf;
- RETURN(E_OK);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int move_field(FIELD *field,int frow, int fcol)
-|
-| Description : Moves the disconnected field to the new location in
-| the forms subwindow.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid argument passed
-| E_CONNECTED - field is connected
-+--------------------------------------------------------------------------*/
-int move_field(FIELD *field, int frow, int fcol)
-{
- if ( !field || (frow<0) || (fcol<0) )
- RETURN(E_BAD_ARGUMENT);
-
- if (field->form)
- RETURN(E_CONNECTED);
-
- field->frow = frow;
- field->fcol = fcol;
- RETURN(E_OK);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_field_type(FIELD *field, FIELDTYPE *type,...)
-|
-| Description : Associate the specified fieldtype with the field.
-| Certain field types take additional arguments. Look
-| at the spec of the field types !
-|
-| Return Values : E_OK - success
-| E_SYSTEM_ERROR - system error
-+--------------------------------------------------------------------------*/
-int set_field_type(FIELD *field,FIELDTYPE *type, ...)
-{
- va_list ap;
- int res = E_SYSTEM_ERROR;
- int err = 0;
-
- va_start(ap,type);
-
- Normalize_Field(field);
- Free_Type(field);
-
- field->type = type;
- field->arg = (void *)Make_Argument(field->type,&ap,&err);
-
- if (err)
- {
- Free_Argument(field->type,(TypeArgument *)(field->arg));
- field->type = (FIELDTYPE *)0;
- field->arg = (void *)0;
- }
- else
- {
- res = E_OK;
- if (field->type)
- field->type->ref++;
- }
-
- va_end(ap);
- RETURN(res);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : FIELDTYPE *field_type(const FIELD *field)
-|
-| Description : Retrieve the associated fieldtype for this field.
-|
-| Return Values : Pointer to fieldtype of NULL if none is defined.
-+--------------------------------------------------------------------------*/
-FIELDTYPE *field_type(const FIELD * field)
-{
- return Normalize_Field(field)->type;
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : void *field_arg(const FIELD *field)
-|
-| Description : Retrieve pointer to the fields argument structure.
-|
-| Return Values : Pointer to structure or NULL if none is defined.
-+--------------------------------------------------------------------------*/
-void *field_arg(const FIELD * field)
-{
- return Normalize_Field(field)->arg;
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_max_field(FIELD *field, int maxgrow)
-|
-| Description : Set the maximum growth for a dynamic field. If maxgrow=0
-| the field may grow to any possible size.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid argument
-+--------------------------------------------------------------------------*/
-int set_max_field(FIELD *field, int maxgrow)
-{
- if (!field || (maxgrow<0))
- RETURN(E_BAD_ARGUMENT);
- else
- {
- bool single_line_field = Single_Line_Field(field);
-
- if (maxgrow>0)
- {
- if (( single_line_field && (maxgrow < field->dcols)) ||
- (!single_line_field && (maxgrow < field->drows)))
- RETURN(E_BAD_ARGUMENT);
- }
- field->maxgrow = maxgrow;
- field->status &= ~_MAY_GROW;
- if (!(field->opts & O_STATIC))
- {
- if ((maxgrow==0) ||
- ( single_line_field && (field->dcols < maxgrow)) ||
- (!single_line_field && (field->drows < maxgrow)))
- field->status |= _MAY_GROW;
- }
- }
- RETURN(E_OK);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int dynamic_field_info(const FIELD *field,
-| int *drows, int *dcols,
-| int *maxgrow)
-|
-| Description : Retrieve informations about a dynamic fields current
-| dynamic parameters.
-|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid argument
-+--------------------------------------------------------------------------*/
-int dynamic_field_info(const FIELD *field,
- int *drows, int *dcols, int *maxgrow)
-{
- if (!field)
- RETURN(E_BAD_ARGUMENT);
-
- if (drows) *drows = field->drows;
- if (dcols) *dcols = field->dcols;
- if (maxgrow) *maxgrow = field->maxgrow;
-
- RETURN(E_OK);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : int set_new_page(FIELD *field, bool new_page_flag)
-|
-| Description : Marks the field as the beginning of a new page of
-| the form.
-|
-| Return Values : E_OK - success
-| E_CONNECTED - field is connected
-+--------------------------------------------------------------------------*/
-int set_new_page(FIELD * field, bool new_page_flag)
-{
- Normalize_Field(field);
- if (field->form)
- RETURN(E_CONNECTED);
-
- if (new_page_flag)
- field->status |= _NEWPAGE;
- else
- field->status &= ~_NEWPAGE;
-
- RETURN(E_OK);
-}
-
-/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : bool new_page(const FIELD *field)
-|
-| Description : Retrieve the info whether or not the field starts a
-| new page on the form.
-|
-| Return Values : TRUE - field starts a new page
-| FALSE - field doesn't start a new page
-+--------------------------------------------------------------------------*/
-bool new_page(const FIELD * field)
-{
- return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE;
-}
-