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