builder.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * builder.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 09dfd1512c9450ab2ac662ea5e5d21eb81eab323 $
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 #ifdef HAVE_CONFIG_H
00026 # include "config.h"
00027 #endif
00028 
00029 #ifndef BUILDER_HPP
00030 #define BUILDER_HPP
00031 
00032 #include "builder_data.hpp"
00033 #include "../src/skin_common.hpp"
00034 
00035 #include <string>
00036 #include <list>
00037 #include <map>
00038 
00039 class Theme;
00040 class Bezier;
00041 class CmdGeneric;
00042 class GenericFont;
00043 class Position;
00044 class GenericRect;
00045 
00046 
00047 /// Class for skin construction
00048 class Builder: public SkinObject
00049 {
00050 public:
00051     Builder( intf_thread_t *pIntf, const BuilderData &rData,
00052              const string &rPath );
00053     virtual ~Builder();
00054 
00055     /// Create a Theme object, ready to use.
00056     /// Return NULL in case of problem
00057     Theme *build();
00058 
00059     /// Parse an action tag and returns a command
00060     CmdGeneric *parseAction( const string &rAction );
00061 
00062 private:
00063     /// Data from the XML
00064     const BuilderData &m_rData;
00065     /// Path of the theme
00066     const string m_path;
00067 
00068     /// Theme under construction
00069     Theme *m_pTheme;
00070 
00071     void addTheme( const BuilderData::Theme &rData );
00072     void addIniFile( const BuilderData::IniFile &rData );
00073     void addBitmap( const BuilderData::Bitmap &rData );
00074     void addSubBitmap( const BuilderData::SubBitmap &rData );
00075     void addBitmapFont( const BuilderData::BitmapFont &rData );
00076     void addFont( const BuilderData::Font &rData );
00077     void addPopupMenu( const BuilderData::PopupMenu &rData );
00078     void addMenuItem( const BuilderData::MenuItem &rData );
00079     void addMenuSeparator( const BuilderData::MenuSeparator &rData );
00080     void addWindow( const BuilderData::Window &rData );
00081     void addLayout( const BuilderData::Layout &rData );
00082     void addAnchor( const BuilderData::Anchor &rData );
00083     void addButton( const BuilderData::Button &rData );
00084     void addCheckbox( const BuilderData::Checkbox &rData );
00085     void addImage( const BuilderData::Image &rData );
00086     void addPanel( const BuilderData::Panel &rData );
00087     void addText( const BuilderData::Text &rData );
00088     void addRadialSlider( const BuilderData::RadialSlider &rData );
00089     void addSlider( const BuilderData::Slider &rData );
00090     void addList( const BuilderData::List &rData );
00091     void addTree( const BuilderData::Tree &rData );
00092     void addVideo( const BuilderData::Video &rData );
00093 
00094     /// Helper for build(); gluing BuilderData::list<T>s to addType(T&)
00095     template<class T> void add_objects(const std::list<T> &list,
00096                                        void (Builder::*addfn)(const T &));
00097 
00098     /// Compute the position of a control
00099     const Position makePosition( const string &rLeftTop,
00100                                  const string &rRightBottom,
00101                                  int xPos, int yPos, int width, int height,
00102                                  const GenericRect &rRect,
00103                                  bool xKeepRatio = false,
00104                                  bool yKeepRatio = false ) const;
00105 
00106     // Build the full path of a file
00107     string getFilePath( const string &fileName ) const;
00108 
00109     /// Get a font from its id
00110     GenericFont *getFont( const string &fontId );
00111 
00112     /// Function to parse "points" tags
00113     Bezier *getPoints( const char *pTag ) const;
00114 
00115     /// Compute a color value
00116     uint32_t getColor( const string &rVal ) const;
00117 
00118     /// Image handler (used to load image files)
00119     image_handler_t *m_pImageHandler;
00120 };
00121 
00122 #endif
00123 

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