1 #ifndef _DIALOG_H_INCLUDE
2 #define _DIALOG_H_INCLUDE
5 * dialog.h -- common declarations for all dialog modules
7 * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
9 * Substantial rennovation: 12/18/95, Jordan K. Hubbard
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
44 /* special return codes for `fire' actions */
45 #define DITEM_STATUS(flag) ((flag) & 0x0000FFFF)
46 #define DITEM_SUCCESS 0
47 #define DITEM_FAILURE 1
49 /* Flags - returned in upper 16 bits of return status */
50 #define DITEM_LEAVE_MENU (1 << 16)
51 #define DITEM_REDRAW (1 << 17)
52 #define DITEM_RECREATE (1 << 18)
53 #define DITEM_RESTORE (1 << 19)
54 #define DITEM_CONTINUE (1 << 20)
56 /* Attributes as used by entry fields right now */
57 #define DITEM_NO_ECHO 0x0001
60 /* negative offsets for buttons in item lists, if specified */
62 #define CANCEL_BUTTON -1
64 /* for use in describing more exotic behaviors */
65 typedef struct _dmenu_item {
68 int (*checked)(struct _dmenu_item *self);
69 int (*fire)(struct _dmenu_item *self);
70 void (*selected)(struct _dmenu_item *self, int is_selected);
72 char lbra, mark, rbra;
86 extern int DialogX, DialogY, DialogInputAttrs;
91 #define screen_attr attributes[0]
92 #define shadow_attr attributes[1]
93 #define dialog_attr attributes[2]
94 #define title_attr attributes[3]
95 #define border_attr attributes[4]
96 #define button_active_attr attributes[5]
97 #define button_inactive_attr attributes[6]
98 #define button_key_active_attr attributes[7]
99 #define button_key_inactive_attr attributes[8]
100 #define button_label_active_attr attributes[9]
101 #define button_label_inactive_attr attributes[10]
102 #define inputbox_attr attributes[11]
103 #define inputbox_border_attr attributes[12]
104 #define searchbox_attr attributes[13]
105 #define searchbox_title_attr attributes[14]
106 #define searchbox_border_attr attributes[15]
107 #define position_indicator_attr attributes[16]
108 #define menubox_attr attributes[17]
109 #define menubox_border_attr attributes[18]
110 #define item_attr attributes[19]
111 #define item_selected_attr attributes[20]
112 #define tag_attr attributes[21]
113 #define tag_selected_attr attributes[22]
114 #define tag_key_attr attributes[23]
115 #define tag_key_selected_attr attributes[24]
116 #define check_attr attributes[25]
117 #define check_selected_attr attributes[26]
118 #define uarrow_attr attributes[27]
119 #define darrow_attr attributes[28]
121 /* number of attributes */
122 #define ATTRIBUTE_COUNT 29
124 extern chtype attributes[];
127 extern bool use_shadow;
128 void draw_shadow(WINDOW *win, int y, int x, int height, int width);
130 void draw_box(WINDOW *win, int y, int x, int height, int width, chtype box, chtype border);
131 int line_edit(WINDOW *dialog, int box_y, int box_x, int flen, int box_width, chtype attrs, int first, unsigned char *result, int attr_mask);
132 int strheight(const char *p);
133 int strwidth(const char *p);
135 void dialog_create_rc(unsigned char *filename);
136 int dialog_yesno(unsigned char *title, unsigned char *prompt, int height, int width);
137 int dialog_noyes(unsigned char *title, unsigned char *prompt, int height, int width);
138 int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, int width, int pause, int use_shell);
139 int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause);
140 int dialog_textbox(unsigned char *title, unsigned char *file, int height, int width);
141 int dialog_menu(unsigned char *title, unsigned char *prompt, int height, int width, int menu_height,
142 int item_no, void *itptr, unsigned char *result, int *ch, int *sc);
143 int dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
144 int item_no, void *itptr, unsigned char *result);
145 int dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int width, int list_height,
146 int item_no, void *itptr, unsigned char *result);
147 int dialog_inputbox(unsigned char *title, unsigned char *prompt, int height, int width, unsigned char *result);
148 void dialog_clear_norefresh(void);
149 void dialog_clear(void);
150 void dialog_update(void);
151 void init_dialog(void);
152 void end_dialog(void);
154 /* Additions to libdialog */
155 char *dialog_fselect(char *dir, char *fmask);
156 int dialog_dselect(char *dir, char *fmask);
157 void dialog_notify(char *msg);
158 int dialog_mesgbox(unsigned char *title, unsigned char *prompt, int height, int width);
159 void use_helpfile(char *helpfile);
160 void use_helpline(char *helpline);
161 char *get_helpline(void);
162 void restore_helpline(char *helpline);
163 void dialog_gauge(char *title, char *prompt, int y, int x, int height, int width, int perc);
166 * Display a tree menu from file
168 * filename - file with like find(1) output
169 * FS - fields separator
170 * title - title of dialog box
171 * prompt - prompt text into dialog box
172 * height - height of dialog box
173 * width - width of dialog box
174 * menu_height - height of menu box
175 * result - pointer to char array
179 * 0 - Ok, result set (must be freed later)
182 int dialog_ftree(unsigned char *filename, unsigned char FS,
183 unsigned char *title, unsigned char *prompt,
184 int height, int width, int menu_height,
185 unsigned char **result);
188 * Display a tree menu from array
190 * names - array with like find(1) output
191 * size - size of array
192 * FS - fields separator
193 * title - title of dialog box
194 * prompt - prompt text into dialog box
195 * height - height of dialog box
196 * width - width of dialog box
197 * menu_height - height of menu box
198 * result - pointer to char array
206 int dialog_tree(unsigned char **names, int size, unsigned char FS,
207 unsigned char *title, unsigned char *prompt,
208 int height, int width, int menu_height,
209 unsigned char **result);
211 #endif /* _DIALOG_H_INCLUDE */