]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/window.h
Add decorations for things which should be exported from the library
[libs/gui.git] / source / graphics / window.h
1 #ifndef MSP_GRAPHICS_WINDOW_H_
2 #define MSP_GRAPHICS_WINDOW_H_
3
4 #include <string>
5 #include <sigc++/signal.h>
6 #include "mspgui_api.h"
7
8 namespace Msp {
9 namespace Graphics {
10
11 class Display;
12 struct Monitor;
13
14 struct WindowOptions
15 {
16         int x = 0;
17         int y = 0;
18         bool user_position = false;
19         unsigned width = 640;
20         unsigned height = 480;
21         bool fullscreen = false;
22         const Monitor *fullscreen_monitor = nullptr;
23         bool fullscreen_exclusive = true;
24         bool resizable = false;
25 };
26
27 class MSPGUI_API Window
28 {
29 public:
30         struct Private;
31         struct Event;
32
33         /** Provides input events.  The event structure contents are platform-
34         specific.  Applications will want to use the enclosed Keyboard and Mouse
35         objects instead. */
36         sigc::signal<void, const Event &> signal_input_event;
37
38         sigc::signal<void> signal_got_focus;
39         sigc::signal<void> signal_lost_focus;
40
41         sigc::signal<void, int, int> signal_move;
42         sigc::signal<void, unsigned, unsigned> signal_resize;
43         sigc::signal<void, unsigned, unsigned, unsigned, unsigned, const Event &> signal_expose;
44         sigc::signal<void> signal_close;
45
46 protected:
47         Display &display;
48         WindowOptions options;
49         bool visible = false;
50         bool kbd_autorepeat = true;
51         bool touch_input = false;
52         bool resizing = false;
53         bool moving = false;
54         Private *priv = nullptr;
55
56 public:
57         Window(Display &, unsigned w, unsigned h, bool fs = false);
58         Window(Display &, const WindowOptions &);
59 private:
60         void init();
61         void platform_init();
62         void platform_cleanup();
63 public:
64         ~Window();
65
66         void set_title(const std::string &);
67         void reconfigure(const WindowOptions &);
68 private:
69         void set_fullscreen_mode();
70         void platform_reconfigure(bool);
71 public:
72         void set_keyboard_autorepeat(bool);
73         bool get_keyboard_autorepeat() const { return kbd_autorepeat; }
74         void show_cursor(bool);
75         void warp_pointer(int, int);
76         void set_touch_input(bool);
77 private:
78         void platform_set_touch_input();
79 public:
80         bool get_touch_input() const { return touch_input; }
81
82         Display &get_display() const { return display; }
83         const WindowOptions &get_options() const { return options; }
84         unsigned get_width() const { return options.width; }
85         unsigned get_height() const { return options.height; }
86         const Private &get_private() const { return *priv; }
87
88         void show();
89         void hide();
90 private:
91         void platform_show();
92         void platform_hide();
93
94 public:
95         bool event(const Event &evnt);
96 };
97
98 } // namespace Graphics
99 } // namespace Msp
100
101 #endif