]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/skin_parser.hpp
* skins2:
[vlc] / modules / gui / skins2 / parser / skin_parser.hpp
1 /*****************************************************************************
2  * skin_parser.hpp
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef SKIN_PARSER_HPP
25 #define SKIN_PARSER_HPP
26
27 #include "xmlparser.hpp"
28 #include "builder_data.hpp"
29 #include <set>
30
31
32 /// Parser for the skin DTD
33 class SkinParser: public XMLParser
34 {
35     public:
36         SkinParser( intf_thread_t *pIntf, const string &rFileName,
37                     const string &rPath, bool useDTD = true,
38                     BuilderData *pData = NULL );
39         virtual ~SkinParser();
40
41         const BuilderData &getData() const { return *m_pData; }
42
43         static int convertColor( const char *transcolor );
44
45     private:
46         /// Path of the theme
47         const string m_path;
48         /// Container for mapping data from the XML
49         BuilderData *m_pData;
50         /// Indicate whether the class owns the data
51         bool m_ownData;
52         /// Current IDs
53         string m_curBitmapId;
54         string m_curWindowId;
55         string m_curLayoutId;
56         string m_curPopupId;
57         string m_curListId;
58         string m_curTreeId;
59         /// Current position of menu items in the popups
60         list<int> m_popupPosList;
61         /// Current offset of the controls
62         int m_xOffset, m_yOffset;
63         list<int> m_xOffsetList, m_yOffsetList;
64         /// Stack of panel ids
65         list<string> m_panelStack;
66         /// Layer of the current control in the layout
67         int m_curLayer;
68         /// Set of used id
69         set<string> m_idSet;
70
71         /// Callbacks
72         virtual void handleBeginElement( const string &rName,
73                                          AttrList_t &attr );
74         virtual void handleEndElement( const string &rName );
75
76         /// Helper functions
77         //@{
78         bool convertBoolean( const char *value ) const;
79         /// Transform to int, and check that it is in the given range (if not,
80         /// the closest range boundary will be used)
81         int convertInRange( const char *value, int minValue, int maxValue,
82                             const string &rAttribute ) const;
83         //@}
84
85         /// Generate a new id
86         const string generateId() const;
87
88         /// Check if the id is unique, and if not generate a new one
89         const string uniqueId( const string &id );
90 };
91
92 #endif