]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/builder.hpp
d0831b68ab2d16bb05a38b3e8be52f086dc75cd5
[vlc] / modules / gui / skins2 / parser / builder.hpp
1 /*****************************************************************************
2  * builder.hpp
3  *****************************************************************************
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  * 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
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef BUILDER_HPP
26 #define BUILDER_HPP
27
28 #include "builder_data.hpp"
29 #include "../src/skin_common.hpp"
30
31 #include <string>
32 #include <list>
33 #include <map>
34
35 class Theme;
36 class Bezier;
37 class CmdGeneric;
38 class GenericFont;
39 class Position;
40 class Box;
41
42
43 /// Class for skin construction
44 class Builder: public SkinObject
45 {
46     public:
47         Builder( intf_thread_t *pIntf, const BuilderData &rData,
48                  const string &rPath );
49         virtual ~Builder();
50
51         /// Create a Theme object, ready to use.
52         /// Return NULL in case of problem
53         Theme *build();
54
55         /// Parse an action tag and returns a command
56         CmdGeneric *parseAction( const string &rAction );
57
58     private:
59         /// Data from the XML
60         const BuilderData &m_rData;
61         /// Path of the theme
62         const string m_path;
63
64         /// Theme under construction
65         Theme *m_pTheme;
66
67         void addTheme( const BuilderData::Theme &rData );
68         void addIniFile( const BuilderData::IniFile &rData );
69         void addBitmap( const BuilderData::Bitmap &rData );
70         void addSubBitmap( const BuilderData::SubBitmap &rData );
71         void addBitmapFont( const BuilderData::BitmapFont &rData );
72         void addFont( const BuilderData::Font &rData );
73         void addPopupMenu( const BuilderData::PopupMenu &rData );
74         void addMenuItem( const BuilderData::MenuItem &rData );
75         void addMenuSeparator( const BuilderData::MenuSeparator &rData );
76         void addWindow( const BuilderData::Window &rData );
77         void addLayout( const BuilderData::Layout &rData );
78         void addAnchor( const BuilderData::Anchor &rData );
79         void addButton( const BuilderData::Button &rData );
80         void addCheckbox( const BuilderData::Checkbox &rData );
81         void addImage( const BuilderData::Image &rData );
82         void addText( const BuilderData::Text &rData );
83         void addRadialSlider( const BuilderData::RadialSlider &rData );
84         void addSlider( const BuilderData::Slider &rData );
85         void addList( const BuilderData::List &rData );
86         void addTree( const BuilderData::Tree &rData );
87         void addVideo( const BuilderData::Video &rData );
88
89         /// Compute the position of a control
90         const Position makePosition( const string &rLeftTop,
91                                      const string &rRightBottom,
92                                      int xPos, int yPos, int width, int height,
93                                      const Box &rBox ) const;
94
95         // Build the full path of a file
96         string getFilePath( const string &fileName ) const;
97
98         /// Get a font from its id
99         GenericFont *getFont( const string &fontId );
100
101         /// Function to parse "points" tags
102         Bezier *getPoints( const char *pTag ) const;
103
104         /// Compute a color value
105         uint32_t getColor( const string &rVal ) const;
106
107         /// Image handler (used to load image files)
108         image_handler_t *m_pImageHandler;
109 };
110
111 #endif
112