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

📄 layout.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            m_bHeightUnspecified  = (m_LayoutRect.m_eHeightType == CSS2TypeAuto ? TRUE : FALSE);        }    }    return retVal;}HX_RESULT CSmilBasicRegion::resolveDimension(double dLeft,  CSS2Type eLeftType,                                             double dRight, CSS2Type eRightType,                                             double dWidth, CSS2Type eWidthType,                                             BOOL bHaveParentWidth, double dParentWidth,                                             REF(INT32) rlRectMin,                                             REF(INT32) rlRectMax){    HX_RESULT retVal = HXR_OK;    // Convert any percentage values    if (eLeftType  == CSS2TypePercentage ||        eRightType == CSS2TypePercentage ||        eWidthType == CSS2TypePercentage)    {        if (bHaveParentWidth)        {            if (eLeftType == CSS2TypePercentage)            {                eLeftType = CSS2TypeLength;                dLeft     = dLeft * dParentWidth / 100.0;            }            if (eRightType == CSS2TypePercentage)            {                eRightType = CSS2TypeLength;                dRight     = dRight * dParentWidth / 100.0;            }            if (eWidthType == CSS2TypePercentage)            {                eWidthType = CSS2TypeLength;                dWidth     = dWidth * dParentWidth / 100.0;            }        }        else        {            retVal = HXR_FAIL;        }    }    if (SUCCEEDED(retVal))    {        // Apply the following algorithm, where bbw        // is the "bounding box width" or in this        // case, the parent dimension (pw). See the SMIL 2.0 Layout        // module for full detail.        //        //        Attribute values       Resulting value             RECT values        // Case left   width  right   left     width    right    min(=left) max(=pw-right)        // =============================================================================        //  0   auto   auto   auto      0       pw        0         0         pw        //  1   auto   auto     R       0      pw-R       R         0        pw-R        //  2   auto     W    auto      0        W       pw-W       0          W        //  3   auto     W      R    pw-R-W      W        R      pw-R-W      pw-R        //  4     L    auto   auto      L      pw-L       0         L         pw        //  5     L    auto     R       L     pw-R-L      R         L        pw-R        //  6     L      W    auto      L        W     pw-L-W       L         L+W        //  7     L      W      R       L        W     pw-L-W       L         L+W        //        // The algorithm is the same for top/height/bottom.        //        double dMin = 0.0;        double dMax = 0.0;        // Which case do we have?        if (eLeftType == CSS2TypeAuto)        {            if (eWidthType == CSS2TypeAuto)            {                if (eRightType == CSS2TypeAuto)                {                    // Case 0                    if (bHaveParentWidth)                    {                        dMin = 0.0;                        dMax = dParentWidth;                    }                    else                    {                        retVal = HXR_FAIL;                    }                }                else                {                    // Case 1                    if (bHaveParentWidth)                    {                        dMin = 0.0;                        dMax = dParentWidth - dRight;                    }                    else                    {                        retVal = HXR_FAIL;                    }                }            }            else            {                if (eRightType == CSS2TypeAuto)                {                    // Case 2                    dMin = 0.0;                    dMax = dWidth;                }                else                {                    // Case 3                    if (bHaveParentWidth)                    {                        dMin = dParentWidth - dRight - dWidth;                        dMax = dParentWidth - dRight;                    }                    else                    {                        retVal = HXR_FAIL;                    }                }            }        }        else        {            if (eWidthType == CSS2TypeAuto)            {                if (eRightType == CSS2TypeAuto)                {                    // Case 4                    if (bHaveParentWidth)                    {                        dMin = dLeft;                        dMax = dParentWidth;                    }                    else                    {                        retVal = HXR_FAIL;                    }                }                else                {                    // Case 5                    if (bHaveParentWidth)                    {                        dMin = dLeft;                        dMax = dParentWidth - dRight;                    }                    else                    {                        retVal = HXR_FAIL;                    }                }            }            else            {                if (eRightType == CSS2TypeAuto)                {                    // Case 6                    dMin = dLeft;                    dMax = dLeft + dWidth;                }                else                {                    // Case 7                    dMin = dLeft;                    dMax = dLeft + dWidth;                }            }        }        // Now assign the out parameters        if (SUCCEEDED(retVal))        {            rlRectMin = (INT32) (dMin + 0.5);            rlRectMax = (INT32) (dMax + 0.5);        }    }    return retVal;}CSmilBasicRootLayout::CSmilBasicRootLayout() :    CSmilBasicBox(){    m_pRoot              = NULL;    m_OriginalSize.cx    = 0;    m_OriginalSize.cy    = 0;    m_bOriginalWidthSet  = FALSE;    m_bOriginalHeightSet = FALSE;}CSmilBasicRootLayout::~CSmilBasicRootLayout(){}HX_RESULT CSmilBasicRootLayout::computeDimension(BoxDimension eDim){    HX_RESULT retVal = HXR_OK;    // There's nothing to do here really. For <root-layout>    // and <viewport>, the width and height will get resolved    // either from the values of "width" and "height" themselves,    // or they will get resolved from their children's width    // and height. So if we are already resolved, we will stay    // resolved and return HXR_OK. If not, we will stay not resolved    // and return HXR_FAIL.    if ((eDim == BoxDimensionWidth  && !m_bWidthResolved) ||        (eDim == BoxDimensionHeight && !m_bHeightResolved))    {        retVal = HXR_FAIL;    }    return retVal;}HX_RESULT CSmilBasicRootLayout::resolveFromChildren(BoxDimension eDim){    HX_RESULT retVal = HXR_OK;    INT32 lMax = 0;    retVal     = computeChildrenMax(eDim, TRUE, lMax);    if (SUCCEEDED(retVal))    {        if (eDim == BoxDimensionWidth)        {            m_bWidthResolved    = TRUE;            m_Rect.left         = 0;            m_Rect.right        = lMax;            if (!m_bOriginalWidthSet)            {                m_OriginalSize.cx   = m_Rect.right;                m_bOriginalWidthSet = TRUE;            }        }        else        {            m_bHeightResolved = TRUE;            m_Rect.top        = 0;            m_Rect.bottom     = lMax;            if (!m_bOriginalHeightSet)            {                m_OriginalSize.cy    = m_Rect.bottom;                m_bOriginalHeightSet = TRUE;            }        }    }    return retVal;}void CSmilBasicRootLayout::SetParserRootLayout(CSmilRootLayout* pRoot){    // Assign the member variable    m_pRoot = pRoot;    // Set up the box parameters    if (pRoot)    {        // Get the resizeBehavior from our CSmilRootLayout element        m_eResizeBehavior = pRoot->m_eResizeBehavior;        // Check if the width is resolved on its own.        // Based on its values along, the width of the        // root-layout is only resolved if the width        // is specified as an absolute length        if (pRoot->m_eWidthType == CSS2TypeLength)        {            // Assign the rect values            m_Rect.left  = 0;            m_Rect.right = (INT32) (pRoot->m_dWidth + 0.5);            // Set the resolved flag            m_bWidthResolved = TRUE;            // Set the original width and the flag            if (!m_bOriginalWidthSet)            {                m_OriginalSize.cx   = m_Rect.right;                m_bOriginalWidthSet = TRUE;            }        }        // Check if the height is resolved on its own.        // Based on its values along, the height of the        // root-layout is only resolved if the height        // is specified as an absolute length        if (pRoot->m_eHeightType == CSS2TypeLength)        {            // Assign the rect values            m_Rect.top    = 0;            m_Rect.bottom = (INT32) (pRoot->m_dHeight + 0.5);            // Set the resolved flag            m_bHeightResolved = TRUE;            // Set the original height and the flag            if (!m_bOriginalHeightSet)            {                m_OriginalSize.cy    = m_Rect.bottom;                m_bOriginalHeightSet = TRUE;            }        }    }}BOOL CSmilBasicRootLayout::IsWidthSet() const{    return m_bWidthResolved;}BOOL CSmilBasicRootLayout::IsHeightSet() const{    return m_bHeightResolved;}UINT32 CSmilBasicRootLayout::GetWidth() const{    return (UINT32) HXxRECT_WIDTH(m_Rect);}UINT32 CSmilBasicRootLayout::GetHeight() const{    return (UINT32) HXxRECT_HEIGHT(m_Rect);}UINT32 CSmilBasicRootLayout::GetBackgroundColor() const{    UINT32 ulRet = 0;    if (m_pRoot)    {        ulRet = m_pRoot->m_ulBackgroundColor;    }    return ulRet;}#if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)CSmilBasicViewport::CSmilBasicViewport(CSmilViewport* pPort) :    CSmilBasicBox(){    // Assign member variables    m_pPort              = pPort;    m_ulNumActiveMedia   = 0;    m_bOpen              = FALSE;    m_OriginalSize.cx    = 0;    m_OriginalSize.cy    = 0;    m_bOriginalWidthSet  = FALSE;    m_bOriginalHeightSet = FALSE;    m_bViewportIsSetup   = FALSE;    // Determine if the width and height are resolved    if (pPort)    {        // Get the resize behavior from our CSmilViewport element        m_eResizeBehavior = pPort->m_eResizeBehavior;        // Copy the id for convenience        m_id = pPort->m_pNode->m_id;        // Check if the width is resolved on its own.        // Based on its values along, the width of the        // viewport is only resolved if the width        // is specified as an absolute length        if (pPort->m_eWidthType == CSS2TypeLength)        {            // Assign the rect values            m_Rect.left  = 0;            m_Rect.right = (INT32) (pPort->m_dWidth + 0.5);            // Set the resolved flag            m_bWidthResolved = TRUE;            // Set the original width and flag            if (!m_bOriginalWidthSet)            {                m_OriginalSize.cx   = m_Rect.right;                m_bOriginalWidthSet = TRUE;            }        }        // Check if the height is resolved on its own.        // Based on its values along, the height of the        // viewport is only resolved if the height        // is specified as an absolute length        if (pPort->m_eHeightType == CSS2TypeLength)        {            // Assign the rect values            m_Rect.top    = 0;            m_Rect.bottom = (INT32) (pPort->m_dHeight + 0.5);            // Set the resolved flag            m_bHeightResolved = TRUE;            // Set the original height and flag            if (!m_bOriginalHeightSet)            {                m_OriginalSize.cy    = m_Rect.bottom;                m_bOriginalHeightSet = TRUE;            }        }    }}CSmilBasicViewport::~CSmilBasicViewport(){}HX_RESULT CSmilBasicViewport::computeDimension(BoxDimension eDim){    HX_RESULT retVal = HXR_OK;    // There's nothing to do here really. For <root-layout>    // and <viewport>, the width and height will get resolved    // either from the values of "width" and "height" themselves,    // or they will get resolved from their children's width    // and height. So if we are already resolved, we will stay    // resolved and return HXR_OK. If not, we will stay not resolved    // and return HXR_FAIL.    if ((eDim == BoxDimensionWidth  && !m_bWidthResolved) ||        (eDim == BoxDimensionHeight && !m_bHeightResolved))    {        retVal = HXR_FAIL;    }    return retVal;}HX_RESULT CSmilBasicViewport::resolveFromChildren(BoxDimension eDim){    HX_RESULT retVal = HXR_OK;    INT32 lMax = 0;    retVal     = computeChildrenMax(eDim, TRUE, lMax);    if (SUCCEEDED(retVal))    {        if (eDim == BoxDimensionWidth)        {            m_bWidthResolved = TRUE;            m_Rect.left      = 0;            m_Rect.right     = lMax;            if (!m_bOriginalWidthSet)            {                m_OriginalSize.cx   = m_Rect.right;                m_bOriginalWidthSet = TRUE;            }        }        else        {            m_bHeightResolved = TRUE;            m_Rect.top        = 0;            m_Rect.bottom     = lMax;            if (!m_bOriginalHeightSet)            {                m_OriginalSize.cy    = m_Rect.bottom;                m_bOriginalHeightSet = TRUE;            }        }    }    return retVal;}#endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */

⌨️ 快捷键说明

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