Merge commit '315633ecce31cd5af92112ab9903f6e7e8ae8df7'
[free-mc.git] / src / wtools.h
blob7691f237ed8cb145b14e055862a9062c7e6c6bb3
1 #ifndef MC_WTOOLS_H
2 #define MC_WTOOLS_H
4 #include "widget.h"
6 typedef struct {
7 struct Dlg_head *dlg;
8 struct WListbox *list;
9 } Listbox;
11 /* Listbox utility functions */
12 Listbox *create_listbox_window (int cols, int lines, const char *title, const char *help);
13 #define LISTBOX_APPEND_TEXT(l,h,t,d) \
14 listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d)
16 int run_listbox (Listbox *l);
18 /* Quick Widgets */
19 enum {
20 quick_end, quick_checkbox,
21 quick_button, quick_input,
22 quick_label, quick_radio
23 } /* quick_t */;
25 /* The widget is placed on relative_?/divisions_? of the parent widget */
27 typedef struct {
28 int widget_type;
29 int relative_x;
30 int x_divisions;
31 int relative_y;
32 int y_divisions;
34 const char *text; /* Text */
35 int hotkey_pos; /* the hotkey position */
36 int value; /* Buttons only: value of button */
37 int *result; /* Checkbutton: where to store result */
38 char **str_result; /* Input lines: destination */
39 const char *histname; /* Name of the section for saving history */
40 } QuickWidget;
41 #define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL }
43 typedef struct {
44 int xlen, ylen;
45 int xpos, ypos; /* if -1, then center the dialog */
46 const char *title;
47 const char *help;
48 QuickWidget *widgets;
49 int i18n; /* If true, internationalization has happened */
50 } QuickDialog;
52 int quick_dialog (QuickDialog *qd);
53 int quick_dialog_skip (QuickDialog *qd, int nskip);
55 /* The input dialogs */
57 /* Pass this as def_text to request a password */
58 #define INPUT_PASSWORD ((char *) -1)
60 char *input_dialog (const char *header, const char *text, const char *def_text);
61 char *input_dialog_help (const char *header, const char *text, const char *help, const char *def_text);
62 char *input_expand_dialog (const char *header, const char *text, const char *def_text);
64 void query_set_sel (int new_sel);
66 /* Create message box but don't dismiss it yet, not background safe */
67 struct Dlg_head *create_message (int flags, const char *title,
68 const char *text, ...)
69 __attribute__ ((format (__printf__, 3, 4)));
71 /* Show message box, background safe */
72 void message (int flags, const char *title, const char *text, ...)
73 __attribute__ ((format (__printf__, 3, 4)));
76 /* Use this as header for message() - it expands to "Error" */
77 #define MSG_ERROR ((char *) -1)
79 int query_dialog (const char *header, const char *text, int flags, int count, ...);
81 /* flags for message() and query_dialog() */
82 enum {
83 D_NORMAL = 0,
84 D_ERROR = 1
85 } /* dialog options */;
87 #endif