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 */
|
2011-02-16 18:19:48 +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))
|
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) ********************************************************************/
|
|
|
|
|
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
|
|
|
/* menu command execution */
|
|
|
|
typedef cb_ret_t (*menu_exec_fn) (int command);
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
struct WDialog
|
2010-04-06 11:16:11 +04:00
|
|
|
{
|
2012-06-20 12:05:13 +04:00
|
|
|
Widget widget;
|
|
|
|
|
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 */
|
2014-02-08 19:37:11 +04:00
|
|
|
const int *color; /* Color set. Unused in viewer and editor */
|
2009-10-28 12:04:08 +03:00
|
|
|
char *title; /* Title of the dialog */
|
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 flags */
|
2010-06-05 18:48:06 +04:00
|
|
|
gboolean winch_pending; /* SIGWINCH signal has been got. Resize dialog after rise */
|
2010-04-06 11:16:11 +04:00
|
|
|
int mouse_status; /* For the autorepeat status of the mouse */
|
2003-10-25 03:20:30 +04:00
|
|
|
|
|
|
|
/* Internal variables */
|
2010-04-05 20:59:21 +04:00
|
|
|
GList *widgets; /* widgets list */
|
2013-07-23 02:16:20 +04:00
|
|
|
GList *current; /* Currently active widget */
|
2011-04-17 14:12:07 +04:00
|
|
|
unsigned long widget_id; /* maximum id of all widgets */
|
2010-04-06 11:16:11 +04:00
|
|
|
void *data; /* Data can be passed to dialog */
|
2011-05-01 15:42:17 +04:00
|
|
|
char *event_group; /* Name of event group for this dialog */
|
2010-04-18 14:23:06 +04:00
|
|
|
|
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
|
|
|
|
|
|
|
extern GList *top_dlg;
|
|
|
|
|
|
|
|
/* A hook list for idle events */
|
|
|
|
extern hook_t *idle_hook;
|
|
|
|
|
2010-11-22 14:45:18 +03:00
|
|
|
extern int fast_refresh;
|
|
|
|
extern int mouse_close_dialog;
|
|
|
|
|
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);
|
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
unsigned long add_widget_autopos (WDialog * dest, void *w, widget_pos_flags_t pos_flags,
|
2011-04-17 14:21:17 +04:00
|
|
|
const void *before);
|
2012-09-28 11:18:45 +04:00
|
|
|
unsigned long add_widget (WDialog * dest, void *w);
|
|
|
|
unsigned long add_widget_before (WDialog * h, void *w, void *before);
|
2011-04-17 14:21:17 +04:00
|
|
|
void del_widget (void *w);
|
2009-08-16 19:27:33 +04:00
|
|
|
|
|
|
|
/* sets size of dialog, leaving positioning to automatic mehtods
|
2010-04-06 11:16:11 +04:00
|
|
|
according to dialog flags */
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_set_size (WDialog * h, int lines, int cols);
|
2009-08-16 19:27:33 +04:00
|
|
|
/* this function allows to set dialog position */
|
2016-06-02 16:12:24 +03:00
|
|
|
void dlg_set_position (WDialog * h, int y, int x, int lines, int cols);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2013-06-24 11:40:53 +04:00
|
|
|
void dlg_init (WDialog * h);
|
|
|
|
int dlg_run (WDialog * d);
|
|
|
|
void dlg_destroy (WDialog * h);
|
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
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_redraw (WDialog * h);
|
2004-12-03 22:17:46 +03:00
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_broadcast_msg (WDialog * h, widget_msg_t message);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
|
|
|
/* Default callback 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);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
|
|
|
/* Default paint routine for dialogs */
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_default_repaint (WDialog * h);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_erase (WDialog * h);
|
|
|
|
void dlg_stop (WDialog * h);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* Widget selection */
|
2011-04-23 16:51:53 +04:00
|
|
|
void dlg_select_widget (void *w);
|
2016-02-23 09:49:58 +03:00
|
|
|
void dlg_set_bottom_widget (void *w);
|
2012-09-28 11:18:45 +04:00
|
|
|
void dlg_one_up (WDialog * h);
|
|
|
|
void dlg_one_down (WDialog * h);
|
|
|
|
gboolean dlg_focus (WDialog * h);
|
|
|
|
Widget *find_widget_type (const WDialog * h, widget_cb_fn callback);
|
|
|
|
Widget *dlg_find_by_id (const WDialog * h, unsigned long id);
|
|
|
|
void dlg_select_by_id (const WDialog * h, unsigned long id);
|
2003-10-25 03:20:30 +04:00
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
/* Redraw all dialogs */
|
|
|
|
void do_refresh (void);
|
|
|
|
|
|
|
|
/* Used in load_prompt() */
|
2012-09-28 11:18:45 +04:00
|
|
|
void update_cursor (WDialog * h);
|
2010-11-10 14:09:42 +03:00
|
|
|
|
2016-06-18 20:29:46 +03:00
|
|
|
void dlg_set_current_widget_next (WDialog * h);
|
|
|
|
void dlg_set_current_widget_prev (WDialog * h);
|
|
|
|
|
|
|
|
GList *dlg_get_widget_next_of (GList * w);
|
|
|
|
GList *dlg_get_widget_prev_of (GList * w);
|
|
|
|
|
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
|
|
|
|
2011-04-17 14:12:07 +04:00
|
|
|
static inline unsigned long
|
2016-03-03 22:51:40 +03:00
|
|
|
dlg_get_current_widget_id (const WDialog * h)
|
2010-04-05 20:59:21 +04:00
|
|
|
{
|
2012-06-20 15:09:44 +04:00
|
|
|
return WIDGET (h->current->data)->id;
|
2003-11-27 03:46:39 +03:00
|
|
|
}
|
|
|
|
|
2013-06-24 10:47:03 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-11-10 14:09:42 +03:00
|
|
|
#endif /* MC__DIALOG_H */
|