]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/window.h
2d4376e1761baf82c7e59316b7823e5436721d9b
[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 platform_reconfigure(bool);
68 public:
69         void set_keyboard_autorepeat(bool);
70         bool get_keyboard_autorepeat() const { return kbd_autorepeat; }
71         void show_cursor(bool);
72         void warp_pointer(int, int);
73         void set_touch_input(bool);
74 private:
75         void platform_set_touch_input();
76 public:
77         bool get_touch_input() const { return touch_input; }
78
79         Display &get_display() const { return display; }
80         const WindowOptions &get_options() const { return options; }
81         virtual unsigned get_width() const { return options.width; }
82         virtual unsigned get_height() const { return options.height; }
83         const Private &get_private() const { return *priv; }
84
85         void show();
86         void hide();
87 private:
88         void platform_show();
89         void platform_hide();
90
91 public:
92         bool event(const Event &evnt);
93 };
94
95 } // namespace Graphics
96 } // namespace Msp
97
98 #endif