]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Move navigation logic from Container to 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         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 ghost(bool);
39                 void gravity(int, int);
40                 void grid(unsigned);
41                 void layout();
42                 void panel(const std::string &);
43         };
44
45 private:
46         template<typename T>
47         class ArrangedLoader: public DataFile::Loader
48         {
49         private:
50                 typename T::Loader arr_loader;
51
52         public:
53                 ArrangedLoader(Loader &, T &);
54         };
55
56 protected:
57         Layout *layout;
58
59         Panel(const Panel &);
60         Panel &operator=(const Panel &);
61 public:
62         Panel();
63         virtual ~Panel();
64
65         virtual const char *get_class() const { return "panel"; }
66
67         void set_layout(Layout *);
68         Layout *get_layout() { return layout; }
69
70 protected:
71         virtual void autosize_special(const Part &, Geometry &) const;
72         virtual void render_special(const Part &, GL::Renderer &) const;
73
74 public:
75         virtual bool navigate(Navigation);
76
77 protected:
78         virtual void on_geometry_change();
79         virtual void on_child_added(Widget &);
80         virtual void on_child_removed(Widget &);
81 };
82
83 } // namespace GLtk
84 } // namespace Msp
85
86 #endif