SDL Utility
|
Stores information about a window. You probably want RenderWindow. More...
#include <Window.hpp>
Public Types | |
enum | Flags { Fullscreen = ((Uint32)1 << 0) , OpenGL = ((Uint32)1 << 1) , Shown = ((Uint32)1 << 2) , Hidden = ((Uint32)1 << 3) , Borderless = ((Uint32)1 << 4) , Resizable = ((Uint32)1 << 5) , Minimized = ((Uint32)1 << 6) , Maximized = ((Uint32)1 << 7) , InputGrabbed = ((Uint32)1 << 8) , InputFocus = ((Uint32)1 << 9) , MouseFocus = ((Uint32)1 << 10) , Foregin = ((Uint32)1 << 11) , FullscreenDesktop = (Fullscreen | ((Uint32)1 << 12)) } |
Public Member Functions | |
Window () | |
Default Constructor. No window is created. More... | |
Window (Vector2u dimension, const std::string &title, Uint32 windowFlags) | |
Creates a window with the given parameters. More... | |
Window (const Window &other)=delete | |
Window (Window &&other)=delete | |
virtual | ~Window () |
void | Create (Vector2u dimension, const std::string &title, Uint32 windowFlags) |
Creates the window. More... | |
void | Close () |
Destroys the window. More... | |
bool | IsOpen () const |
Wether or not the window object is created. More... | |
bool | PollEvent (SDL_Event *event) |
A non-blocking event polling function. More... | |
bool | WaitEvent (SDL_Event *event) |
A blocking event polling function. More... | |
Vector2i | GetPosition () const |
Returns the current position of the window. More... | |
void | SetPosition (Vector2i position) |
Sets a new window position. More... | |
void | SetPosition (int x, int y) |
Sets a new window position. More... | |
Vector2u | GetSize () const |
Gets the current window size. More... | |
void | SetSize (Vector2u size) |
Sets a new window size. More... | |
void | SetSize (unsigned int width, unsigned int height) |
Sets a new window size. More... | |
std::string | GetTitle () const |
Gets the current window title. More... | |
void | SetTitle (std::string title) |
Sets a new window title. More... | |
SDL_Window *const | GetWindow () const |
Returns a constant pointer to the SDL_Window. More... | |
void | SetVisible (bool visible) |
Set the windows visibility. More... | |
void | SetVsync (bool vsync) |
(De)activates VSync !globally! More... | |
void | SetMouseCursorVisible (bool visible) |
Hides/Shows the mouse cursor inside the windos. More... | |
void | SetMouseCursorGrabbed (bool grabbed) |
Traps the mouse cursor inside the window. More... | |
void | SetIcon (Uint32 width, Uint32 height, const Uint8 *pixels) |
Sets the window icon to an array of RGBA values. More... | |
void | SetIcon (Uint32 width, Uint32 height, const Uint32 *pixels) |
Sets the window icon to an array of RGBA values. More... | |
void | SetIcon (SDL_Surface *icon) |
Sets the window icon to a SDL_Surface. More... | |
void | SetMouseCursor (SDL_Cursor *cursor) |
Changes the mouse cursor. More... | |
void | SetMouseCursor (const Cursor &cursor) |
Changes the mouse cursor. More... | |
Protected Member Functions | |
virtual void | OnCreate () |
This function is called after Create() finishes. More... | |
virtual bool | OnResize () |
This function is called after a SDL_WINDOWEVENT_RESIZED is polled. (PollEvent() must be called for this to work) More... | |
virtual void | OnClose () |
This function is called after Close() finishes. More... | |
Protected Attributes | |
SDL_Window * | window |
Stores information about a window. You probably want RenderWindow.
enum Window::Flags |
Window::Window | ( | ) |
Default Constructor. No window is created.
Creates a window with the given parameters.
[in] | dimension | A vector containing the width and height |
[in] | title | The title of the create window |
|
delete |
|
delete |
|
virtual |
void Window::Close | ( | ) |
Destroys the window.
Creates the window.
This function creates the SDL_Window object. If they were already created the function does nothing and returns. If it fails to create either, an ObjectCreationException is thrown.
[in] | dimension | A vector containing the width and height |
[in] | title | The title of the create window |
Vector2i Window::GetPosition | ( | ) | const |
Returns the current position of the window.
Vector2u Window::GetSize | ( | ) | const |
Gets the current window size.
std::string Window::GetTitle | ( | ) | const |
Gets the current window title.
SDL_Window* const Window::GetWindow | ( | ) | const |
Returns a constant pointer to the SDL_Window.
bool Window::IsOpen | ( | ) | const |
Wether or not the window object is created.
|
protectedvirtual |
This function is called after Close() finishes.
Reimplemented in RenderWindow.
|
protectedvirtual |
This function is called after Create() finishes.
Reimplemented in RenderWindow.
|
protectedvirtual |
This function is called after a SDL_WINDOWEVENT_RESIZED is polled. (PollEvent() must be called for this to work)
Reimplemented in RenderWindow.
bool Window::PollEvent | ( | SDL_Event * | event | ) |
A non-blocking event polling function.
[out] | event | An object to write the latest event to |
void Window::SetIcon | ( | SDL_Surface * | icon | ) |
Sets the window icon to a SDL_Surface.
[in] | icon | A SDL_Surface* holding the icon data |
Sets the window icon to an array of RGBA values.
[in] | width | Width of the icon (in px) |
[in] | height | Height of the icon (in px) |
[in] | pixels | Array of color data (RGBA as one 32-Bit integer value) |
Sets the window icon to an array of RGBA values.
[in] | width | Width of the icon (in px) |
[in] | height | Height of the icon (in px) |
[in] | pixels | Array of color data (RGBA as seperate 8-Bit integer values) |
void Window::SetMouseCursor | ( | const Cursor & | cursor | ) |
Changes the mouse cursor.
[in] | cursor | The cursor object holding cursor data |
void Window::SetMouseCursor | ( | SDL_Cursor * | cursor | ) |
Changes the mouse cursor.
[in] | cursor | A pointer to a SDL_Cursor containing cursor data |
void Window::SetMouseCursorGrabbed | ( | bool | grabbed | ) |
Traps the mouse cursor inside the window.
[in] | grabbed | Wether to (un)trap the cursor |
void Window::SetMouseCursorVisible | ( | bool | visible | ) |
Hides/Shows the mouse cursor inside the windos.
[in] | visible | The new visibility of the cursor |
void Window::SetPosition | ( | int | x, |
int | y | ||
) |
Sets a new window position.
[in] | x | The new x position |
[in] | y | The new y position |
void Window::SetPosition | ( | Vector2i | position | ) |
Sets a new window position.
[in] | position | A vector with the new position |
void Window::SetSize | ( | unsigned int | width, |
unsigned int | height | ||
) |
Sets a new window size.
[in] | width | The new width of the window |
[in] | height | The new height of the window |
void Window::SetSize | ( | Vector2u | size | ) |
Sets a new window size.
[in] | size | A vector with the new size |
void Window::SetTitle | ( | std::string | title | ) |
Sets a new window title.
[in] | title | The new window title |
void Window::SetVisible | ( | bool | visible | ) |
Set the windows visibility.
[in] | visible | The new visibility setting |
void Window::SetVsync | ( | bool | vsync | ) |
(De)activates VSync !globally!
[in] | vsync | Wether to enable or disable vsync |
bool Window::WaitEvent | ( | SDL_Event * | event | ) |
A blocking event polling function.
[out] | event | An object to write the latest event to |
|
protected |