#include <math.h>
SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName,
- const string &rPath ):
- XMLParser( pIntf, rFileName ), m_xOffset( 0 ), m_yOffset( 0 ),
- m_path( rPath )
+ const string &rPath, bool useDTD, BuilderData *pData ):
+ XMLParser( pIntf, rFileName, useDTD ), m_path( rPath), m_pData(pData),
+ m_ownData(pData == NULL), m_xOffset( 0 ), m_yOffset( 0 )
{
+ // Make sure the data is allocated
+ if( m_pData == NULL )
+ {
+ m_pData = new BuilderData();
+ }
+}
+
+
+SkinParser::~SkinParser()
+{
+ if( m_ownData )
+ {
+ delete m_pData;
+ }
}
m_errors = true; return; \
}
- if( rName == "Anchor" )
+ if( rName == "Include" )
+ {
+ RequireDefault( "file" );
+
+ OSFactory *pFactory = OSFactory::instance( getIntf() );
+ string fullPath = m_path + pFactory->getDirSeparator() + attr["file"];
+ msg_Dbg( getIntf(), "Opening included XML file: %s", fullPath.c_str() );
+ // FIXME: We do not use the DTD to validate the included XML file,
+ // as the parser seems to dislike it otherwise...
+ SkinParser subParser( getIntf(), fullPath.c_str(), false, m_pData );
+ subParser.parse();
+ }
+
+ else if( rName == "Anchor" )
{
RequireDefault( "priority" );
CheckDefault( "x", "0" );
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ),
atoi( attr["priority"] ), attr["points"], m_curLayoutId );
- m_data.m_listAnchor.push_back( anchor );
+ m_pData->m_listAnchor.push_back( anchor );
}
else if( rName == "Bitmap" )
m_curBitmapId = uniqueId( attr["id"] );
const BuilderData::Bitmap bitmap( m_curBitmapId,
- convertFileName( attr["file"] ),
- convertColor( attr["alphacolor"] ) );
- m_data.m_listBitmap.push_back( bitmap );
+ attr["file"], convertColor( attr["alphacolor"] ) );
+ m_pData->m_listBitmap.push_back( bitmap );
}
else if( rName == "SubBitmap" )
RequireDefault( "width" );
RequireDefault( "height" );
- const BuilderData::SubBitmap bitmap( uniqueId( attr["id"] ),
+ const BuilderData::SubBitmap bitmap( attr["id"],
m_curBitmapId, atoi( attr["x"] ), atoi( attr["y"] ),
atoi( attr["width"] ), atoi( attr["height"] ) );
- m_data.m_listSubBitmap.push_back( bitmap );
+ m_pData->m_listSubBitmap.push_back( bitmap );
}
else if( rName == "BitmapFont" )
CheckDefault( "type", "digits" );
const BuilderData::BitmapFont font( attr["id"],
- convertFileName( attr["file"] ),
- attr["type"] );
- m_data.m_listBitmapFont.push_back( font );
+ attr["file"], attr["type"] );
+ m_pData->m_listBitmapFont.push_back( font );
}
else if( rName == "Button" )
attr["tooltiptext"], attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listButton.push_back( button );
+ m_pData->m_listButton.push_back( button );
}
else if( rName == "Checkbox" )
attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId,
m_curLayoutId );
m_curLayer++;
- m_data.m_listCheckbox.push_back( checkbox );
+ m_pData->m_listCheckbox.push_back( checkbox );
}
else if( rName == "Font" )
CheckDefault( "size", "12" );
const BuilderData::Font fontData( uniqueId( attr["id"] ),
- convertFileName( attr["file"] ),
- atoi( attr["size"] ) );
- m_data.m_listFont.push_back( fontData );
+ attr["file"], atoi( attr["size"] ) );
+ m_pData->m_listFont.push_back( fontData );
}
else if( rName == "Group" )
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "action", "none" );
+ CheckDefault( "action2", "none" );
CheckDefault( "resize", "mosaic" );
CheckDefault( "help", "" );
const BuilderData::Image imageData( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["visible"],
- attr["image"], attr["action"], attr["resize"], attr["help"],
- m_curLayer, m_curWindowId, m_curLayoutId );
+ attr["image"], attr["action"], attr["action2"], attr["resize"],
+ attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listImage.push_back( imageData );
+ m_pData->m_listImage.push_back( imageData );
}
else if( rName == "Layout" )
atoi( attr["height"] ), atoi( attr["minwidth"] ),
atoi( attr["maxwidth"] ), atoi( attr["minheight"] ),
atoi( attr["maxheight"] ), m_curWindowId );
- m_data.m_listLayout.push_back( layout );
+ m_pData->m_listLayout.push_back( layout );
m_curLayer = 0;
}
convertColor( attr["selcolor"] ), attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listList.push_back( listData );
+ m_pData->m_listList.push_back( listData );
}
else if( rName == "Playtree" )
convertColor( attr["selcolor"] ), attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listTree.push_back( treeData );
+ m_pData->m_listTree.push_back( treeData );
}
else if( rName == "RadialSlider" )
attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId,
m_curLayoutId );
m_curLayer++;
- m_data.m_listRadialSlider.push_back( radial );
+ m_pData->m_listRadialSlider.push_back( radial );
}
else if( rName == "Slider" )
CheckDefault( "over", "none" );
CheckDefault( "thickness", "10" );
CheckDefault( "value", "none" );
- CheckDefault( "background", "none" );
- CheckDefault( "nbimages", "1" );
CheckDefault( "tooltiptext", "" );
CheckDefault( "help", "" );
newValue = "playtree.slider";
}
const BuilderData::Slider slider( uniqueId( attr["id"] ),
- attr["visible"],
- atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
- attr["lefttop"], attr["rightbottom"], attr["up"], attr["down"],
+ attr["visible"], atoi( attr["x"] ) + m_xOffset,
+ atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
+ attr["rightbottom"], attr["up"], attr["down"],
attr["over"], attr["points"], atoi( attr["thickness"] ),
- newValue, attr["background"], atoi( attr["nbimages"] ),
- attr["tooltiptext"], attr["help"], m_curLayer,
- m_curWindowId, m_curLayoutId );
+ newValue, "none", 0, 0, 0, 0, attr["tooltiptext"],
+ attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listSlider.push_back( slider );
+ m_pData->m_listSlider.push_back( slider );
+ }
+
+ else if( rName == "SliderBackground" )
+ {
+ RequireDefault( "image" );
+ CheckDefault( "nbhoriz", "1" );
+ CheckDefault( "nbvert", "1" );
+ CheckDefault( "padhoriz", "0" );
+ CheckDefault( "padvert", "0" );
+
+ // Retrieve the current slider data
+ BuilderData::Slider &slider = m_pData->m_listSlider.back();
+
+ slider.m_imageId = attr["image"];
+ slider.m_nbHoriz = atoi( attr["nbhoriz"] );
+ slider.m_nbVert = atoi( attr["nbvert"] );
+ slider.m_padHoriz = atoi( attr["padhoriz"] );
+ slider.m_padVert = atoi( attr["padvert"] );
}
else if( rName == "Text" )
CheckDefault( "y", "0" );
CheckDefault( "text", "" );
CheckDefault( "color", "#000000" );
+ CheckDefault( "scrolling", "auto" );
+ CheckDefault( "alignment", "left" );
CheckDefault( "width", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
attr["visible"], attr["font"],
attr["text"], atoi( attr["width"] ),
attr["lefttop"], attr["rightbottom"],
- convertColor( attr["color"] ), attr["help"], m_curLayer,
- m_curWindowId, m_curLayoutId );
+ convertColor( attr["color"] ),
+ attr["scrolling"], attr["alignment"],
+ attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listText.push_back( textData );
+ m_pData->m_listText.push_back( textData );
}
else if( rName == "Theme" )
atoi( attr["magnet"] ),
convertInRange( attr["alpha"], 1, 255, "alpha" ),
convertInRange( attr["movealpha"], 1, 255, "movealpha" ) );
- m_data.m_listTheme.push_back( theme );
+ m_pData->m_listTheme.push_back( theme );
}
else if( rName == "ThemeInfo" )
attr["visible"], convertBoolean( attr["autoresize"] ),
attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
- m_data.m_listVideo.push_back( videoData );
+ m_pData->m_listVideo.push_back( videoData );
}
else if( rName == "Window" )
convertBoolean( attr["visible"] ),
convertBoolean( attr["dragdrop"] ),
convertBoolean( attr["playondrop"] ) );
- m_data.m_listWindow.push_back( window );
+ m_pData->m_listWindow.push_back( window );
}
}
}
-string SkinParser::convertFileName( const char *fileName ) const
-{
- OSFactory *pFactory = OSFactory::instance( getIntf() );
- return m_path + pFactory->getDirSeparator() + string( fileName );
-}
-
-
int SkinParser::convertInRange( const char *value, int minValue, int maxValue,
const string &rAttribute ) const
{