1 #ifndef EL__BFU_BUTTON_H
2 #define EL__BFU_BUTTON_H
4 #include "bfu/common.h"
5 #include "util/align.h"
12 typedef void (done_handler_T
)(void *);
14 struct widget_info_button
{
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()
25 /* Button flags, go into widget.gid */
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);
39 * The dialog in which the button is to be added.
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.
47 * Can be ::B_ENTER, ::B_ESC, or 0.
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.
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);
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.
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)
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)
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);