]> git.tdb.fi Git - libs/gltk.git/blob - source/panel.h
Implement next/previous navigation in 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         std::vector<Widget *> nav_order;
62         Layout *layout;
63
64         Panel(const Panel &);
65         Panel &operator=(const Panel &);
66 public:
67         Panel();
68         virtual ~Panel();
69
70         virtual const char *get_class() const { return "panel"; }
71
72         void set_layout(Layout *);
73         Layout *get_layout() { return layout; }
74
75 protected:
76         virtual void autosize_special(const Part &, Geometry &) const;
77         virtual void render_special(const Part &, GL::Renderer &) const;
78
79 public:
80         virtual bool navigate(Navigation);
81 protected:
82         Widget *find_next_child(int, int, int, int, int) const;
83         static int compute_delta(int, int, int, int, int);
84
85         virtual void on_geometry_change();
86         virtual void on_child_added(Widget &);
87         virtual void on_child_removed(Widget &);
88 };
89
90 } // namespace GLtk
91 } // namespace Msp
92
93 #endif