]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/logic.cpp
Add getter for Panel::layout
[libs/gltk.git] / source / logic.cpp
index 85ec710def369c7b6764e0cb69f0e628f03e8af6..e9542a6dfb26815f7d4e371911ae65775e991b8b 100644 (file)
@@ -1,10 +1,4 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
+#include <msp/core/maputils.h>
 #include "logic.h"
 
 using namespace std;
@@ -13,7 +7,7 @@ namespace Msp {
 namespace GLtk {
 
 Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
-       logic(l),
+       DataFile::ObjectLoader<Logic>(l),
        widgets(w)
 {
        add("bind", &Loader::bind);
@@ -21,17 +15,14 @@ Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
 
 void Logic::Loader::bind(const string &wdg, const string &data)
 {
-       map<string, Widget *>::const_iterator i = widgets.find(wdg);
-       if(i==widgets.end())
-               throw KeyError("Unknown widget", wdg);
+       WidgetBinding act;
+       act.wdg = get_item(widgets, wdg);
 
        string::size_type colon = data.find(':');
-       WidgetBinding act;
-       act.wdg = i->second;
        act.type = data.substr(0, colon);
        if(colon!=string::npos)
                act.data = data.substr(colon+1);
-       logic.bindings.push_back(act);
+       obj.bindings.push_back(act);
 }
 
 } // namespace GLtk