]> git.tdb.fi Git - libs/gui.git/blob - source/gbase/window.h
9fa0734ae4675cbcf196a491548810c2abdb6fff
[libs/gui.git] / source / gbase / window.h
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007-2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GBASE_WINDOW_H_
9 #define MSP_GBASE_WINDOW_H_
10
11 #include <string>
12 #include <sigc++/signal.h>
13 #include "eventsource.h"
14
15 namespace Msp {
16 namespace Graphics {
17
18 class Display;
19
20 struct WindowOptions
21 {
22         unsigned width;
23         unsigned height;
24         bool fullscreen;
25         bool resizable;
26
27         WindowOptions();
28 };
29
30 class Window: public EventSource
31 {
32 public:
33         struct Private;
34         struct Event;
35
36         sigc::signal<void> signal_close;
37
38 protected:
39         Display &display;
40         WindowOptions options;
41         bool visible;
42         bool kbd_autorepeat;
43         bool resizing;
44         Private *priv;
45
46 public:
47         Window(Display &, unsigned w, unsigned h, bool fs=false);
48         Window(Display &, const WindowOptions &);
49 private:
50         void init();
51 public:
52         virtual ~Window();
53
54         void set_title(const std::string &);
55         void reconfigure(const WindowOptions &);
56         void set_keyboard_autorepeat(bool);
57         bool get_keyboard_autorepeat() const { return kbd_autorepeat; }
58         void show_cursor(bool);
59         void warp_pointer(int, int);
60
61         Display &get_display() const { return display; }
62         const WindowOptions &get_options() const { return options; }
63         virtual unsigned get_width() const { return options.width; }
64         virtual unsigned get_height() const { return options.height; }
65         const Private &get_private() const { return *priv; }
66
67         void show();
68         void hide();
69
70         bool event(const Event &evnt);
71 };
72
73 } // namespace Graphics
74 } // namespace Msp
75
76 #endif