Loading...
Searching...
No Matches
Window/Window.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_WINDOW_HPP
26#define SFML_WINDOW_HPP
27
29// Headers
31#include <SFML/Window/Event.hpp>
32#include <SFML/Window/Input.hpp>
38#include <SFML/System/Clock.hpp>
40#include <queue>
41#include <string>
42
43
44namespace sf
45{
46namespace priv
47{
48 class WindowImpl;
49}
50
56{
57public :
58
64
74 Window(VideoMode Mode, const std::string& Title, unsigned long WindowStyle = Style::Resize | Style::Close, const WindowSettings& Params = WindowSettings());
75
83 Window(WindowHandle Handle, const WindowSettings& Params = WindowSettings());
84
89 virtual ~Window();
90
100 void Create(VideoMode Mode, const std::string& Title, unsigned long WindowStyle = Style::Resize | Style::Close, const WindowSettings& Params = WindowSettings());
101
109 void Create(WindowHandle Handle, const WindowSettings& Params = WindowSettings());
110
117 void Close();
118
127 bool IsOpened() const;
128
135 unsigned int GetWidth() const;
136
143 unsigned int GetHeight() const;
144
152
161 bool GetEvent(Event& EventReceived);
162
169 void UseVerticalSync(bool Enabled);
170
178
186 void SetCursorPosition(unsigned int Left, unsigned int Top);
187
196 void SetPosition(int Left, int Top);
197
205 void SetSize(unsigned int Width, unsigned int Height);
206
213 void Show(bool State);
214
222 void EnableKeyRepeat(bool Enabled);
223
232 void SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels);
233
243 bool SetActive(bool Active = true) const;
244
249 void Display();
250
257 const Input& GetInput() const;
258
265 void SetFramerateLimit(unsigned int Limit);
266
273 float GetFrameTime() const;
274
282 void SetJoystickThreshold(float Threshold);
283
284private :
285
290 virtual void OnCreate();
291
298 virtual void OnEvent(const Event& EventReceived);
299
306 void Initialize(priv::WindowImpl* Impl);
307
309 // Member data
311 priv::WindowImpl* myWindow;
312 std::queue<Event> myEvents;
313 Input myInput;
314 Clock myClock;
315 WindowSettings mySettings;
316 float myLastFrameTime;
317 bool myIsExternal;
318 unsigned int myFramerateLimit;
319 int mySetCursorPosX;
320 int mySetCursorPosY;
321};
322
323} // namespace sf
324
325
326#endif // SFML_WINDOW_HPP
#define SFML_API
Definition Config.hpp:114
Clock is an utility class for manipulating time.
Definition Clock.hpp:40
Event defines a system event and its parameters.
Definition Event.hpp:198
Input handles real-time input from keyboard and mouse.
Definition Input.hpp:45
VideoMode defines a video mode (width, height, bpp, frequency) and provides static functions for gett...
Definition VideoMode.hpp:43
Base class for classes that want to receive events from a window (for internal use only).
const Input & GetInput() const
Get the input manager of the window.
unsigned int GetWidth() const
Get the width of the rendering region of the window.
void SetCursorPosition(unsigned int Left, unsigned int Top)
Change the position of the mouse cursor.
void SetIcon(unsigned int Width, unsigned int Height, const Uint8 *Pixels)
Change the window's icon.
void SetPosition(int Left, int Top)
Change the position of the window on screen.
void EnableKeyRepeat(bool Enabled)
Enable or disable automatic key-repeat.
float GetFrameTime() const
Get time elapsed since last frame.
Window()
Default constructor.
void SetFramerateLimit(unsigned int Limit)
Limit the framerate to a maximum fixed frequency.
void Create(WindowHandle Handle, const WindowSettings &Params=WindowSettings())
Create (or recreate) the window from an existing control.
void ShowMouseCursor(bool Show)
Show or hide the mouse cursor.
bool GetEvent(Event &EventReceived)
Get the event on top of events stack, if any, and pop it.
void Show(bool State)
Show or hide the window.
Window(VideoMode Mode, const std::string &Title, unsigned long WindowStyle=Style::Resize|Style::Close, const WindowSettings &Params=WindowSettings())
Construct a new window.
bool SetActive(bool Active=true) const
Activate of deactivate the window as the current target for rendering.
void Create(VideoMode Mode, const std::string &Title, unsigned long WindowStyle=Style::Resize|Style::Close, const WindowSettings &Params=WindowSettings())
Create (or recreate) the window.
void Close()
Close (destroy) the window.
virtual ~Window()
Destructor.
unsigned int GetHeight() const
Get the height of the rendering region of the window.
void UseVerticalSync(bool Enabled)
Enable / disable vertical synchronization.
void SetJoystickThreshold(float Threshold)
Change the joystick threshold, ie.
void SetSize(unsigned int Width, unsigned int Height)
Change the size of the rendering region of the window.
bool IsOpened() const
Tell whether or not the window is opened (ie.
void Display()
Display the window on screen.
Window(WindowHandle Handle, const WindowSettings &Params=WindowSettings())
Construct the window from an existing control.
const WindowSettings & GetSettings() const
Get the creation settings of the window.
@ Resize
Titlebar + resizable border + maximize button.
@ Close
Titlebar + close button.
NonCopyable()
The default constructor won't be generated, so provide it.
Structure defining the creation settings of windows.