2011-10-15 14:56:47 +04:00
|
|
|
/*
|
|
|
|
Dialog box features module for the Midnight Commander
|
2003-10-25 03:20:30 +04:00
|
|
|
*/
|
|
|
|
|
2009-02-05 21:28:18 +03:00
|
|
|
/** \file dialog.h
|
|
|
|
* \brief Header: dialog box features module
|
|
|
|
*/
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
#ifndef MC__DIALOG_H
|
|
|
|
#define MC__DIALOG_H
|
2004-12-03 22:17:46 +03:00
|
|
|
|
2010-04-18 14:23:06 +04:00
|
|
|
#include <sys/types.h> /* size_t */
|
|
|
|
|
2009-10-30 14:50:04 +03:00
|
|
|
#include "lib/global.h"
|
2010-11-09 11:08:20 +03:00
|
|
|
#include "lib/hook.h" /* hook_t */
|
2020-11-06 08:19:16 +03:00
|
|
|
#include "lib/keybind.h" /* global_keymap_t */
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
|
|
|
#define DIALOG(x) ((WDialog *)(x))
|
2019-11-17 17:58:52 +03:00
|
|
|
#define CONST_DIALOG(x) ((const WDialog *)(x))
|
2010-11-10 14:09:42 +03:00
|
|
|
|
2003-10-25 03:20:30 +04:00
|
|
|
/* Common return values */
|
2014-06-27 12:45:33 +04:00
|
|
|
/* ATTENTION: avoid overlapping with FileProgressStatus values */
|
2010-04-18 14:23:06 +04:00
|
|
|
#define B_EXIT 0
|
|
|
|
#define B_CANCEL 1
|
|
|
|
#define B_ENTER 2
|
|
|
|
#define B_HELP 3
|
2003-10-25 03:20:30 +04:00
|
|
|
#define B_USER 100
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** enums ***************************************************************************************/
|
2009-11-01 12:23:15 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* Dialog color constants */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
DLG_COLOR_NORMAL,
|
|
|
|
DLG_COLOR_FOCUS,
|
|
|
|
DLG_COLOR_HOT_NORMAL,
|
|
|
|
DLG_COLOR_HOT_FOCUS,
|
|
|
|
DLG_COLOR_TITLE,
|
|
|
|
DLG_COLOR_COUNT
|
|
|
|
} dlg_colors_enum_t;
|
|
|
|
|
|
|
|
/*** typedefs(not structures) ********************************************************************/
|
|
|
|
|
2016-09-27 13:53:17 +03:00
|
|
|
typedef struct WDialog WDialog;
|
|
|
|
|
2009-10-24 12:58:02 +04:00
|
|
|
/* get string representation of shortcut assigned with command */
|
|
|
|
/* as menu is a widget of dialog, ask dialog about shortcut string */
|
2015-11-21 18:15:11 +03:00
|
|
|
typedef char *(*dlg_shortcut_str) (long command);
|
2009-10-24 12:58:02 +04:00
|
|
|
|
2010-04-18 14:23:06 +04:00
|
|
|
/* get dialog name to show in dialog list */
|
2012-09-28 11:18:45 +04:00
|
|
|
typedef char *(*dlg_title_str) (const WDialog * h, size_t len);
|
2010-04-18 14:23:06 +04:00
|
|
|
|
2010-10-12 13:33:09 +04:00
|
|
|
typedef int dlg_colors_t[DLG_COLOR_COUNT];
|
2009-08-11 10:51:00 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
struct WDialog
|
2010-04-06 11:16:11 +04:00
|
|
|
{
|
2016-09-27 13:53:17 +03:00
|
|
|
WGroup group; /* base class */
|
2012-06-20 12:05:13 +04:00
|
|
|
|
2003-10-25 03:20:30 +04:00
|
|
|
/* Set by the user */
|
2016-05-08 21:10:05 +03:00
|
|
|
gboolean compact; /* Suppress spaces around the frame */
|
2010-04-06 11:16:11 +04:00
|
|
|
const char *help_ctx; /* Name of the help entry */
|
2019-11-17 17:58:52 +03:00
|
|
|
const int *colors; /* Color set. Unused in viewer and editor */
|
2003-10-25 03:20:30 +04:00
|
|
|
|
|
|
|
/* Set and received by the user */
|
2013-06-24 11:40:53 +04:00
|
|
|
int ret_value; /* Result of dlg_run() */
|
2003-10-25 03:20:30 +04:00
|
|
|
|
|
|
|
/* Internal variables */
|
2011-05-01 15:42:17 +04:00
|
|
|
char *event_group; /* Name of event group for this dialog */
|
2016-10-16 19:45:50 +03:00
|
|
|
Widget *bg; /* WFrame or WBackground */
|
2010-04-18 14:23:06 +04:00
|
|
|
|
2023-02-23 11:53:17 +03:00
|
|
|
/* Data can be passed to dialog */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
int i;
|
|
|
|
} data;
|
|
|
|
|
2010-04-06 11:16:11 +04:00
|
|
|
dlg_shortcut_str get_shortcut; /* Shortcut string */
|
2010-04-18 14:23:06 +04:00
|
|
|
dlg_title_str get_title; /* useless for modal dialogs */
|
2009-11-01 12:23:15 +03:00
|
|
|
};
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
/* Color styles for normal and error dialogs */
|
|
|
|
extern dlg_colors_t dialog_colors;
|
|
|
|
extern dlg_colors_t alarm_colors;
|
2014-02-08 19:37:11 +04:00
|
|
|
extern dlg_colors_t listbox_colors;
|
2010-11-10 14:09:42 +03:00
|
|
|
|
|
|
|
/* A hook list for idle events */
|
|
|
|
extern hook_t *idle_hook;
|
|
|
|
|
2016-11-25 10:39:08 +03:00
|
|
|
extern gboolean mouse_close_dialog;
|
2010-11-22 14:45:18 +03:00
|
|
|
|
2011-02-16 18:19:48 +03:00
|
|
|
extern const global_keymap_t *dialog_map;
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
2003-10-25 03:20:30 +04:00
|
|
|
/* Creates a dialog head */
|
2013-06-24 11:40:53 +04:00
|
|
|
WDialog *dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
|
2016-05-08 21:10:05 +03:00
|
|
|
widget_pos_flags_t pos_flags, gboolean compact,
|
2016-03-06 09:44:16 +03:00
|
|
|
const int *colors, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback,
|
2016-05-08 21:10:05 +03:00
|
|
|
const char *help_ctx, const char *title);
|
2009-05-30 21:39:02 +04:00
|
|
|
|
|
|
|
void dlg_set_default_colors (void);
|
|
|
|
|
2013-06-24 11:40:53 +04:00
|
|
|
void dlg_init (WDialog * h);
|
|
|
|
int dlg_run (WDialog * d);
|
2004-12-03 22:17:46 +03:00
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_run_done (WDialog * h);
|
|
|
|
void dlg_save_history (WDialog * h);
|
|
|
|
void dlg_process_event (WDialog * h, int key, Gpm_Event * event);
|
2010-04-18 14:23:06 +04:00
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
char *dlg_get_title (const WDialog * h, size_t len);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2016-11-15 09:33:34 +03:00
|
|
|
/* Default callbacks for dialogs */
|
2012-09-28 15:05:43 +04:00
|
|
|
cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data);
|
2016-11-15 09:33:34 +03:00
|
|
|
void dlg_default_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2023-04-15 10:17:41 +03:00
|
|
|
void dlg_close (WDialog * h);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2013-06-24 10:47:03 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2010-11-10 14:09:42 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
2011-04-17 14:12:07 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2010-11-12 11:03:57 +03:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
#endif /* MC__DIALOG_H */
|