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