summaryrefslogtreecommitdiff
path: root/render/box.h
blob: b67d6e7b14493d310f32b0a044fb235c9254eaaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * 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 James Bursa <bursa@users.sourceforge.net>
 * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
 */

#ifndef _NETSURF_RENDER_BOX_H_
#define _NETSURF_RENDER_BOX_H_

#include <limits.h>
#include "libxml/HTMLparser.h"
#include "netsurf/css/css.h"
#ifdef riscos
#include "netsurf/riscos/font.h"
#endif

/**
 * structures
 */

typedef enum {
	BOX_BLOCK, BOX_INLINE_CONTAINER, BOX_INLINE,
	BOX_TABLE, BOX_TABLE_ROW, BOX_TABLE_CELL,
	BOX_TABLE_ROW_GROUP,
	BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT
} box_type;

struct column {
	enum { COLUMN_WIDTH_UNKNOWN = 0, COLUMN_WIDTH_FIXED,
	       COLUMN_WIDTH_AUTO, COLUMN_WIDTH_PERCENT } type;
	unsigned long min, max, width;
};

struct formoption {
	int selected;
	char* value;
	char* text;
	struct formoption* next;
};

struct gui_gadget {
	enum { GADGET_HIDDEN = 0, GADGET_TEXTBOX, GADGET_RADIO, GADGET_CHECKBOX,
		GADGET_SELECT, GADGET_TEXTAREA, GADGET_ACTIONBUTTON } type;
	char* name;
	struct form* form;
        union {
		struct {
			char* value;
		} hidden;
		struct {
			unsigned int maxlength;
			char* text;
			int size;
		} textbox;
		struct {
		        char* butttype;
			char* label;
			int pressed;
		} actionbutt;
		struct {
			int numitems;
			struct formoption* items;
			int size;
			int multiple;
		} select;
		struct {
			int selected;
			char* value;
		} checkbox;
		struct {
			int selected;
			char* value;
		} radio;
		struct {
			int cols;
			int rows;
			char* text;
		} textarea;
	} data;
};

/* state of a plugin handling this box, platform dependent */
struct plugin_state;

/* parameters for <object> and related elements */
struct object_params {
        char* data;
        char* type;
        char* codetype;
        char* codebase;
        char* classid;
        char* paramds;       /* very likely to change */
        unsigned int* width;
        unsigned int* height;
	/* not a parameter, but stored here for convenience */
	struct plugin_state *plugin_state;
};

struct box {
	box_type type;
	struct css_style * style;
	unsigned long x, y, width, height;
	unsigned long min_width, max_width;
	char * text;
	unsigned int space : 1;	/* 1 <=> followed by a space */
	char * href;
	char * title;
	unsigned int length;
	unsigned int columns;
	unsigned int rows;
	unsigned int start_column; /* start column of table cell */
	struct box * next;
	struct box * prev;
	struct box * children;
	struct box * last;
	struct box * parent;
	struct box * float_children;
	struct box * next_float;
	struct column *col;
	struct font_data *font;
	struct gui_gadget* gadget;
	struct content* object;  /* usually an image */
	struct object_params *object_params;
};

struct form
{
	char* action; /* url */
	enum {method_GET, method_POST} method;
};

struct formsubmit
{
	struct form* form;
	struct gui_gadget* items;
};

struct page_elements
{
	struct form** forms;
	struct gui_gadget** gadgets;
	struct img** images;
	int numForms;
	int numGadgets;
	int numImages;
};


#define UNKNOWN_WIDTH ULONG_MAX
#define UNKNOWN_MAX_WIDTH ULONG_MAX

/**
 * interface
 */

void xml_to_box(xmlNode *n, struct content *c);
void box_dump(struct box * box, unsigned int depth);
void box_free(struct box *box);

#endif