]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/logic.cpp
Pass coordinates relative to the receiving widget's geometry
[libs/gltk.git] / source / logic.cpp
diff --git a/source/logic.cpp b/source/logic.cpp
new file mode 100644 (file)
index 0000000..40d06b2
--- /dev/null
@@ -0,0 +1,38 @@
+/* $Id$
+
+This file is part of libmspgltk
+Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "logic.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GLtk {
+
+Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
+       logic(l),
+       widgets(w)
+{
+       add("action", &Loader::action);
+}
+
+void Logic::Loader::action(const string &wdg, const string &data)
+{
+       map<string, Widget *>::const_iterator i=widgets.find(wdg);
+       if(i==widgets.end())
+               throw KeyError("Unknown widget", wdg);
+
+       unsigned colon=data.find(':');
+       WidgetAction act;
+       act.wdg=i->second;
+       act.type=data.substr(0, colon);
+       if(colon!=string::npos)
+               act.data=data.substr(colon+1);
+       logic.actions.push_back(act);
+}
+
+} // namespace GLtk
+} // namespace Msp