1 2 // Copyright Michael D. Parker 2018. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.sdl.bind.sdlmessagebox; 8 9 import bindbc.sdl.config; 10 import bindbc.sdl.bind.sdlvideo : SDL_Window; 11 12 static if(sdlSupport >= SDLSupport.sdl2012) { 13 enum SDL_MessageBoxFlags { 14 SDL_MESSAGEBOX_ERROR = 0x00000010, 15 SDL_MESSAGEBOX_WARNING = 0x00000020, 16 SDL_MESSAGEBOX_INFORMATION = 0x00000040, 17 SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, 18 SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100, 19 } 20 } 21 else { 22 enum SDL_MessageBoxFlags { 23 SDL_MESSAGEBOX_ERROR = 0x00000010, 24 SDL_MESSAGEBOX_WARNING = 0x00000020, 25 SDL_MESSAGEBOX_INFORMATION = 0x00000040, 26 } 27 } 28 mixin(expandEnum!SDL_MessageBoxFlags); 29 30 enum SDL_MessageBoxButtonFlags { 31 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, 32 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002, 33 } 34 mixin(expandEnum!SDL_MessageBoxButtonFlags); 35 36 struct SDL_MessageBoxButtonData { 37 uint flags; 38 int buttonid; 39 const(char)* text; 40 } 41 42 struct SDL_MessageBoxColor { 43 ubyte r, g, b; 44 } 45 46 enum SDL_MessageBoxColorType { 47 SDL_MESSAGEBOX_COLOR_BACKGROUND, 48 SDL_MESSAGEBOX_COLOR_TEXT, 49 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, 50 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, 51 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, 52 SDL_MESSAGEBOX_COLOR_MAX, 53 } 54 mixin(expandEnum!SDL_MessageBoxColorType); 55 56 struct SDL_MessageBoxColorScheme { 57 SDL_MessageBoxColor[SDL_MESSAGEBOX_COLOR_MAX] colors; 58 } 59 60 struct SDL_MessageBoxData { 61 uint flags; 62 SDL_Window* window; 63 const(char)* title; 64 const(char)* message; 65 int numbuttons; 66 const(SDL_MessageBoxButtonData)* buttons; 67 const(SDL_MessageBoxColorScheme)* colorScheme; 68 } 69 70 static if(staticBinding) { 71 extern(C) @nogc nothrow { 72 int SDL_ShowMessageBox(const(SDL_MessageBoxData)*,int*); 73 int SDL_ShowSimpleMessageBox(uint,const(char)*,const(char)*,SDL_Window*); 74 } 75 } 76 else { 77 extern(C) @nogc nothrow { 78 alias pSDL_ShowMessageBox = int function(const(SDL_MessageBoxData)*,int*); 79 alias pSDL_ShowSimpleMessageBox = int function(uint,const(char)*,const(char)*,SDL_Window*); 80 } 81 82 __gshared { 83 pSDL_ShowMessageBox SDL_ShowMessageBox; 84 pSDL_ShowSimpleMessageBox SDL_ShowSimpleMessageBox; 85 } 86 }