ELinks 0.12pre5.GIT
[elinks.git] / src / bfu / widget.h
blob68496326a3248a8a21ea5010d1bfd50b99ee2025
1 #ifndef EL__BFU_WIDGET_H
2 #define EL__BFU_WIDGET_H
4 /* XXX: Include common definitions first */
5 #include "bfu/common.h"
7 #include "bfu/button.h"
8 #include "bfu/checkbox.h"
9 #include "bfu/group.h"
10 #include "bfu/inpfield.h"
11 #include "bfu/inphist.h"
12 #include "bfu/leds.h"
13 #include "bfu/listbox.h"
14 #include "bfu/msgbox.h"
15 #include "bfu/text.h"
16 #include "util/lists.h"
17 #include "util/box.h"
19 struct dialog_data;
22 struct widget_ops {
23 /* XXX: Order matters here. --Zas */
24 widget_handler_T *display;
25 widget_handler_T *init;
26 widget_handler_T *mouse;
27 widget_handler_T *kbd;
28 widget_handler_T *select;
29 widget_handler_T *clear;
32 struct widget {
33 const struct widget_ops *ops;
35 unsigned char *text;
37 widget_handler_T *handler;
39 void *data;
40 int datalen; /* 0 = no alloc/copy to cdata. */
42 union {
43 struct widget_info_checkbox checkbox;
44 struct widget_info_field field;
45 struct widget_info_button button;
46 struct widget_info_text text;
47 } info;
49 enum widget_type type;
52 struct widget_data {
53 struct widget *widget;
55 /* For WIDGET_FIELD: @cdata is in the charset of the terminal.
56 * (That charset can be UTF-8 only if CONFIG_UTF8 is defined,
57 * and is assumed to be unibyte otherwise.) The UTF-8 I/O
58 * option has no effect here.
60 * For WIDGET_TEXT: @cdata is cast from/to an unsigned char **
61 * that points to the first element of an array. Each element
62 * in this array corresponds to one line of text, and is an
63 * unsigned char * that points to the first character of that
64 * line. The array has @widget_data.info.text.lines elements. */
65 unsigned char *cdata;
67 struct box box;
69 union {
70 struct widget_data_info_field field;
71 struct widget_data_info_checkbox checkbox;
72 struct widget_data_info_text text;
73 } info;
76 void display_widget(struct dialog_data *, struct widget_data *);
78 static inline int
79 widget_is_focusable(struct widget_data *widget_data)
81 switch (widget_data->widget->type) {
82 case WIDGET_LISTBOX: return 0;
83 case WIDGET_TEXT: return text_is_scrollable(widget_data);
84 default: return 1;
89 #endif