⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skin_parser.cpp

📁 uclinux 下的vlc播放器源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    {        RequireDefault( "id" );        RequireDefault( "font" );        CheckDefault( "visible", "true" );        CheckDefault( "flat", "false" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "width", "0" );        CheckDefault( "height", "0" );        CheckDefault( "lefttop", "lefttop" );        CheckDefault( "rightbottom", "lefttop" );        CheckDefault( "xkeepratio", "false" );        CheckDefault( "ykeepratio", "false" );        CheckDefault( "bgimage", "none" );        CheckDefault( "itemimage", "none" );        CheckDefault( "openimage", "none" );        CheckDefault( "closedimage", "none" );        CheckDefault( "fgcolor", "#000000" );        CheckDefault( "playcolor", "#FF0000" );        CheckDefault( "bgcolor1", "#FFFFFF" );        CheckDefault( "bgcolor2", "#FFFFFF" );        CheckDefault( "selcolor", "#0000FF" );        CheckDefault( "help", "" );        m_curTreeId = uniqueId( attr["id"] );        const BuilderData::Tree treeData( m_curTreeId, atoi( attr["x"] ) +                m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],                attr["flat"],                atoi( attr["width"]), atoi( attr["height"] ),                attr["lefttop"], attr["rightbottom"],                convertBoolean( attr["xkeepratio"] ),                convertBoolean( attr["ykeepratio"] ),                attr["font"], "playtree",                attr["bgimage"], attr["itemimage"],                attr["openimage"], attr["closedimage"],                attr["fgcolor"], attr["playcolor"],                attr["bgcolor1"], attr["bgcolor2"],                attr["selcolor"], attr["help"],                m_curLayer, m_curWindowId, m_curLayoutId );        m_curLayer++;        m_pData->m_listTree.push_back( treeData );    }    else if( rName == "RadialSlider" )    {        RequireDefault( "sequence" );        RequireDefault( "nbimages" );        CheckDefault( "id", "none" );        CheckDefault( "visible", "true" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "lefttop", "lefttop" );        CheckDefault( "rightbottom", "lefttop" );        CheckDefault( "xkeepratio", "false" );        CheckDefault( "ykeepratio", "false" );        CheckDefault( "minangle", "0" );        CheckDefault( "maxangle", "360" );        CheckDefault( "value", "none" );        CheckDefault( "tooltiptext", "" );        CheckDefault( "help", "" );        const BuilderData::RadialSlider radial( uniqueId( attr["id"] ),                attr["visible"],                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,                attr["lefttop"], attr["rightbottom"],                convertBoolean( attr["xkeepratio"] ),                convertBoolean( attr["ykeepratio"] ), attr["sequence"],                atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI /180,                atof( attr["maxAngle"] ) * M_PI / 180, attr["value"],                attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId,                m_curLayoutId );        m_curLayer++;        m_pData->m_listRadialSlider.push_back( radial );    }    else if( rName == "Slider" )    {        RequireDefault( "up" );        RequireDefault( "points" );        CheckDefault( "id", "none" );        CheckDefault( "visible", "true" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "width", "0" );        CheckDefault( "height", "0" );        CheckDefault( "lefttop", "lefttop" );        CheckDefault( "rightbottom", "lefttop" );        CheckDefault( "xkeepratio", "false" );        CheckDefault( "ykeepratio", "false" );        CheckDefault( "down", "none" );        CheckDefault( "over", "none" );        CheckDefault( "thickness", "10" );        CheckDefault( "value", "none" );        CheckDefault( "tooltiptext", "" );        CheckDefault( "help", "" );        string newValue = attr["value"];        if( m_curListId != "" )        {            // Slider associated to a list            newValue = "playlist.slider";        }        else if( m_curTreeId != "" )        {            // Slider associated to a tree            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"], convertBoolean( attr["xkeepratio"] ),                convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"],                attr["over"], attr["points"], atoi( attr["thickness"] ),                newValue, "none", 0, 0, 0, 0, attr["tooltiptext"],                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );        m_curLayer++;        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" )    {        RequireDefault( "font" );        CheckDefault( "id", "none" );        CheckDefault( "visible", "true" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "text", "" );        CheckDefault( "color", "#000000" );        CheckDefault( "scrolling", "auto" );        CheckDefault( "alignment", "left" );        CheckDefault( "width", "0" );        CheckDefault( "lefttop", "lefttop" );        CheckDefault( "rightbottom", "lefttop" );        CheckDefault( "xkeepratio", "false" );        CheckDefault( "ykeepratio", "false" );        CheckDefault( "help", "" );        const BuilderData::Text textData( uniqueId( attr["id"] ),                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,                attr["visible"], attr["font"],                attr["text"], atoi( attr["width"] ),                attr["lefttop"], attr["rightbottom"],                convertBoolean( attr["xkeepratio"] ),                convertBoolean( attr["ykeepratio"] ),                convertColor( attr["color"] ),                attr["scrolling"], attr["alignment"],                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );        m_curLayer++;        m_pData->m_listText.push_back( textData );    }    else if( rName == "Theme" )    {        RequireDefault( "version" );        CheckDefault( "tooltipfont", "defaultfont" );        CheckDefault( "magnet", "15" );        CheckDefault( "alpha", "255" );        CheckDefault( "movealpha", "255" );        // Check the version        if( strcmp( attr["version"], SKINS_DTD_VERSION ) )        {            msg_Err( getIntf(), "bad theme version : %s (you need version %s)",                     attr["version"], SKINS_DTD_VERSION );            m_errors = true;            return;        }        const BuilderData::Theme theme( attr["tooltipfont"],                atoi( attr["magnet"] ),                convertInRange( attr["alpha"], 1, 255, "alpha" ),                convertInRange( attr["movealpha"], 1, 255, "movealpha" ) );        m_pData->m_listTheme.push_back( theme );    }    else if( rName == "ThemeInfo" )    {        CheckDefault( "name", "" );        CheckDefault( "author", "" );        CheckDefault( "email", "" );        CheckDefault( "website", "" );        msg_Info( getIntf(), "skin: %s  author: %s", attr["name"],                  attr["author"] );    }    else if( rName == "Video" )    {        CheckDefault( "id", "none" );        CheckDefault( "visible", "true" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "width", "0" );        CheckDefault( "height", "0" );        CheckDefault( "lefttop", "lefttop" );        CheckDefault( "rightbottom", "lefttop" );        CheckDefault( "xkeepratio", "false" );        CheckDefault( "ykeepratio", "false" );        CheckDefault( "autoresize", "false" );        CheckDefault( "help", "" );        const BuilderData::Video videoData( uniqueId( attr["id"] ),                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,                atoi( attr["width"] ), atoi( attr["height" ]),                attr["lefttop"], attr["rightbottom"],                convertBoolean( attr["xkeepratio"] ),                convertBoolean( attr["ykeepratio"] ),                attr["visible"], convertBoolean( attr["autoresize"] ),                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );        m_curLayer++;        m_pData->m_listVideo.push_back( videoData );    }    else if( rName == "Window" )    {        CheckDefault( "id", "none" );        CheckDefault( "visible", "true" );        CheckDefault( "x", "0" );        CheckDefault( "y", "0" );        CheckDefault( "dragdrop", "true" );        CheckDefault( "playondrop", "true" );        m_curWindowId = uniqueId( attr["id"] );        const BuilderData::Window window( m_curWindowId,                atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,                convertBoolean( attr["visible"] ),                convertBoolean( attr["dragdrop"] ),                convertBoolean( attr["playondrop"] ) );        m_pData->m_listWindow.push_back( window );    }}void SkinParser::handleEndElement( const string &rName ){    if( rName == "Group" )    {        m_xOffset -= m_xOffsetList.back();        m_yOffset -= m_yOffsetList.back();        m_xOffsetList.pop_back();        m_yOffsetList.pop_back();    }    else if( rName == "Playlist" )    {        m_curListId = "";    }    else if( rName == "Playtree" )    {        m_curTreeId = "";    }    else if( rName == "Popup" )    {        m_curPopupId = "";        m_popupPosList.pop_back();    }}bool SkinParser::convertBoolean( const char *value ) const{    return strcmp( value, "true" ) == 0;}int SkinParser::convertColor( const char *transcolor ){    // TODO: move to the builder    unsigned long iRed, iGreen, iBlue;    iRed = iGreen = iBlue = 0;    sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue );    return ( iRed << 16 | iGreen << 8 | iBlue );}int SkinParser::convertInRange( const char *value, int minValue, int maxValue,                                const string &rAttribute ) const{    int intValue = atoi( value );    if( intValue < minValue )    {        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "                  "expected range [%i, %i], using %i instead",                  rAttribute.c_str(), intValue, minValue, maxValue, minValue );        return minValue;    }    else if( intValue > maxValue )    {        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "                  "expected range [%i, %i], using %i instead",                  rAttribute.c_str(), intValue, minValue, maxValue, maxValue );        return maxValue;    }    else    {        return intValue;    }}const string SkinParser::generateId() const{    static int i = 1;    char genId[5];    snprintf( genId, 4, "%i", i++ );    string base = "_ReservedId_" + (string)genId;    return base;}const string SkinParser::uniqueId( const string &id ){    string newId;    if( m_idSet.find( id ) != m_idSet.end() )    {        // The id was already used        if( id != "none" )        {            msg_Warn( getIntf(), "non-unique id: %s", id.c_str() );        }        newId = generateId();    }    else    {        // OK, this is a new id        newId = id;    }    // Add the id to the set    m_idSet.insert( newId );    return newId;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -