]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Move all child widget handling into Container
[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         Layout *layout;
38
39         Panel(const Panel &);
40         Panel &operator=(const Panel &);
41 public:
42         Panel();
43         virtual ~Panel();
44
45         virtual const char *get_class() const { return "panel"; }
46
47         void set_layout(Layout *);
48         virtual void autosize();
49
50 protected:
51         virtual void render_special(const Part &, GL::Renderer &) const;
52
53         virtual void on_geometry_change();
54         virtual void on_child_added(Widget &);
55         virtual void on_child_removed(Widget &);
56 };
57
58 } // namespace GLtk
59 } // namespace Msp
60
61 #endif