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