Retry only for https protocol
[elinks.git] / src / bfu / button.h
blob8fb14ed53ab35b5bcedaa52b86e6583db2ab7127
1 #ifndef EL__BFU_BUTTON_H
2 #define EL__BFU_BUTTON_H
4 #include "bfu/common.h"
5 #include "util/align.h"
7 struct dialog;
8 struct dialog_data;
9 struct terminal;
10 struct widget_data;
12 typedef void (done_handler_T)(void *);
14 struct widget_info_button {
15 int flags;
16 int hotkey_pos; /* -1 means no hotkey, hotkeys are marked by ~. */
17 int textlen; /* Text length without hotkey */
18 int truetextlen; /* Original text length (with hotkey if any) */
19 /* Used by some default handlers like ok_dialog()
20 * as a callback. */
21 done_handler_T *done;
22 void *done_data;
25 /* Button flags, go into widget.gid */
26 #define B_ENTER 1
27 #define B_ESC 2
29 /* Define to find buttons without keyboard accelerator. */
30 /* #define DEBUG_BUTTON_HOTKEY */
32 /** @def add_dlg_ok_button
33 * Add a button that will close the dialog if pressed.
35 * void add_dlg_ok_button(struct dialog *dlg, unsigned char *text, int flags,
36 * ::done_handler_T *done, void *data);
38 * @param dlg
39 * The dialog in which the button is to be added.
41 * @param text
42 * Text displayed in the button. This string should contain a
43 * keyboard accelerator, marked with a preceding '~'. The pointer
44 * must remain valid as long as the dialog exists.
46 * @param flags
47 * Can be ::B_ENTER, ::B_ESC, or 0.
49 * @param done
50 * A function that BFU calls when the user presses this button.
51 * Before calling this, BFU checks the values of widgets.
52 * After the function returns, BFU closes the dialog.
54 * @param data
55 * A pointer to be passed to the @a done callback. */
57 /** @def add_dlg_button
58 * Add a button that need not close the dialog if pressed.
60 * void add_dlg_button(struct dialog *dlg, unsigned char *text, int flags,
61 * ::widget_handler_T *handler, void *data);
63 * @param handler
64 * A function that BFU calls when the user presses this button.
65 * BFU does not automatically check the values of widgets
66 * or close the dialog.
68 * @param data
69 * A pointer to any data needed by @a handler. It does not get this
70 * pointer as a parameter but can read it from widget_data->widget->data.
72 * The other parameters are as in ::add_dlg_ok_button. */
74 #ifdef DEBUG_BUTTON_HOTKEY
75 void add_dlg_button_do(const unsigned char *file, int line, struct dialog *dlg, unsigned char *text, int flags, widget_handler_T *handler, void *data, done_handler_T *done, void *done_data);
76 #define add_dlg_ok_button(dlg, text, flags, done, data) \
77 add_dlg_button_do(__FILE__, __LINE__, dlg, text, flags, ok_dialog, NULL, done, data)
79 #define add_dlg_button(dlg, text, flags, handler, data) \
80 add_dlg_button_do(__FILE__, __LINE__, dlg, text, flags, handler, data, NULL, NULL)
82 #else
83 void add_dlg_button_do(struct dialog *dlg, unsigned char *text, int flags, widget_handler_T *handler, void *data, done_handler_T *done, void *done_data);
85 #define add_dlg_ok_button(dlg, text, flags, done, data) \
86 add_dlg_button_do(dlg, text, flags, ok_dialog, NULL, done, data)
88 #define add_dlg_button(dlg, text, flags, handler, data) \
89 add_dlg_button_do(dlg, text, flags, handler, data, NULL, NULL)
90 #endif
92 extern const struct widget_ops button_ops;
93 void dlg_format_buttons(struct dialog_data *, struct widget_data *, int, int, int *, int, int *, enum format_align, int);
95 #endif