Пример #1
0
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::HitTest(CPoint pt, CRect* lpRect) const
{
	if (!IsExpanded())
		return NULL;

	int nOffset = m_pPanel->GetScrollOffset() - m_nCaptionHeight - m_rcGroupCurrent.top + GetScrollOffsetPos();
	pt.y += nOffset;

	for (int i = 0; i < GetItemCount(); i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		CRect rcItem = pItem->GetItemRect();

		if (rcItem.PtInRect(pt) && pItem->IsVisible())
		{
			if (lpRect)
			{
				rcItem.OffsetRect(0, -nOffset);
				*lpRect = rcItem;
			}
			return pItem;
		}
	}
	return NULL;
}
Пример #2
0
void CXTPTaskPanelGroup::RepositionAutoHeightControls(int nHeightOffset)
{
	if (GetItemLayout() == xtpTaskItemLayoutImages)
		return;

	int nCount = 0, i, nTotalHeight = 0, nItemCount = GetItemCount(), nOffset = 0;

	for (i = 0; i < nItemCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		if (pItem->IsAutoHeight() && pItem->IsVisible())
		{
			nCount++;
			nTotalHeight += max(1, pItem->GetSize().cy);
		}
	}

	if (nCount == 0)
		return;

	for (i = 0; i < nItemCount; i++)
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(i);
		pItem->m_rcItem.OffsetRect(0, nOffset);

		if (pItem->IsAutoHeight() && pItem->IsVisible())
		{
			int nItemHeight = max(1, pItem->GetSize().cy);
			int nItemHeightOffset = nCount > 1 ? (int)(nItemHeight* nHeightOffset / nTotalHeight) : nHeightOffset;

			nCount--;
			nTotalHeight -= nItemHeight;
			nHeightOffset -= nItemHeightOffset;

			pItem->m_rcItem.bottom += nItemHeightOffset;
			nOffset += nItemHeightOffset;
		}
	}


}
Пример #3
0
void CXTPTaskPanelGroup::EnsureVisible(CXTPTaskPanelGroupItem* pItem, BOOL bUpdateScrollButtons /*= TRUE*/)
{
	if (m_pPanel->IsExplorerBehaviour() || GetItemCount() == 0 || !IsExpanded())
		return;

	if (!pItem || pItem->GetItemGroup() != this || !pItem->IsVisible())
		return;

	int nIndex = pItem->GetIndex();

	if (m_nScrollOffset > nIndex)
	{
		SetOffsetItem(nIndex, bUpdateScrollButtons);
		return;
	}

	CRect rcItem(pItem->GetItemRect());
	if (rcItem.bottom - GetScrollOffsetPos() > m_nExpandedClientHeight)
	{
		int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top;
		if (rcItem.top - GetScrollOffsetPos() <= nTopMargin)
			return;

		int nScrollOffset = m_nScrollOffset + 1;
		for (; nScrollOffset <= nIndex; nScrollOffset++)
		{
			CXTPTaskPanelGroupItem* pItemScroll = GetAt(nScrollOffset);
			if (!pItemScroll || !pItemScroll->IsVisible())
				continue;

			int nScrollOffsetPos = pItemScroll->GetItemRect().top - nTopMargin;

			if (rcItem.bottom - nScrollOffsetPos <= m_nExpandedClientHeight)
				break;

			if (rcItem.top - nScrollOffsetPos <= nTopMargin)
				break;
		}
		SetOffsetItem(nScrollOffset, bUpdateScrollButtons);
	}
}
Пример #4
0
int CXTPTaskPanelGroup::GetOffsetItem() const
{
	if (m_nScrollOffset == 0)
		return 0;

	if (m_nScrollOffset < GetItemCount())
	{
		CXTPTaskPanelGroupItem* pItem = GetAt(m_nScrollOffset);

		if (pItem->IsVisible())
			return m_nScrollOffset;

		int nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, +1);

		if (nScrollOffset != -1)
			return nScrollOffset;

		nScrollOffset = m_pItems->GetNextVisibleIndex(m_nScrollOffset, -1);
		if (nScrollOffset != -1)
			return nScrollOffset;
	}

	return 0;
}
Пример #5
0
void CXTPTaskPanelGroup::OnCalcClientHeight(CDC* pDC, CRect rc)
{
	CXTPTaskPanelPaintManager* pPaintManager = GetPaintManager();
	CRect rcMarginsOuter = pPaintManager->GetGroupOuterMargins(this);
	CRect rcMarginsInner = pPaintManager->GetGroupInnerMargins(this);

	rc.DeflateRect(rcMarginsOuter);
	CRect rcItems(rc);

	rcItems.DeflateRect(rcMarginsInner);
	m_nItemsInRow = 1;
	int nItemCount = GetItemCount();

	if (GetItemLayout() == xtpTaskItemLayoutImages)
	{
		CSize szIcon = GetItemIconSize();
		CRect rcInnerMargins(pPaintManager->m_rcImageLayoutIconPadding);
		CSize szButton(szIcon.cx + rcInnerMargins.right + rcInnerMargins.left,
			szIcon.cy + rcInnerMargins.top + rcInnerMargins.bottom);

		int nRowIcons = max(1, rcItems.Width() / szButton.cx), x = 0, y = 0;
		BOOL bWrap = FALSE;

		for (int i = 0; i < nItemCount; i++)
		{
			CXTPTaskPanelGroupItem* pItem = GetAt(i);

			if (!pItem->IsVisible())
				continue;

			if (bWrap)
			{
				x = 0;
				y++;
				bWrap = FALSE;
			}

			CRect rcItem(CPoint(rcItems.left + x * szButton.cx, rcItems.top + y * szButton.cy), szButton);
			pItem->OnReposition(rcItem);

			if (++x == nRowIcons)
				bWrap = TRUE;
		}
		rcItems.bottom = rcItems.top + rcMarginsInner.bottom + szButton.cy * (y + 1);
		m_nItemsInRow = nRowIcons;

		SetOffsetItem(m_nScrollOffset);
	}
	else
	{
		BOOL bMultiColumn = m_pPanel->IsMultiColumn();
		int nRowHeight = 0;
		CRect rcItemOuterMargins(0, 0, 0, 0);
		int nColumnWidth = m_pPanel->GetColumnWidth();
		ASSERT(nColumnWidth > 0);
		int x = 0;
		BOOL bWrap = FALSE;

		int nRowIcons = max(1, rcItems.Width() / nColumnWidth);

		for (int i = 0; i < nItemCount; i++)
		{
			CXTPTaskPanelGroupItem* pItem = GetAt(i);

			if (!pItem->IsVisible())
				continue;

			if (bMultiColumn)
			{
				if (bWrap)
				{
					rcItems.top += nRowHeight;

					nRowHeight = 0;
					x = 0;
					bWrap = FALSE;
				}

				CRect rcItem = pItem->OnReposition(CRect(rcItems.left + x * nColumnWidth, rcItems.top, rcItems.left + (x + 1) * nColumnWidth, rcItems.bottom));


				rcItemOuterMargins = pPaintManager->GetItemOuterMargins(pItem);

				nRowHeight = max(nRowHeight, rcItem.Height() + rcItemOuterMargins.bottom);

				if (++x == nRowIcons)
					bWrap = TRUE;
			}
			else
			{
				CRect rcItem = pItem->OnReposition(rcItems);
				rcItems.top = rcItem.bottom + pPaintManager->GetItemOuterMargins(pItem).bottom;
			}
		}
		if (bMultiColumn)
		{
			rcItems.top += nRowHeight;
			m_nItemsInRow = nRowIcons;
		}
		rcItems.bottom = rcItems.top + rcMarginsInner.bottom;
	}

	int nMinClientHeight = GetMinimumClientHeight();
	if (rcItems.bottom - rc.top < nMinClientHeight)
		rcItems.bottom = rc.top + nMinClientHeight;

	m_nExpandedClientHeight = rcItems.bottom - rc.top;

	m_nCaptionHeight = pPaintManager->DrawGroupCaption(pDC, this, FALSE);
}