2 Dialog box features module for the Midnight Commander
6 * \brief Header: dialog box features module
12 #include <sys/types.h> /* size_t */
14 #include "lib/global.h"
15 #include "lib/hook.h" /* hook_t */
16 #include "lib/keybind.h" /* global_keymap_t */
18 /*** typedefs(not structures) and defined constants **********************************************/
20 #define DIALOG(x) ((WDialog *)(x))
21 #define CONST_DIALOG(x) ((const WDialog *)(x))
23 /* Common return values */
24 /* ATTENTION: avoid overlapping with FileProgressStatus values */
31 /*** enums ***************************************************************************************/
33 /* Dialog color constants */
44 /*** typedefs(not structures) ********************************************************************/
46 typedef struct WDialog WDialog
;
48 /* get string representation of shortcut assigned with command */
49 /* as menu is a widget of dialog, ask dialog about shortcut string */
50 typedef char *(*dlg_shortcut_str
) (long command
);
52 /* get dialog name to show in dialog list */
53 typedef char *(*dlg_title_str
) (const WDialog
* h
, size_t len
);
55 typedef int dlg_colors_t
[DLG_COLOR_COUNT
];
57 /*** structures declarations (and typedefs of structures)*****************************************/
61 WGroup group
; /* base class */
64 gboolean compact
; /* Suppress spaces around the frame */
65 const char *help_ctx
; /* Name of the help entry */
66 const int *colors
; /* Color set. Unused in viewer and editor */
68 /* Set and received by the user */
69 int ret_value
; /* Result of dlg_run() */
71 /* Internal variables */
72 char *event_group
; /* Name of event group for this dialog */
73 Widget
*bg
; /* WFrame or WBackground */
75 /* Data can be passed to dialog */
82 dlg_shortcut_str get_shortcut
; /* Shortcut string */
83 dlg_title_str get_title
; /* useless for modal dialogs */
86 /*** global variables defined in .c file *********************************************************/
88 /* Color styles for normal and error dialogs */
89 extern dlg_colors_t dialog_colors
;
90 extern dlg_colors_t alarm_colors
;
91 extern dlg_colors_t listbox_colors
;
93 /* A hook list for idle events */
94 extern hook_t
*idle_hook
;
96 extern gboolean mouse_close_dialog
;
98 extern const global_keymap_t
*dialog_map
;
100 /*** declarations of public functions ************************************************************/
102 /* Creates a dialog head */
103 WDialog
*dlg_create (gboolean modal
, int y1
, int x1
, int lines
, int cols
,
104 widget_pos_flags_t pos_flags
, gboolean compact
,
105 const int *colors
, widget_cb_fn callback
, widget_mouse_cb_fn mouse_callback
,
106 const char *help_ctx
, const char *title
);
108 void dlg_set_default_colors (void);
110 void dlg_init (WDialog
* h
);
111 int dlg_run (WDialog
* d
);
113 void dlg_run_done (WDialog
* h
);
114 void dlg_save_history (WDialog
* h
);
115 void dlg_process_event (WDialog
* h
, int key
, Gpm_Event
* event
);
117 char *dlg_get_title (const WDialog
* h
, size_t len
);
119 /* Default callbacks for dialogs */
120 cb_ret_t
dlg_default_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
);
121 void dlg_default_mouse_callback (Widget
* w
, mouse_msg_t msg
, mouse_event_t
* event
);
123 void dlg_close (WDialog
* h
);
125 /* --------------------------------------------------------------------------------------------- */
126 /*** inline functions ****************************************************************************/
127 /* --------------------------------------------------------------------------------------------- */
129 #endif /* MC__DIALOG_H */