]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/userinterface.h
Add getter for Panel::layout
[libs/gltk.git] / source / userinterface.h
index c0750c003b5a15cc4e4bda9bf42d5f46ab91c329..04a9ccfd10b6cd815f1618f9a217fd3db59f39ff 100644 (file)
@@ -1,13 +1,7 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2008  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GLTK_USERINTERFACE_H_
 #define MSP_GLTK_USERINTERFACE_H_
 
+#include <msp/core/maputils.h>
 #include "logic.h"
 #include "root.h"
 
@@ -33,8 +27,10 @@ public:
                void root();
        };
 
+       typedef std::map<std::string, Widget *> WidgetMap;
+
 private:
-       std::map<std::string, Widget *> widgets;
+       WidgetMap widgets;
        Root root;
        Logic logic;
 
@@ -46,15 +42,7 @@ public:
        template<typename W>
        W &get_widget(const std::string &n) const
        {
-               std::map<std::string, Widget *>::const_iterator i = widgets.find(n);
-               if(i==widgets.end())
-                       throw KeyError("Unknown widget", n);
-
-               W *w = dynamic_cast<W *>(i->second);
-               if(!w)
-                       throw Exception("Widget type mismatch");
-
-               return *w;
+               return dynamic_cast<W &>(*get_item(widgets, n));
        }
 
        template<typename W>