1 #ifndef _DIALOG_H_INCLUDE 2 #define _DIALOG_H_INCLUDE 3 4 /* 5 * dialog.h -- common declarations for all dialog modules 6 * 7 * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 8 * 9 * Substantial rennovation: 12/18/95, Jordan K. Hubbard 10 * 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. 15 * 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. 20 * 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. 24 * 25 * $FreeBSD: stable/9/gnu/lib/libodialog/dialog.h 171951 2007-08-24 16:26:24Z ache $ 26 * 27 */ 28 29 #define HAVE_NCURSES 30 31 #ifdef HAVE_NCURSES 32 #include <ncurses.h> 33 34 #else 35 36 #ifdef ultrix 37 #include <cursesX.h> 38 #else 39 #include <curses.h> 40 #endif 41 42 #endif 43 44 /* special return codes for `fire' actions */ 45 #define DITEM_STATUS(flag) ((flag) & 0x0000FFFF) 46 #define DITEM_SUCCESS 0 47 #define DITEM_FAILURE 1 48 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) 55 56 /* Attributes as used by entry fields right now */ 57 #define DITEM_NO_ECHO 0x0001 58 59 60 /* negative offsets for buttons in item lists, if specified */ 61 #define OK_BUTTON -2 62 #define CANCEL_BUTTON -1 63 64 /* for use in describing more exotic behaviors */ 65 typedef struct _dmenu_item { 66 char *prompt; 67 char *title; 68 int (*checked)(struct _dmenu_item *self); 69 int (*fire)(struct _dmenu_item *self); 70 void (*selected)(struct _dmenu_item *self, int is_selected); 71 void *data; 72 char lbra, mark, rbra; 73 long aux; 74 } dialogMenuItem; 75 76 #define VERSION "0.4" 77 #define MAX_LEN 4096 78 79 #ifndef TRUE 80 #define TRUE (1) 81 #endif 82 #ifndef FALSE 83 #define FALSE (0) 84 #endif 85 86 extern int DialogX, DialogY, DialogInputAttrs; 87 88 /* 89 * Attribute names 90 */ 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] 120 121 /* number of attributes */ 122 #define ATTRIBUTE_COUNT 29 123 124 extern chtype attributes[]; 125 126 #ifdef HAVE_NCURSES 127 extern bool use_shadow; 128 void draw_shadow(WINDOW *win, int y, int x, int height, int width); 129 #endif 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); 134 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); 153 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); 164 165 /* 166 * Display a tree menu from file 167 * 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 176 * 177 * return values: 178 * -1 - ESC pressed 179 * 0 - Ok, result set (must be freed later) 180 * 1 - Cancel 181 */ 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); 186 187 /* 188 * Display a tree menu from array 189 * 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 199 * 200 * return values: 201 * -1 - ESC pressed 202 * 0 - Ok, result set 203 * 1 - Cancel 204 */ 205 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); 210 211 #endif /* _DIALOG_H_INCLUDE */ 212