]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/window.h
Allow configuring window positions as well
[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, int, int> signal_move;
37         sigc::signal<void, unsigned, unsigned> signal_resize;
38         sigc::signal<void, unsigned, unsigned, unsigned, unsigned, const Event &> signal_expose;
39         sigc::signal<void> signal_close;
40
41 protected:
42         Display &display;
43         WindowOptions options;
44         bool visible;
45         bool kbd_autorepeat;
46         bool touch_input;
47         bool resizing;
48         bool moving;
49         Private *priv;
50
51 public:
52         Window(Display &, unsigned w, unsigned h, bool fs = false);
53         Window(Display &, const WindowOptions &);
54 private:
55         void init();
56         void platform_init();
57         void platform_cleanup();
58 public:
59         virtual ~Window();
60
61         void set_title(const std::string &);
62         void reconfigure(const WindowOptions &);
63 private:
64         void platform_reconfigure(bool);
65 public:
66         void set_keyboard_autorepeat(bool);
67         bool get_keyboard_autorepeat() const { return kbd_autorepeat; }
68         void show_cursor(bool);
69         void warp_pointer(int, int);
70         void set_touch_input(bool);
71 private:
72         void platform_set_touch_input();
73 public:
74         bool get_touch_input() const { return touch_input; }
75
76         Display &get_display() const { return display; }
77         const WindowOptions &get_options() const { return options; }
78         virtual unsigned get_width() const { return options.width; }
79         virtual unsigned get_height() const { return options.height; }
80         const Private &get_private() const { return *priv; }
81
82         void show();
83         void hide();
84 private:
85         void platform_show();
86         void platform_hide();
87
88 public:
89         bool event(const Event &evnt);
90 };
91
92 } // namespace Graphics
93 } // namespace Msp
94
95 #endif