ScummVM API documentation
dialog.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef MADS_CORE_DIALOG_H
23#define MADS_CORE_DIALOG_H
24
25#include "mads/core/general.h"
26#include "mads/core/window.h"
27#include "mads/core/keys.h"
28
29namespace MADS {
30
31#define DIALOG_ENGLISH 0 /* English language */
32#define DIALOG_GERMAN 1 /* German language */
33
34#define DIALOG_MAX_ITEM 50 /* Maximum items in a box */
35#define DIALOG_MAX_BUFFER 16 /* Maximum buffer areas in box */
36#define DIALOG_MAX_LIST 4 /* Maximum number of list windows */
37#define DIALOG_MAX_PROMPT_CHARS 72 /* Maximum length of prompt string */
38#define DIALOG_MAX_LIST_CHARS 13 /* Maximum length of list string */
39
40#define DIALOG_DEFAULT_STRING_SPACE 1024/* Default workspace size */
41
42#define DIALOG_FILE_WIDTH 61 /* Proper width for file dialog box*/
43#define DIALOG_FILE_BUFFER 46 /* Proper width for file name buf. */
44
45#define DD_DYNAMIC 0x80 /* Dialog allocated dynamically*/
46#define DD_STATIC 0x00 /* Dialog pre-allocated static */
47#define DD_EXITFLAG 0x40 /* Dialog is terminating */
48#define DD_COMPUTED 0x20 /* Dialog boundaries computed */
49#define DD_SCREENSAVED 0x10 /* Dialog window has saved */
50#define DD_FILEMENU 0x08 /* Dialog uses file functions */
51#define DD_DYNAMICSTRINGS 0x04 /* Dialog has dynamic strings */
52
53#define DD_CENTER -1 /* Dialog centered on axis */
54
55#define DD_AUTO -1 /* Auto-compute (width, etc.) */
56
57#define DD_DEFAULT -1 /* Default color */
58
59#define DD_LINEACROSS 0 /* Line across the box */
60
61#define DD_PAUSE 1 /* Use OK button to exit */
62#define DD_PERMANENT 2 /* No window cleanup */
63#define DD_MANUAL 3 /* Caller calls window_destroy */
64
65#define DD_I_NONE 0 /* Blank item type */
66#define DD_I_STRING 1 /* Item is a string input line */
67#define DD_I_FILENAME 2 /* Item is a filename input */
68#define DD_I_LISTBASED 3 /* Item is a list-based string */
69#define DD_I_CHECKBOX 4 /* Item is a checkoff box */
70#define DD_I_BUTTON 5 /* Item is a bottom-row button */
71#define DD_I_MESSAGE 6 /* Item is a message string */
72
73#define DD_I_FILELIST 7 /* Item is a file list */
74#define DD_I_DIRSLIST 8 /* Item is a directory list */
75#define DD_I_LIST 9 /* Item is a string list */
76
77#define DD_IX_CENTER -1 /* X control: Center this item */
78#define DD_IX_LEFT -2 /* X control: Left margin item */
79#define DD_IX_RIGHT -3 /* X control: Right margin itm */
80
81#define DD_IY_BUTTON -1 /* Y control: button line */
82#define DD_IY_AUTOFILL -2 /* Y control: autofill from top*/
83
84#define DD_C_HOME -257 /* Move cursor home */
85#define DD_C_END -258 /* Move cursor to end */
86
87#define DD_MC_NONE -1 /* Mouse not in any item */
88#define DD_MC_SCROLL -2 /* Mouse in a scroll bar */
89#define DD_MC_SCROLL_UP -3 /* Mouse in scroll up arrow */
90#define DD_MC_SCROLL_DOWN -4 /* Mouse in scroll down arrow */
91#define DD_MC_SCROLL_LEFT -5 /* Mouse in scroll left arrow */
92#define DD_MC_SCROLL_RIGHT -6 /* Mouse in scroll right arrow */
93#define DD_MC_SCROLL_PAGE_UP -7 /* Mouse pageing up */
94#define DD_MC_SCROLL_PAGE_DOWN -8 /* Mouse pageing down */
95#define DD_MC_SCROLL_PAGE_LEFT -9 /* Mouse pageing left */
96#define DD_MC_SCROLL_PAGE_RIGHT -10 /* Mouse pageing right */
97
98#define CANCEL_BUTTON "Cancel"
99#define CANCEL_GERMAN "Abbrechen"
100
101#define DD_CANCEL_BUTTON 0x01 /* Cancel button bit mask */
102#define DD_OK_BUTTON 0x02 /* OK button bit mask */
103#define DD_YES_BUTTON 0x04 /* Yes button bit mask */
104#define DD_NO_BUTTON 0x08 /* No button bit mask */
105#define DD_BEGONE_BUTTON 0x10 /* Begone button bit mask */
106
107#define DD_CHECK_GREY 0x80 /* Greyed out checkbox */
108#define DD_CHECK_RADIO 0x40 /* Checkbox is part of an ex- */
109/* clusive (radio button) group*/
110#define DD_CHECK_TRUE 0x01 /* Checkbox is selected. */
111
112#define DD_ERR_NOMOREITEMS -1 /* Ran out of items */
113#define DD_ERR_NOMOREBUFFERS -2 /* Ran out of string buffers */
114#define DD_ERR_NOMORELISTS -3 /* Ran out of string lists */
115#define DD_ERR_NOMOREMEMORY -4 /* Ran out of memory */
116#define DD_ERR_ABORTEDBYCALLBACK -5 /* Aborted by callback routine */
117#define DD_ERR_NOMORESTRINGS -6 /* Ran out of string space */
118
119#define DD_DEFAULT_NORMAL_COLOR colorbyte (black, white)
120#define DD_DEFAULT_SELECT_COLOR colorbyte (white, black)
121#define DD_DEFAULT_HILITE_COLOR colorbyte (hi_white, white)
122#define DD_DEFAULT_GREYED_COLOR colorbyte (hi_black, white)
123
124
125/* Quick dialog definition macros */
126
127#define dialog_declare(dd) DialogPtr dd = NULL; ItemPtr ok_item = nullptr, cancel_item = nullptr, result_item = nullptr
128#define dialog_declare_ok(dd) DialogPtr dd = NULL; ItemPtr ok_item = nullptr, result_item = nullptr
129#define dialog_buttons(dd) ok_item = dialog_ok_button(dd);cancel_item = dialog_cancel_button(dd)
130#define dialog_exec(dd, ii) result_item = dialog_execute(dd, ii, ok_item, NULL);
131
132
134 short id; /* Item ID code */
135 short type; /* Item type */
136 short x, y; /* Item base location */
137 short x2; /* Item secondary x value */
138 short width; /* Item total width */
139 short buf_id; /* Item buffer identifier */
140 short buf_width; /* Item input area width */
141 short status; /* Item status */
142 short keystroke; /* Item keystroke activator */
143 short _class; /* Item checkbox class */
144 char *prompt; /* Item prompt/string */
145};
146
147typedef DialogItem Item;
148typedef Item *ItemPtr;
149
151 char *list;
152 Window window;
153 short base_x, base_y;
154 short rows, columns;
155 short thumb;
156 short base_entry;
157 short picked_entry;
158 short entry_width;
159 short elements, element_offset;
160 short max_elements;
161};
162
163typedef DialogList List;
164typedef List *ListPtr;
165
166struct DialogBox {
167 Window window; /* window boundaries */
168 short base_x, base_y; /* upper left text coords */
169 short width; /* width */
170
171 short normal_color; /* dialog display colors */
172 short select_color;
173 short hilite_color;
174
175 short num_items; /* number of dialog items */
176 short status; /* general status flags */
177 short fill_marker; /* vertical fill marker */
178 short active_button; /* currently active button */
179 short active_item; /* currently active item */
180
181 short cursor_x, cursor_y; /* current cursor coordinates */
182
183 void (*callback)(); /* callback routine for list */
184 /* selection. */
185
186 void (*checkbox_callback)(); /* callback routine for check */
187 /* box modification. */
188
189 Item item[DIALOG_MAX_ITEM]; /* items in this dialog */
190 ItemPtr default_item; /* Item for default button */
191 ItemPtr cancel_item; /* Item for "Cancel" button */
192 ItemPtr path_item; /* Item holding filename path */
193
194 short button_left, button_right; /* button horiz fill markers */
195 short button_flag; /* button row occupied flag */
196 short buffers_allocated; /* # buffers now in use */
197
198 char *buffer[DIALOG_MAX_BUFFER]; /* string i/o buffers */
199 int buf_cursor[DIALOG_MAX_BUFFER]; /* string i/o cursors */
200 int buf_selbase[DIALOG_MAX_BUFFER]; /* string i/o select base */
201 int buf_seltarget[DIALOG_MAX_BUFFER]; /* string i/o select target */
202 int buf_base_x[DIALOG_MAX_BUFFER]; /* string i/o base locations */
203 int buf_status[DIALOG_MAX_BUFFER]; /* string i/o status */
204 int buf_select[DIALOG_MAX_BUFFER]; /* string i/o selection status */
205
206 short lists_allocated; /* # windows now in use */
207
208 List lists[DIALOG_MAX_LIST]; /* list windows */
209
210 char *string_space; /* String space for prompts */
211 char *string_marker; /* Marker for next string */
212 long string_space_remaining; /* Amount of string space left */
213};
214
215typedef DialogBox Dialog;
216typedef Dialog *DialogPtr;
217
218#define StringMode(x) (((x).type == DD_I_STRING) || ((x).type == DD_I_FILENAME) || ((x).type == DD_I_LISTBASED))
219#define DialogString(x) StringMode(x->item[x->active_item])
220
221extern int dialog_error;
222extern bool dialog_quicksearch_flag;
223extern bool dialog_wildcard_exits;
224extern long dialog_timeout;
225extern int dialog_language;
226
230extern ItemPtr dialog_add_button(DialogPtr dialog, int x, int y, const char *prompt);
231
235extern ItemPtr dialog_add_checkbox(DialogPtr dialog, int x, int y,
236 const char *prompt, int default_val, int class_);
237
241extern void dialog_grey_checkbox(ItemPtr item);
242
246extern ItemPtr dialog_add_message(DialogPtr dialog, int x, int y, const char *prompt);
247
251extern void dialog_add_blank(DialogPtr dialog);
252
256extern ItemPtr dialog_add_string(DialogPtr dialog, int x, int y,
257 const char *prompt, const char *default_val, int width);
258
262extern ItemPtr dialog_add_listbased(DialogPtr dialog, int x, int y, const char *prompt,
263 const char *default_val, int width, const char *title, char *mylist,
264 int elements, int element_offset, int entry_width, int rows, int columns);
265
269extern ItemPtr dialog_append_list(DialogPtr dialog, int x, int y,
270 ItemPtr base_string, const char *title, const char *mylist, int elements,
271 int element_offset, int entry_width, int rows, int columns);
272
273extern void dialog_set_colors(int normal, int select, int hilite, int greyed);
274extern void dialog_set_workspace_size(long workspace);
275extern void dialog_set_string_space(DialogPtr dialog, const char *space, long size);
276
280extern DialogPtr dialog_create(DialogPtr dialog, int ul_x, int ul_y,
281 int width, int normal_color, int select_color, int hilite_color);
282
286extern void dialog_destroy(DialogPtr dialog);
287
291extern void dialog_destroy_persist(DialogPtr dialog);
292
299extern int dialog_read_dir_to_list(ListPtr target, const char *wild, int dirflag);
300
308extern void dialog_set_list_callback(DialogPtr dialog, void (*(callback))());
309
333typedef int (*MouseCallback)(int mouse_button, int mouse_status, int mouse_x, int mouse_y, int mouse_video_mode);
334extern void dialog_set_mouse_callback(MouseCallback callback, int double_only);
335
336typedef void (*PageCallback)(int mykey, ItemPtr item, DialogPtr dialog);
337extern void dialog_set_page_callback(PageCallback fn);
338
350extern void dialog_set_checkbox_callback(DialogPtr dialog, void (*(callback))());
351
355extern int dialog_read_checkbox(DialogPtr dialog, ItemPtr item);
356
360extern char *dialog_read_list(DialogPtr dialog, ItemPtr item);
361
365extern char *dialog_read_filename(DialogPtr dialog, ItemPtr item);
366
370extern void dialog_show_all(DialogPtr dialog);
371
376extern ItemPtr dialog_execute(DialogPtr dialog, ItemPtr active_item,
377 ItemPtr default_button, KeyPtr key_buffer);
378
379extern DialogPtr dialog_create_default();
380
385extern int dialog_alert(int x, int y, int buttons, const char *string1,
386 const char *string2, const char *string3, const char *string4);
387
388extern void dialog_set_alert_colors(int normal, int select, int hilite);
389extern int dialog_alert_center(int buttons, const char *string1,
390 const char *string2, const char *string3, const char *string4);
391extern int dialog_alert_ok(const char *string1, const char *string2,
392 const char *string3, const char *string4);
393extern void dialog_say(const char *message, int x);
394extern Window dialog_sayit(int saymode);
395
396extern ItemPtr dialog_left_message(DialogPtr dialog, const char *prompt);
397extern ItemPtr dialog_center_message(DialogPtr dialog, const char *prompt);
398extern ItemPtr dialog_left_string(DialogPtr dialog, const char *prompt, const char *string, int width);
399extern ItemPtr dialog_left_button(DialogPtr dialog, const char *prompt);
400extern ItemPtr dialog_ok_button(DialogPtr dialog);
401extern ItemPtr dialog_cancel_button(DialogPtr dialog);
402extern char *dialog_get_string(DialogPtr dialog, ItemPtr item, char *target);
403
404extern ItemPtr dialog_add_number(DialogPtr dialog, int x, int y,
405 const char *prompt, int num, int width);
406extern ItemPtr dialog_left_number(DialogPtr dialog, char *prompt,
407 int num, int width);
408extern int dialog_get_number(DialogPtr dialog, ItemPtr item);
409
410extern void dialog_trap_critical();
411extern void dialog_restore_critical();
412
413extern void dialog_watch_point(const char *string, long x, long y);
414
415extern void init_dialog();
416
417} // namespace MADS
418
419#endif
Definition: dialog.h:166
Definition: dialog.h:133
Definition: dialog.h:150
Definition: keys.h:191
Definition: window.h:75