1 #ifndef MSP_GLTK_PANEL_H_
2 #define MSP_GLTK_PANEL_H_
4 #include <msp/core/typeregistry.h>
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
16 class Panel: public Container
19 class Loader: public DataFile::DerivedObjectLoader<Panel, Widget::Loader>
22 typedef std::map<std::string, Widget *> WidgetMap;
28 void operator()(const std::string &, Loader &) const;
35 Loader(Panel &, WidgetMap &);
39 Widget &get_last_widget();
43 void child(const std::string &);
44 void constraint(Layout::ConstraintType, const std::string &);
45 void expand(bool, bool);
47 void gravity(int, int);
58 class ArrangedLoader: public DataFile::Loader
61 typename T::Loader arr_loader;
64 ArrangedLoader(Loader &, T &);
68 std::vector<Widget *> nav_order;
71 static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
72 static bool widget_registry_init_done;
75 Panel &operator=(const Panel &);
81 static void register_child_type(const std::string &);
83 virtual const char *get_class() const { return "panel"; }
85 void set_layout(Layout *);
86 Layout *get_layout() { return layout; }
89 virtual void autosize_special(const Part &, Geometry &) const;
90 virtual void render_special(const Part &, GL::Renderer &) const;
93 virtual bool navigate(Navigation);
95 Widget *find_next_child(int, int, int, int, int) const;
96 static int compute_delta(int, int, int, int, int);
98 virtual void on_size_change();
99 virtual void on_child_added(Widget &);
100 virtual void on_child_removed(Widget &);
105 void Panel::register_child_type(const std::string &name)
107 widget_registry.register_type<T>(name);
112 void Panel::Loader::child(const std::string &n)
115 wdg_map[n] = last_widget;
119 void Panel::Loader::unnamed_child()
121 RefPtr<T> chl = new T();
124 last_widget = chl.release();
129 void Panel::Loader::AddChildType<T>::operator()(const std::string &kwd, Loader &ldr) const
131 ldr.add(kwd, &Loader::child<T>);
132 ldr.add(kwd, &Loader::unnamed_child<T>);