]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
830f5426bd72b0e2b9e5a6802c82d1c0f2865e1c
[libs/gltk.git] / source / panel.h
1 #ifndef MSP_GLTK_PANEL_H_
2 #define MSP_GLTK_PANEL_H_
3
4 #include "container.h"
5 #include "layout.h"
6
7 namespace Msp {
8 namespace GLtk {
9
10 /**
11 Panels are containers for other widgets.  Panel styles should have a special
12 part "children" to render the child widgets.  All properties of this part are
13 ignored.
14 */
15 class Panel: public Container
16 {
17 public:
18         class Loader: public DataFile::DerivedObjectLoader<Panel, Widget::Loader>
19         {
20         public:
21                 typedef std::map<std::string, Widget *> WidgetMap;
22
23         protected:
24                 WidgetMap &wdg_map;
25                 Widget *last_widget;
26         
27         public:
28                 Loader(Panel &, WidgetMap &);
29         private:
30                 Layout &get_layout();
31                 Widget &get_last_widget();
32                 template<typename T>
33                 void arrangement();
34                 template<typename T>
35                 void child(const std::string &);
36                 void constraint(Layout::ConstraintType, const std::string &);
37                 void expand(bool, bool);
38                 void gravity(int, int);
39                 void grid(unsigned);
40                 void panel(const std::string &);
41         };
42
43 private:
44         template<typename T>
45         class ArrangedLoader: public DataFile::Loader
46         {
47         private:
48                 typename T::Loader arr_loader;
49
50         public:
51                 ArrangedLoader(Loader &, T &);
52         };
53
54 protected:
55         Layout *layout;
56
57         Panel(const Panel &);
58         Panel &operator=(const Panel &);
59 public:
60         Panel();
61         virtual ~Panel();
62
63         virtual const char *get_class() const { return "panel"; }
64
65         void set_layout(Layout *);
66         virtual void autosize();
67
68 protected:
69         virtual void render_special(const Part &, GL::Renderer &) const;
70
71         virtual void on_geometry_change();
72         virtual void on_child_added(Widget &);
73         virtual void on_child_removed(Widget &);
74 };
75
76 } // namespace GLtk
77 } // namespace Msp
78
79 #endif