1 #ifndef EL__BFU_BUTTON_H
2 #define EL__BFU_BUTTON_H
4 #include "bfu/common.h"
5 #include "util/align.h"
11 typedef void (done_handler_T
)(void *);
13 struct widget_info_button
{
15 int hotkey_pos
; /* -1 means no hotkey, hotkeys are marked by ~. */
16 int textlen
; /* Text length without hotkey */
17 int truetextlen
; /* Original text length (with hotkey if any) */
18 /* Used by some default handlers like ok_dialog()
24 /* Button flags, go into widget.gid */
28 /* Define to find buttons without keyboard accelerator. */
29 /* #define DEBUG_BUTTON_HOTKEY */
31 /** @def add_dlg_ok_button
32 * Add a button that will close the dialog if pressed.
34 * void add_dlg_ok_button(struct dialog *dlg, unsigned char *text, int flags,
35 * ::done_handler_T *done, void *done_data);
38 * The dialog in which the button is to be added.
41 * Text displayed in the button. This string should contain a
42 * keyboard accelerator, marked with a preceding '~'. The pointer
43 * must remain valid as long as the dialog exists.
46 * Can be ::B_ENTER, ::B_ESC, or 0.
49 * A function that BFU calls when the user presses this button.
50 * Before calling this, BFU checks the values of widgets.
51 * After the function returns, BFU closes the dialog.
54 * A pointer to be passed to the @a done callback. */
56 /** @def add_dlg_button
57 * Add a button that need not close the dialog if pressed.
59 * void add_dlg_button(struct dialog *dlg, unsigned char *text, int flags,
60 * ::widget_handler_t *handler, void *data);
63 * A function that BFU calls when the user presses this button.
64 * BFU does not automatically check the values of widgets
65 * or close the dialog.
68 * A pointer to any data needed by @a handler. It does not get this
69 * pointer as a parameter but can read it from widget_data->widget->data.
71 * The other parameters are as in ::add_dlg_ok_button. */
73 #ifdef DEBUG_BUTTON_HOTKEY
74 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
);
75 #define add_dlg_ok_button(dlg, text, flags, done, data) \
76 add_dlg_button_do(__FILE__, __LINE__, dlg, text, flags, ok_dialog, NULL, done, data)
78 #define add_dlg_button(dlg, text, flags, handler, data) \
79 add_dlg_button_do(__FILE__, __LINE__, dlg, text, flags, handler, data, NULL, NULL)
82 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
);
84 #define add_dlg_ok_button(dlg, text, flags, done, data) \
85 add_dlg_button_do(dlg, text, flags, ok_dialog, NULL, done, data)
87 #define add_dlg_button(dlg, text, flags, handler, data) \
88 add_dlg_button_do(dlg, text, flags, handler, data, NULL, NULL)
91 extern const struct widget_ops button_ops
;
92 void dlg_format_buttons(struct terminal
*, struct widget_data
*, int, int, int *, int, int *, enum format_align
, int);