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