summaryrefslogtreecommitdiff
path: root/render/box.h
blob: e978662ad0c497166a5bb4086ceadcb38c7f85fb (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
/**
 * $Id: box.h,v 1.14 2002/12/30 02:06:03 monkeyson Exp $
 */

#ifndef _NETSURF_RENDER_BOX_H_
#define _NETSURF_RENDER_BOX_H_

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

/**
 * 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_OPTION,
		GADGET_SELECT, GADGET_TEXTAREA, GADGET_ACTIONBUTTON } type;
        union {
		struct {
			int maxlength;
			char* text;
			int size;
		} textbox;
		struct {
			char* label;
		} actionbutt;
		struct {
			int numitems;
			struct formoption* items;
			int size;
			int multiple;
		} select;
	} data;
};

struct img {
	int width;
	int height;
	char* alt;
	char* src;
};

struct box {
	box_type type;
	xmlNode * node;
	struct css_style * style;
	unsigned long x, y, width, height;
	unsigned long min_width, max_width;
	const char * text;
	int space;	/* 1 <=> followed by a space */
	const char * href;
	unsigned int length;
	unsigned int columns;
	struct box * next;
	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 img* img;
};

#define UNKNOWN_WIDTH ULONG_MAX
#define UNKNOWN_MAX_WIDTH ULONG_MAX

/**
 * interface
 */

void xml_to_box(xmlNode * n, struct css_style * parent_style, struct css_stylesheet * stylesheet,
		struct css_selector ** selector, unsigned int depth,
		struct box * parent, struct box * inline_container,
		const char *href, struct font_set *fonts,
		struct gui_gadget* current_select, struct formoption* current_option);
void box_dump(struct box * box, unsigned int depth);
void box_free(struct box *box);

#endif