]> git.tdb.fi Git - libs/gltk.git/blob - panel.h
1126e837836e46f5d88590e2cf94df3b14efc174
[libs/gltk.git] / 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         virtual void autosize();
65
66 protected:
67         virtual Child *create_child(Widget *);
68
69 public:
70         void raise(Widget &);
71         Widget *get_input_focus() const { return input_focus; }
72         Widget *get_final_input_focus() const;
73
74 protected:
75         virtual void render_special(const Part &, GL::Renderer &) const;
76
77 public:
78         virtual void button_press(int, int, unsigned);
79         virtual void button_release(int, int, unsigned);
80         virtual void pointer_motion(int, int);
81         virtual void pointer_leave();
82         virtual void key_press(unsigned, unsigned);
83         virtual void key_release(unsigned, unsigned);
84         virtual void character(wchar_t);
85         virtual void focus_out();
86 protected:
87         virtual void on_geometry_change();
88         virtual void on_child_added(Widget &);
89         virtual void on_child_removed(Widget &);
90
91         void set_pointer_focus(Widget *);
92         void set_input_focus(Widget *);
93 };
94
95 } // namespace GLtk
96 } // namespace Msp
97
98 #endif