1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#ifndef __FLATWINDOW_H__
#define __FLATWINDOW_H__
#include "object.hpp"
#include "serial/keyfocusable.hpp"
#include <string>
class SDL_Window;
class SDL_KeyEvent;
namespace flat {
struct window_status
{
window_status( unsigned char _fullscreen = 0,
unsigned char _hidden = 0,
unsigned char _borderless = 0,
unsigned char _resizable = 1,
unsigned char _minimized = 0,
unsigned char _maximized = 0,
unsigned char _focus = 1)
: fullscreen(_fullscreen), hidden(_hidden), borderless(_borderless),
resizable(_resizable), minimized(_minimized), maximized(_maximized),
focus(_focus) {}
unsigned char fullscreen;
unsigned char hidden;
unsigned char borderless;
unsigned char resizable;
unsigned char minimized;
unsigned char maximized;
unsigned char focus;
};
class FlatLayer;
class FlatWindow : virtual public object, public KeyFocusable
{
private:
std::string m_title;
window_status m_status;
SDL_Rect * m_bounds;
SDL_Window * m_sdl_window;
SDL_Surface * m_screen;
FlatLayer * m_main_layer;
void key_cb(const SDL_KeyboardEvent*) override;
// TODO window calls
//protected:
//virtual void resizeEvent();
//virtual void quitEvent();
public:
FlatWindow(int x, int y,
int width, int height,
const std::string& title,
window_status status = window_status());
FlatWindow( SDL_Rect *bounds, const std::string& title,
window_status status = window_status());
FlatWindow( int width, int height,
const std::string &title,
window_status status = window_status());
FlatWindow(const FlatWindow&);
~FlatWindow();
int open();
void close();
int getWidth() const;
int getHeight() const;
const SDL_Rect * getBounds() const;
SDL_Window * getSDLWindow();
SDL_Surface * getScreenSurface();
const std::string& getTitle() const;
void setTitle(const std::string&);
window_status getWindowStatus() const;
void setWindowStatus(window_status);
static uint32_t winstatus_to_flags(window_status);
};
}
#endif
|