/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/***************************************************/
/* File   : Forms.h                                */
/*                                                 */
/* Purpose: Functions to manage HTML forms.        */
/*                                                 */
/* Author : Merlyn Kline for Customer browser     */
/*          This source adapted by A.D.Hodgkinson  */
/*                                                 */
/* History: 28-Jan-97: Created.                    */
/***************************************************/

/* Various definitions */

typedef enum form_fieldtype
{
  form_text,
  form_password,
  form_checkbox,
  form_radio,
  form_select,
  form_textarea,
  form_image,
  form_submit,
  form_reset,
  form_button,
  form_file,
  form_hidden

} form_fieldtype;

typedef struct fv_select
{
  int  scroll;
  char selection[4];

} fv_select;

typedef union
{
  char      text[4];
  int       checked;
  fv_select select;

} form_field_value;

/* Miscellaneous definitions */

#define FE_PassCode "****************************************"

/* Function prototypes */

_kernel_oserror  * form_new_form              (browser_data * b, HStream * token);
_kernel_oserror  * form_discard               (browser_data * b);
_kernel_oserror  * form_put_field             (browser_data * b, HStream * token, char * value, int update);
_kernel_oserror  * form_new_field             (browser_data * b, HStream * token, form_fieldtype type, char * value);

form_field_value * form_get_field             (browser_data * b, HStream * token);
char             * form_get_field_text        (browser_data * b, HStream * token);
void               form_get_linesize          (BBox * fontbox, int * lh, int * lb);
void               form_abandon_menu          (void);

int                form_give_focus            (browser_data * b);

_kernel_oserror  * form_click_field           (browser_data * b, HStream * token, int mode, int x, int y);
_kernel_oserror  * form_cancel_edit           (browser_data * b);
_kernel_oserror  * form_finish_edit           (browser_data * b);
const char       * form_button_text           (HStream * tp);
int                form_token_cursor_editable (browser_data * b, HStream * token);
_kernel_oserror  * form_process_key           (browser_data * b, int * key);
void               form_select_menu_event     (WimpPollBlock * e);
void               form_check_caret           (browser_data * b);
void               form_caret_may_need_moving (browser_data * b);

void               form_textarea_redraw       (browser_data * b, HStream * token, BBox * box, BBox * gw, int fh, int multiline, int password);