void CXTPCoreTreeControl::RecalcLayout()
{
	if (!GetSafeHwnd())
		return;

	if (m_nLockRedraw > 0)
		return;


	CXTPClientRect rc(this);

	m_rcControl = rc;
	CRect rcMargin(0, 0, 0, 0);

	{
		CClientDC dc(this);

		int nPos = RecalcTreeItems(m_pItems, &dc, 0, rcMargin);

		m_nClientHeight = nPos;
	}

	UpdateScrollBar();

	RedrawControl();
}
Beispiel #2
0
void SSkinScrollbar::_Draw(IRenderTarget *pRT, LPCRECT prcDraw, DWORD dwState,BYTE byAlpha)
{
    if(!m_pImg) return;
    int nSbCode=LOWORD(dwState);
    int nState=LOBYTE(HIWORD(dwState));
    BOOL bVertical=HIBYTE(HIWORD(dwState));
    CRect rcMargin(0,0,0,0);
    if(bVertical)
        rcMargin.top=m_nMargin,rcMargin.bottom=m_nMargin;
    else
        rcMargin.left=m_nMargin,rcMargin.right=m_nMargin;

    CRect rcSour=GetPartRect(nSbCode,nState,bVertical);
    
    pRT->DrawBitmap9Patch(prcDraw,m_pImg,&rcSour,&rcMargin,m_bTile?EM_TILE:EM_STRETCH,byAlpha);
    
    if(nSbCode==SB_THUMBTRACK && m_bHasGripper)
    {
        rcSour=GetPartRect(SB_THUMBGRIPPER,0,bVertical);
        CRect rcDraw=*prcDraw;
        
        if (bVertical)
            rcDraw.top+=(rcDraw.Height()-rcSour.Height())/2,rcDraw.bottom=rcDraw.top+rcSour.Height();
        else
            rcDraw.left+=(rcDraw.Width()-rcSour.Width())/2,rcDraw.right=rcDraw.left+rcSour.Width();
        pRT->DrawBitmap9Patch(&rcDraw,m_pImg,&rcSour,&rcMargin,m_bTile?EM_TILE:EM_STRETCH,byAlpha);
    }
}
int CXTPCoreTreeControl::RecalcTreeItems(CXTPCoreTreeItems* pItems, CDC* pDC, int nLevel, LPCRECT lprcMargin)
{
	int nTop = lprcMargin->top;
	int nWidth = m_rcControl.Width() - lprcMargin->left - lprcMargin->right;

	POSITION pos = pItems->GetHeadPosition();
	while (pos)
	{
		CXTPCoreTreeItem* pItem = pItems->GetNext(pos);

		CSize sz = pItem->CalcSize(pDC, nWidth);

		pItem->SetRect(CRect(m_rcControl.left + lprcMargin->left, nTop, m_rcControl.right - lprcMargin->right, nTop + sz.cy));

		nTop += sz.cy;

		if (pItem->IsExpanded() && pItem->HasChildren())
		{
			CRect rcMargin(lprcMargin);
			rcMargin.top = nTop;

			rcMargin.left += m_pPaintManager->GetChildrenIndent(pItem);

			nTop = RecalcTreeItems(pItem->GetChildren(), pDC, nLevel + 1, rcMargin);
		}
	}

	return nTop;
}
Beispiel #4
0
	UINT SFencesView::OnWndNcHitTest(CPoint point)
	{
		CRect rcMargin(5, 5, 5, 5);
		CRect rcWindow = GetClientRect();

		if (point.x > rcWindow.right - rcMargin.right)
		{
			if (point.y > rcWindow.bottom - rcMargin.bottom)
			{
				return HTBOTTOMRIGHT;
			}
			else if (point.y < (rcWindow.top+rcMargin.top))
			{
				return HTTOPRIGHT;
			}
			return HTRIGHT;
		}
		else if (point.x < rcWindow.left+rcMargin.left)
		{
			if (point.y > rcWindow.bottom - rcMargin.bottom)
			{
				return HTBOTTOMLEFT;
			}
			else if (point.y < (rcWindow.top+rcMargin.top))
			{
				return HTTOPLEFT;
			}
			return HTLEFT;
		}
		else if (point.y > rcWindow.bottom - rcMargin.bottom)
		{
			return HTBOTTOM;
		}
		else if (point.y < (rcWindow.top+rcMargin.top))
		{
			return HTTOP;
		}

		return HTCLIENT;
	}
HRESULT CCUILayoutHorizontal::CalcSize(IUIFrame* pHostFrame, SIZE szOld, SIZE* pOutSize)
{
	DEBUG_ASSERT(pHostFrame) ;
	IF_RETURN(NULL == pHostFrame, E_INVALIDARG) ;
	DEBUG_ASSERT(pOutSize) ;
	IF_RETURN(NULL == pOutSize, E_INVALIDARG) ;

	BOOL bAutoWidth = FALSE, bAutoHeight = FALSE ;
	pHostFrame->GetAutoWidth(&bAutoWidth) ;
	pHostFrame->GetAutoHeight(&bAutoHeight) ;

	if (!bAutoWidth && !bAutoHeight)
	{
		*pOutSize = szOld ;
		return S_OK ;
	}

	CRect _rcPadding(0, 0, 0, 0) ;
	pHostFrame->GetPadding(_rcPadding) ;
	CRect _rcExtPadding(0, 0, 0, 0) ;
	CComQIPtr<IUIFrameInternal> pFrameInternal = pHostFrame ;
	if (pFrameInternal)
	{
		pFrameInternal->GetExtPadding(&_rcExtPadding) ;
	}

	CSize szMinBoundSize = szOld ;
	if (bAutoHeight)
	{
		szMinBoundSize.cy = 0 ;
	}

	if (bAutoWidth)
	{
		szMinBoundSize.cx = 0 ;
	}

	VEC_FRAME _vec_frame ;
	LONG lChildrenCount = 0 ;
	pHostFrame->GetChildrenCount(&lChildrenCount) ;
	for (INT i = 0; i < lChildrenCount; ++i)
	{
		//IF_CONTINUE(i == this->m_nFillItem - 1) ;

		CComPtr<IUIElement> pElement ;
		pHostFrame->GetChildByIndex(i, &pElement) ;
		CComQIPtr<IUIFrame> pFrame = pElement ;
		IF_CONTINUE(NULL == pFrame) ;

		CComQIPtr<IUIFrameInternal> pFrameInternal = pFrame ;
		IF_CONTINUE(NULL == pFrameInternal) ;

		BOOL bHidden = FALSE ;
		pFrame->GetHidden(&bHidden) ;
		IF_CONTINUE(TRUE == bHidden) ;

		BOOL bFloat = TRUE ;
		pFrame->GetFloat(&bFloat) ;
		IF_CONTINUE(TRUE == bFloat) ;

		BOOL bChildHeightAsParent = FALSE ;
		pFrame->GetHeightAsParent(&bChildHeightAsParent) ;
		BOOL bChildWidthAsParent = FALSE ;
		pFrame->GetWidthAsParent(&bChildWidthAsParent) ;
		BOOL bChildAutoHeight = FALSE ;
		pFrame->GetAutoHeight(&bChildAutoHeight) ;
		BOOL bChildAutoWidth = FALSE ;
		pFrame->GetAutoWidth(&bChildAutoWidth) ;

		if (bChildHeightAsParent && bChildAutoWidth && bAutoHeight)
		{
			_vec_frame.push_back(pFrame) ;
		}
		else
		{
			CRect rcFrameMargin(0, 0, 0, 0) ;
			pFrame->GetMargin(&rcFrameMargin) ;
			
			CSize szEstimateSize(-1, -1) ;
			if (bChildWidthAsParent)
			{
				szEstimateSize.cx = 0 ;
			}
			if (bChildHeightAsParent && !bAutoHeight)
			{
				szEstimateSize.cy = szOld.cy - _rcPadding.top - _rcPadding.bottom - _rcExtPadding.top - _rcExtPadding.bottom ;		
			}
			pFrameInternal->SetEstimateSize(szEstimateSize) ;

			CSize szFrame(0, 0) ;
			pFrame->GetSize(&szFrame) ;
			if (i == this->m_nFillItem -1  || -1 * lChildrenCount + i == this->m_nFillItem)
			{
				szFrame.cx = 0 ;
			}

			if (bAutoHeight)
			{
				INT nHeight = szFrame.cy + rcFrameMargin.top + rcFrameMargin.bottom ;
				if (nHeight > szMinBoundSize.cy)
				{
					szMinBoundSize.cy = nHeight ;
				}
			}

			if (bAutoWidth)
			{
				szMinBoundSize.cx += (szFrame.cx + rcFrameMargin.left + rcFrameMargin.right) ;
			}
		}
	}

	if (bAutoWidth)
	{
		for (INT i = 0; i < (INT)_vec_frame.size(); ++i)
		{
			CComPtr<IUIFrame> pFrame = _vec_frame[i] ;
			CComQIPtr<IUIFrameInternal> pFrameInternal = _vec_frame[i] ;
			IF_CONTINUE(NULL == pFrame || NULL == pFrameInternal) ;

			CRect rcMargin(0, 0, 0, 0) ;
			pFrame->GetMargin(&rcMargin) ;

			CSize szEstimateSize(0, 0) ;
			szEstimateSize.cx = -1 ;
			szEstimateSize.cy = szMinBoundSize.cy - rcMargin.top - rcMargin.bottom ;
			pFrameInternal->SetEstimateSize(szEstimateSize) ;

			CSize szFrame(0, 0) ;
			pFrame->GetSize(&szFrame) ;
			szMinBoundSize.cx = szFrame.cx + rcMargin.left + rcMargin.right ;
		}
	}


	if (bAutoWidth)
	{
		szMinBoundSize.cx += _rcPadding.left + _rcPadding.right + _rcExtPadding.left + _rcExtPadding.right ;
	}

	if (bAutoHeight)
	{
		szMinBoundSize.cy += _rcPadding.top + _rcPadding.bottom + _rcExtPadding.top + _rcExtPadding.bottom ;
	}

	*pOutSize = szMinBoundSize ;
	return S_OK ;
}