]> git.tdb.fi Git - libs/gltk.git/blob - source/root.h
Strip copyright messages and id tags from individual files
[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/gbase/window.h>
6 #include <msp/time/timestamp.h>
7 #include "panel.h"
8
9 namespace Msp {
10 namespace GLtk {
11
12 class Label;
13
14 /**
15 A Root is a special type of Panel that covers and entire Window and accepts
16 input from it.  When created, a Root widget will take its size from the window
17 it is created for.  The size can be changed, but a Root should always be
18 rendered to fill the window in order to get coordinates mapped correctly.
19 */
20 class Root: public Panel, public Graphics::EventSource, public sigc::trackable
21 {
22 public:
23         sigc::signal<std::string, int, int> signal_tooltip;
24
25 private:
26         const Resources &resources;
27         Graphics::Window &window;
28         Label *lbl_tooltip;
29         int pointer_x;
30         int pointer_y;
31         Time::TimeStamp tooltip_timeout;
32         Widget *tooltip_target;
33
34 public:
35         Root(const Resources &, Graphics::Window &);
36
37         virtual const char *get_class() const { return "root"; }
38
39         const Resources &get_resources() const { return resources; }
40         virtual unsigned get_width() const { return geom.w; }
41         virtual unsigned get_height() const { return geom.h; }
42
43         void tick();
44         void render() const;
45
46 private:
47         void button_press_event(int, int, unsigned, unsigned);
48         void button_release_event(int, int, unsigned, unsigned);
49         void pointer_motion_event(int, int);
50         void key_press_event(unsigned, unsigned, wchar_t);
51         void key_release_event(unsigned, unsigned);
52
53         void translate_coords(int &, int &);
54 };
55
56 } // namespace GLtk
57 } // namespace Msp
58
59 #endif