]> git.tdb.fi Git - libs/gui.git/blob - source/window.h
1047038366917854f776f22fae72de60e87ad480
[libs/gui.git] / source / window.h
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007 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 "types.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
31 {
32 public:
33         sigc::signal<void, int, int, unsigned, unsigned> signal_button_press;
34         sigc::signal<void, int, int, unsigned, unsigned> signal_button_release;
35         sigc::signal<void, int, int> signal_pointer_motion;
36         sigc::signal<void, unsigned, unsigned, unsigned> signal_key_press;
37         sigc::signal<void, unsigned, unsigned> signal_key_release;
38         sigc::signal<void, unsigned, unsigned> signal_resize;
39         sigc::signal<void> signal_close;
40
41 protected:
42         Display &display;
43         WindowOptions options;
44         WindowHandle window;
45         Atom wm_delete_window;
46
47 public:
48         Window(Display &, unsigned w, unsigned h, bool fs=false);
49         Window(Display &, const WindowOptions &);
50         ~Window();
51
52         void set_title(const std::string &);
53
54         unsigned get_width() const  { return options.width; }
55         unsigned get_height() const { return options.height; }
56         WindowHandle get_handle() const { return window; }
57
58         void show();
59         void hide();
60
61         void event(const XEvent &ev);
62 protected:
63         void init();
64 };
65
66 } // namespace Graphics
67 } // namespace Msp
68
69 #endif