SDL Library
SDL_messagebox.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | #ifndef _SDL_messagebox_h |
miruga27 | 0:7fb6877b5d7c | 23 | #define _SDL_messagebox_h |
miruga27 | 0:7fb6877b5d7c | 24 | |
miruga27 | 0:7fb6877b5d7c | 25 | #include "SDL_stdinc.h" |
miruga27 | 0:7fb6877b5d7c | 26 | #include "SDL_video.h" /* For SDL_Window */ |
miruga27 | 0:7fb6877b5d7c | 27 | |
miruga27 | 0:7fb6877b5d7c | 28 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 29 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 30 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 31 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 32 | #endif |
miruga27 | 0:7fb6877b5d7c | 33 | |
miruga27 | 0:7fb6877b5d7c | 34 | /** |
miruga27 | 0:7fb6877b5d7c | 35 | * \brief SDL_MessageBox flags. If supported will display warning icon, etc. |
miruga27 | 0:7fb6877b5d7c | 36 | */ |
miruga27 | 0:7fb6877b5d7c | 37 | typedef enum |
miruga27 | 0:7fb6877b5d7c | 38 | { |
miruga27 | 0:7fb6877b5d7c | 39 | SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ |
miruga27 | 0:7fb6877b5d7c | 40 | SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ |
miruga27 | 0:7fb6877b5d7c | 41 | SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ |
miruga27 | 0:7fb6877b5d7c | 42 | } SDL_MessageBoxFlags; |
miruga27 | 0:7fb6877b5d7c | 43 | |
miruga27 | 0:7fb6877b5d7c | 44 | /** |
miruga27 | 0:7fb6877b5d7c | 45 | * \brief Flags for SDL_MessageBoxButtonData. |
miruga27 | 0:7fb6877b5d7c | 46 | */ |
miruga27 | 0:7fb6877b5d7c | 47 | typedef enum |
miruga27 | 0:7fb6877b5d7c | 48 | { |
miruga27 | 0:7fb6877b5d7c | 49 | SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ |
miruga27 | 0:7fb6877b5d7c | 50 | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ |
miruga27 | 0:7fb6877b5d7c | 51 | } SDL_MessageBoxButtonFlags; |
miruga27 | 0:7fb6877b5d7c | 52 | |
miruga27 | 0:7fb6877b5d7c | 53 | /** |
miruga27 | 0:7fb6877b5d7c | 54 | * \brief Individual button data. |
miruga27 | 0:7fb6877b5d7c | 55 | */ |
miruga27 | 0:7fb6877b5d7c | 56 | typedef struct |
miruga27 | 0:7fb6877b5d7c | 57 | { |
miruga27 | 0:7fb6877b5d7c | 58 | Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ |
miruga27 | 0:7fb6877b5d7c | 59 | int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ |
miruga27 | 0:7fb6877b5d7c | 60 | const char * text; /**< The UTF-8 button text */ |
miruga27 | 0:7fb6877b5d7c | 61 | } SDL_MessageBoxButtonData; |
miruga27 | 0:7fb6877b5d7c | 62 | |
miruga27 | 0:7fb6877b5d7c | 63 | /** |
miruga27 | 0:7fb6877b5d7c | 64 | * \brief RGB value used in a message box color scheme |
miruga27 | 0:7fb6877b5d7c | 65 | */ |
miruga27 | 0:7fb6877b5d7c | 66 | typedef struct |
miruga27 | 0:7fb6877b5d7c | 67 | { |
miruga27 | 0:7fb6877b5d7c | 68 | Uint8 r, g, b; |
miruga27 | 0:7fb6877b5d7c | 69 | } SDL_MessageBoxColor; |
miruga27 | 0:7fb6877b5d7c | 70 | |
miruga27 | 0:7fb6877b5d7c | 71 | typedef enum |
miruga27 | 0:7fb6877b5d7c | 72 | { |
miruga27 | 0:7fb6877b5d7c | 73 | SDL_MESSAGEBOX_COLOR_BACKGROUND, |
miruga27 | 0:7fb6877b5d7c | 74 | SDL_MESSAGEBOX_COLOR_TEXT, |
miruga27 | 0:7fb6877b5d7c | 75 | SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, |
miruga27 | 0:7fb6877b5d7c | 76 | SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, |
miruga27 | 0:7fb6877b5d7c | 77 | SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, |
miruga27 | 0:7fb6877b5d7c | 78 | SDL_MESSAGEBOX_COLOR_MAX |
miruga27 | 0:7fb6877b5d7c | 79 | } SDL_MessageBoxColorType; |
miruga27 | 0:7fb6877b5d7c | 80 | |
miruga27 | 0:7fb6877b5d7c | 81 | /** |
miruga27 | 0:7fb6877b5d7c | 82 | * \brief A set of colors to use for message box dialogs |
miruga27 | 0:7fb6877b5d7c | 83 | */ |
miruga27 | 0:7fb6877b5d7c | 84 | typedef struct |
miruga27 | 0:7fb6877b5d7c | 85 | { |
miruga27 | 0:7fb6877b5d7c | 86 | SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; |
miruga27 | 0:7fb6877b5d7c | 87 | } SDL_MessageBoxColorScheme; |
miruga27 | 0:7fb6877b5d7c | 88 | |
miruga27 | 0:7fb6877b5d7c | 89 | /** |
miruga27 | 0:7fb6877b5d7c | 90 | * \brief MessageBox structure containing title, text, window, etc. |
miruga27 | 0:7fb6877b5d7c | 91 | */ |
miruga27 | 0:7fb6877b5d7c | 92 | typedef struct |
miruga27 | 0:7fb6877b5d7c | 93 | { |
miruga27 | 0:7fb6877b5d7c | 94 | Uint32 flags; /**< ::SDL_MessageBoxFlags */ |
miruga27 | 0:7fb6877b5d7c | 95 | SDL_Window *window; /**< Parent window, can be NULL */ |
miruga27 | 0:7fb6877b5d7c | 96 | const char *title; /**< UTF-8 title */ |
miruga27 | 0:7fb6877b5d7c | 97 | const char *message; /**< UTF-8 message text */ |
miruga27 | 0:7fb6877b5d7c | 98 | |
miruga27 | 0:7fb6877b5d7c | 99 | int numbuttons; |
miruga27 | 0:7fb6877b5d7c | 100 | const SDL_MessageBoxButtonData *buttons; |
miruga27 | 0:7fb6877b5d7c | 101 | |
miruga27 | 0:7fb6877b5d7c | 102 | const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ |
miruga27 | 0:7fb6877b5d7c | 103 | } SDL_MessageBoxData; |
miruga27 | 0:7fb6877b5d7c | 104 | |
miruga27 | 0:7fb6877b5d7c | 105 | /** |
miruga27 | 0:7fb6877b5d7c | 106 | * \brief Create a modal message box. |
miruga27 | 0:7fb6877b5d7c | 107 | * |
miruga27 | 0:7fb6877b5d7c | 108 | * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. |
miruga27 | 0:7fb6877b5d7c | 109 | * \param buttonid The pointer to which user id of hit button should be copied. |
miruga27 | 0:7fb6877b5d7c | 110 | * |
miruga27 | 0:7fb6877b5d7c | 111 | * \return -1 on error, otherwise 0 and buttonid contains user id of button |
miruga27 | 0:7fb6877b5d7c | 112 | * hit or -1 if dialog was closed. |
miruga27 | 0:7fb6877b5d7c | 113 | * |
miruga27 | 0:7fb6877b5d7c | 114 | * \note This function should be called on the thread that created the parent |
miruga27 | 0:7fb6877b5d7c | 115 | * window, or on the main thread if the messagebox has no parent. It will |
miruga27 | 0:7fb6877b5d7c | 116 | * block execution of that thread until the user clicks a button or |
miruga27 | 0:7fb6877b5d7c | 117 | * closes the messagebox. |
miruga27 | 0:7fb6877b5d7c | 118 | */ |
miruga27 | 0:7fb6877b5d7c | 119 | extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); |
miruga27 | 0:7fb6877b5d7c | 120 | |
miruga27 | 0:7fb6877b5d7c | 121 | /** |
miruga27 | 0:7fb6877b5d7c | 122 | * \brief Create a simple modal message box |
miruga27 | 0:7fb6877b5d7c | 123 | * |
miruga27 | 0:7fb6877b5d7c | 124 | * \param flags ::SDL_MessageBoxFlags |
miruga27 | 0:7fb6877b5d7c | 125 | * \param title UTF-8 title text |
miruga27 | 0:7fb6877b5d7c | 126 | * \param message UTF-8 message text |
miruga27 | 0:7fb6877b5d7c | 127 | * \param window The parent window, or NULL for no parent |
miruga27 | 0:7fb6877b5d7c | 128 | * |
miruga27 | 0:7fb6877b5d7c | 129 | * \return 0 on success, -1 on error |
miruga27 | 0:7fb6877b5d7c | 130 | * |
miruga27 | 0:7fb6877b5d7c | 131 | * \sa SDL_ShowMessageBox |
miruga27 | 0:7fb6877b5d7c | 132 | */ |
miruga27 | 0:7fb6877b5d7c | 133 | extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); |
miruga27 | 0:7fb6877b5d7c | 134 | |
miruga27 | 0:7fb6877b5d7c | 135 | |
miruga27 | 0:7fb6877b5d7c | 136 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 137 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 138 | } |
miruga27 | 0:7fb6877b5d7c | 139 | #endif |
miruga27 | 0:7fb6877b5d7c | 140 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 141 | |
miruga27 | 0:7fb6877b5d7c | 142 | #endif /* _SDL_messagebox_h */ |
miruga27 | 0:7fb6877b5d7c | 143 | |
miruga27 | 0:7fb6877b5d7c | 144 | /* vi: set ts=4 sw=4 expandtab: */ |