SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::MessageBox Struct Reference

MessageBox structure containing title, text, window, etc. More...

Inheritance diagram for SDL::MessageBox:
Inheritance graph
[legend]

Public Member Functions

constexpr MessageBox (const SDL_MessageBoxData &messageBox={})
 Wraps MessageBox.
 
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.
 
void Show (int *buttonid) const
 Create a modal message box.
 
constexpr SDL_MessageBoxFlags GetFlags () const
 Get the flags.
 
constexpr MessageBoxSetFlags (SDL_MessageBoxFlags newFlags)
 Set the flags.
 
constexpr WindowRef GetWindow () const
 Get the window.
 
constexpr MessageBoxSetWindow (WindowRef newWindow)
 Set the window.
 
constexpr const char * GetTitle () const
 Get the title.
 
constexpr MessageBoxSetTitle (const char *newTitle)
 Set the title.
 
constexpr const char * GetMessage () const
 Get the message.
 
constexpr MessageBoxSetMessage (const char *newMessage)
 Set the message.
 
constexpr std::span< const MessageBoxButtonDataGetButtons () const
 Get the buttons.
 
constexpr MessageBoxSetButtons (std::span< const MessageBoxButtonData > newButtons)
 Set the buttons.
 
constexpr const MessageBoxColorSchemeGetColorScheme () const
 Get the colorScheme.
 
constexpr MessageBoxSetColorScheme (OptionalRef< const MessageBoxColorScheme > newColorScheme)
 Set the colorScheme.
 

Detailed Description

Since
This struct is available since SDL 3.2.0.

Constructor & Destructor Documentation

◆ MessageBox() [1/2]

constexpr SDL::MessageBox::MessageBox ( const SDL_MessageBoxData &  messageBox = {})
inlineconstexpr
Parameters
messageBoxthe value to be wrapped

◆ MessageBox() [2/2]

constexpr SDL::MessageBox::MessageBox ( MessageBoxFlags  flags,
OptionalWindow  window,
const char *  title,
const char *  message,
std::span< const MessageBoxButtonData buttons,
OptionalRef< const MessageBoxColorScheme colorScheme 
)
inlineconstexpr
Parameters
flagsthe value for flags.
windowthe value for window.
titlethe value for title.
messagethe value for message.
buttonsthe value for buttons.
colorSchemethe value for colorScheme.

Member Function Documentation

◆ GetButtons()

constexpr std::span< const MessageBoxButtonData > SDL::MessageBox::GetButtons ( ) const
inlineconstexpr
Returns
current buttons value.

◆ GetColorScheme()

constexpr const MessageBoxColorScheme * SDL::MessageBox::GetColorScheme ( ) const
inlineconstexpr
Returns
current colorScheme value.

◆ GetFlags()

constexpr SDL_MessageBoxFlags SDL::MessageBox::GetFlags ( ) const
inlineconstexpr
Returns
current flags value.

◆ GetMessage()

constexpr const char * SDL::MessageBox::GetMessage ( ) const
inlineconstexpr
Returns
current message value.

◆ GetTitle()

constexpr const char * SDL::MessageBox::GetTitle ( ) const
inlineconstexpr
Returns
current title value.

◆ GetWindow()

constexpr WindowRef SDL::MessageBox::GetWindow ( ) const
inlineconstexpr
Returns
current window value.

◆ SetButtons()

constexpr MessageBox & SDL::MessageBox::SetButtons ( std::span< const MessageBoxButtonData newButtons)
inlineconstexpr
Parameters
newButtonsthe new buttons value.
Returns
Reference to self.

◆ SetColorScheme()

constexpr MessageBox & SDL::MessageBox::SetColorScheme ( OptionalRef< const MessageBoxColorScheme newColorScheme)
inlineconstexpr
Parameters
newColorSchemethe new colorScheme value.
Returns
Reference to self.

◆ SetFlags()

constexpr MessageBox & SDL::MessageBox::SetFlags ( SDL_MessageBoxFlags  newFlags)
inlineconstexpr
Parameters
newFlagsthe new flags value.
Returns
Reference to self.

◆ SetMessage()

constexpr MessageBox & SDL::MessageBox::SetMessage ( const char *  newMessage)
inlineconstexpr
Parameters
newMessagethe new message value.
Returns
Reference to self.

◆ SetTitle()

constexpr MessageBox & SDL::MessageBox::SetTitle ( const char *  newTitle)
inlineconstexpr
Parameters
newTitlethe new title value.
Returns
Reference to self.

◆ SetWindow()

constexpr MessageBox & SDL::MessageBox::SetWindow ( WindowRef  newWindow)
inlineconstexpr
Parameters
newWindowthe new window value.
Returns
Reference to self.

◆ Show()

void SDL::MessageBox::Show ( int *  buttonid) const
inline

If your needs aren't complex, it might be easier to use ShowSimpleMessageBox.

This function should be called on the thread that created the parent window, or on the main thread if the messagebox has no parent. It will block execution of that thread until the user clicks a button or closes the messagebox.

This function may be called at any time, even before InitSubSystem(). This makes it useful for reporting errors like a failure to create a renderer or OpenGL context.

On X11, SDL rolls its own dialog box with X11 primitives instead of a formal toolkit like GTK+ or Qt.

Note that if InitSubSystem() would fail because there isn't any available video target, this function is likely to fail for the same reasons. If this is a concern, check the return value from this function and fall back to writing to stderr if you can.

Parameters
buttonidthe pointer to which user id of hit button should be copied.
Exceptions
Erroron failure.
Since
This function is available since SDL 3.2.0.
See also
ShowSimpleMessageBox

The documentation for this struct was generated from the following file: