3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/input/keys.h>
14 Root::Root(Resources &r, Graphics::Window &w):
18 set_geometry(Geometry(0, 0, window.get_width(), window.get_height()));
22 window.signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event));
23 window.signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event));
24 window.signal_pointer_motion.connect(sigc::mem_fun(this, &Root::pointer_motion_event));
25 window.signal_key_press.connect(sigc::mem_fun(this, &Root::key_press_event));
26 window.signal_key_release.connect(sigc::mem_fun(this, &Root::key_release_event));
29 void Root::button_press_event(int x, int y, unsigned btn, unsigned)
33 translate_coords(x, y);
34 button_press(x, y, btn);
38 void Root::button_release_event(int x, int y, unsigned btn, unsigned)
42 translate_coords(x, y);
43 button_release(x, y, btn);
47 void Root::pointer_motion_event(int x, int y)
51 translate_coords(x, y);
56 void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch)
59 key_press(Input::key_from_sys(key), mod, ch);
62 void Root::key_release_event(unsigned key, unsigned mod)
65 key_release(Input::key_from_sys(key), mod);
68 void Root::translate_coords(int &x, int &y)
70 x=x*geom.w/window.get_width();
71 y=geom.h-1-y*geom.h/window.get_height();