]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/panel.cpp
Enable loading of widgets from datafiles (not implemented for all widgets yet)
[libs/gltk.git] / source / panel.cpp
index d3e8df0c374c0f190e4da38ffb50617a588613a4..c93d430be07f16a988fa1a120af013104cd8889e 100644 (file)
@@ -1,6 +1,10 @@
+#include <msp/core/refptr.h>
+#include "label.h"
 #include "panel.h"
 #include "part.h"
 
+using namespace std;
+
 namespace Msp {
 namespace GLtk {
 
@@ -142,5 +146,23 @@ void Panel::set_input_focus(Widget *wdg)
        }
 }
 
+
+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