theme.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * theme.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 67eb601381e3097d8a42275090f3079155cfe15b $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
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 /// Class storing the data of the current theme
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     /// Store the bitmaps by ID
00086     IDmap<GenericBitmapPtr> m_bitmaps;
00087     /// Store the fonts by ID
00088     IDmap<GenericFontPtr> m_fonts;
00089     /// Store the popups by ID
00090     IDmap<PopupPtr> m_popups;
00091     /// Store the windows by ID
00092     IDmap<TopWindowPtr> m_windows;
00093     /// Store the layouts by ID
00094     IDmap<GenericLayoutPtr> m_layouts;
00095     /// Store the controls by ID
00096     IDmap<CtrlGenericPtr> m_controls;
00097     /// Store the panel positions by ID
00098     IDmap<PositionPtr> m_positions;
00099     /// Store the commands
00100     list<CmdGenericPtr> m_commands;
00101     /// Store the Bezier curves
00102     list<BezierPtr> m_curves;
00103     /// Store the variables
00104     list<VariablePtr> m_vars;
00105 
00106     WindowManager m_windowManager;
00107 };
00108 
00109 
00110 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6