1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
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.
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.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef SKIN_PARSER_HPP
25 #define SKIN_PARSER_HPP
27 #include "xmlparser.hpp"
28 #include "builder_data.hpp"
32 /// Parser for the skin DTD
33 class SkinParser: public XMLParser
46 SkinParser( intf_thread_t *pIntf, const string &rFileName,
47 const string &rPath, BuilderData *pData = NULL );
48 virtual ~SkinParser();
50 const BuilderData &getData() const { return *m_pData; }
52 static int convertColor( const char *transcolor );
57 /// Container for mapping data from the XML
59 /// Indicate whether the class owns the data
68 /// Current position of menu items in the popups
69 list<int> m_popupPosList;
70 /// Current offset of the controls
71 int m_xOffset, m_yOffset;
72 list<int> m_xOffsetList, m_yOffsetList;
73 /// Stack of panel ids
74 list<string> m_panelStack;
75 /// Layer of the current control in the layout
81 virtual void handleBeginElement( const string &rName,
83 virtual void handleEndElement( const string &rName );
87 bool convertBoolean( const char *value ) const;
88 /// Transform to int, and check that it is in the given range (if not,
89 /// the closest range boundary will be used)
90 int convertInRange( const char *value, int minValue, int maxValue,
91 const string &rAttribute ) const;
95 const string generateId() const;
97 /// Check if the id is unique, and if not generate a new one
98 const string uniqueId( const string &id );
100 /// Management of relative positions
101 const int getRefWidth( bool toScreen );
102 const int getRefHeight( bool toScreen );
103 const int getDimension( string value, int refDimension );
104 const int getPosition( string value );
105 void updateWindowPos( int width, int height );
107 void convertPosition( string position,
108 string xOffset, string yOffset,
109 string xMargin, string yMargin,
110 int width, int height, int refWidth, int refHeight,
111 int* p_x, int* p_y );
113 /// Helper for handleBeginElement: Provide default attribute if missing.
114 static void DefaultAttr( AttrList_t &attr, const char *a, const char *b )
116 if( attr.find(a) == attr.end() ) attr[strdup(a)] = strdup(b);
118 /// Helper for handleBeginElement: Complain if a named attribute is missing.
119 bool MissingAttr( AttrList_t &attr, const string &name, const char *a );