]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Add nameless child keywords for Panel
[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
30         private:
31                 template<typename T>
32                 void add_child_type(const std::string &);
33                 Layout &get_layout();
34                 Widget &get_last_widget();
35                 template<typename T>
36                 void arrangement();
37                 template<typename T>
38                 void child(const std::string &);
39                 void constraint(Layout::ConstraintType, const std::string &);
40                 void expand(bool, bool);
41                 void ghost(bool);
42                 void gravity(int, int);
43                 void grid(unsigned);
44                 void layout();
45                 template<typename T>
46                 void unnamed_child();
47         };
48
49 private:
50         template<typename T>
51         class ArrangedLoader: public DataFile::Loader
52         {
53         private:
54                 typename T::Loader arr_loader;
55
56         public:
57                 ArrangedLoader(Loader &, T &);
58         };
59
60 protected:
61         Layout *layout;
62
63         Panel(const Panel &);
64         Panel &operator=(const Panel &);
65 public:
66         Panel();
67         virtual ~Panel();
68
69         virtual const char *get_class() const { return "panel"; }
70
71         void set_layout(Layout *);
72         Layout *get_layout() { return layout; }
73
74 protected:
75         virtual void autosize_special(const Part &, Geometry &) const;
76         virtual void render_special(const Part &, GL::Renderer &) const;
77
78 public:
79         virtual bool navigate(Navigation);
80 protected:
81         Widget *find_next_child(int, int, int, int, int) const;
82         static int compute_delta(int, int, int, int, int);
83
84         virtual void on_geometry_change();
85         virtual void on_child_added(Widget &);
86         virtual void on_child_removed(Widget &);
87 };
88
89 } // namespace GLtk
90 } // namespace Msp
91
92 #endif