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;
167 std::span<const MessageBoxButtonData> buttons,
222 constexpr const char*
GetTitle() const noexcept {
return title; }
241 constexpr const char*
GetMessage() const noexcept {
return message; }
251 message = newMessage;
270 numbuttons = newNumbuttons;
279 constexpr std::span<const MessageBoxButtonData>
GetButtons() const noexcept
281 if (numbuttons == 0)
return {};
282 return std::span(buttons,
size_t(numbuttons));
292 std::span<const MessageBoxButtonData> newButtons)
noexcept
294 if (newButtons.empty()) {
298 numbuttons = newButtons.size();
299 buttons = newButtons.data();
323 colorScheme = newColorScheme;
360 void Show(
int* buttonid)
const;
398 CheckError(SDL_ShowMessageBox(&messageboxdata, buttonid));
452 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:199
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
buttons placed right to left
Definition SDL3pp_messagebox.h:60
constexpr MessageBoxFlags MESSAGEBOX_INFORMATION
informational dialog
Definition SDL3pp_messagebox.h:54
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
Marks the default button when escape is hit.
Definition SDL3pp_messagebox.h:81
SDL_MessageBoxColorType MessageBoxColorType
An enumeration of indices inside the colors array of MessageBoxColorScheme.
Definition SDL3pp_messagebox.h:107
void Show(int *buttonid) const
Create a modal message box.
Definition SDL3pp_messagebox.h:401
constexpr MessageBoxColorType MESSAGEBOX_COLOR_COUNT
Size of the colors array of MessageBoxColorScheme.
Definition SDL3pp_messagebox.h:124
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
SDL_MessageBoxData MessageBoxRaw
Alias to raw representation for MessageBox.
Definition SDL3pp_messagebox.h:29
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
SDL_MessageBoxColorScheme MessageBoxColorScheme
A set of colors to use for message box dialogs.
Definition SDL3pp_messagebox.h:134
SDL_MessageBoxButtonData MessageBoxButtonData
Individual button data.
Definition SDL3pp_messagebox.h:92
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
buttons placed left to right
Definition SDL3pp_messagebox.h:57
constexpr MessageBoxColorType MESSAGEBOX_COLOR_TEXT
TEXT.
Definition SDL3pp_messagebox.h:112
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
void ShowSimpleMessageBox(MessageBoxFlags flags, StringParam title, StringParam message, WindowRef window)
Display a simple modal message box.
Definition SDL3pp_messagebox.h:447
Uint32 MessageBoxFlags
Message box flags.
Definition SDL3pp_messagebox.h:46
SDL_MessageBoxColor MessageBoxColor
RGB value used in a message box color scheme.
Definition SDL3pp_messagebox.h:99
void ShowMessageBox(const MessageBoxRaw &messageboxdata, int *buttonid)
Create a modal message box.
Definition SDL3pp_messagebox.h:396
Uint32 MessageBoxButtonFlags
MessageBoxButtonData flags.
Definition SDL3pp_messagebox.h:75
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
ResourceRef< Window > WindowRef
Reference for Window.
Definition SDL3pp_video.h:54
Main include header for the SDL3pp library.
MessageBox structure containing title, text, window, etc.
Definition SDL3pp_messagebox.h:142
constexpr MessageBox & SetFlags(MessageBoxFlags newFlags) noexcept
Set the flags.
Definition SDL3pp_messagebox.h:192
constexpr const char * GetMessage() const noexcept
Get the message.
Definition SDL3pp_messagebox.h:241
constexpr MessageBox & SetButtons(std::span< const MessageBoxButtonData > newButtons) noexcept
Set the buttons.
Definition SDL3pp_messagebox.h:291
constexpr std::span< const MessageBoxButtonData > GetButtons() const noexcept
Get the buttons.
Definition SDL3pp_messagebox.h:279
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:222
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 int GetNumbuttons() const noexcept
Get the numbuttons.
Definition SDL3pp_messagebox.h:260
MessageBox & SetWindow(WindowRef newWindow) noexcept
Set the window.
Definition SDL3pp_messagebox.h:211
constexpr MessageBox & SetMessage(const char *newMessage) noexcept
Set the message.
Definition SDL3pp_messagebox.h:249
constexpr MessageBox & SetColorScheme(OptionalRef< const MessageBoxColorScheme > newColorScheme) noexcept
Set the colorScheme.
Definition SDL3pp_messagebox.h:320
constexpr const MessageBoxColorScheme * GetColorScheme() const noexcept
Get the colorScheme.
Definition SDL3pp_messagebox.h:309
constexpr MessageBox & SetNumbuttons(int newNumbuttons) noexcept
Set the numbuttons.
Definition SDL3pp_messagebox.h:268
constexpr MessageBoxFlags GetFlags() const noexcept
Get the flags.
Definition SDL3pp_messagebox.h:184
WindowRef GetWindow() const noexcept
Get the window.
Definition SDL3pp_messagebox.h:203
constexpr MessageBox & SetTitle(const char *newTitle) noexcept
Set the title.
Definition SDL3pp_messagebox.h:230