rewrite: update default dumb and smart prefixes
[elinks/elinks-j605.git] / src / bfu / widget.h
blob2cafbd6b49b4cafe831d70818e20e2e4433f4cec
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.
66 * For WIDGET_LISTBOX: @cdata points to struct listbox_data. */
67 unsigned char *cdata;
69 struct box box;
71 union {
72 struct widget_data_info_field field;
73 struct widget_data_info_checkbox checkbox;
74 struct widget_data_info_text text;
75 } info;
78 void display_widget(struct dialog_data *, struct widget_data *);
80 static inline int
81 widget_is_focusable(struct widget_data *widget_data)
83 switch (widget_data->widget->type) {
84 case WIDGET_LISTBOX: return 0;
85 case WIDGET_TEXT: return text_is_scrollable(widget_data);
86 default: return 1;
91 #endif