libSDL2pp
C++11 bindings/wrapper for SDL2
Window.hh
1/*
2 libSDL2pp - C++11 bindings/wrapper for SDL2
3 Copyright (C) 2013-2017 Dmitry Marakasov <amdmi3@amdmi3.ru>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 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
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef SDL2PP_WINDOW_HH
23#define SDL2PP_WINDOW_HH
24
25#include <string>
26
27#include <SDL_version.h>
28#include <SDL_stdinc.h>
29#include <SDL_video.h>
30
31#include <SDL2pp/Point.hh>
32#include <SDL2pp/Export.hh>
33
34struct SDL_Window;
35
36namespace SDL2pp {
37
38class Surface;
39
67class SDL2PP_EXPORT Window {
68private:
69 SDL_Window* window_;
70
71public:
78 explicit Window(SDL_Window* window);
79
95 Window(const std::string& title, int x, int y, int w, int h, Uint32 flags);
96
103 virtual ~Window();
104
111 Window(Window&& other) noexcept;
112
121 Window& operator=(Window&& other) noexcept;
122
129 Window(const Window& other) = delete;
130
137 Window& operator=(const Window& other) = delete;
138
145 SDL_Window* Get() const;
146
156 Point GetSize() const;
157
166 int GetWidth() const;
167
176 int GetHeight() const;
177
187 Point GetDrawableSize() const;
188
197 int GetDrawableWidth() const;
198
207 int GetDrawableHeight() const;
208
219 Window& SetTitle(const std::string& title);
220
229 std::string GetTitle() const;
230
239 Window& Maximize();
240
249 Window& Minimize();
250
259 Window& Hide();
260
269 Window& Restore();
270
279 Window& Raise();
280
289 Window& Show();
290
303 Window& SetFullscreen(Uint32 flags);
304
316 Window& SetSize(int w, int h);
317
328 Window& SetSize(const Point& size);
329
338 float GetBrightness() const;
339
352 Window& SetBrightness(float brightness);
353
362 Point GetPosition() const;
363
375 Window& SetPosition(int x, int y);
376
387 Window& SetPosition(const Point& pos);
388
397 Point GetMinimumSize() const;
398
410 Window& SetMinimumSize(int w, int h);
411
422 Window& SetMinimumSize(const Point& size);
423
432 Point GetMaximumSize() const;
433
445 Window& SetMaximumSize(int w, int h);
446
457 Window& SetMaximumSize(const Point& size);
458
467 bool GetGrab() const;
468
479 Window& SetGrab(bool grabbed);
480
491 int GetDisplayIndex() const;
492
505 void GetDisplayMode(SDL_DisplayMode& mode) const;
506
515 Uint32 GetFlags() const;
516
529 Window& SetIcon(const Surface& icon);
530
541 Window& SetBordered(bool bordered = true);
542
543#if SDL_VERSION_ATLEAST(2, 0, 5)
556 Window& SetOpacity(float opacity = 1.0f);
557
568 float GetOpacity() const;
569
580 Window& SetResizable(bool resizable = true);
581#endif
582};
583
584}
585
586#endif
2D point
Definition: Point.hh:51
Image stored in system memory with direct access to pixel data.
Definition: Surface.hh:53
GUI window object.
Definition: Window.hh:67
Window & operator=(const Window &other)=delete
Deleted assignment operator.
Window(const Window &other)=delete
Deleted copy constructor.