Ticket #1530
[pantumic.git] / src / wtools.h
blob00bb86be5ef75572e413e60fbf9bf3c9cb591e0b
2 /** \file wtools.h
3 * \brief Header: widget based utility functions
4 */
6 #ifndef MC_WTOOLS_H
7 #define MC_WTOOLS_H
9 #include "widget.h"
11 typedef struct {
12 struct Dlg_head *dlg;
13 struct WListbox *list;
14 } Listbox;
16 /* Listbox utility functions */
17 Listbox *create_listbox_window_delta (int delta_x, int delta_y, int cols, int lines, const char *title, const char *help);
19 Listbox *create_listbox_window (int cols, int lines, const char *title, const char *help);
20 #define LISTBOX_APPEND_TEXT(l,h,t,d) \
21 listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d)
23 int run_listbox (Listbox *l);
25 /* Quick Widgets */
26 enum {
27 quick_end, quick_checkbox,
28 quick_button, quick_input,
29 quick_label, quick_radio
30 } /* quick_t */;
32 /* The widget is placed on relative_?/divisions_? of the parent widget */
34 typedef struct {
35 int widget_type;
36 int relative_x;
37 int x_divisions;
38 int relative_y;
39 int y_divisions;
41 const char *text; /* Text */
42 int hotkey_pos; /* the hotkey position */
43 int value; /* Buttons only: value of button */
44 int *result; /* Checkbutton: where to store result */
45 char **str_result; /* Input lines: destination */
46 const char *histname; /* Name of the section for saving history */
47 bcback cb; /* Callback for quick_button */
49 Widget *widget;
50 } QuickWidget;
51 #define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL }
53 typedef struct {
54 int xlen, ylen;
55 int xpos, ypos; /* if -1, then center the dialog */
56 const char *title;
57 const char *help;
58 QuickWidget *widgets;
59 int i18n; /* If true, internationalization has happened */
60 } QuickDialog;
62 int quick_dialog (QuickDialog *qd);
63 int quick_dialog_skip (QuickDialog *qd, int nskip);
65 /* The input dialogs */
67 /* Pass this as def_text to request a password */
68 #define INPUT_PASSWORD ((char *) -1)
70 char *input_dialog (const char *header, const char *text,
71 const char *history_name, const char *def_text);
72 char *input_dialog_help (const char *header, const char *text, const char *help,
73 const char *history_name, const char *def_text);
74 char *input_expand_dialog (const char *header, const char *text,
75 const char *history_name, const char *def_text);
77 void query_set_sel (int new_sel);
79 /* Create message box but don't dismiss it yet, not background safe */
80 struct Dlg_head *create_message (int flags, const char *title,
81 const char *text, ...)
82 __attribute__ ((format (__printf__, 3, 4)));
84 /* Show message box, background safe */
85 void message (int flags, const char *title, const char *text, ...)
86 __attribute__ ((format (__printf__, 3, 4)));
89 /* Use this as header for message() - it expands to "Error" */
90 #define MSG_ERROR ((char *) -1)
92 int query_dialog (const char *header, const char *text, int flags, int count, ...);
94 /* flags for message() and query_dialog() */
95 enum {
96 D_NORMAL = 0,
97 D_ERROR = 1
98 } /* dialog options */;
100 #endif