grafthistory: support curl
[elinks/elinks-j605.git] / src / bfu / widget.h
blob777e440dc9651575f953afae192bae918ae7a520
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 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_listbox listbox;
46 struct widget_info_button button;
47 struct widget_info_text text;
48 } info;
50 enum widget_type type;
53 struct widget_data {
54 struct widget *widget;
55 unsigned char *cdata;
57 struct box box;
59 union {
60 struct widget_data_info_field field;
61 struct widget_data_info_checkbox checkbox;
62 struct widget_data_info_text text;
63 } info;
66 void display_widget(struct dialog_data *, struct widget_data *);
68 static inline int
69 widget_is_focusable(struct widget_data *widget_data)
71 switch (widget_data->widget->type) {
72 case WIDGET_LISTBOX: return 0;
73 case WIDGET_TEXT: return text_is_scrollable(widget_data);
74 default: return 1;
79 #endif