SFML - Simple and Fast Multimedia Library

SFML 2.5.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Window/Window.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 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
31#include <SFML/Window/ContextSettings.hpp>
32#include <SFML/Window/Cursor.hpp>
33#include <SFML/Window/Export.hpp>
34#include <SFML/Window/GlResource.hpp>
35#include <SFML/Window/VideoMode.hpp>
36#include <SFML/Window/WindowHandle.hpp>
37#include <SFML/Window/WindowStyle.hpp>
38#include <SFML/System/Clock.hpp>
39#include <SFML/System/NonCopyable.hpp>
40#include <SFML/System/String.hpp>
41#include <SFML/System/Vector2.hpp>
42
43
44namespace sf
45{
46namespace priv
47{
48 class GlContext;
49 class WindowImpl;
50}
51
52class Event;
53
58 class SFML_WINDOW_API Window : GlResource, NonCopyable
59{
60public:
61
69 Window();
70
90 Window(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
91
106 explicit Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());
107
114 virtual ~Window();
115
133 void create(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
134
150 void create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
151
162 void close();
163
174 bool isOpen() const;
175
187 const ContextSettings& getSettings() const;
188
212 bool pollEvent(Event& event);
213
239 bool waitEvent(Event& event);
240
249 Vector2i getPosition() const;
250
263 void setPosition(const Vector2i& position);
264
276 Vector2u getSize() const;
277
286 void setSize(const Vector2u& size);
287
296 void setTitle(const String& title);
297
315 void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
316
325 void setVisible(bool visible);
326
340 void setVerticalSyncEnabled(bool enabled);
341
350 void setMouseCursorVisible(bool visible);
351
363 void setMouseCursorGrabbed(bool grabbed);
364
382 void setMouseCursor(const Cursor& cursor);
383
396 void setKeyRepeatEnabled(bool enabled);
397
413 void setFramerateLimit(unsigned int limit);
414
426 void setJoystickThreshold(float threshold);
427
444 bool setActive(bool active = true) const;
445
460 void requestFocus();
461
473 bool hasFocus() const;
474
483 void display();
484
497 WindowHandle getSystemHandle() const;
498
499protected:
500
509 virtual void onCreate();
510
518 virtual void onResize();
519
520private:
521
534 bool filterEvent(const Event& event);
535
540 void initialize();
541
543 // Member data
545 priv::WindowImpl* m_impl;
546 priv::GlContext* m_context;
547 Clock m_clock;
548 Time m_frameTimeLimit;
549 Vector2u m_size;
550};
551
552} // namespace sf
553
554
555#endif // SFML_WINDOW_HPP
556
557
sf::Clock
Utility class that measures the elapsed time.
Definition: Clock.hpp:42
sf::Cursor
Cursor defines the appearance of a system cursor.
Definition: Cursor.hpp:47
sf::Event
Defines a system event and its parameters.
Definition: Event.hpp:45
sf::GlResource
Base class for classes that require an OpenGL context.
Definition: GlResource.hpp:47
sf::NonCopyable
Utility class that makes any derived class non-copyable.
Definition: NonCopyable.hpp:42
sf::String
Utility string class that automatically handles conversions between types and encodings.
Definition: String.hpp:46
sf::Time
Represents a time value.
Definition: Time.hpp:41
sf::Vector2
Utility template class for manipulating 2-dimensional vectors.
Definition: Vector2.hpp:38
sf::VideoMode
VideoMode defines a video mode (width, height, bpp)
Definition: VideoMode.hpp:42
sf::Window
Window that serves as a target for OpenGL rendering.
Definition: Window/Window.hpp:59
sf::Window::getSettings
const ContextSettings & getSettings() const
Get the settings of the OpenGL context of the window.
sf::Window::onCreate
virtual void onCreate()
Function called after the window has been created.
sf::Window::onResize
virtual void onResize()
Function called after the window has been resized.
sf::Window::setVisible
void setVisible(bool visible)
Show or hide the window.
sf::Window::Window
Window(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Construct a new window.
sf::Window::create
void create(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window.
sf::Window::pollEvent
bool pollEvent(Event &event)
Pop the event on top of the event queue, if any, and return it.
sf::Window::getSize
Vector2u getSize() const
Get the size of the rendering region of the window.
sf::Window::setTitle
void setTitle(const String &title)
Change the title of the window.
sf::Window::getPosition
Vector2i getPosition() const
Get the position of the window.
sf::Window::Window
Window()
Default constructor.
sf::Window::requestFocus
void requestFocus()
Request the current window to be made the active foreground window.
sf::Window::setVerticalSyncEnabled
void setVerticalSyncEnabled(bool enabled)
Enable or disable vertical synchronization.
sf::Window::setMouseCursorGrabbed
void setMouseCursorGrabbed(bool grabbed)
Grab or release the mouse cursor.
sf::Window::setIcon
void setIcon(unsigned int width, unsigned int height, const Uint8 *pixels)
Change the window's icon.
sf::Window::setPosition
void setPosition(const Vector2i &position)
Change the position of the window on screen.
sf::Window::Window
Window(WindowHandle handle, const ContextSettings &settings=ContextSettings())
Construct the window from an existing control.
sf::Window::close
void close()
Close the window and destroy all the attached resources.
sf::Window::setJoystickThreshold
void setJoystickThreshold(float threshold)
Change the joystick threshold.
sf::Window::setActive
bool setActive(bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
sf::Window::setMouseCursor
void setMouseCursor(const Cursor &cursor)
Set the displayed cursor to a native system cursor.
sf::Window::setMouseCursorVisible
void setMouseCursorVisible(bool visible)
Show or hide the mouse cursor.
sf::Window::waitEvent
bool waitEvent(Event &event)
Wait for an event and return it.
sf::Window::setSize
void setSize(const Vector2u &size)
Change the size of the rendering region of the window.
sf::Window::~Window
virtual ~Window()
Destructor.
sf::Window::create
void create(WindowHandle handle, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window from an existing control.
sf::Window::getSystemHandle
WindowHandle getSystemHandle() const
Get the OS-specific handle of the window.
sf::Window::hasFocus
bool hasFocus() const
Check whether the window has the input focus.
sf::Window::display
void display()
Display on screen what has been rendered to the window so far.
sf::Window::isOpen
bool isOpen() const
Tell whether or not the window is open.
sf::Window::setKeyRepeatEnabled
void setKeyRepeatEnabled(bool enabled)
Enable or disable automatic key-repeat.
sf::Window::setFramerateLimit
void setFramerateLimit(unsigned int limit)
Limit the framerate to a maximum fixed frequency.
sf::WindowHandle
platform specific WindowHandle
Define a low-level window handle type, specific to each platform.
Definition: WindowHandle.hpp:68
sf::Style::Default
@ Default
Default window style.
Definition: WindowStyle.hpp:46
sf::ContextSettings
Structure defining the settings of the OpenGL context attached to a window.
Definition: ContextSettings.hpp:38