2010-11-12 11:03:57 +03:00
|
|
|
/** \file quick.h
|
|
|
|
* \brief Header: quick dialog engine
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MC__QUICK_H
|
|
|
|
#define MC__QUICK_H
|
|
|
|
|
2012-05-28 16:59:20 +04:00
|
|
|
#include "lib/tty/mouse.h"
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_CHECKBOX(txt, st, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_checkbox, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.checkbox = { \
|
|
|
|
.text = txt, \
|
|
|
|
.state = st \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_BUTTON(txt, act, cb, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_button, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.button = { \
|
|
|
|
.text = txt, \
|
|
|
|
.action = act, \
|
|
|
|
.callback = cb \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_INPUT(txt, flags_, hname, res, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_input, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.label_text = NULL, \
|
|
|
|
.label_location = input_label_none, \
|
|
|
|
.label = NULL, \
|
|
|
|
.text = txt, \
|
|
|
|
.flags = flags_, \
|
|
|
|
.histname = hname, \
|
|
|
|
.result = res \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_LABELED_INPUT(label_, label_loc, txt, flags_, hname, res, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_input, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.label_text = label_, \
|
|
|
|
.label_location = label_loc, \
|
|
|
|
.label = NULL, \
|
|
|
|
.text = txt, \
|
|
|
|
.flags = flags_, \
|
|
|
|
.histname = hname, \
|
|
|
|
.result = res \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_LABEL(txt, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_label, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.label = { \
|
|
|
|
.text = txt, \
|
|
|
|
.input = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_RADIO(cnt, items_, val, id_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_radio, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = id_, \
|
|
|
|
.u = { \
|
|
|
|
.radio = { \
|
|
|
|
.count = cnt, \
|
|
|
|
.items = items_, \
|
|
|
|
.value = val \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_START_GROUPBOX(t) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_start_groupbox, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.groupbox = { \
|
|
|
|
.title = t \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_STOP_GROUPBOX \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_stop_groupbox, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.text = NULL, \
|
|
|
|
.flags = 0, \
|
|
|
|
.histname = NULL, \
|
|
|
|
.result = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_SEPARATOR(line_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_separator, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.separator = { \
|
|
|
|
.space = TRUE, \
|
|
|
|
.line = line_ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_START_COLUMNS \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_start_columns, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.text = NULL, \
|
|
|
|
.flags = 0, \
|
|
|
|
.histname = NULL, \
|
|
|
|
.result = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_NEXT_COLUMN \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_next_column, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.text = NULL, \
|
|
|
|
.flags = 0, \
|
|
|
|
.histname = NULL, \
|
|
|
|
.result = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_STOP_COLUMNS \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_stop_columns, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.text = NULL, \
|
|
|
|
.flags = 0, \
|
|
|
|
.histname = NULL, \
|
|
|
|
.result = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QUICK_START_BUTTONS(space_, line_) \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_buttons, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.separator = { \
|
|
|
|
.space = space_, \
|
|
|
|
.line = line_ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2012-09-25 10:20:18 +04:00
|
|
|
#define QUICK_BUTTONS_OK_CANCEL \
|
|
|
|
QUICK_START_BUTTONS (TRUE, TRUE), \
|
|
|
|
QUICK_BUTTON (N_("&OK"), B_ENTER, NULL, NULL), \
|
|
|
|
QUICK_BUTTON (N_("&Cancel"), B_CANCEL, NULL, NULL)
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
#define QUICK_END \
|
|
|
|
{ \
|
|
|
|
.widget_type = quick_end, \
|
|
|
|
.options = 0, \
|
|
|
|
.id = NULL, \
|
|
|
|
.u = { \
|
|
|
|
.input = { \
|
|
|
|
.text = NULL, \
|
|
|
|
.flags = 0, \
|
|
|
|
.histname = NULL, \
|
|
|
|
.result = NULL \
|
|
|
|
} \
|
|
|
|
} \
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/* Quick Widgets */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
quick_end = 0,
|
|
|
|
quick_checkbox = 1,
|
|
|
|
quick_button = 2,
|
|
|
|
quick_input = 3,
|
|
|
|
quick_label = 4,
|
|
|
|
quick_radio = 5,
|
2012-09-16 12:54:19 +04:00
|
|
|
quick_start_groupbox = 6,
|
|
|
|
quick_stop_groupbox = 7,
|
|
|
|
quick_separator = 8,
|
|
|
|
quick_start_columns = 9,
|
|
|
|
quick_next_column = 10,
|
|
|
|
quick_stop_columns = 11,
|
|
|
|
quick_buttons = 12
|
2010-11-12 11:03:57 +03:00
|
|
|
} quick_t;
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
input_label_none = 0,
|
|
|
|
input_label_above = 1,
|
|
|
|
input_label_left = 2,
|
|
|
|
input_label_right = 3,
|
|
|
|
input_label_below = 4
|
|
|
|
} quick_input_label_location_t;
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
/* The widget is placed on relative_?/divisions_? of the parent widget */
|
2012-09-16 12:54:19 +04:00
|
|
|
typedef struct quick_widget_t quick_widget_t;
|
|
|
|
|
|
|
|
struct quick_widget_t
|
2010-11-12 11:03:57 +03:00
|
|
|
{
|
|
|
|
quick_t widget_type;
|
|
|
|
|
|
|
|
widget_options_t options;
|
2012-09-16 12:54:19 +04:00
|
|
|
unsigned long *id;
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/* widget parameters */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char *text;
|
|
|
|
int *state; /* in/out */
|
|
|
|
} checkbox;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char *text;
|
|
|
|
int action;
|
|
|
|
bcback_fn callback;
|
|
|
|
} button;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2012-09-16 12:54:19 +04:00
|
|
|
const char *label_text;
|
|
|
|
quick_input_label_location_t label_location;
|
|
|
|
quick_widget_t *label;
|
2010-11-12 11:03:57 +03:00
|
|
|
const char *text;
|
|
|
|
int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
|
|
|
|
const char *histname;
|
|
|
|
char **result;
|
2012-04-05 13:51:06 +04:00
|
|
|
gboolean strip_password;
|
2010-11-12 11:03:57 +03:00
|
|
|
} input;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char *text;
|
2012-09-16 12:54:19 +04:00
|
|
|
quick_widget_t *input;
|
2010-11-12 11:03:57 +03:00
|
|
|
} label;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
const char **items;
|
|
|
|
int *value; /* in/out */
|
|
|
|
} radio;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char *title;
|
|
|
|
} groupbox;
|
2012-09-16 12:54:19 +04:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
gboolean space;
|
|
|
|
gboolean line;
|
|
|
|
} separator;
|
2010-11-12 11:03:57 +03:00
|
|
|
} u;
|
2012-09-16 12:54:19 +04:00
|
|
|
};
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2012-09-16 12:54:19 +04:00
|
|
|
int y, x; /* if -1, then center the dialog */
|
|
|
|
int cols; /* heigth is calculated automatically */
|
2010-11-12 11:03:57 +03:00
|
|
|
const char *title;
|
|
|
|
const char *help;
|
2012-09-16 12:54:19 +04:00
|
|
|
quick_widget_t *widgets;
|
2010-11-12 11:03:57 +03:00
|
|
|
dlg_cb_fn callback;
|
2012-05-28 16:59:20 +04:00
|
|
|
mouse_h mouse;
|
2012-09-16 12:54:19 +04:00
|
|
|
} quick_dialog_t;
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
2012-09-16 12:54:19 +04:00
|
|
|
int quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip);
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/*** inline functions ****************************************************************************/
|
|
|
|
|
|
|
|
static inline int
|
2012-09-16 12:54:19 +04:00
|
|
|
quick_dialog (quick_dialog_t * quick_dlg)
|
2010-11-12 11:03:57 +03:00
|
|
|
{
|
2012-09-16 12:54:19 +04:00
|
|
|
return quick_dialog_skip (quick_dlg, 1);
|
2010-11-12 11:03:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MC__QUICK_H */
|