22#ifndef MADS_CORE_DIALOG_H
23#define MADS_CORE_DIALOG_H
25#include "mads/core/general.h"
26#include "mads/core/window.h"
27#include "mads/core/keys.h"
31#define DIALOG_ENGLISH 0
32#define DIALOG_GERMAN 1
34#define DIALOG_MAX_ITEM 50
35#define DIALOG_MAX_BUFFER 16
36#define DIALOG_MAX_LIST 4
37#define DIALOG_MAX_PROMPT_CHARS 72
38#define DIALOG_MAX_LIST_CHARS 13
40#define DIALOG_DEFAULT_STRING_SPACE 1024
42#define DIALOG_FILE_WIDTH 61
43#define DIALOG_FILE_BUFFER 46
45#define DD_DYNAMIC 0x80
47#define DD_EXITFLAG 0x40
48#define DD_COMPUTED 0x20
49#define DD_SCREENSAVED 0x10
50#define DD_FILEMENU 0x08
51#define DD_DYNAMICSTRINGS 0x04
59#define DD_LINEACROSS 0
67#define DD_I_FILENAME 2
68#define DD_I_LISTBASED 3
69#define DD_I_CHECKBOX 4
73#define DD_I_FILELIST 7
74#define DD_I_DIRSLIST 8
77#define DD_IX_CENTER -1
81#define DD_IY_BUTTON -1
82#define DD_IY_AUTOFILL -2
88#define DD_MC_SCROLL -2
89#define DD_MC_SCROLL_UP -3
90#define DD_MC_SCROLL_DOWN -4
91#define DD_MC_SCROLL_LEFT -5
92#define DD_MC_SCROLL_RIGHT -6
93#define DD_MC_SCROLL_PAGE_UP -7
94#define DD_MC_SCROLL_PAGE_DOWN -8
95#define DD_MC_SCROLL_PAGE_LEFT -9
96#define DD_MC_SCROLL_PAGE_RIGHT -10
98#define CANCEL_BUTTON "Cancel"
99#define CANCEL_GERMAN "Abbrechen"
101#define DD_CANCEL_BUTTON 0x01
102#define DD_OK_BUTTON 0x02
103#define DD_YES_BUTTON 0x04
104#define DD_NO_BUTTON 0x08
105#define DD_BEGONE_BUTTON 0x10
107#define DD_CHECK_GREY 0x80
108#define DD_CHECK_RADIO 0x40
110#define DD_CHECK_TRUE 0x01
112#define DD_ERR_NOMOREITEMS -1
113#define DD_ERR_NOMOREBUFFERS -2
114#define DD_ERR_NOMORELISTS -3
115#define DD_ERR_NOMOREMEMORY -4
116#define DD_ERR_ABORTEDBYCALLBACK -5
117#define DD_ERR_NOMORESTRINGS -6
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)
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);
153 short base_x, base_y;
159 short elements, element_offset;
168 short base_x, base_y;
181 short cursor_x, cursor_y;
186 void (*checkbox_callback)();
189 Item item[DIALOG_MAX_ITEM];
194 short button_left, button_right;
196 short buffers_allocated;
198 char *buffer[DIALOG_MAX_BUFFER];
199 int buf_cursor[DIALOG_MAX_BUFFER];
200 int buf_selbase[DIALOG_MAX_BUFFER];
201 int buf_seltarget[DIALOG_MAX_BUFFER];
202 int buf_base_x[DIALOG_MAX_BUFFER];
203 int buf_status[DIALOG_MAX_BUFFER];
204 int buf_select[DIALOG_MAX_BUFFER];
206 short lists_allocated;
208 List lists[DIALOG_MAX_LIST];
212 long string_space_remaining;
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])
221extern int dialog_error;
222extern bool dialog_quicksearch_flag;
223extern bool dialog_wildcard_exits;
224extern long dialog_timeout;
225extern int dialog_language;
230extern ItemPtr dialog_add_button(
DialogPtr dialog,
int x,
int y,
const char *prompt);
236 const char *prompt,
int default_val,
int class_);
241extern void dialog_grey_checkbox(
ItemPtr item);
246extern ItemPtr dialog_add_message(
DialogPtr dialog,
int x,
int y,
const char *prompt);
251extern void dialog_add_blank(
DialogPtr dialog);
257 const char *prompt,
const char *default_val,
int width);
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);
270 ItemPtr base_string,
const char *title,
const char *mylist,
int elements,
271 int element_offset,
int entry_width,
int rows,
int columns);
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);
281 int width,
int normal_color,
int select_color,
int hilite_color);
286extern void dialog_destroy(
DialogPtr dialog);
291extern void dialog_destroy_persist(
DialogPtr dialog);
299extern int dialog_read_dir_to_list(
ListPtr target,
const char *wild,
int dirflag);
308extern void dialog_set_list_callback(
DialogPtr dialog,
void (*(callback))());
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);
337extern void dialog_set_page_callback(PageCallback fn);
350extern void dialog_set_checkbox_callback(
DialogPtr dialog,
void (*(callback))());
370extern void dialog_show_all(
DialogPtr dialog);
385extern int dialog_alert(
int x,
int y,
int buttons,
const char *string1,
386 const char *string2,
const char *string3,
const char *string4);
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);
398extern ItemPtr dialog_left_string(
DialogPtr dialog,
const char *prompt,
const char *
string,
int width);
402extern char *dialog_get_string(
DialogPtr dialog,
ItemPtr item,
char *target);
405 const char *prompt,
int num,
int width);
410extern void dialog_trap_critical();
411extern void dialog_restore_critical();
413extern void dialog_watch_point(
const char *
string,
long x,
long y);
415extern void init_dialog();