Widget::render_part(part);
}
+
+Label::Loader::Loader(Label &l):
+ Widget::Loader(l)
+{
+ add("text", &Label::text);
+}
+
+Label &Label::Loader::get_object()
+{
+ return static_cast<Label &>(wdg);
+}
+
} // namespace GLtk
} // namespace Msp
class Label: public Widget
{
public:
+ class Loader: public Widget::Loader
+ {
+ public:
+ Loader(Label &);
+ Label &get_object();
+ };
+
Label(const Resources &, const std::string & =std::string());
void set_text(const std::string &);
private:
+#include <msp/core/refptr.h>
+#include "label.h"
#include "panel.h"
#include "part.h"
+using namespace std;
+
namespace Msp {
namespace GLtk {
}
}
+
+Panel::Loader::Loader(Panel &p, map<string, Widget *> &m):
+ Widget::Loader(p),
+ panel(p),
+ wdg_map(m)
+{
+ add("label", &Loader::child<Label>);
+}
+
+template<typename T>
+void Panel::Loader::child(const string &n)
+{
+ RefPtr<T> chl=new T(panel.res);
+ load_sub(*chl);
+ panel.add(*chl.get());
+ wdg_map[n]=chl.release();
+}
+
} // namespace GLtk
} // namespace Msp
class Panel: public Widget
{
public:
+ class Loader: public Widget::Loader
+ {
+ private:
+ Panel &panel;
+ std::map<std::string, Widget *> &wdg_map;
+
+ public:
+ Loader(Panel &, std::map<std::string, Widget *> &);
+ private:
+ template<typename T>
+ void child(const std::string &);
+ };
+
Panel(const Resources &);
~Panel();
{
set_geometry(Geometry(0, 0, window.get_width(), window.get_height()));
+ update_style();
+
window.signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event));
window.signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event));
window.signal_pointer_motion.connect(sigc::mem_fun(this, &Root::pointer_motion_event));
}
+void Root::button_press_event(int x, int y, unsigned btn, unsigned)
+{
+ button_press(x, y, btn);
+}
+
+void Root::button_release_event(int x, int y, unsigned btn, unsigned)
+{
+ button_release(x, y, btn);
+}
+
+void Root::pointer_motion_event(int x, int y)
+{
+ pointer_motion(x, y);
+}
+
} // namespace GLtk
} // namespace Msp
GL::pop_matrix();
}
+
+Widget::Loader::Loader(Widget &w):
+ wdg(w)
+{
+ add("position", &Loader::position);
+ add("size", &Loader::size);
+ add("style", &Loader::style);
+}
+
+void Widget::Loader::position(int x, int y)
+{
+ wdg.set_position(x, y);
+}
+
+void Widget::Loader::size(unsigned w, unsigned h)
+{
+ wdg.set_size(w, h);
+}
+
+void Widget::Loader::style(const string &s)
+{
+ wdg.set_style(s);
+}
+
} // namespace GLtk
} // namespace Msp
class Widget
{
public:
+ class Loader: public Msp::DataFile::Loader
+ {
+ protected:
+ Widget &wdg;
+
+ public:
+ Loader(Widget &);
+ private:
+ void position(int, int);
+ void size(unsigned, unsigned);
+ void style(const std::string &);
+ };
+
virtual ~Widget() { }
void set_position(int, int);
void set_size(unsigned, unsigned);