]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Use DerivedObjectLoader for widget loaders
[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 DataFile::DerivedObjectLoader<Panel, Widget::Loader>
20         {
21         public:
22                 typedef std::map<std::string, Widget *> WidgetMap;
23
24         private:
25                 WidgetMap &wdg_map;
26         
27         public:
28                 Loader(Panel &, WidgetMap &);
29         private:
30                 template<typename T>
31                 void child(const std::string &);
32                 void panel(const std::string &);
33         };
34
35 protected:
36         Layout *layout;
37
38         Panel(const Panel &);
39         Panel &operator=(const Panel &);
40 public:
41         Panel();
42         virtual ~Panel();
43
44         virtual const char *get_class() const { return "panel"; }
45
46         void set_layout(Layout *);
47         virtual void autosize();
48
49 protected:
50         virtual void render_special(const Part &, GL::Renderer &) const;
51
52         virtual void on_geometry_change();
53         virtual void on_child_added(Widget &);
54         virtual void on_child_removed(Widget &);
55 };
56
57 } // namespace GLtk
58 } // namespace Msp
59
60 #endif