当前位置: 首页>>代码示例>>C++>>正文


C++ SWindow::GetScale方法代码示例

本文整理汇总了C++中SWindow::GetScale方法的典型用法代码示例。如果您正苦于以下问题:C++ SWindow::GetScale方法的具体用法?C++ SWindow::GetScale怎么用?C++ SWindow::GetScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SWindow的用法示例。


在下文中一共展示了SWindow::GetScale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MeasureChildren

	//nWidth,nHeight == -1:wrap_content
	CSize SLinearLayout::MeasureChildren(SWindow * pParent,int nWidth,int nHeight) const
	{
		CSize *pSize = new CSize [pParent->GetChildrenCount()];


        ILayoutParam * pParentLayoutParam = pParent->GetLayoutParam();

		int iChild = 0;

		SWindow *pChild = pParent->GetNextLayoutChild(NULL);
		while(pChild)
		{
			SLinearLayoutParam *pLinearLayoutParam = pChild->GetLayoutParamT<SLinearLayoutParam>();
			int nScale = pChild->GetScale();
			CSize szChild(SIZE_WRAP_CONTENT,SIZE_WRAP_CONTENT);
			if(pLinearLayoutParam->IsMatchParent(Horz))
            {
                if(!pParentLayoutParam->IsWrapContent(Horz))
                    szChild.cx = nWidth;
            }
			else if(pLinearLayoutParam->IsSpecifiedSize(Horz))
            {
                szChild.cx = pLinearLayoutParam->GetSpecifiedSize(Horz).toPixelSize(nScale);
                szChild.cx += pLinearLayoutParam->extend_left.toPixelSize(nScale) + pLinearLayoutParam->extend_right.toPixelSize(nScale);
            }
			if(pLinearLayoutParam->IsMatchParent(Vert))
            {
                if(!pParentLayoutParam->IsWrapContent(Vert))
                    szChild.cy = nHeight;
            }
			else if(pLinearLayoutParam->IsSpecifiedSize(Vert))
            {
                szChild.cy = pLinearLayoutParam->GetSpecifiedSize(Vert).toPixelSize(nScale);
                szChild.cy += pLinearLayoutParam->extend_top.toPixelSize(nScale) + pLinearLayoutParam->extend_bottom.toPixelSize(nScale);
            }
			if(szChild.cx == SIZE_WRAP_CONTENT || szChild.cy == SIZE_WRAP_CONTENT)
			{
                int nWid = szChild.cx, nHei = szChild.cy;
                if(nWid == SIZE_WRAP_CONTENT)
                    nWid = nWidth * pParentLayoutParam->IsWrapContent(Horz)?-1:1; //把父窗口的WrapContent属性通过-1标志传递给GetDesiredSize
                if(nHei == SIZE_WRAP_CONTENT)
                    nHei = nHeight * pParentLayoutParam->IsWrapContent(Vert)?-1:1;//把父窗口的WrapContent属性通过-1标志传递给GetDesiredSize

				CSize szCalc = pChild->GetDesiredSize(nWid,nHei);
				if(szChild.cx == SIZE_WRAP_CONTENT) 
                {
                    szChild.cx = szCalc.cx;
                    szChild.cx += pLinearLayoutParam->extend_left.toPixelSize(nScale) + pLinearLayoutParam->extend_right.toPixelSize(nScale);
                }
				if(szChild.cy == SIZE_WRAP_CONTENT) 
                {
                    szChild.cy = szCalc.cy;
                    szChild.cy += pLinearLayoutParam->extend_top.toPixelSize(nScale) + pLinearLayoutParam->extend_bottom.toPixelSize(nScale);
                }
			}

			pSize [iChild++] = szChild;

			pChild = pParent->GetNextLayoutChild(pChild);
		}
		

		CSize szRet;
		for(int i=0;i<iChild;i++)
		{
			if(m_orientation == Horz)
			{
				szRet.cx += pSize[i].cx;
				szRet.cy = (std::max)(szRet.cy,pSize[i].cy);
			}else
			{
				szRet.cx = (std::max)(szRet.cx,pSize[i].cx);
				szRet.cy += pSize[i].cy;
			}
		}
		delete []pSize;
		return szRet;
	}
开发者ID:,项目名称:,代码行数:79,代码来源:

示例2: LayoutChildren

    void SLinearLayout::LayoutChildren(SWindow * pParent)
    {
        CRect rcParent = pParent->GetChildrenLayoutRect();
		        
        CSize *pSize = new CSize [pParent->GetChildrenCount()];
		SWindow ** pChilds = new SWindow * [pParent->GetChildrenCount()];
		int nChilds = 0;
		
        int offset = 0;
        float fWeight= 0.0f;

        {//assign width or height

            int iChild = 0;

			SWindow *pChild=pParent->GetNextLayoutChild(NULL);
            while(pChild)
            {
				SLinearLayoutParam *pLinearLayoutParam = pChild->GetLayoutParamT<SLinearLayoutParam>();

				int nScale = pChild->GetScale();

                CSize szChild(SIZE_WRAP_CONTENT,SIZE_WRAP_CONTENT);
                if(pLinearLayoutParam->IsMatchParent(Horz))
                    szChild.cx = rcParent.Width();
                else if(pLinearLayoutParam->IsSpecifiedSize(Horz))
                {
                    szChild.cx = pLinearLayoutParam->GetSpecifiedSize(Horz).toPixelSize(nScale);
                    szChild.cx += pLinearLayoutParam->extend_left.toPixelSize(nScale) + pLinearLayoutParam->extend_right.toPixelSize(nScale);
                }

                if(pLinearLayoutParam->IsMatchParent(Vert))
                    szChild.cy = rcParent.Height();
                else if(pLinearLayoutParam->IsSpecifiedSize(Vert))
                {
                    szChild.cy = pLinearLayoutParam->GetSpecifiedSize(Vert).toPixelSize(nScale);
                    szChild.cy += pLinearLayoutParam->extend_top.toPixelSize(nScale) + pLinearLayoutParam->extend_bottom.toPixelSize(nScale);
                }
                
                if(pLinearLayoutParam->weight > 0.0f)
                {
                    fWeight += pLinearLayoutParam->weight;
                }

                if(szChild.cx == SIZE_WRAP_CONTENT || szChild.cy == SIZE_WRAP_CONTENT)
                {
                    CSize szCalc = pChild->GetDesiredSize(szChild.cx,szChild.cy);
                    if(szChild.cx == SIZE_WRAP_CONTENT)
                    {
                        szChild.cx = szCalc.cx;
                        szChild.cx += pLinearLayoutParam->extend_left.toPixelSize(nScale) + pLinearLayoutParam->extend_right.toPixelSize(nScale);
                    }
                    if(szChild.cy == SIZE_WRAP_CONTENT) 
                    {
                        szChild.cy = szCalc.cy;
                        szChild.cy += pLinearLayoutParam->extend_top.toPixelSize(nScale) + pLinearLayoutParam->extend_bottom.toPixelSize(nScale);
                    }
                }

				pChilds[iChild] = pChild;
                pSize [iChild] = szChild;
                offset += m_orientation == Vert ? szChild.cy:szChild.cx;

				iChild++;
				pChild=pParent->GetNextLayoutChild(pChild);
            }

			nChilds = iChild;
        }

        int size = m_orientation == Vert? rcParent.Height():rcParent.Width();
        if(fWeight > 0.0f && size > offset)
        {//assign size by weight
            int nRemain = size - offset;
			for(int iChild = 0;iChild < nChilds;iChild ++)
            {
				SWindow *pChild = pChilds[iChild];

				SLinearLayoutParam *pLinearLayoutParam = pChild->GetLayoutParamT<SLinearLayoutParam>();

                if(pLinearLayoutParam->weight > 0.0f)
                {
                    LONG & szChild = m_orientation == Vert? pSize[iChild].cy:pSize[iChild].cx;
                    szChild += (int)(nRemain*pLinearLayoutParam->weight/fWeight);
                }
            }
        }
        {//assign position
            offset = 0;
			for(int iChild = 0;iChild < nChilds;iChild ++)
			{
				SWindow *pChild = pChilds[iChild];


                SLinearLayoutParam *pLinearLayoutParam = pChild->GetLayoutParamT<SLinearLayoutParam>();
				int nScale = pChild->GetScale();
                Gravity gravity = pLinearLayoutParam->gravity == G_Undefined? m_gravity:pLinearLayoutParam->gravity;
                if(gravity == G_Undefined) gravity = G_Left;

                if(m_orientation == Vert)
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的SWindow::GetScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。