libSDL2pp  0.16.0
C++11 bindings/wrapper for SDL2
Public Member Functions | List of all members
SDL2pp::Window Class Reference

GUI window object. More...

#include <SDL2pp/Window.hh>

Public Member Functions

 Window (SDL_Window *window)
 Construct from existing SDL_Window structure. More...
 
 Window (const std::string &title, int x, int y, int w, int h, Uint32 flags)
 Create window with specified title and dimensions. More...
 
virtual ~Window ()
 Destructor. More...
 
 Window (Window &&other) noexcept
 Move constructor. More...
 
Windowoperator= (Window &&other) noexcept
 Move assignment operator. More...
 
 Window (const Window &other)=delete
 Deleted copy constructor. More...
 
Windowoperator= (const Window &other)=delete
 Deleted assignment operator. More...
 
SDL_Window * Get () const
 Get pointer to managed SDL_Window structure. More...
 
Point GetSize () const
 Get dimensions of the window. More...
 
int GetWidth () const
 Get width of the window. More...
 
int GetHeight () const
 Get height of the window. More...
 
Point GetDrawableSize () const
 Get drawable dimensions of the window. More...
 
int GetDrawableWidth () const
 Get drawable width of the window. More...
 
int GetDrawableHeight () const
 Get drawable height of the window. More...
 
WindowSetTitle (const std::string &title)
 Set window title. More...
 
std::string GetTitle () const
 Get window title. More...
 
WindowMaximize ()
 Make a window as large as possible. More...
 
WindowMinimize ()
 Minimize a window to an iconic representation. More...
 
WindowHide ()
 Hide a window. More...
 
WindowRestore ()
 Restore the size and position of a minimized or maximized window. More...
 
WindowRaise ()
 Raise a window above other windows and set the input focus. More...
 
WindowShow ()
 Show a window. More...
 
WindowSetFullscreen (Uint32 flags)
 Set a window's fullscreen state. More...
 
WindowSetSize (int w, int h)
 Set the size of a window's client area. More...
 
WindowSetSize (const Point &size)
 Set the size of a window's client area. More...
 
float GetBrightness () const
 Get the brightness (gamma multiplier) for the display that owns a given window. More...
 
WindowSetBrightness (float brightness)
 Set the brightness (gamma multiplier) for the display that owns a given window. More...
 
Point GetPosition () const
 Get the position of a window. More...
 
WindowSetPosition (int x, int y)
 Set the position of a window. More...
 
WindowSetPosition (const Point &pos)
 Set the position of a window. More...
 
Point GetMinimumSize () const
 Get the minimum size of a window's client area. More...
 
WindowSetMinimumSize (int w, int h)
 Set the minimum size of a window's client area. More...
 
WindowSetMinimumSize (const Point &size)
 Set the minimum size of a window's client area. More...
 
Point GetMaximumSize () const
 Get the maximum size of a window's client area. More...
 
WindowSetMaximumSize (int w, int h)
 Set the maximum size of a window's client area. More...
 
WindowSetMaximumSize (const Point &size)
 Set the maximum size of a window's client area. More...
 
bool GetGrab () const
 Get a window's input grab mode. More...
 
WindowSetGrab (bool grabbed)
 Set a window's input grab mode. More...
 
int GetDisplayIndex () const
 Get the index of the display associated with a window. More...
 
void GetDisplayMode (SDL_DisplayMode &mode) const
 Get information about the display mode to use when a window is visible at fullscreen. More...
 
Uint32 GetFlags () const
 Get the window flags. More...
 
WindowSetIcon (const Surface &icon)
 Set the icon for a window. More...
 
WindowSetBordered (bool bordered=true)
 Set the border state of a window. More...
 
WindowSetOpacity (float opacity=1.0f)
 Set the opacity for a window. More...
 
float GetOpacity () const
 Get the opacity of a window. More...
 
WindowSetResizable (bool resizable=true)
 Set user-resizable state of a window. More...
 

Detailed Description

GUI window object.

SDL2pp::Window is a wrapper around SDL_Window structure and related functions which take care of GUI window management.

Usage example:

{
SDL2pp::SDL sdl(SDL_INIT_VIDEO);
SDL2pp::Window window("Test Window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_OPENGL);
SDL_Delay(3000); // show window for 3 seconds
}

Constructor & Destructor Documentation

◆ Window() [1/4]

SDL2pp::Window::Window ( SDL_Window *  window)
explicit

Construct from existing SDL_Window structure.

Parameters
[in]windowExisting SDL_Window to manage

◆ Window() [2/4]

SDL2pp::Window::Window ( const std::string &  title,
int  x,
int  y,
int  w,
int  h,
Uint32  flags 
)

Create window with specified title and dimensions.

Parameters
[in]titleTitle of the windows, in UTF-8 encoding
[in]xX position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
[in]yX position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
[in]wWidth of the window
[in]hHeight of the window
[in]flags0 or more SDL_WindowFlags OR'd together
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_CreateWindow

◆ ~Window()

SDL2pp::Window::~Window ( )
virtual

◆ Window() [3/4]

SDL2pp::Window::Window ( Window &&  other)
noexcept

Move constructor.

Parameters
[in]otherSDL2pp::Window object to move data from

◆ Window() [4/4]

SDL2pp::Window::Window ( const Window other)
delete

Deleted copy constructor.

This class is not copyable

Member Function Documentation

◆ Get()

SDL_Window * SDL2pp::Window::Get ( ) const

Get pointer to managed SDL_Window structure.

Returns
Pointer to managed SDL_Window structure

◆ GetBrightness()

float SDL2pp::Window::GetBrightness ( ) const

Get the brightness (gamma multiplier) for the display that owns a given window.

Returns
Brightness for the display where 0.0 is completely dark and 1.0 is normal brightness
See also
http://wiki.libsdl.org/SDL_GetWindowBrightness

◆ GetDisplayIndex()

int SDL2pp::Window::GetDisplayIndex ( ) const

Get the index of the display associated with a window.

Returns
Index of the display containing the center of the window
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetWindowDisplayIndex

◆ GetDisplayMode()

void SDL2pp::Window::GetDisplayMode ( SDL_DisplayMode &  mode) const

Get information about the display mode to use when a window is visible at fullscreen.

Parameters
[out]modeSDL_DisplayMode structure filled in with the fullscreen display mode
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetWindowDisplayMode

◆ GetDrawableHeight()

int SDL2pp::Window::GetDrawableHeight ( ) const

Get drawable height of the window.

Returns
Height of the window drawable area in pixels
See also
http://wiki.libsdl.org/SDL_GL_GetDrawableSize

◆ GetDrawableSize()

Point SDL2pp::Window::GetDrawableSize ( ) const

Get drawable dimensions of the window.

Returns
SDL2pp::Point representing dimensions (width and height) of the window drawable area in pixels
See also
http://wiki.libsdl.org/SDL_GL_GetDrawableSize

◆ GetDrawableWidth()

int SDL2pp::Window::GetDrawableWidth ( ) const

Get drawable width of the window.

Returns
Width of the window drawable area in pixels
See also
http://wiki.libsdl.org/SDL_GL_GetDrawableSize

◆ GetFlags()

Uint32 SDL2pp::Window::GetFlags ( ) const

Get the window flags.

Returns
Mask of the SDL_WindowFlags associated with window
See also
http://wiki.libsdl.org/SDL_GetWindowFlags

◆ GetGrab()

bool SDL2pp::Window::GetGrab ( ) const

Get a window's input grab mode.

Returns
True if input is grabbed, flase otherwise
See also
http://wiki.libsdl.org/SDL_GetWindowGrab

◆ GetHeight()

int SDL2pp::Window::GetHeight ( ) const

Get height of the window.

Returns
Height of the window in pixels
See also
http://wiki.libsdl.org/SDL_GetWindowSize

◆ GetMaximumSize()

Point SDL2pp::Window::GetMaximumSize ( ) const

Get the maximum size of a window's client area.

Returns
Point representing maximum area of window's client area
See also
http://wiki.libsdl.org/SDL_GetWindowMaximumSize

◆ GetMinimumSize()

Point SDL2pp::Window::GetMinimumSize ( ) const

Get the minimum size of a window's client area.

Returns
Point representing minimum area of window's client area
See also
http://wiki.libsdl.org/SDL_GetWindowMinimumSize

◆ GetOpacity()

float SDL2pp::Window::GetOpacity ( ) const

Get the opacity of a window.

Returns
Opacity value (0.0f - transparent, 1.0f - opaque)
Exceptions
SDL2pp:Exception
See also
http://wiki.libsdl.org/SDL_GetWindowOpacity

◆ GetPosition()

Point SDL2pp::Window::GetPosition ( ) const

Get the position of a window.

Returns
Point representing window position
See also
http://wiki.libsdl.org/SDL_GetWindowPosition

◆ GetSize()

Point SDL2pp::Window::GetSize ( ) const

Get dimensions of the window.

Returns
SDL2pp::Point representing dimensions (width and height) of the window in pixels
See also
http://wiki.libsdl.org/SDL_GetWindowSize

◆ GetTitle()

std::string SDL2pp::Window::GetTitle ( ) const

Get window title.

Returns
Title of the window in UTF-8 format or "" if there is no title
See also
http://wiki.libsdl.org/SDL_GetWindowTitle

◆ GetWidth()

int SDL2pp::Window::GetWidth ( ) const

Get width of the window.

Returns
Width of the window in pixels
See also
http://wiki.libsdl.org/SDL_GetWindowSize

◆ Hide()

Window & SDL2pp::Window::Hide ( )

Hide a window.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_HideWindow

◆ Maximize()

Window & SDL2pp::Window::Maximize ( )

Make a window as large as possible.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_MaximizeWindow

◆ Minimize()

Window & SDL2pp::Window::Minimize ( )

Minimize a window to an iconic representation.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_MinimizeWindow

◆ operator=() [1/2]

Window & SDL2pp::Window::operator= ( Window &&  other)
noexcept

Move assignment operator.

Parameters
[in]otherSDL2pp::Window object to move data from
Returns
Reference to self

◆ operator=() [2/2]

Window& SDL2pp::Window::operator= ( const Window other)
delete

Deleted assignment operator.

This class is not copyable

◆ Raise()

Window & SDL2pp::Window::Raise ( )

Raise a window above other windows and set the input focus.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_RaiseWindow

◆ Restore()

Window & SDL2pp::Window::Restore ( )

Restore the size and position of a minimized or maximized window.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_RestoreWindow

◆ SetBordered()

Window & SDL2pp::Window::SetBordered ( bool  bordered = true)

Set the border state of a window.

Parameters
[in]borderedFalse to remove border, true to add border
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowBordered

◆ SetBrightness()

Window & SDL2pp::Window::SetBrightness ( float  brightness)

Set the brightness (gamma multiplier) for the display that owns a given window.

Parameters
[in]brightnessBrightness value to set where 0.0 is completely dark and 1.0 is normal brightness
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetWindowBrightness

◆ SetFullscreen()

Window & SDL2pp::Window::SetFullscreen ( Uint32  flags)

Set a window's fullscreen state.

Parameters
[in]flagsSDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP or 0
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetWindowFullscreen

◆ SetGrab()

Window & SDL2pp::Window::SetGrab ( bool  grabbed)

Set a window's input grab mode.

Parameters
[in]grabbedTrue to grab input, false to release input
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowGrab

◆ SetIcon()

Window & SDL2pp::Window::SetIcon ( const Surface icon)

Set the icon for a window.

Parameters
[in]iconSurface containing the icon for the window
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowIcon

Icon surface may be destroyed after calling this function

◆ SetMaximumSize() [1/2]

Window & SDL2pp::Window::SetMaximumSize ( int  w,
int  h 
)

Set the maximum size of a window's client area.

Parameters
[in]wMaximum width of the window in pixels
[in]hMaximum height of the window in pixels
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowMaximumSize

◆ SetMaximumSize() [2/2]

Window & SDL2pp::Window::SetMaximumSize ( const Point size)

Set the maximum size of a window's client area.

Parameters
[in]sizeMaximum area of the window in pixels
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowMaximumSize

◆ SetMinimumSize() [1/2]

Window & SDL2pp::Window::SetMinimumSize ( int  w,
int  h 
)

Set the minimum size of a window's client area.

Parameters
[in]wMinimum width of the window in pixels
[in]hMinimum height of the window in pixels
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowMinimumSize

◆ SetMinimumSize() [2/2]

Window & SDL2pp::Window::SetMinimumSize ( const Point size)

Set the minimum size of a window's client area.

Parameters
[in]sizeMinimum area of the window in pixels
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowMinimumSize

◆ SetOpacity()

Window & SDL2pp::Window::SetOpacity ( float  opacity = 1.0f)

Set the opacity for a window.

Parameters
[in]opacityThe opacity value (0.0f - transparent, 1.0f - opaque)
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetWindowOpacity

◆ SetPosition() [1/2]

Window & SDL2pp::Window::SetPosition ( int  x,
int  y 
)

Set the position of a window.

Parameters
[in]xX coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
[in]yY coordinate of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowPosition

◆ SetPosition() [2/2]

Window & SDL2pp::Window::SetPosition ( const Point pos)

Set the position of a window.

Parameters
[in]posPoint representin position of the a window
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowPosition

◆ SetResizable()

Window & SDL2pp::Window::SetResizable ( bool  resizable = true)

Set user-resizable state of a window.

Parameters
[in]resizableTrue to allow resizing, false to disallow
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowResizable

◆ SetSize() [1/2]

Window & SDL2pp::Window::SetSize ( int  w,
int  h 
)

Set the size of a window's client area.

Parameters
[in]wWidth of the window in pixels
[in]hHeight of the window in pixels
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowSize

◆ SetSize() [2/2]

Window & SDL2pp::Window::SetSize ( const Point size)

Set the size of a window's client area.

Parameters
[in]sizePoint representing window dimensions
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowSize

◆ SetTitle()

Window & SDL2pp::Window::SetTitle ( const std::string &  title)

Set window title.

Parameters
[in]titleNew window title in UTF-8 encoding
Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_SetWindowTitle

◆ Show()

Window & SDL2pp::Window::Show ( )

Show a window.

Returns
Reference to self
See also
http://wiki.libsdl.org/SDL_ShowWindow

The documentation for this class was generated from the following files: