1 module allegro5.allegro_native_dialog; 2 3 version(ALLEGRO_NO_PRAGMA_LIB) {} 4 else 5 { 6 pragma(lib, "allegro_dialog"); 7 } 8 9 version (ALLEGRO_UNSTABLE) 10 version = AllegroNativeDialogUnstable; 11 version(ALLEGRO_INTERNAL_UNSTABLE) 12 version = AllegroNativeDialogUnstable; 13 version(ALLEGRO_NATIVE_DIALOG_SRC) 14 version = AllegroNativeDialogUnstable; 15 16 import allegro5.allegro; 17 import allegro5.internal.da5; 18 19 extern (C) 20 { 21 alias ALLEGRO_GTK_TOPLEVEL_INTERNAL ALLEGRO_GTK_TOPLEVEL; 22 23 struct ALLEGRO_FILECHOOSER {}; 24 struct ALLEGRO_TEXTLOG {}; 25 struct ALLEGRO_MENU {}; 26 27 struct ALLEGRO_MENU_INFO 28 { 29 const_char* caption; 30 ushort id; 31 int flags; 32 ALLEGRO_BITMAP* icon; 33 } 34 35 template ALLEGRO_MENU_SEPARATOR() 36 { 37 const ALLEGRO_MENU_SEPARATOR = ALLEGRO_MENU_INFO(null, -1, 0, null); 38 } 39 40 template ALLEGRO_START_OF_MENU(const_char[] caption, int id) 41 { 42 const ALLEGRO_START_OF_MENU = ALLEGRO_MENU_INFO(mixin(`"` ~ caption ~ `->\0"`), id, 0, NULL); 43 } 44 45 template ALLEGRO_END_OF_MENU() 46 { 47 const ALLEGRO_END_OF_MENU = ALLEGRO_MENU_INFO(null, 0, 0, null); 48 } 49 50 bool al_init_native_dialog_addon(); 51 void al_shutdown_native_dialog_addon(); 52 ALLEGRO_FILECHOOSER* al_create_native_file_dialog(in ALLEGRO_PATH* initial_path, in char* title, in char* patterns, int mode); 53 void al_show_native_file_dialog(ALLEGRO_DISPLAY* display, ALLEGRO_FILECHOOSER* dialog); 54 int al_get_native_file_dialog_count(in ALLEGRO_FILECHOOSER* dialog); 55 ALLEGRO_PATH* al_get_native_file_dialog_path(in ALLEGRO_FILECHOOSER* dialog, size_t index); 56 void al_destroy_native_file_dialog(ALLEGRO_FILECHOOSER* dialog); 57 58 int al_show_native_message_box(ALLEGRO_DISPLAY* display, in char* title, in char* heading, in char* text, in char* buttons, int flags); 59 60 ALLEGRO_TEXTLOG* al_open_native_text_log(in char* title, int flags); 61 void al_close_native_text_log(ALLEGRO_TEXTLOG* textlog); 62 void al_append_native_text_log(ALLEGRO_TEXTLOG* textlog, in char* format, ...); 63 ALLEGRO_EVENT_SOURCE* al_get_native_text_log_event_source(ALLEGRO_TEXTLOG* textlog); 64 65 /* creating/modifying menus */ 66 ALLEGRO_MENU* al_create_menu();; 67 ALLEGRO_MENU* al_create_popup_menu();; 68 ALLEGRO_MENU* al_build_menu(ALLEGRO_MENU_INFO* info); 69 int al_append_menu_item(ALLEGRO_MENU* parent, in char* title, ushort id, int flags, ALLEGRO_BITMAP* icon, ALLEGRO_MENU* submenu); 70 int al_insert_menu_item(ALLEGRO_MENU* parent, int pos, in char* title, ushort id, int flags, ALLEGRO_BITMAP* icon, ALLEGRO_MENU* submenu); 71 bool al_remove_menu_item(ALLEGRO_MENU* menu, int pos); 72 ALLEGRO_MENU* al_clone_menu(ALLEGRO_MENU* menu); 73 ALLEGRO_MENU* al_clone_menu_for_popup(ALLEGRO_MENU* menu); 74 void al_destroy_menu(ALLEGRO_MENU* menu); 75 76 /* properties */ 77 const_char* al_get_menu_item_caption(ALLEGRO_MENU* menu, int pos); 78 void al_set_menu_item_caption(ALLEGRO_MENU* menu, int pos, in char* caption); 79 int al_get_menu_item_flags(ALLEGRO_MENU* menu, int pos); 80 void al_set_menu_item_flags(ALLEGRO_MENU* menu, int pos, int flags); 81 version (AllegroNativeDialogUnstable) 82 { 83 int al_toggle_menu_item_flags(ALLEGRO_MENU* menu, int pos, int flags); 84 } 85 ALLEGRO_BITMAP* al_get_menu_item_icon(ALLEGRO_MENU* menu, int pos); 86 void al_set_menu_item_icon(ALLEGRO_MENU* menu, int pos, ALLEGRO_BITMAP* icon); 87 88 /* querying menus */ 89 ALLEGRO_MENU* al_find_menu(ALLEGRO_MENU* haystack, ushort id); 90 bool al_find_menu_item(ALLEGRO_MENU* haystack, ushort id, ALLEGRO_MENU** menu, int* index); 91 92 /* menu events */ 93 ALLEGRO_EVENT_SOURCE* al_get_default_menu_event_source();; 94 ALLEGRO_EVENT_SOURCE* al_enable_menu_event_source(ALLEGRO_MENU* menu); 95 void al_disable_menu_event_source(ALLEGRO_MENU* menu); 96 97 /* displaying menus */ 98 ALLEGRO_MENU* al_get_display_menu(ALLEGRO_DISPLAY* display); 99 bool al_set_display_menu(ALLEGRO_DISPLAY* display, ALLEGRO_MENU* menu); 100 bool al_popup_menu(ALLEGRO_MENU* popup, ALLEGRO_DISPLAY* display); 101 ALLEGRO_MENU* al_remove_display_menu(ALLEGRO_DISPLAY* display); 102 103 uint al_get_allegro_native_dialog_version(); 104 105 enum 106 { 107 ALLEGRO_FILECHOOSER_FILE_MUST_EXIST = 1, 108 ALLEGRO_FILECHOOSER_SAVE = 2, 109 ALLEGRO_FILECHOOSER_FOLDER = 4, 110 ALLEGRO_FILECHOOSER_PICTURES = 8, 111 ALLEGRO_FILECHOOSER_SHOW_HIDDEN = 16, 112 ALLEGRO_FILECHOOSER_MULTIPLE = 32 113 } 114 115 enum 116 { 117 ALLEGRO_MESSAGEBOX_WARN = 1<<0, 118 ALLEGRO_MESSAGEBOX_ERROR = 1<<1, 119 ALLEGRO_MESSAGEBOX_OK_CANCEL = 1<<2, 120 ALLEGRO_MESSAGEBOX_YES_NO = 1<<3, 121 ALLEGRO_MESSAGEBOX_QUESTION = 1<<4 122 } 123 124 enum 125 { 126 ALLEGRO_TEXTLOG_NO_CLOSE = 1<<0, 127 ALLEGRO_TEXTLOG_MONOSPACE = 1<<1 128 } 129 130 enum 131 { 132 ALLEGRO_EVENT_NATIVE_DIALOG_CLOSE = 600, 133 ALLEGRO_EVENT_MENU_CLICK = 601 134 } 135 136 enum 137 { 138 ALLEGRO_MENU_ITEM_ENABLED = 0, 139 ALLEGRO_MENU_ITEM_CHECKBOX = 1, 140 ALLEGRO_MENU_ITEM_CHECKED = 2, 141 ALLEGRO_MENU_ITEM_DISABLED = 4 142 } 143 }