v0.1.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Pages
CGUL::Window Class Reference

A class capable of creating windows and manipulating them. More...

#include <Window.hpp>

Public Member Functions

 Window ()
 Default constructor.
 
virtual ~Window ()
 Deconstructor.
 
void Create (const WindowStyle &style)
 Creates a window based on the given style. More...
 
void Close ()
 Destroys the window.
 
void HandleMessages ()
 Handles system messages and updates input. More...
 
void SetStyle (const WindowStyle &style)
 Updates a window's style. More...
 
WindowStyle GetStyle () const
 Gets some information about the window. More...
 
void SetTitle (const String &title)
 Sets the title of the window. More...
 
String GetTitle () const
 Gets the title of the window. More...
 
void SetBackgroundColor (const Color &color)
 Sets the background color of the window. More...
 
Color GetBackgroundColor () const
 Gets the background color of the window. More...
 
void SetWidth (UInt32 width)
 Sets the width of the window, excluding the border. More...
 
UInt32 GetWidth () const
 Gets the width of the window, excluding the border. More...
 
void SetHeight (UInt32 height)
 Sets the height of the window, excluding the border. More...
 
UInt32 GetHeight () const
 Gets the height of the window, excluding the border. More...
 
void SetSize (const UCoord32 &size) const
 Sets the size of the window, excluding the border. More...
 
UCoord32 GetSize () const
 Gets the size of the window, excluding the border. More...
 
void SetPosition (const SCoord32 &position)
 Sets the position of the window on the screen. More...
 
SCoord32 GetPosition () const
 Gets the position of the window on the screen. More...
 
void SetResizable (Boolean resizable)
 Sets whether the window is resizable or not. More...
 
Boolean GetResizable () const
 Gets whether the window is resizable or not. More...
 
void SetAlwaysOnTop (Boolean alwaysOnTop)
 Sets whether the window is always on top. More...
 
Boolean GetAlwaysOnTop () const
 Gets whether the window is always on top. More...
 
URect32 GetFrameSize () const
 Gets the window's border extents (the frame around the window). More...
 
Boolean IsOpen () const
 Checks if the window is still open. More...
 
Boolean IsFocused () const
 Checks if the window currently has focus. More...
 
void SetMousePosition (SCoord32 mousePosition)
 Sets the mouse position relative to the window.
 
void SetCursorShow (bool show)
 Sets if the mouse is visible in the window or not.
 

Static Public Member Functions

static void Update ()
 Updates all windows in the current application. More...
 

Public Attributes

Event< WindowKeyButtonEventonKeyButton
 
Event< WindowMouseButtonEventonMouseButton
 
Event< WindowMouseMoveEventonMouseMove
 

Friends

class OpenGL::Context
 

Detailed Description

A class capable of creating windows and manipulating them.

Internally this class can work very differently depending on the operating system. Direct calls are made to WinAPI on Microsoft Windows, Cocoa on Mac OS X, and X11 on linux and other unix platforms. Each window api is different, and windows behave differently depending on the desktop environment. Note also that certain X11 environments may wrongfully ignore essential messages resulting in some features not working – this is not an issue with CGUL, but instead with the environment itself.

Member Function Documentation

void CGUL::Window::Create ( const WindowStyle style)

Creates a window based on the given style.

See the tutorial on create_window.

CGUL::Boolean CGUL::Window::GetAlwaysOnTop ( ) const

Gets whether the window is always on top.

Returns
True if always on top, false otherwise.
CGUL::Color CGUL::Window::GetBackgroundColor ( ) const

Gets the background color of the window.

Returns
The window's background color.
CGUL::URect32 CGUL::Window::GetFrameSize ( ) const

Gets the window's border extents (the frame around the window).

Returns
A vector containing the border extents.
CGUL::UInt32 CGUL::Window::GetHeight ( ) const

Gets the height of the window, excluding the border.

Returns
The height of the window.
CGUL::SCoord32 CGUL::Window::GetPosition ( ) const

Gets the position of the window on the screen.

Returns
The position of the window.
CGUL::Boolean CGUL::Window::GetResizable ( ) const

Gets whether the window is resizable or not.

Returns
True if resizable, false otherwise.
CGUL::UCoord32 CGUL::Window::GetSize ( ) const

Gets the size of the window, excluding the border.

Returns
The size of the window.
CGUL::WindowStyle CGUL::Window::GetStyle ( ) const

Gets some information about the window.

Returns
A WindowStyle structure.
CGUL::String CGUL::Window::GetTitle ( ) const

Gets the title of the window.

Returns
The window title.
CGUL::UInt32 CGUL::Window::GetWidth ( ) const

Gets the width of the window, excluding the border.

Returns
The width of the window.
void CGUL::Window::HandleMessages ( )

Handles system messages and updates input.

This method acts a little bit differently on each operating system. It is important to call this every tick for every window.

CGUL::Boolean CGUL::Window::IsFocused ( ) const

Checks if the window currently has focus.

Warning
Can be weird on Mac when running an application from the console. Macs have two forms of focus and when an application is launced through a terminal it gets a little wonky.
Returns
True if the window is focused, false otherwise.
bool CGUL::Window::IsOpen ( ) const

Checks if the window is still open.

Returns
False if the window has been closed, true if it is still open.
void CGUL::Window::SetAlwaysOnTop ( Boolean  alwaysOnTop)

Sets whether the window is always on top.

Parameters
alwaysOnTopTrue for always on top, false otherwise.
void CGUL::Window::SetBackgroundColor ( const Color color)

Sets the background color of the window.

Parameters
colorThe new background color.
void CGUL::Window::SetHeight ( UInt32  height)

Sets the height of the window, excluding the border.

Parameters
heightThe new height of the window.
void CGUL::Window::SetPosition ( const SCoord32 position)

Sets the position of the window on the screen.

Parameters
positionThe new position of the window.
void CGUL::Window::SetResizable ( Boolean  resizable)

Sets whether the window is resizable or not.

Parameters
resizableTrue for resizable, false otherwise.
void CGUL::Window::SetSize ( const UCoord32 size) const

Sets the size of the window, excluding the border.

Returns
The new size of the window.
void CGUL::Window::SetStyle ( const WindowStyle style)

Updates a window's style.

Parameters
styleThe style structure.

This method will reset all elements within the WindowStyle, not only those which have changed. It can be used to "backup" a window at a given state and then reset to it later. Alternatively, it is possible to grab the current style with GetStyle and then modify individual elements, and pass it back into SetStyle.

void CGUL::Window::SetTitle ( const String title)

Sets the title of the window.

Parameters
titleThe new title string.
void CGUL::Window::SetWidth ( UInt32  width)

Sets the width of the window, excluding the border.

Parameters
widthThe new width of the window.
void CGUL::Window::Update ( )
static

Updates all windows in the current application.

The operating system usually handles windows under the same application in bulk. For this reason, it is only necessary to call update once for every window. It is still important to update a window's input manually, however.

See Also
UpdateInput

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