/****************************************************************************1* Copyright (c) 1998 Free Software Foundation, Inc. *2* *3* Permission is hereby granted, free of charge, to any person obtaining a *4* copy of this software and associated documentation files (the *5* "Software"), to deal in the Software without restriction, including *6* without limitation the rights to use, copy, modify, merge, publish, *7* distribute, distribute with modifications, sublicense, and/or sell *8* copies of the Software, and to permit persons to whom the Software is *9* furnished to do so, subject to the following conditions: *10* *11* The above copyright notice and this permission notice shall be included *12* in all copies or substantial portions of the Software. *13* *14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *15* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *17* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *20* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *21* *22* Except as contained in this notice, the name(s) of the above copyright *23* holders shall not be used in advertising or otherwise to promote the *24* sale, use or other dealings in this Software without prior written *25* authorization. *26****************************************************************************/2728/****************************************************************************29* Author: Juergen Pfeifer <[email protected]> 1995,1997 *30****************************************************************************/31#include "form.priv.h"3233MODULE_ID("$Id$")3435/*---------------------------------------------------------------------------36| Facility : libnform37| Function : int set_current_field(FORM * form,FIELD * field)38|39| Description : Set the current field of the form to the specified one.40|41| Return Values : E_OK - success42| E_BAD_ARGUMENT - invalid form or field pointer43| E_REQUEST_DENIED - field not selectable44| E_BAD_STATE - called from a hook routine45| E_INVALID_FIELD - current field can't be left46| E_SYSTEM_ERROR - system error47+--------------------------------------------------------------------------*/48int set_current_field(FORM * form, FIELD * field)49{50int err = E_OK;5152if ( !form || !field )53RETURN(E_BAD_ARGUMENT);5455if ( (form != field->form) || Field_Is_Not_Selectable(field) )56RETURN(E_REQUEST_DENIED);5758if (!(form->status & _POSTED))59{60form->current = field;61form->curpage = field->page;62}63else64{65if (form->status & _IN_DRIVER)66err = E_BAD_STATE;67else68{69if (form->current != field)70{71if (!_nc_Internal_Validation(form))72err = E_INVALID_FIELD;73else74{75Call_Hook(form,fieldterm);76if (field->page != form->curpage)77{78Call_Hook(form,formterm);79err = _nc_Set_Form_Page(form,field->page,field);80Call_Hook(form,forminit);81}82else83{84err = _nc_Set_Current_Field(form,field);85}86Call_Hook(form,fieldinit);87_nc_Refresh_Current_Field(form);88}89}90}91}92RETURN(err);93}9495/*---------------------------------------------------------------------------96| Facility : libnform97| Function : FIELD *current_field(const FORM * form)98|99| Description : Return the current field.100|101| Return Values : Pointer to the current field.102+--------------------------------------------------------------------------*/103FIELD *current_field(const FORM * form)104{105return Normalize_Form(form)->current;106}107108/*---------------------------------------------------------------------------109| Facility : libnform110| Function : int field_index(const FIELD * field)111|112| Description : Return the index of the field in the field-array of113| the form.114|115| Return Values : >= 0 : field index116| -1 : fieldpointer invalid or field not connected117+--------------------------------------------------------------------------*/118int field_index(const FIELD * field)119{120return ( (field && field->form) ? field->index : -1 );121}122123/* fld_current.c ends here */124125126