The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sdl::twindow Class Reference

The wrapper class for the SDL_Window class. More...

#include <window.hpp>

Inheritance diagram for sdl::twindow:
Inheritance graph

Public Member Functions

 twindow (const std::string &title, const int x, const int y, const int w, const int h, const Uint32 window_flags, const Uint32 render_flags)
 Constructor. More...
 
 ~twindow ()
 
void set_size (const int w, const int h)
 Wrapper for SDL_SetWindowSize. More...
 
void center ()
 Dummy function for centering the window. More...
 
void maximize ()
 Dummy function for maximizing the window. More...
 
void restore ()
 Dummy function for restoring the window. More...
 
void to_window ()
 Dummy function for returning the window to windowed mode. More...
 
void full_screen ()
 Dummy function for setting the window to fullscreen mode. More...
 
void fill (Uint8 r, Uint8 g, Uint8 b, Uint8 a=0)
 Clears the contents of the window with a given color. More...
 
void render ()
 Renders the contents of the window. More...
 
void set_title (const std::string &title)
 Sets the title of the window. More...
 
void set_icon (const surface &icon)
 Sets the icon of the window. More...
 
int get_flags ()
 
void set_minimum_size (int min_w, int min_h)
 Set mimimum size of the window. More...
 
 operator SDL_Window * ()
 Conversion operator to a SDL_Window*. More...
 

Private Member Functions

 operator SDL_Renderer * ()
 Conversion operator to a SDL_Renderer*. More...
 

Private Attributes

SDL_Window * window_
 The SDL_Window we own. More...
 
Uint32 pixel_format_
 The preferred pixel format for the renderer. More...
 

Detailed Description

The wrapper class for the SDL_Window class.

At the moment of writing it is not certain yet how many windows will be created. At least one as main window, but maybe the GUI dialogues will have their own window. Once that is known it might be a good idea to evaluate whether the class should become a singleton or not.

The class also wraps several functions operating on SDL_Window objects. For functions not wrapped the class offers an implicit conversion operator to a pointer to the SDL_Window object it owns.

Definition at line 52 of file window.hpp.

Constructor & Destructor Documentation

sdl::twindow::twindow ( const std::string title,
const int  x,
const int  y,
const int  w,
const int  h,
const Uint32  window_flags,
const Uint32  render_flags 
)

Constructor.

The function calls SDL_CreateWindow and SDL_CreateRenderer.

Parameters
titleUsed as title for SDL_CreateWindow.
xUsed as x for SDL_CreateWindow.
yUsed as y for SDL_CreateWindow.
wUsed as w for SDL_CreateWindow.
hUsed as x for SDL_CreateWindow.
window_flagsUsed as flags for SDL_CreateWindow.
render_flagsUsed as flags for SDL_CreateRenderer.

Definition at line 26 of file window.cpp.

References fill(), lg::info(), pixel_format_, render(), and window_.

sdl::twindow::~twindow ( )

Definition at line 62 of file window.cpp.

References window_.

Member Function Documentation

void sdl::twindow::center ( )

Dummy function for centering the window.

Definition at line 74 of file window.cpp.

References window_.

void sdl::twindow::fill ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = 0 
)

Clears the contents of the window with a given color.

Parameters
rRed value of the color.
gGreen value of the color.
bBlue value of the color.

Definition at line 99 of file window.cpp.

Referenced by main(), and twindow().

void sdl::twindow::full_screen ( )

Dummy function for setting the window to fullscreen mode.

Definition at line 94 of file window.cpp.

References window_.

int sdl::twindow::get_flags ( )

Definition at line 123 of file window.cpp.

References window_.

void sdl::twindow::maximize ( )

Dummy function for maximizing the window.

Definition at line 79 of file window.cpp.

References window_.

sdl::twindow::operator SDL_Renderer * ( )
private

Conversion operator to a SDL_Renderer*.

Todo:
Evaluate whether the function should become public or not.

Definition at line 138 of file window.cpp.

sdl::twindow::operator SDL_Window * ( )

Conversion operator to a SDL_Window*.

Definition at line 133 of file window.cpp.

void sdl::twindow::render ( )

Renders the contents of the window.

Definition at line 108 of file window.cpp.

Referenced by main(), and twindow().

void sdl::twindow::restore ( )

Dummy function for restoring the window.

Definition at line 89 of file window.cpp.

References window_.

void sdl::twindow::set_icon ( const surface icon)

Sets the icon of the window.

This is a wrapper for SDL_SetWindowIcon.

Note
The icon is a SDL_Surface and not a SDL_Texture, this is part of the SDL 2 API.
Parameters
iconThe new icon for the window.

Definition at line 118 of file window.cpp.

References window_.

void sdl::twindow::set_minimum_size ( int  min_w,
int  min_h 
)

Set mimimum size of the window.

This is a wrapper for SDL_SetWindowMinimumWindowSize.

Definition at line 128 of file window.cpp.

References window_.

void sdl::twindow::set_size ( const int  w,
const int  h 
)

Wrapper for SDL_SetWindowSize.

Parameters
wUsed as w for SDL_SetWindowSize.
hUsed as x for SDL_SetWindowSize.

Definition at line 69 of file window.cpp.

References window_.

void sdl::twindow::set_title ( const std::string title)

Sets the title of the window.

This is a wrapper for SDL_SetWindowTitle.

Parameters
titleThe new title for the window.

Definition at line 113 of file window.cpp.

References window_.

void sdl::twindow::to_window ( )

Dummy function for returning the window to windowed mode.

Definition at line 84 of file window.cpp.

References window_.

Member Data Documentation

Uint32 sdl::twindow::pixel_format_
private

The preferred pixel format for the renderer.

Definition at line 180 of file window.hpp.

Referenced by twindow().

SDL_Window* sdl::twindow::window_
private

The SDL_Window we own.

Definition at line 177 of file window.hpp.

Referenced by center(), full_screen(), get_flags(), maximize(), restore(), set_icon(), set_minimum_size(), set_size(), set_title(), to_window(), twindow(), and ~twindow().


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