Remove empty lines in start of header files
[elinks.git] / src / document / forms.h
blob8ebf4ed7102ac556e47930c5eba2612a5e233d3d
1 #ifndef EL__DOCUMENT_FORMS_H
2 #define EL__DOCUMENT_FORMS_H
4 #include "util/lists.h"
6 struct document;
7 struct menu_item;
11 enum form_method {
12 FORM_METHOD_GET,
13 FORM_METHOD_POST,
14 FORM_METHOD_POST_MP,
15 FORM_METHOD_POST_TEXT_PLAIN,
18 struct form {
19 LIST_HEAD(struct form);
21 /* The value of @form_num serves both as a unique ID of the form.
22 * However @form_num and @form_end also stores information about where
23 * in the source the form is positioned. Combined they are used to
24 * figured which form items belong to which forms after rendering
25 * tables.
27 * Initially the range between @form_num and @form_end will stretch from
28 * 0 to INT_MAX. When a new form is added the range is partitioned so
29 * the forms each has unique source ranges. */
30 int form_num;
31 int form_end;
33 unsigned char *action;
34 unsigned char *name;
35 unsigned char *target;
36 enum form_method method;
38 struct list_head items; /* -> struct form_control */
43 enum form_type {
44 FC_TEXT,
45 FC_PASSWORD,
46 FC_FILE,
47 FC_TEXTAREA,
48 FC_CHECKBOX,
49 FC_RADIO,
50 FC_SELECT,
51 FC_SUBMIT,
52 FC_IMAGE,
53 FC_RESET,
54 FC_BUTTON,
55 FC_HIDDEN,
58 enum form_mode {
59 FORM_MODE_NORMAL,
60 FORM_MODE_READONLY,
61 FORM_MODE_DISABLED,
64 #define form_field_is_readonly(field) ((field)->mode != FORM_MODE_NORMAL)
66 enum form_wrap {
67 FORM_WRAP_NONE,
68 FORM_WRAP_SOFT,
69 FORM_WRAP_HARD,
72 struct form_control {
73 LIST_HEAD(struct form_control);
75 struct form *form;
76 int g_ctrl_num;
78 /* The value of @position is relative to the place of the form item in
79 * the source. */
80 int position;
82 enum form_type type;
83 enum form_mode mode;
85 unsigned char *name;
86 unsigned char *alt;
87 unsigned char *default_value;
88 int default_state;
89 int size;
90 int cols, rows;
91 enum form_wrap wrap;
92 int maxlength;
93 int nvalues;
94 unsigned char **values;
95 unsigned char **labels;
96 struct menu_item *menu;
99 /* Numerical form type <-> form type name */
100 int str2form_type(unsigned char *s);
101 unsigned char *form_type2str(enum form_type num);
103 struct form *init_form(void);
104 void done_form(struct form *form);
105 int has_form_submit(struct form *form);
107 int get_form_control_link(struct document *document, struct form_control *fc);
108 void done_form_control(struct form_control *fc);
110 #endif