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"
53 SDL_MESSAGEBOX_WARNING;
56 SDL_MESSAGEBOX_INFORMATION;
59 SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT;
62 SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT;
79 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
83 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
114 SDL_MESSAGEBOX_COLOR_BACKGROUND;
117 SDL_MESSAGEBOX_COLOR_TEXT;
120 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER;
123 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND;
126 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED;
129 SDL_MESSAGEBOX_COLOR_COUNT;
171 std::span<const MessageBoxButtonData> buttons,
188 constexpr SDL_MessageBoxFlags
GetFlags()
const {
return flags; }
207 constexpr SDL_Window*
GetWindow()
const {
return window; }
226 constexpr const char*
GetTitle()
const {
return title; }
255 message = newMessage;
274 numbuttons = newNumbuttons;
283 constexpr std::span<const MessageBoxButtonData>
GetButtons()
const
285 if (numbuttons == 0)
return {};
286 return std::span(buttons,
size_t(numbuttons));
296 std::span<const MessageBoxButtonData> newButtons)
298 if (newButtons.empty()) {
302 numbuttons = newButtons.size();
303 buttons = newButtons.data();
327 colorScheme = newColorScheme;
363 void Show(
int* buttonid)
const;
401 CheckError(SDL_ShowMessageBox(&messageboxdata, buttonid));
453 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:198
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
buttons placed right to left
Definition: SDL3pp_messagebox.h:61
SDL_MessageBoxButtonData MessageBoxButtonData
Individual button data.
Definition: SDL3pp_messagebox.h:93
SDL_MessageBoxData MessageBoxRaw
Alias to raw representation for MessageBox.
Definition: SDL3pp_messagebox.h:30
constexpr MessageBoxFlags MESSAGEBOX_INFORMATION
informational dialog
Definition: SDL3pp_messagebox.h:55
Uint32 MessageBoxFlags
Message box flags.
Definition: SDL3pp_messagebox.h:47
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
Marks the default button when escape is hit.
Definition: SDL3pp_messagebox.h:82
void Show(int *buttonid) const
Create a modal message box.
Definition: SDL3pp_messagebox.h:404
constexpr MessageBoxColorType MESSAGEBOX_COLOR_COUNT
Size of the colors array of MessageBoxColorScheme.
Definition: SDL3pp_messagebox.h:128
SDL_MessageBoxColorType MessageBoxColorType
An enumeration of indices inside the colors array of MessageBoxColorScheme.
Definition: SDL3pp_messagebox.h:111
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BORDER
BUTTON_BORDER.
Definition: SDL3pp_messagebox.h:119
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_BACKGROUND
BUTTON_BACKGROUND.
Definition: SDL3pp_messagebox.h:122
constexpr MessageBoxButtonFlags MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
Marks the default button when return is hit.
Definition: SDL3pp_messagebox.h:78
constexpr MessageBoxFlags MESSAGEBOX_ERROR
error dialog
Definition: SDL3pp_messagebox.h:49
constexpr MessageBoxFlags MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT
buttons placed left to right
Definition: SDL3pp_messagebox.h:58
SDL_MessageBoxColorScheme MessageBoxColorScheme
A set of colors to use for message box dialogs.
Definition: SDL3pp_messagebox.h:138
constexpr MessageBoxColorType MESSAGEBOX_COLOR_TEXT
TEXT.
Definition: SDL3pp_messagebox.h:116
void ShowSimpleMessageBox(MessageBoxFlags flags, StringParam title, StringParam message, WindowParam window)
Display a simple modal message box.
Definition: SDL3pp_messagebox.h:448
constexpr MessageBoxFlags MESSAGEBOX_WARNING
warning dialog
Definition: SDL3pp_messagebox.h:52
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BUTTON_SELECTED
BUTTON_SELECTED.
Definition: SDL3pp_messagebox.h:125
constexpr MessageBoxColorType MESSAGEBOX_COLOR_BACKGROUND
BACKGROUND.
Definition: SDL3pp_messagebox.h:113
SDL_MessageBoxColor MessageBoxColor
RGB value used in a message box color scheme.
Definition: SDL3pp_messagebox.h:100
Uint32 MessageBoxButtonFlags
MessageBoxButtonData flags.
Definition: SDL3pp_messagebox.h:76
void ShowMessageBox(const MessageBoxRaw &messageboxdata, int *buttonid)
Create a modal message box.
Definition: SDL3pp_messagebox.h:399
Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:328
Main include header for the SDL3pp library.
MessageBox structure containing title, text, window, etc.
Definition: SDL3pp_messagebox.h:146
constexpr MessageBox & SetColorScheme(OptionalRef< const MessageBoxColorScheme > newColorScheme)
Set the colorScheme.
Definition: SDL3pp_messagebox.h:324
constexpr SDL_Window * GetWindow() const
Get the window.
Definition: SDL3pp_messagebox.h:207
constexpr MessageBox & SetTitle(const char *newTitle)
Set the title.
Definition: SDL3pp_messagebox.h:234
constexpr MessageBox & SetMessage(const char *newMessage)
Set the message.
Definition: SDL3pp_messagebox.h:253
constexpr const char * GetMessage() const
Get the message.
Definition: SDL3pp_messagebox.h:245
constexpr const char * GetTitle() const
Get the title.
Definition: SDL3pp_messagebox.h:226
constexpr std::span< const MessageBoxButtonData > GetButtons() const
Get the buttons.
Definition: SDL3pp_messagebox.h:283
constexpr SDL_MessageBoxFlags GetFlags() const
Get the flags.
Definition: SDL3pp_messagebox.h:188
constexpr MessageBox & SetNumbuttons(int newNumbuttons)
Set the numbuttons.
Definition: SDL3pp_messagebox.h:272
constexpr int GetNumbuttons() const
Get the numbuttons.
Definition: SDL3pp_messagebox.h:264
constexpr const MessageBoxColorScheme * GetColorScheme() const
Get the colorScheme.
Definition: SDL3pp_messagebox.h:313
constexpr MessageBox(MessageBoxFlags flags, WindowRef window, const char *title, const char *message, std::span< const MessageBoxButtonData > buttons, OptionalRef< const MessageBoxColorScheme > colorScheme)
Constructs from its fields.
Definition: SDL3pp_messagebox.h:167
constexpr MessageBox & SetFlags(SDL_MessageBoxFlags newFlags)
Set the flags.
Definition: SDL3pp_messagebox.h:196
constexpr MessageBox(const MessageBoxRaw &messageBox={})
Wraps MessageBox.
Definition: SDL3pp_messagebox.h:152
constexpr MessageBox & SetButtons(std::span< const MessageBoxButtonData > newButtons)
Set the buttons.
Definition: SDL3pp_messagebox.h:295
constexpr MessageBox & SetWindow(SDL_Window *newWindow)
Set the window.
Definition: SDL3pp_messagebox.h:215
Safely wrap Window for non owning parameters.
Definition: SDL3pp_video.h:57
Semi-safe reference for Window.
Definition: SDL3pp_video.h:2925