X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=bb3913c73fbf5db85fc85217a98dce872417666a;hb=6be5b834084fb3ab421b94b6c4ad8eece6bab754;hp=83042a63f3c8a62339d40b7ae5708306fef398da;hpb=e7bc29984e91ee36555d6a4e4eece22170d10ba4;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index 83042a6..bb3913c 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,9 +1,16 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "root.h" namespace Msp { namespace GLtk { -Root::Root(Resources &r, Window &w): +Root::Root(Resources &r, Graphics::Window &w): Panel(r), window(w) { @@ -14,22 +21,33 @@ Root::Root(Resources &r, Window &w): window.signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event)); window.signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event)); window.signal_pointer_motion.connect(sigc::mem_fun(this, &Root::pointer_motion_event)); + window.signal_key_press.connect(sigc::mem_fun(this, &Root::key_press)); + window.signal_key_release.connect(sigc::mem_fun(this, &Root::key_release)); } void Root::button_press_event(int x, int y, unsigned btn, unsigned) { + translate_coords(x, y); button_press(x, y, btn); } void Root::button_release_event(int x, int y, unsigned btn, unsigned) { + translate_coords(x, y); button_release(x, y, btn); } void Root::pointer_motion_event(int x, int y) { + translate_coords(x, y); pointer_motion(x, y); } +void Root::translate_coords(int &x, int &y) +{ + x=x*geom.w/window.get_width(); + y=geom.h-1-y*geom.h/window.get_height(); +} + } // namespace GLtk } // namespace Msp