]> git.tdb.fi Git - libs/gui.git/blob - source/gbase/window.h
Move Image from mspgl to here
[libs/gui.git] / source / gbase / 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 #ifndef WIN32
46         Atom wm_delete_window;
47         Cursor invisible_cursor;
48 #endif
49
50 public:
51         Window(Display &, unsigned w, unsigned h, bool fs=false);
52         Window(Display &, const WindowOptions &);
53         ~Window();
54
55         void set_title(const std::string &);
56         void reconfigure(const WindowOptions &);
57         void show_cursor(bool);
58
59         Display &get_display() const { return display; }
60         const WindowOptions &get_options() const { return options; }
61         unsigned get_width() const  { return options.width; }
62         unsigned get_height() const { return options.height; }
63         WindowHandle get_handle() const { return window; }
64
65         void show();
66         void hide();
67
68 #ifndef WIN32
69         void event(const XEvent &ev);
70 #endif
71 protected:
72         void init();
73 #ifdef WIN32
74         int wndproc(UINT, WPARAM, LPARAM);
75         static LRESULT CALLBACK wndproc_(HWND, UINT, WPARAM, LPARAM);
76 #endif
77 };
78
79 } // namespace Graphics
80 } // namespace Msp
81
82 #endif