2003-10-25 04:35:49 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
2009-08-14 14:37:33 +04:00
|
|
|
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-10-25 04:35:49 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Form handling functions (interface).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_RENDER_FORM_H_
|
|
|
|
#define _NETSURF_RENDER_FORM_H_
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2003-10-25 18:13:49 +04:00
|
|
|
struct box;
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_control;
|
|
|
|
struct form_option;
|
2009-08-14 14:37:33 +04:00
|
|
|
struct form_select_menu;
|
2014-11-11 20:11:59 +03:00
|
|
|
struct form;
|
2012-08-21 18:27:52 +04:00
|
|
|
struct html_content;
|
2013-02-07 02:39:45 +04:00
|
|
|
struct dom_string;
|
2014-02-03 21:56:24 +04:00
|
|
|
struct content;
|
2014-07-06 21:34:34 +04:00
|
|
|
struct nsurl;
|
2014-10-17 15:21:06 +04:00
|
|
|
struct fetch_multipart_data;
|
2014-11-02 23:10:32 +03:00
|
|
|
struct redraw_context;
|
2014-11-09 15:22:11 +03:00
|
|
|
struct browser_window;
|
2014-11-02 23:10:32 +03:00
|
|
|
|
2014-10-17 15:21:06 +04:00
|
|
|
enum browser_mouse_state;
|
2003-10-25 04:35:49 +04:00
|
|
|
|
2009-02-20 14:39:25 +03:00
|
|
|
|
2003-10-25 04:35:49 +04:00
|
|
|
|
2004-05-21 14:25:42 +04:00
|
|
|
/** Type of a struct form_control. */
|
|
|
|
typedef enum {
|
|
|
|
GADGET_HIDDEN,
|
|
|
|
GADGET_TEXTBOX,
|
|
|
|
GADGET_RADIO,
|
|
|
|
GADGET_CHECKBOX,
|
|
|
|
GADGET_SELECT,
|
|
|
|
GADGET_TEXTAREA,
|
|
|
|
GADGET_IMAGE,
|
|
|
|
GADGET_PASSWORD,
|
|
|
|
GADGET_SUBMIT,
|
|
|
|
GADGET_RESET,
|
2009-02-20 14:39:25 +03:00
|
|
|
GADGET_FILE,
|
|
|
|
GADGET_BUTTON
|
2004-05-21 14:25:42 +04:00
|
|
|
} form_control_type;
|
|
|
|
|
2013-02-07 02:39:45 +04:00
|
|
|
/** Data for textarea */
|
|
|
|
struct form_textarea_data {
|
|
|
|
struct form_control *gadget;
|
|
|
|
};
|
|
|
|
|
2014-11-11 20:11:59 +03:00
|
|
|
/** Option in a select. */
|
|
|
|
struct form_option {
|
|
|
|
void *node; /**< Corresponding DOM node */
|
|
|
|
bool selected;
|
|
|
|
bool initial_selected;
|
|
|
|
char *value;
|
|
|
|
char *text; /**< NUL terminated. */
|
|
|
|
struct form_option* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct image_input_coords {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
2003-10-25 04:35:49 +04:00
|
|
|
/** Form control. */
|
|
|
|
struct form_control {
|
2009-02-20 14:39:25 +03:00
|
|
|
void *node; /**< Corresponding DOM node */
|
2014-02-17 18:38:53 +04:00
|
|
|
struct html_content *html; /**< HTML content containing control */
|
2009-02-20 14:39:25 +03:00
|
|
|
|
|
|
|
form_control_type type; /**< Type of control */
|
|
|
|
|
|
|
|
struct form *form; /**< Containing form */
|
|
|
|
|
|
|
|
char *name; /**< Control name */
|
|
|
|
char *value; /**< Current value of control */
|
|
|
|
char *initial_value; /**< Initial value of control */
|
|
|
|
bool disabled; /**< Whether control is disabled */
|
|
|
|
|
|
|
|
struct box *box; /**< Box for control */
|
|
|
|
|
|
|
|
unsigned int length; /**< Number of characters in control */
|
|
|
|
unsigned int maxlength; /**< Maximum characters permitted */
|
|
|
|
|
|
|
|
bool selected; /**< Whether control is selected */
|
|
|
|
|
2003-10-25 04:35:49 +04:00
|
|
|
union {
|
|
|
|
struct {
|
2004-07-20 00:40:11 +04:00
|
|
|
int mx, my;
|
2003-10-25 04:35:49 +04:00
|
|
|
} 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;
|
2009-08-14 14:37:33 +04:00
|
|
|
struct form_select_menu *menu;
|
2003-10-25 04:35:49 +04:00
|
|
|
} select;
|
2013-02-07 02:39:45 +04:00
|
|
|
struct {
|
|
|
|
struct textarea *ta;
|
|
|
|
struct dom_string *initial;
|
|
|
|
struct form_textarea_data data;
|
|
|
|
} text; /**< input type=text or textarea */
|
2003-10-25 04:35:49 +04:00
|
|
|
} data;
|
2009-02-20 14:39:25 +03:00
|
|
|
|
2004-04-09 03:46:41 +04:00
|
|
|
struct form_control *prev; /**< Previous control in this form */
|
2003-10-25 04:35:49 +04:00
|
|
|
struct form_control *next; /**< Next control in this form. */
|
|
|
|
};
|
|
|
|
|
2014-01-05 20:14:17 +04:00
|
|
|
|
2014-02-08 21:11:55 +04:00
|
|
|
void form_select_process_selection(struct form_control *control, int item);
|
2014-01-04 20:30:09 +04:00
|
|
|
|
2003-10-25 04:35:49 +04:00
|
|
|
#endif
|