3 This file is part of libmspgltk
4 Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/input/keys.h>
14 Root::Root(const Resources &r, Graphics::Window &w):
19 set_geometry(Geometry(0, 0, window.get_width(), window.get_height()));
23 window.signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event));
24 window.signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event));
25 window.signal_pointer_motion.connect(sigc::mem_fun(this, &Root::pointer_motion_event));
26 window.signal_key_press.connect(sigc::mem_fun(this, &Root::key_press_event));
27 window.signal_key_release.connect(sigc::mem_fun(this, &Root::key_release_event));
30 void Root::button_press_event(int x, int y, unsigned btn, unsigned)
34 translate_coords(x, y);
35 button_press(x, y, btn);
39 void Root::button_release_event(int x, int y, unsigned btn, unsigned)
43 translate_coords(x, y);
44 button_release(x, y, btn);
48 void Root::pointer_motion_event(int x, int y)
52 translate_coords(x, y);
57 void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch)
60 key_press(Input::key_from_sys(key), mod, ch);
63 void Root::key_release_event(unsigned key, unsigned mod)
66 key_release(Input::key_from_sys(key), mod);
69 void Root::translate_coords(int &x, int &y)
71 x=x*geom.w/window.get_width();
72 y=geom.h-1-y*geom.h/window.get_height();