2003-10-25 04:35:49 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Form handling functions (interface).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_RENDER_FORM_H_
|
|
|
|
#define _NETSURF_RENDER_FORM_H_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2004-01-20 22:08:34 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-10-25 04:35:49 +04:00
|
|
|
|
2003-10-25 18:13:49 +04:00
|
|
|
struct box;
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_control;
|
|
|
|
struct form_option;
|
|
|
|
|
|
|
|
/** HTML form. */
|
|
|
|
struct form {
|
2003-10-25 18:13:49 +04:00
|
|
|
char *action; /**< Url to submit to. */
|
|
|
|
enum {
|
|
|
|
method_GET, /**< GET, always url encoded. */
|
|
|
|
method_POST_URLENC, /**< POST, url encoded. */
|
|
|
|
method_POST_MULTIPART /**< POST, multipart/form-data. */
|
|
|
|
} method; /**< Method and enctype. */
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_control *controls; /**< Linked list of controls. */
|
|
|
|
struct form_control *last_control; /**< Last control in list. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Form control. */
|
|
|
|
struct form_control {
|
|
|
|
enum { GADGET_HIDDEN, GADGET_TEXTBOX, GADGET_RADIO, GADGET_CHECKBOX,
|
|
|
|
GADGET_SELECT, GADGET_TEXTAREA, GADGET_IMAGE,
|
2004-03-21 23:07:14 +03:00
|
|
|
GADGET_PASSWORD, GADGET_SUBMIT, GADGET_RESET,
|
|
|
|
GADGET_FILE } type;
|
2003-10-25 04:35:49 +04:00
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
char *initial_value;
|
|
|
|
bool disabled;
|
|
|
|
struct form *form;
|
|
|
|
struct box *box;
|
|
|
|
struct box *caret_inline_container;
|
|
|
|
struct box *caret_text_box;
|
|
|
|
int caret_char_offset;
|
|
|
|
unsigned int maxlength;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int mx, my;
|
|
|
|
} image;
|
|
|
|
struct {
|
|
|
|
int num_items;
|
|
|
|
struct form_option *items, *last_item;
|
|
|
|
bool multiple;
|
|
|
|
int num_selected;
|
|
|
|
/** Currently selected item, if num_selected == 1. */
|
|
|
|
struct form_option *current;
|
|
|
|
} select;
|
|
|
|
struct {
|
|
|
|
int selected;
|
|
|
|
} checkbox;
|
|
|
|
struct {
|
|
|
|
int selected;
|
|
|
|
} radio;
|
|
|
|
} data;
|
|
|
|
struct form_control *next; /**< Next control in this form. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Option in a select. */
|
|
|
|
struct form_option {
|
|
|
|
bool selected;
|
|
|
|
bool initial_selected;
|
|
|
|
char* value;
|
|
|
|
char* text;
|
|
|
|
struct form_option* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Successful control, as defined by HTML 4.01 17.13. */
|
|
|
|
struct form_successful_control {
|
2004-03-21 23:07:14 +03:00
|
|
|
bool file; /**< It's a file */
|
2003-10-25 04:35:49 +04:00
|
|
|
char *name; /**< Control name. */
|
|
|
|
char *value; /**< Current value. */
|
|
|
|
struct form_successful_control *next; /**< Next in linked list. */
|
|
|
|
};
|
|
|
|
|
|
|
|
void form_add_control(struct form *form, struct form_control *control);
|
|
|
|
struct form_successful_control *form_successful_controls(struct form *form,
|
|
|
|
struct form_control *submit_button);
|
|
|
|
char *form_url_encode(struct form_successful_control *control);
|
|
|
|
void form_free_successful(struct form_successful_control *control);
|
|
|
|
|
|
|
|
#endif
|