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-2017 Laurent Gomila (laurent@sfml-dev.org)
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
37#include <SFML/System/Clock.hpp>
41
42
43namespace sf
44{
45namespace priv
46{
47 class GlContext;
48 class WindowImpl;
49}
50
51class Event;
52
58{
59public:
60
69
89 Window(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
90
105 explicit Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());
106
113 virtual ~Window();
114
132 void create(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
133
149 void create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
150
161 void close();
162
173 bool isOpen() const;
174
187
211 bool pollEvent(Event& event);
212
238 bool waitEvent(Event& event);
239
249
262 void setPosition(const Vector2i& position);
263
276
285 void setSize(const Vector2u& size);
286
295 void setTitle(const String& title);
296
314 void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
315
324 void setVisible(bool visible);
325
339 void setVerticalSyncEnabled(bool enabled);
340
349 void setMouseCursorVisible(bool visible);
350
362 void setMouseCursorGrabbed(bool grabbed);
363
376 void setKeyRepeatEnabled(bool enabled);
377
393 void setFramerateLimit(unsigned int limit);
394
406 void setJoystickThreshold(float threshold);
407
424 bool setActive(bool active = true) const;
425
441
453 bool hasFocus() const;
454
463 void display();
464
478
479protected:
480
489 virtual void onCreate();
490
498 virtual void onResize();
499
500private:
501
514 bool filterEvent(const Event& event);
515
520 void initialize();
521
523 // Member data
525 priv::WindowImpl* m_impl;
526 priv::GlContext* m_context;
527 Clock m_clock;
528 Time m_frameTimeLimit;
529 Vector2u m_size;
530};
531
532} // namespace sf
533
534
535#endif // SFML_WINDOW_HPP
536
537
#define SFML_WINDOW_API
Utility class that measures the elapsed time.
Definition Clock.hpp:42
Defines a system event and its parameters.
Definition Event.hpp:45
GlResource()
Default constructor.
NonCopyable()
Default constructor.
Utility string class that automatically handles conversions between types and encodings.
Definition String.hpp:46
Represents a time value.
Definition Time.hpp:41
VideoMode defines a video mode (width, height, bpp).
Definition VideoMode.hpp:42
const ContextSettings & getSettings() const
Get the settings of the OpenGL context of the window.
virtual void onCreate()
Function called after the window has been created.
virtual void onResize()
Function called after the window has been resized.
void setVisible(bool visible)
Show or hide the window.
Window(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Construct a new window.
void create(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window.
bool pollEvent(Event &event)
Pop the event on top of the event queue, if any, and return it.
Vector2u getSize() const
Get the size of the rendering region of the window.
void setTitle(const String &title)
Change the title of the window.
Vector2i getPosition() const
Get the position of the window.
Window()
Default constructor.
void requestFocus()
Request the current window to be made the active foreground window.
void setVerticalSyncEnabled(bool enabled)
Enable or disable vertical synchronization.
void setMouseCursorGrabbed(bool grabbed)
Grab or release the mouse cursor.
void setIcon(unsigned int width, unsigned int height, const Uint8 *pixels)
Change the window's icon.
void setPosition(const Vector2i &position)
Change the position of the window on screen.
Window(WindowHandle handle, const ContextSettings &settings=ContextSettings())
Construct the window from an existing control.
void close()
Close the window and destroy all the attached resources.
void setJoystickThreshold(float threshold)
Change the joystick threshold.
bool setActive(bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
void setMouseCursorVisible(bool visible)
Show or hide the mouse cursor.
bool waitEvent(Event &event)
Wait for an event and return it.
void setSize(const Vector2u &size)
Change the size of the rendering region of the window.
virtual ~Window()
Destructor.
void create(WindowHandle handle, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window from an existing control.
WindowHandle getSystemHandle() const
Get the OS-specific handle of the window.
bool hasFocus() const
Check whether the window has the input focus.
void display()
Display on screen what has been rendered to the window so far.
bool isOpen() const
Tell whether or not the window is open.
void setKeyRepeatEnabled(bool enabled)
Enable or disable automatic key-repeat.
void setFramerateLimit(unsigned int limit)
Limit the framerate to a maximum fixed frequency.
platform–specific WindowHandle
Define a low-level window handle type, specific to each platform.
@ Default
Default window style.
unsigned char Uint8
Definition Config.hpp:209
unsigned int Uint32
Definition Config.hpp:217
Vector2< unsigned int > Vector2u
Definition Vector2.hpp:254
Vector2< int > Vector2i
Definition Vector2.hpp:253
Structure defining the settings of the OpenGL context attached to a window.