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"
52 SDL_MESSAGEBOX_WARNING;
55 SDL_MESSAGEBOX_INFORMATION;
58 SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT;
61 SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT;
78 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
82 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
110 SDL_MESSAGEBOX_COLOR_BACKGROUND;
113 SDL_MESSAGEBOX_COLOR_TEXT;
116 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER;
119 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND;
122 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED;
125 SDL_MESSAGEBOX_COLOR_COUNT;
168 std::span<const MessageBoxButtonData> buttons,
185 constexpr SDL_MessageBoxFlags
GetFlags() const noexcept {
return flags; }
204 constexpr SDL_Window*
GetWindow() const noexcept {
return window; }
223 constexpr const char*
GetTitle() const noexcept {
return title; }
242 constexpr const char*
GetMessage() const noexcept {
return message; }
252 message = newMessage;
271 numbuttons = newNumbuttons;
280 constexpr std::span<const MessageBoxButtonData>
GetButtons() const noexcept
282 if (numbuttons == 0)
return {};
283 return std::span(buttons,
size_t(numbuttons));
293 std::span<const MessageBoxButtonData> newButtons)
noexcept
295 if (newButtons.empty()) {
299 numbuttons = newButtons.size();
300 buttons = newButtons.data();
324 colorScheme = newColorScheme;
359 void Show(
int* buttonid)
const;
395 CheckError(SDL_ShowMessageBox(&messageboxdata, buttonid));
447 CheckError(SDL_ShowSimpleMessageBox(flags, title, message, window));
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
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:197
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
buttons placed right to left
Definition: SDL3pp_messagebox.h:60
SDL_MessageBoxButtonData MessageBoxButtonData
Individual button data.
Definition: SDL3pp_messagebox.h:92
SDL_MessageBoxData MessageBoxRaw
Alias to raw representation for MessageBox.
Definition: SDL3pp_messagebox.h:29
constexpr MessageBoxFlags MESSAGEBOX_INFORMATION
informational dialog
Definition: SDL3pp_messagebox.h:54
Uint32 MessageBoxFlags
Message box flags.
Definition: SDL3pp_messagebox.h:46
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
Marks the default button when escape is hit.
Definition: SDL3pp_messagebox.h:81
void Show(int *buttonid) const
Create a modal message box.
Definition: SDL3pp_messagebox.h:398
constexpr MessageBoxColorType MESSAGEBOX_COLOR_COUNT
Size of the colors array of MessageBoxColorScheme.
Definition: SDL3pp_messagebox.h:124
SDL_MessageBoxColorType MessageBoxColorType
An enumeration of indices inside the colors array of MessageBoxColorScheme.
Definition: SDL3pp_messagebox.h:107
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BORDER
BUTTON_BORDER.
Definition: SDL3pp_messagebox.h:115
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BACKGROUND
BUTTON_BACKGROUND.
Definition: SDL3pp_messagebox.h:118
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
Marks the default button when return is hit.
Definition: SDL3pp_messagebox.h:77
constexpr MessageBoxFlags MESSAGEBOX_ERROR
error dialog
Definition: SDL3pp_messagebox.h:48
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
buttons placed left to right
Definition: SDL3pp_messagebox.h:57
SDL_MessageBoxColorScheme MessageBoxColorScheme
A set of colors to use for message box dialogs.
Definition: SDL3pp_messagebox.h:134
constexpr MessageBoxColorType MESSAGEBOX_COLOR_TEXT
TEXT.
Definition: SDL3pp_messagebox.h:112
void ShowSimpleMessageBox(MessageBoxFlags flags, StringParam title, StringParam message, WindowParam window)
Display a simple modal message box.
Definition: SDL3pp_messagebox.h:442
constexpr MessageBoxFlags MESSAGEBOX_WARNING
warning dialog
Definition: SDL3pp_messagebox.h:51
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_SELECTED
BUTTON_SELECTED.
Definition: SDL3pp_messagebox.h:121
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BACKGROUND
BACKGROUND.
Definition: SDL3pp_messagebox.h:109
SDL_MessageBoxColor MessageBoxColor
RGB value used in a message box color scheme.
Definition: SDL3pp_messagebox.h:99
Uint32 MessageBoxButtonFlags
MessageBoxButtonData flags.
Definition: SDL3pp_messagebox.h:75
void ShowMessageBox(const MessageBoxRaw &messageboxdata, int *buttonid)
Create a modal message box.
Definition: SDL3pp_messagebox.h:393
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
Main include header for the SDL3pp library.
MessageBox structure containing title, text, window, etc.
Definition: SDL3pp_messagebox.h:142
constexpr SDL_Window * GetWindow() const noexcept
Get the window.
Definition: SDL3pp_messagebox.h:204
constexpr const char * GetMessage() const noexcept
Get the message.
Definition: SDL3pp_messagebox.h:242
constexpr MessageBox & SetFlags(SDL_MessageBoxFlags newFlags) noexcept
Set the flags.
Definition: SDL3pp_messagebox.h:193
constexpr MessageBox & SetButtons(std::span< const MessageBoxButtonData > newButtons) noexcept
Set the buttons.
Definition: SDL3pp_messagebox.h:292
constexpr std::span< const MessageBoxButtonData > GetButtons() const noexcept
Get the buttons.
Definition: SDL3pp_messagebox.h:280
constexpr MessageBox(const MessageBoxRaw &messageBox={}) noexcept
Wraps MessageBox.
Definition: SDL3pp_messagebox.h:148
constexpr const char * GetTitle() const noexcept
Get the title.
Definition: SDL3pp_messagebox.h:223
constexpr int GetNumbuttons() const noexcept
Get the numbuttons.
Definition: SDL3pp_messagebox.h:261
constexpr MessageBox(MessageBoxFlags flags, WindowRef window, const char *title, const char *message, std::span< const MessageBoxButtonData > buttons, OptionalRef< const MessageBoxColorScheme > colorScheme) noexcept
Constructs from its fields.
Definition: SDL3pp_messagebox.h:163
constexpr MessageBox & SetMessage(const char *newMessage) noexcept
Set the message.
Definition: SDL3pp_messagebox.h:250
constexpr MessageBox & SetColorScheme(OptionalRef< const MessageBoxColorScheme > newColorScheme) noexcept
Set the colorScheme.
Definition: SDL3pp_messagebox.h:321
constexpr const MessageBoxColorScheme * GetColorScheme() const noexcept
Get the colorScheme.
Definition: SDL3pp_messagebox.h:310
constexpr MessageBox & SetNumbuttons(int newNumbuttons) noexcept
Set the numbuttons.
Definition: SDL3pp_messagebox.h:269
constexpr MessageBox & SetWindow(SDL_Window *newWindow) noexcept
Set the window.
Definition: SDL3pp_messagebox.h:212
constexpr MessageBox & SetTitle(const char *newTitle) noexcept
Set the title.
Definition: SDL3pp_messagebox.h:231
constexpr SDL_MessageBoxFlags GetFlags() const noexcept
Get the flags.
Definition: SDL3pp_messagebox.h:185
Safely wrap Window for non owning parameters.
Definition: SDL3pp_video.h:54
Semi-safe reference for Window.
Definition: SDL3pp_video.h:2962