1 
2 //          Copyright 2018 - 2021 Michael D. Parker
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 // SDL_MessageBoxFlags
13 enum SDL_MESSAGEBOX_ERROR = 0x00000010;
14 enum SDL_MESSAGEBOX_WARNING = 0x00000020;
15 enum SDL_MESSAGEBOX_INFORMATION = 0x00000040;
16 static if(sdlSupport >= SDLSupport.sdl2012) {
17     enum SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080;
18     enum SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100;
19 }
20 alias SDL_MessageBoxFlags = int;
21 
22 enum SDL_MessageBoxButtonFlags {
23     SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,
24     SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002,
25 }
26 mixin(expandEnum!SDL_MessageBoxButtonFlags);
27 
28 struct SDL_MessageBoxButtonData {
29     uint flags;
30     int buttonid;
31     const(char)* text;
32 }
33 
34 struct SDL_MessageBoxColor {
35     ubyte r, g, b;
36 }
37 
38 enum SDL_MessageBoxColorType {
39     SDL_MESSAGEBOX_COLOR_BACKGROUND,
40     SDL_MESSAGEBOX_COLOR_TEXT,
41     SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
42     SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
43     SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
44     SDL_MESSAGEBOX_COLOR_MAX,
45 }
46 mixin(expandEnum!SDL_MessageBoxColorType);
47 
48 struct SDL_MessageBoxColorScheme {
49     SDL_MessageBoxColor[SDL_MESSAGEBOX_COLOR_MAX] colors;
50 }
51 
52 struct SDL_MessageBoxData {
53     uint flags;
54     SDL_Window* window;
55     const(char)* title;
56     const(char)* message;
57     int numbuttons;
58     const(SDL_MessageBoxButtonData)* buttons;
59     const(SDL_MessageBoxColorScheme)* colorScheme;
60 }
61 
62 static if(staticBinding) {
63     extern(C) @nogc nothrow {
64         int SDL_ShowMessageBox(const(SDL_MessageBoxData)* messageboxdata, int* buttonid);
65         int SDL_ShowSimpleMessageBox(uint flags, const(char)* title, const(char)* messsage, SDL_Window* window);
66     }
67 }
68 else {
69     extern(C) @nogc nothrow {
70         alias pSDL_ShowMessageBox = int function(const(SDL_MessageBoxData)* messageboxdata, int* buttonid);
71         alias pSDL_ShowSimpleMessageBox = int function(uint flags, const(char)* title, const(char)* messsage, SDL_Window* window);
72     }
73 
74     __gshared {
75         pSDL_ShowMessageBox SDL_ShowMessageBox;
76         pSDL_ShowSimpleMessageBox SDL_ShowSimpleMessageBox;
77     }
78 }