builder.hpp 4.3 KB
Newer Older
1 2 3
/*****************************************************************************
 * builder.hpp
 *****************************************************************************
4
 * Copyright (C) 2003 the VideoLAN team
5
 * $Id$
6 7
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8
 *          Olivier Teulière <ipkiss@via.ecp.fr>
9 10 11 12 13 14 15 16 17 18 19
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
20 21 22
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24
 *****************************************************************************/

25 26 27 28
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

29 30 31 32
#ifndef BUILDER_HPP
#define BUILDER_HPP

#include "builder_data.hpp"
33
#include "../src/skin_common.hpp"
34 35 36 37 38 39

#include <string>
#include <list>
#include <map>

class Theme;
40 41 42 43
class Bezier;
class CmdGeneric;
class GenericFont;
class Position;
Olivier Teulière's avatar
Olivier Teulière committed
44
class GenericRect;
45 46 47 48 49


/// Class for skin construction
class Builder: public SkinObject
{
50 51
public:
    Builder( intf_thread_t *pIntf, const BuilderData &rData,
52
             const std::string &rPath );
53 54 55 56 57 58 59
    virtual ~Builder();

    /// Create a Theme object, ready to use.
    /// Return NULL in case of problem
    Theme *build();

    /// Parse an action tag and returns a command
60
    CmdGeneric *parseAction( const std::string &rAction );
61 62 63 64 65

private:
    /// Data from the XML
    const BuilderData &m_rData;
    /// Path of the theme
66
    const std::string m_path;
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

    /// Theme under construction
    Theme *m_pTheme;

    void addTheme( const BuilderData::Theme &rData );
    void addIniFile( const BuilderData::IniFile &rData );
    void addBitmap( const BuilderData::Bitmap &rData );
    void addSubBitmap( const BuilderData::SubBitmap &rData );
    void addBitmapFont( const BuilderData::BitmapFont &rData );
    void addFont( const BuilderData::Font &rData );
    void addPopupMenu( const BuilderData::PopupMenu &rData );
    void addMenuItem( const BuilderData::MenuItem &rData );
    void addMenuSeparator( const BuilderData::MenuSeparator &rData );
    void addWindow( const BuilderData::Window &rData );
    void addLayout( const BuilderData::Layout &rData );
    void addAnchor( const BuilderData::Anchor &rData );
    void addButton( const BuilderData::Button &rData );
    void addCheckbox( const BuilderData::Checkbox &rData );
    void addImage( const BuilderData::Image &rData );
    void addPanel( const BuilderData::Panel &rData );
    void addText( const BuilderData::Text &rData );
    void addRadialSlider( const BuilderData::RadialSlider &rData );
    void addSlider( const BuilderData::Slider &rData );
    void addList( const BuilderData::List &rData );
    void addTree( const BuilderData::Tree &rData );
    void addVideo( const BuilderData::Video &rData );

94 95 96 97
    /// Helper for build(); gluing BuilderData::list<T>s to addType(T&)
    template<class T> void add_objects(const std::list<T> &list,
                                       void (Builder::*addfn)(const T &));

98
    /// Compute the position of a control
99 100
    const Position makePosition( const std::string &rLeftTop,
                                 const std::string &rRightBottom,
101 102 103 104 105 106
                                 int xPos, int yPos, int width, int height,
                                 const GenericRect &rRect,
                                 bool xKeepRatio = false,
                                 bool yKeepRatio = false ) const;

    // Build the full path of a file
107
    std::string getFilePath( const std::string &fileName ) const;
108 109

    /// Get a font from its id
110
    GenericFont *getFont( const std::string &fontId );
111 112 113 114 115

    /// Function to parse "points" tags
    Bezier *getPoints( const char *pTag ) const;

    /// Compute a color value
116
    uint32_t getColor( const std::string &rVal ) const;
117 118 119

    /// Image handler (used to load image files)
    image_handler_t *m_pImageHandler;
120 121 122 123
};

#endif