X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fuserinterface.h;h=04a9ccfd10b6cd815f1618f9a217fd3db59f39ff;hb=754751fd474c6eac073fa7e89a18142fc89cb4fb;hp=c821320b672e3a5445e935522eec1453faa460f1;hpb=86d9edd57268b4ebdc92844d65db4469d516b1d1;p=libs%2Fgltk.git diff --git a/source/userinterface.h b/source/userinterface.h index c821320..04a9ccf 100644 --- a/source/userinterface.h +++ b/source/userinterface.h @@ -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 #include "logic.h" #include "root.h" @@ -33,8 +27,10 @@ public: void root(); }; + typedef std::map WidgetMap; + private: - std::map widgets; + WidgetMap widgets; Root root; Logic logic; @@ -46,21 +42,13 @@ public: template W &get_widget(const std::string &n) const { - std::map::const_iterator i=widgets.find(n); - if(i==widgets.end()) - throw KeyError("Unknown widget", n); - - W *w=dynamic_cast(i->second); - if(!w) - throw Exception("Widget type mismatch"); - - return *w; + return dynamic_cast(*get_item(widgets, n)); } template void get_widget(const std::string &n, W *&w) const { - w=&get_widget(n); + w = &get_widget(n); } };