]> git.tdb.fi Git - libs/gltk.git/blob - source/widget.h
Add key events
[libs/gltk.git] / source / widget.h
1 #ifndef MSP_GLTK_WIDGET_H_
2 #define MSP_GLTK_WIDGET_H_
3
4 #include <string>
5 #include "geometry.h"
6 #include "state.h"
7
8 namespace Msp {
9 namespace GLtk {
10
11 class Part;
12 class Resources;
13 class Style;
14
15 class Widget
16 {
17 public:
18         virtual ~Widget() { }
19         void set_position(int, int);
20         void set_size(unsigned, unsigned);
21         void set_geometry(const Geometry &);
22         void set_style(const std::string &);
23         const Geometry &get_geometry() const { return geom; }
24         void render() const;
25         virtual void button_press(int, int, unsigned) { }
26         virtual void button_release(int, int, unsigned) { }
27         virtual void pointer_motion(int, int) { }
28         virtual void pointer_enter() { }
29         virtual void pointer_leave() { }
30         virtual void key_press(unsigned, unsigned, wchar_t) { }
31         virtual void key_release(unsigned, unsigned) { }
32         virtual void focus_in() { }
33         virtual void focus_out() { }
34 protected:
35         const Resources &res;
36         Geometry geom;
37         std::string style_name;
38         const Style *style;
39         State state;
40
41         Widget(const Resources &);
42         virtual const char *get_class() const { return "widget"; }
43         void update_style();
44         virtual void render_part(const Part &) const;
45         void render_graphic(const Part &) const;
46         void render_text(const Part &, const std::string &) const;
47 };
48
49 } // namespace GLtk
50 } // namespace Msp
51
52 #endif