theme.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef THEME_HPP
00026 #define THEME_HPP
00027
00028 #include "generic_bitmap.hpp"
00029 #include "generic_font.hpp"
00030 #include "generic_layout.hpp"
00031 #include "popup.hpp"
00032 #include "../src/window_manager.hpp"
00033 #include "../commands/cmd_generic.hpp"
00034 #include "../utils/bezier.hpp"
00035 #include "../utils/variable.hpp"
00036 #include "../utils/position.hpp"
00037 #include "../controls/ctrl_generic.hpp"
00038 #include <string>
00039 #include <list>
00040 #include <map>
00041
00042 class Builder;
00043 class Interpreter;
00044
00045
00046 class Theme: public SkinObject
00047 {
00048 private:
00049 friend class Builder;
00050 friend class Interpreter;
00051 public:
00052 Theme( intf_thread_t *pIntf ): SkinObject( pIntf ),
00053 m_windowManager( getIntf() ) { }
00054 virtual ~Theme();
00055
00056 void loadConfig();
00057 void saveConfig();
00058
00059 GenericBitmap *getBitmapById( const string &id ) const;
00060 GenericFont *getFontById( const string &id ) const;
00061
00062 # define ObjByID( var ) ( const string &id ) const \
00063 { return var.find_object( id ); }
00064 Popup *getPopupById ObjByID( m_popups )
00065 TopWindow *getWindowById ObjByID( m_windows )
00066 GenericLayout *getLayoutById ObjByID( m_layouts )
00067 CtrlGeneric *getControlById ObjByID( m_controls )
00068 Position *getPositionById ObjByID( m_positions )
00069 # undef ObjById
00070
00071 WindowManager &getWindowManager() { return m_windowManager; }
00072
00073 private:
00074 template<class T> class IDmap: public std::map<string, T> {
00075 private:
00076 typedef typename std::map<string, T> parent;
00077 public:
00078 typename T::pointer find_object(const string &id) const
00079 {
00080 typename parent::const_iterator it = parent::find( id );
00081 return it!=parent::end() ? it->second.get() : NULL;
00082 }
00083 typename T::pointer find_first_object(const string &id) const;
00084 };
00085
00086 IDmap<GenericBitmapPtr> m_bitmaps;
00087
00088 IDmap<GenericFontPtr> m_fonts;
00089
00090 IDmap<PopupPtr> m_popups;
00091
00092 IDmap<TopWindowPtr> m_windows;
00093
00094 IDmap<GenericLayoutPtr> m_layouts;
00095
00096 IDmap<CtrlGenericPtr> m_controls;
00097
00098 IDmap<PositionPtr> m_positions;
00099
00100 list<CmdGenericPtr> m_commands;
00101
00102 list<BezierPtr> m_curves;
00103
00104 list<VariablePtr> m_vars;
00105
00106 WindowManager m_windowManager;
00107 };
00108
00109
00110 #endif