1 /***************************************************************************** 2 * theme.hpp 3 ***************************************************************************** 4 * Copyright (C) 2003 the VideoLAN team 5 * $Id: f1c65f5f425ce09384f851c0fdce13f444b7d7d9 $ 6 * 7 * Authors: Cyril Deguet <asmax@via.ecp.fr> 8 * Olivier Teulière <ipkiss@via.ecp.fr> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License along 21 * with this program; if not, write to the Free Software Foundation, Inc., 22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 *****************************************************************************/ 24 25 #ifndef THEME_HPP 26 #define THEME_HPP 27 28 #include "generic_bitmap.hpp" 29 #include "generic_font.hpp" 30 #include "generic_layout.hpp" 31 #include "popup.hpp" 32 #include "../src/window_manager.hpp" 33 #include "../commands/cmd_generic.hpp" 34 #include "../utils/bezier.hpp" 35 #include "../utils/variable.hpp" 36 #include "../utils/position.hpp" 37 #include "../controls/ctrl_generic.hpp" 38 #include <string> 39 #include <list> 40 #include <map> 41 42 class Builder; 43 class Interpreter; 44 45 /// Class storing the data of the current theme 46 class Theme: public SkinObject 47 { 48 private: 49 friend class Builder; 50 friend class Interpreter; 51 public: Theme(intf_thread_t * pIntf)52 Theme( intf_thread_t *pIntf ): SkinObject( pIntf ), 53 m_windowManager( getIntf() ) { } 54 virtual ~Theme(); 55 56 void loadConfig(); 57 int readConfig(); 58 void saveConfig(); 59 void applyConfig(); 60 61 GenericBitmap *getBitmapById( const std::string &id ) const; 62 GenericFont *getFontById( const std::string &id ) const; 63 64 # define ObjByID( var ) ( const std::string &id ) const \ 65 { return var.find_object( id ); } ObjByID(m_popups)66 Popup *getPopupById ObjByID( m_popups ) 67 TopWindow *getWindowById ObjByID( m_windows ) 68 GenericLayout *getLayoutById ObjByID( m_layouts ) 69 CtrlGeneric *getControlById ObjByID( m_controls ) 70 Position *getPositionById ObjByID( m_positions ) 71 # undef ObjById 72 73 WindowManager &getWindowManager() { return m_windowManager; } 74 75 private: 76 template<class T> class IDmap: public std::map<std::string, T> { 77 private: 78 typedef typename std::map<std::string, T> parent; 79 public: find_object(const std::string & id) const80 typename T::pointer find_object(const std::string &id) const 81 { 82 typename parent::const_iterator it = parent::find( id ); 83 return it!=parent::end() ? it->second.get() : NULL; 84 } 85 typename T::pointer find_first_object(const std::string &id) const; 86 }; 87 88 struct save_t { 89 TopWindow* win; 90 GenericLayout* layout; 91 int x; 92 int y; 93 int width; 94 int height; 95 int visible; 96 }; 97 98 /// Store the bitmaps by ID 99 IDmap<GenericBitmapPtr> m_bitmaps; 100 /// Store the fonts by ID 101 IDmap<GenericFontPtr> m_fonts; 102 /// Store the popups by ID 103 IDmap<PopupPtr> m_popups; 104 /// Store the windows by ID 105 IDmap<TopWindowPtr> m_windows; 106 /// Store the layouts by ID 107 IDmap<GenericLayoutPtr> m_layouts; 108 /// Store the controls by ID 109 IDmap<CtrlGenericPtr> m_controls; 110 /// Store the panel positions by ID 111 IDmap<PositionPtr> m_positions; 112 /// Store the commands 113 std::list<CmdGenericPtr> m_commands; 114 /// Store the Bezier curves 115 std::list<BezierPtr> m_curves; 116 /// Store the variables 117 std::list<VariablePtr> m_vars; 118 /// List saved windows/layouts 119 std::list<save_t> m_saved; 120 121 WindowManager m_windowManager; 122 }; 123 124 125 #endif 126