1#ifndef SDL3PP_MESSAGEBOX_H_
2#define SDL3PP_MESSAGEBOX_H_
4#include <SDL3/SDL_messagebox.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_video.h"
48 SDL_MESSAGEBOX_WARNING;
51 SDL_MESSAGEBOX_INFORMATION;
54 SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT;
57 SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT;
74 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
78 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
109 SDL_MESSAGEBOX_COLOR_BACKGROUND;
112 SDL_MESSAGEBOX_COLOR_TEXT;
115 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER;
118 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND;
121 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED;
124 SDL_MESSAGEBOX_COLOR_COUNT;
147 constexpr MessageBox(
const SDL_MessageBoxData& messageBox = {})
148 : SDL_MessageBoxData{messageBox}
166 std::span<const MessageBoxButtonData> buttons,
168 : SDL_MessageBoxData{flags,
211 CheckError(SDL_ShowMessageBox(
this, buttonid));
219 constexpr SDL_MessageBoxFlags
GetFlags()
const {
return flags; }
248 window = newWindow.
get();
257 constexpr const char*
GetTitle()
const {
return title; }
286 message = newMessage;
295 constexpr std::span<const MessageBoxButtonData>
GetButtons()
const
297 if (numbuttons == 0)
return {};
298 return std::span(buttons,
size_t(numbuttons));
308 std::span<const MessageBoxButtonData> newButtons)
310 if (newButtons.empty()) {
314 numbuttons = newButtons.size();
315 buttons = newButtons.data();
339 colorScheme = newColorScheme;
388 CheckError(SDL_ShowSimpleMessageBox(flags, title, message, window.get()));
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
A optional reference to resource.
Definition SDL3pp_resource.h:88
constexpr T get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
void ShowSimpleMessageBox(MessageBoxFlags flags, StringParam title, StringParam message, OptionalWindow window)
Display a simple modal message box.
Definition SDL3pp_messagebox.h:383
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
buttons placed right to left
Definition SDL3pp_messagebox.h:56
SDL_MessageBoxButtonData MessageBoxButtonData
Individual button data.
Definition SDL3pp_messagebox.h:88
constexpr MessageBoxFlags MESSAGEBOX_INFORMATION
informational dialog
Definition SDL3pp_messagebox.h:50
Uint32 MessageBoxFlags
Message box flags.
Definition SDL3pp_messagebox.h:42
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
Marks the default button when escape is hit.
Definition SDL3pp_messagebox.h:77
constexpr MessageBoxColorType MESSAGEBOX_COLOR_COUNT
Count.
Definition SDL3pp_messagebox.h:123
SDL_MessageBoxColorType MessageBoxColorType
An enumeration of indices inside the colors array of MessageBoxColorScheme.
Definition SDL3pp_messagebox.h:106
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BORDER
BUTTON_BORDER.
Definition SDL3pp_messagebox.h:114
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BACKGROUND
BUTTON_BACKGROUND.
Definition SDL3pp_messagebox.h:117
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
Marks the default button when return is hit.
Definition SDL3pp_messagebox.h:73
constexpr MessageBoxFlags MESSAGEBOX_ERROR
error dialog
Definition SDL3pp_messagebox.h:44
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
buttons placed left to right
Definition SDL3pp_messagebox.h:53
SDL_MessageBoxColorScheme MessageBoxColorScheme
A set of colors to use for message box dialogs.
Definition SDL3pp_messagebox.h:133
constexpr MessageBoxColorType MESSAGEBOX_COLOR_TEXT
TEXT.
Definition SDL3pp_messagebox.h:111
constexpr MessageBoxFlags MESSAGEBOX_WARNING
warning dialog
Definition SDL3pp_messagebox.h:47
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_SELECTED
BUTTON_SELECTED.
Definition SDL3pp_messagebox.h:120
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BACKGROUND
BACKGROUND.
Definition SDL3pp_messagebox.h:108
SDL_MessageBoxColor MessageBoxColor
RGB value used in a message box color scheme.
Definition SDL3pp_messagebox.h:95
Uint32 MessageBoxButtonFlags
MessageBoxButtonData flags.
Definition SDL3pp_messagebox.h:71
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
MessageBox structure containing title, text, window, etc.
Definition SDL3pp_messagebox.h:141
constexpr MessageBox & SetColorScheme(OptionalRef< const MessageBoxColorScheme > newColorScheme)
Set the colorScheme.
Definition SDL3pp_messagebox.h:336
constexpr MessageBox & SetTitle(const char *newTitle)
Set the title.
Definition SDL3pp_messagebox.h:265
constexpr MessageBox & SetMessage(const char *newMessage)
Set the message.
Definition SDL3pp_messagebox.h:284
constexpr const char * GetMessage() const
Get the message.
Definition SDL3pp_messagebox.h:276
void Show(int *buttonid) const
Create a modal message box.
Definition SDL3pp_messagebox.h:209
constexpr const char * GetTitle() const
Get the title.
Definition SDL3pp_messagebox.h:257
constexpr WindowRef GetWindow() const
Get the window.
Definition SDL3pp_messagebox.h:238
constexpr std::span< const MessageBoxButtonData > GetButtons() const
Get the buttons.
Definition SDL3pp_messagebox.h:295
constexpr SDL_MessageBoxFlags GetFlags() const
Get the flags.
Definition SDL3pp_messagebox.h:219
constexpr MessageBox(const SDL_MessageBoxData &messageBox={})
Wraps MessageBox.
Definition SDL3pp_messagebox.h:147
constexpr MessageBox(MessageBoxFlags flags, OptionalWindow window, const char *title, const char *message, std::span< const MessageBoxButtonData > buttons, OptionalRef< const MessageBoxColorScheme > colorScheme)
Constructs from its fields.
Definition SDL3pp_messagebox.h:162
constexpr MessageBox & SetWindow(WindowRef newWindow)
Set the window.
Definition SDL3pp_messagebox.h:246
constexpr const MessageBoxColorScheme * GetColorScheme() const
Get the colorScheme.
Definition SDL3pp_messagebox.h:325
constexpr MessageBox & SetFlags(SDL_MessageBoxFlags newFlags)
Set the flags.
Definition SDL3pp_messagebox.h:227
constexpr MessageBox & SetButtons(std::span< const MessageBoxButtonData > newButtons)
Set the buttons.
Definition SDL3pp_messagebox.h:307
Handle to a non owned window.
Definition SDL3pp_video.h:2778