]> git.tdb.fi Git - libs/gui.git/blob - source/window.h
Initial revision
[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 <X11/Xlib.h>
13 #include <sigc++/signal.h>
14
15 namespace Msp {
16
17 struct DisplayOptions
18 {
19         std::string display;
20         unsigned width;
21         unsigned height;
22         bool fullscreen;
23
24         DisplayOptions();
25 };
26
27 class Window
28 {
29 public:
30         sigc::signal<void, int, int, unsigned, unsigned> signal_button_press;
31         sigc::signal<void, int, int, unsigned, unsigned> signal_button_release;
32         sigc::signal<void, int, int> signal_pointer_motion;
33         sigc::signal<void, unsigned, unsigned, unsigned> signal_key_press;
34         sigc::signal<void, unsigned, unsigned> signal_key_release;
35
36 protected:
37         typedef ::Window Handle;
38
39         Display *display;
40         DisplayOptions options;
41         Handle  window;
42
43         Window();
44 public:
45         Window(unsigned, unsigned);
46         Window(const DisplayOptions &);
47         virtual ~Window();
48
49         unsigned get_width() const  { return options.width; }
50         unsigned get_height() const { return options.height; }
51         void show();
52         void hide();
53         void tick();
54 protected:
55         void prepare();
56         void init();
57         void process_event(const XEvent &);
58
59         static int x_error_handler(Display *, XErrorEvent *);
60 };
61
62 } // namespace Msp
63
64 #endif