]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Adjust event handling to match changes in mspgui
[libs/gltk.git] / source / panel.h
1 #ifndef MSP_GLTK_PANEL_H_
2 #define MSP_GLTK_PANEL_H_
3
4 #include "container.h"
5
6 namespace Msp {
7 namespace GLtk {
8
9 class Layout;
10
11 /**
12 Panels are containers for other widgets.  Panel styles should have a special
13 part "children" to render the child widgets.  All properties of this part are
14 ignored.
15 */
16 class Panel: public Container
17 {
18 public:
19         class Loader: public Widget::Loader
20         {
21         public:
22                 typedef std::map<std::string, Widget *> WidgetMap;
23
24         private:
25                 Panel &pnl;
26                 WidgetMap &wdg_map;
27         
28         public:
29                 Loader(Panel &, WidgetMap &);
30         private:
31                 template<typename T>
32                 void child(const std::string &);
33                 void panel(const std::string &);
34         };
35
36 protected:
37         struct Child: public Container::Child
38         {
39                 Child(Panel &, Widget *);
40                 virtual ~Child();
41
42                 void visibility_changed(bool);
43                 void autosize_changed();
44                 void request_focus();
45                 void grab_pointer();
46                 void ungrab_pointer();
47                 void raise();
48         };
49
50         Layout *layout;
51         Widget *pointer_focus;
52         bool pointer_grabbed;
53         Widget *input_focus;
54
55         Panel(const Panel &);
56         Panel &operator=(const Panel &);
57 public:
58         Panel();
59         virtual ~Panel();
60
61         virtual const char *get_class() const { return "panel"; }
62
63         void set_layout(Layout *);
64
65 protected:
66         virtual Child *create_child(Widget *);
67
68 public:
69         void raise(Widget &);
70         Widget *get_input_focus() const { return input_focus; }
71         Widget *get_final_input_focus() const;
72
73 protected:
74         virtual void render_special(const Part &) const;
75
76 public:
77         virtual void button_press(int, int, unsigned);
78         virtual void button_release(int, int, unsigned);
79         virtual void pointer_motion(int, int);
80         virtual void pointer_leave();
81         virtual void key_press(unsigned, unsigned);
82         virtual void key_release(unsigned, unsigned);
83         virtual void character(wchar_t);
84         virtual void focus_out();
85 protected:
86         virtual void on_child_added(Widget &);
87         virtual void on_child_removed(Widget &);
88
89         void set_pointer_focus(Widget *);
90         void set_input_focus(Widget *);
91 };
92
93 } // namespace GLtk
94 } // namespace Msp
95
96 #endif