SFML - Simple and Fast Multimedia Library

SFML 2.6.0

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

- File List
- File Members

Loading...
Searching...
No Matches
WindowBase.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 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_WINDOWBASE_HPP
26#define SFML_WINDOWBASE_HPP
27
29// Headers
31#include <SFML/Window/Cursor.hpp>
32#include <SFML/Window/Export.hpp>
33#include <SFML/Window/VideoMode.hpp>
34#include <SFML/Window/Vulkan.hpp>
35#include <SFML/Window/WindowHandle.hpp>
36#include <SFML/Window/WindowStyle.hpp>
37#include <SFML/System/Clock.hpp>
38#include <SFML/System/NonCopyable.hpp>
39#include <SFML/System/String.hpp>
40#include <SFML/System/Vector2.hpp>
41
42
43namespace sf
44{
45namespace priv
46{
47 class WindowImpl;
48}
49
50class Event;
51
56 class SFML_WINDOW_API WindowBase : NonCopyable
57{
58public:
59
67 WindowBase();
68
83 WindowBase(VideoMode mode, const String& title, Uint32 style = Style::Default);
84
91 explicit WindowBase(WindowHandle handle);
92
99 virtual ~WindowBase();
100
113 virtual void create(VideoMode mode, const String& title, Uint32 style = Style::Default);
114
121 virtual void create(WindowHandle handle);
122
133 virtual void close();
134
145 bool isOpen() const;
146
170 bool pollEvent(Event& event);
171
197 bool waitEvent(Event& event);
198
207 Vector2i getPosition() const;
208
221 void setPosition(const Vector2i& position);
222
234 Vector2u getSize() const;
235
244 void setSize(const Vector2u& size);
245
254 void setTitle(const String& title);
255
273 void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
274
283 void setVisible(bool visible);
284
293 void setMouseCursorVisible(bool visible);
294
306 void setMouseCursorGrabbed(bool grabbed);
307
325 void setMouseCursor(const Cursor& cursor);
326
339 void setKeyRepeatEnabled(bool enabled);
340
352 void setJoystickThreshold(float threshold);
353
368 void requestFocus();
369
381 bool hasFocus() const;
382
395 WindowHandle getSystemHandle() const;
396
407 bool createVulkanSurface(const VkInstance& instance, VkSurfaceKHR& surface, const VkAllocationCallbacks* allocator = 0);
408
409protected:
410
419 virtual void onCreate();
420
428 virtual void onResize();
429
430private:
431
432 friend class Window;
433
446 bool filterEvent(const Event& event);
447
452 void initialize();
453
460 const WindowBase* getFullscreenWindow();
461
468 void setFullscreenWindow(const WindowBase* window);
469
471 // Member data
473 priv::WindowImpl* m_impl;
474 Vector2u m_size;
475};
476
477} // namespace sf
478
479
480#endif // SFML_WINDOWBASE_HPP
481
482
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::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::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::WindowBase
Window that serves as a base for other windows.
Definition WindowBase.hpp:57
sf::WindowBase::setMouseCursorGrabbed
void setMouseCursorGrabbed(bool grabbed)
Grab or release the mouse cursor.
sf::WindowBase::setMouseCursor
void setMouseCursor(const Cursor &cursor)
Set the displayed cursor to a native system cursor.
sf::WindowBase::WindowBase
WindowBase()
Default constructor.
sf::WindowBase::getSize
Vector2u getSize() const
Get the size of the rendering region of the window.
sf::WindowBase::onCreate
virtual void onCreate()
Function called after the window has been created.
sf::WindowBase::create
virtual void create(VideoMode mode, const String &title, Uint32 style=Style::Default)
Create (or recreate) the window.
sf::WindowBase::requestFocus
void requestFocus()
Request the current window to be made the active foreground window.
sf::WindowBase::createVulkanSurface
bool createVulkanSurface(const VkInstance &instance, VkSurfaceKHR &surface, const VkAllocationCallbacks *allocator=0)
Create a Vulkan rendering surface.
sf::WindowBase::create
virtual void create(WindowHandle handle)
Create (or recreate) the window from an existing control.
sf::WindowBase::setVisible
void setVisible(bool visible)
Show or hide the window.
sf::WindowBase::getPosition
Vector2i getPosition() const
Get the position of the window.
sf::WindowBase::pollEvent
bool pollEvent(Event &event)
Pop the event on top of the event queue, if any, and return it.
sf::WindowBase::~WindowBase
virtual ~WindowBase()
Destructor.
sf::WindowBase::setSize
void setSize(const Vector2u &size)
Change the size of the rendering region of the window.
sf::WindowBase::onResize
virtual void onResize()
Function called after the window has been resized.
sf::WindowBase::close
virtual void close()
Close the window and destroy all the attached resources.
sf::WindowBase::waitEvent
bool waitEvent(Event &event)
Wait for an event and return it.
sf::WindowBase::isOpen
bool isOpen() const
Tell whether or not the window is open.
sf::WindowBase::WindowBase
WindowBase(VideoMode mode, const String &title, Uint32 style=Style::Default)
Construct a new window.
sf::WindowBase::WindowBase
WindowBase(WindowHandle handle)
Construct the window from an existing control.
sf::WindowBase::setPosition
void setPosition(const Vector2i &position)
Change the position of the window on screen.
sf::WindowBase::setTitle
void setTitle(const String &title)
Change the title of the window.
sf::WindowBase::setJoystickThreshold
void setJoystickThreshold(float threshold)
Change the joystick threshold.
sf::WindowBase::hasFocus
bool hasFocus() const
Check whether the window has the input focus.
sf::WindowBase::setIcon
void setIcon(unsigned int width, unsigned int height, const Uint8 *pixels)
Change the window's icon.
sf::WindowBase::getSystemHandle
WindowHandle getSystemHandle() const
Get the OS-specific handle of the window.
sf::WindowBase::setMouseCursorVisible
void setMouseCursorVisible(bool visible)
Show or hide the mouse cursor.
sf::WindowBase::setKeyRepeatEnabled
void setKeyRepeatEnabled(bool enabled)
Enable or disable automatic key-repeat.
sf::Window
Window that serves as a target for OpenGL rendering.
Definition Window/Window.hpp:50