SDL 2.0
SDL_messagebox.h File Reference
#include "SDL_stdinc.h"
#include "SDL_video.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_messagebox.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SDL_MessageBoxButtonData
 
struct  SDL_MessageBoxColor
 
struct  SDL_MessageBoxColorScheme
 
struct  SDL_MessageBoxData
 

Enumerations

enum  SDL_MessageBoxFlags {
  SDL_MESSAGEBOX_ERROR = 0x00000010 ,
  SDL_MESSAGEBOX_WARNING = 0x00000020 ,
  SDL_MESSAGEBOX_INFORMATION = 0x00000040 ,
  SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080 ,
  SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100
}
 
enum  SDL_MessageBoxButtonFlags {
  SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001 ,
  SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002
}
 
enum  SDL_MessageBoxColorType {
  SDL_MESSAGEBOX_COLOR_BACKGROUND ,
  SDL_MESSAGEBOX_COLOR_TEXT ,
  SDL_MESSAGEBOX_COLOR_BUTTON_BORDER ,
  SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND ,
  SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED ,
  SDL_MESSAGEBOX_COLOR_MAX
}
 

Functions

int SDL_ShowMessageBox (const SDL_MessageBoxData *messageboxdata, int *buttonid)
 
int SDL_ShowSimpleMessageBox (Uint32 flags, const char *title, const char *message, SDL_Window *window)
 

Enumeration Type Documentation

◆ SDL_MessageBoxButtonFlags

Flags for SDL_MessageBoxButtonData.

Enumerator
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT 

Marks the default button when return is hit

SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT 

Marks the default button when escape is hit

Definition at line 49 of file SDL_messagebox.h.

50{
51 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
52 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
SDL_MessageBoxButtonFlags
@ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT
@ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT

◆ SDL_MessageBoxColorType

Enumerator
SDL_MESSAGEBOX_COLOR_BACKGROUND 
SDL_MESSAGEBOX_COLOR_TEXT 
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER 
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND 
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED 
SDL_MESSAGEBOX_COLOR_MAX 

Definition at line 73 of file SDL_messagebox.h.

◆ SDL_MessageBoxFlags

SDL_MessageBox flags. If supported will display warning icon, etc.

Enumerator
SDL_MESSAGEBOX_ERROR 

error dialog

SDL_MESSAGEBOX_WARNING 

warning dialog

SDL_MESSAGEBOX_INFORMATION 

informational dialog

SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT 

buttons placed left to right

SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT 

buttons placed right to left

Definition at line 37 of file SDL_messagebox.h.

38{
39 SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
40 SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
41 SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */
42 SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */
43 SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */
SDL_MessageBoxFlags
@ SDL_MESSAGEBOX_ERROR
@ SDL_MESSAGEBOX_WARNING
@ SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT
@ SDL_MESSAGEBOX_INFORMATION
@ SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT

Function Documentation

◆ SDL_ShowMessageBox()

int SDL_ShowMessageBox ( const SDL_MessageBoxData messageboxdata,
int *  buttonid 
)
extern

Create a modal message box.

If your needs aren't complex, it might be easier to use SDL_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 SDL_Init(). 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 SDL_Init() 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
messageboxdatathe SDL_MessageBoxData structure with title, text and other options
buttonidthe pointer to which user id of hit button should be copied
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 2.0.0.
See also
SDL_ShowSimpleMessageBox

◆ SDL_ShowSimpleMessageBox()

int SDL_ShowSimpleMessageBox ( Uint32  flags,
const char *  title,
const char *  message,
SDL_Window window 
)
extern

Display a simple modal message box.

If your needs aren't complex, this function is preferred over SDL_ShowMessageBox.

flags may be any of the following:

  • SDL_MESSAGEBOX_ERROR: error dialog
  • SDL_MESSAGEBOX_WARNING: warning dialog
  • SDL_MESSAGEBOX_INFORMATION: informational dialog

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 SDL_Init(). 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 SDL_Init() 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
flagsan SDL_MessageBoxFlags value
titleUTF-8 title text
messageUTF-8 message text
windowthe parent window, or NULL for no parent
Returns
0 on success or a negative error code on failure; call SDL_GetError() for more information.
Since
This function is available since SDL 2.0.0.
See also
SDL_ShowMessageBox