]> git.tdb.fi Git - libs/gltk.git/blob - source/root.h
Adjust event handling to match changes in mspgui
[libs/gltk.git] / source / root.h
1 #ifndef MSP_GLTK_ROOT_H_
2 #define MSP_GLTK_ROOT_H_
3
4 #include <sigc++/trackable.h>
5 #include <msp/graphics/window.h>
6 #include <msp/input/keyboard.h>
7 #include <msp/input/mouse.h>
8 #include <msp/time/timestamp.h>
9 #include "panel.h"
10
11 namespace Msp {
12 namespace GLtk {
13
14 class Label;
15
16 /**
17 A Root is a special type of Panel that covers and entire Window and accepts
18 input from it.  When created, a Root widget will take its size from the window
19 it is created for.  The size can be changed, but a Root should always be
20 rendered to fill the window in order to get coordinates mapped correctly.
21 */
22 class Root: public Panel, public sigc::trackable
23 {
24 public:
25         sigc::signal<std::string, int, int> signal_tooltip;
26
27 private:
28         const Resources &resources;
29         Graphics::Window &window;
30         Input::Keyboard keyboard;
31         Input::Mouse mouse;
32         Label *lbl_tooltip;
33         int pointer_x;
34         int pointer_y;
35         Time::TimeStamp tooltip_timeout;
36         Widget *tooltip_target;
37
38 public:
39         Root(const Resources &, Graphics::Window &);
40
41         virtual const char *get_class() const { return "root"; }
42
43         const Resources &get_resources() const { return resources; }
44         virtual unsigned get_width() const { return geom.w; }
45         virtual unsigned get_height() const { return geom.h; }
46
47         void tick();
48         void render() const;
49
50 private:
51         void button_press_event(unsigned);
52         void button_release_event(unsigned);
53         void axis_motion_event(unsigned, float, float);
54         void key_press_event(unsigned);
55         void key_release_event(unsigned);
56         void character_event(StringCodec::unichar);
57
58         void get_pointer(int &, int &);
59 };
60
61 } // namespace GLtk
62 } // namespace Msp
63
64 #endif