summaryrefslogtreecommitdiff
path: root/framebuffer/fbtk_widget.h
blob: 5e48cebb6b29ff73d2ba7bbdd9bb6dac1f346732 (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
/*
 * Copyright 2008 Vincent Sanders <vince@simtec.co.uk>
 *
 * 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/>.
 */

#ifndef NETSURF_FB_FBTK_WIDGET_H
#define NETSURF_FB_FBTK_WIDGET_H

enum fbtk_widgettype_e {
	FB_WIDGET_TYPE_ROOT = 0,
	FB_WIDGET_TYPE_WINDOW,
	FB_WIDGET_TYPE_BITMAP,
	FB_WIDGET_TYPE_FILL,
	FB_WIDGET_TYPE_TEXT,
	FB_WIDGET_TYPE_HSCROLL,
	FB_WIDGET_TYPE_VSCROLL,
	FB_WIDGET_TYPE_USER,
};

typedef struct fbtk_widget_list_s fbtk_widget_list_t;

/* wrapper struct for all widget types */
struct fbtk_widget_s {
	/* Generic properties */
	int x;
	int y;
	int width;
	int height;
	colour bg;
	colour fg;

	/* handlers */
	fbtk_mouseclick_t click;
	void *clickpw; /* private data for callback */

	fbtk_input_t input;
	void *inputpw; /* private data for callback */

	fbtk_move_t move;
	void *movepw; /* private data for callback */

	fbtk_redraw_t redraw;
	void *redrawpw; /* private data for callback */

	bool redraw_required;

	fbtk_widget_t *parent; /* parent widget */

	fbtk_callback callback; /* event callback */
	void *callback_context;

	/* Widget specific */
	enum fbtk_widgettype_e type;

	union {
		/* toolkit base handle */
		struct {
			nsfb_t *fb;
			fbtk_widget_t *rootw;
			fbtk_widget_t *input;
		} root;

		/* window */
		struct {
			/* widgets associated with this window */
			fbtk_widget_list_t *widgets; /* begining of list */
			fbtk_widget_list_t *widgets_end; /* end of list */
		} window;

		/* bitmap */
		struct {
			struct bitmap *bitmap;
		} bitmap;

		/* text */
		struct {
			char* text;
			bool outline;
			fbtk_enter_t enter;
			void *pw;
			int idx;
		} text;

		/* application driven widget */
		struct {
			void *pw; /* private data for user widget */
		} user;

		struct {
			int pos;
			int pct;
			struct fbtk_widget_s *btnul; /* scroll button up/left */
			struct fbtk_widget_s *btndr; /* scroll button down/right*/
		} scroll;

	} u;
};


/* widget manipulation functions */

fbtk_widget_t *new_widget(enum fbtk_widgettype_e type);

fbtk_widget_t *add_widget_to_window(fbtk_widget_t *window, fbtk_widget_t *widget);

#endif