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))
22 /* Common return values */
23 /* ATTENTION: avoid overlapping with FileProgressStatus values */
30 /*** enums ***************************************************************************************/
32 /* Dialog color constants */
43 /*** typedefs(not structures) ********************************************************************/
45 typedef struct WDialog WDialog
;
47 /* get string representation of shortcut assigned with command */
48 /* as menu is a widget of dialog, ask dialog about shortcut string */
49 typedef char *(*dlg_shortcut_str
) (long command
);
51 /* get dialog name to show in dialog list */
52 typedef char *(*dlg_title_str
) (const WDialog
* h
, size_t len
);
54 typedef int dlg_colors_t
[DLG_COLOR_COUNT
];
56 /* menu command execution */
57 typedef cb_ret_t (*menu_exec_fn
) (int command
);
59 /*** structures declarations (and typedefs of structures)*****************************************/
63 WGroup group
; /* base class */
66 gboolean compact
; /* Suppress spaces around the frame */
67 const char *help_ctx
; /* Name of the help entry */
68 const int *color
; /* Color set. Unused in viewer and editor */
69 char *title
; /* Title of the dialog */
71 /* Set and received by the user */
72 int ret_value
; /* Result of dlg_run() */
75 int mouse_status
; /* For the autorepeat status of the mouse */
77 /* Internal variables */
78 void *data
; /* Data can be passed to dialog */
79 char *event_group
; /* Name of event group for this dialog */
81 dlg_shortcut_str get_shortcut
; /* Shortcut string */
82 dlg_title_str get_title
; /* useless for modal dialogs */
85 /*** global variables defined in .c file *********************************************************/
87 /* Color styles for normal and error dialogs */
88 extern dlg_colors_t dialog_colors
;
89 extern dlg_colors_t alarm_colors
;
90 extern dlg_colors_t listbox_colors
;
92 extern GList
*top_dlg
;
94 /* A hook list for idle events */
95 extern hook_t
*idle_hook
;
97 extern gboolean fast_refresh
;
98 extern gboolean mouse_close_dialog
;
100 extern const global_keymap_t
*dialog_map
;
102 /*** declarations of public functions ************************************************************/
104 /* Creates a dialog head */
105 WDialog
*dlg_create (gboolean modal
, int y1
, int x1
, int lines
, int cols
,
106 widget_pos_flags_t pos_flags
, gboolean compact
,
107 const int *colors
, widget_cb_fn callback
, widget_mouse_cb_fn mouse_callback
,
108 const char *help_ctx
, const char *title
);
110 void dlg_set_default_colors (void);
112 /* sets size of dialog, leaving positioning to automatic mehtods
113 according to dialog flags */
114 void dlg_set_size (WDialog
* h
, int lines
, int cols
);
115 /* this function allows to set dialog position */
116 void dlg_set_position (WDialog
* h
, int y
, int x
, int lines
, int cols
);
118 void dlg_init (WDialog
* h
);
119 int dlg_run (WDialog
* d
);
120 void dlg_destroy (WDialog
* h
);
122 void dlg_run_done (WDialog
* h
);
123 void dlg_save_history (WDialog
* h
);
124 void dlg_process_event (WDialog
* h
, int key
, Gpm_Event
* event
);
126 void dlg_set_title (WDialog
* h
, const char *title
);
127 char *dlg_get_title (const WDialog
* h
, size_t len
);
129 void dlg_draw (WDialog
* h
);
131 void dlg_broadcast_msg (WDialog
* h
, widget_msg_t message
);
133 /* Default callback for dialogs */
134 cb_ret_t
dlg_default_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
);
136 /* Default paint routine for dialogs */
137 void dlg_default_repaint (WDialog
* h
);
139 void dlg_erase (WDialog
* h
);
140 void dlg_stop (WDialog
* h
);
142 /* Widget selection */
143 Widget
*find_widget_type (const WDialog
* h
, widget_cb_fn callback
);
144 GList
*dlg_find (const WDialog
* h
, const Widget
* w
);
145 Widget
*dlg_find_by_id (const WDialog
* h
, unsigned long id
);
147 /* Redraw all dialogs */
148 void do_refresh (void);
150 /* Used in load_prompt() */
151 void update_cursor (WDialog
* h
);
153 /* --------------------------------------------------------------------------------------------- */
154 /*** inline functions ****************************************************************************/
155 /* --------------------------------------------------------------------------------------------- */
157 static inline unsigned long
158 dlg_get_current_widget_id (const WDialog
* h
)
160 return WIDGET (GROUP (h
)->current
->data
)->id
;
163 /* --------------------------------------------------------------------------------------------- */
165 #endif /* MC__DIALOG_H */