예제 #1
0
BOOL CXTPTabPaintManager::_CreateMultiRowIndexerBestFit(CXTPTabManager* pTabManager, int nWidth, int nRow, int nTotalLength)
{
	const int nRowCount = pTabManager->GetRowCount();
	const int nLengthPerRow = !m_bMultiRowJustified ? nWidth : min(nTotalLength / (nRowCount - nRow), nWidth);

	CXTPTabManager::ROW_ITEMS* pRowItems = pTabManager->m_pRowIndexer->GetRowItems();
	int x = 0;

	for (int i = pRowItems[nRow].nLastItem; i < pTabManager->GetItemCount(); i++)
	{
		CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
		int nLength = pItem->GetButtonLength();

		if (x + nLength > nLengthPerRow && x != 0 && nLength > 0)
		{
			if (nRow == nRowCount - 1)
				return FALSE;

			pRowItems[nRow + 1].nFirstItem = pRowItems[nRow + 1].nLastItem = i;

			if (_CreateMultiRowIndexerBestFit(pTabManager, nWidth, nRow + 1, nTotalLength - x))
				return TRUE;

			if (x + nLength > nWidth)
				return FALSE;
		}
		pRowItems[nRow].nLastItem = i;
		pItem->m_nItemRow = nRow;
		x += nLength;
	}
	return TRUE;
}
예제 #2
0
BOOL CXTPTabManager::DeleteItem(int nItem)
{
	if (nItem < 0 || nItem >= GetItemCount())
		return FALSE;

	CXTPTabManagerItem* pItem = m_arrItems[nItem];

	BOOL bSelected = (m_pSelected == pItem);

	if (m_pHighlighted == pItem)
		m_pHighlighted = NULL;

	m_arrItems.RemoveAt(nItem);

	pItem->OnRemoved();
	pItem->InternalRelease();

	if (bSelected)
	{
		SetCurSel(nItem);
	}


	OnItemsChanged();

	return TRUE;
}
void CXTPDockingPaneTabbedContainer::OnNavigateButtonClick(CXTPTabManagerNavigateButton* pButton)
{
	CXTPTabManager::OnNavigateButtonClick(pButton->GetID());

	CXTPTabManagerItem* pItem = pButton->GetItem() ? pButton->GetItem() : m_pSelected;

	if (pItem && (pButton->GetID() == xtpTabNavigateButtonClose) && pItem->IsClosable())
	{
		CXTPDockingPane* pSelectedPane =  (CXTPDockingPane*)pItem->GetData();

		ClosePane(pSelectedPane);
	}
}
예제 #4
0
void CXTPTabManager::DeleteAllItems()
{
	for (int i = 0; i < m_arrItems.GetSize(); i++)
	{
		CXTPTabManagerItem* pItem = m_arrItems[i];
		pItem->OnRemoved();
		pItem->InternalRelease();
	}

	m_arrItems.RemoveAll();

	m_pHighlighted = m_pSelected = m_pPressed = NULL;

	OnItemsChanged();
}
void CXTPPropertyPageTabNavigator::OnPageChanged()
{
	DeleteAllItems();

	for (int i = 0; i < m_pSheet->GetPageCount(); i++)
	{
		CXTPPropertyPage* pPage = m_pSheet->GetPage(i);

		CString strCaption = pPage->GetCaption();

		CXTPTabManagerItem* pItem = InsertItem(i, strCaption);
		pItem->SetData((DWORD_PTR)pPage);
		pPage->m_dwData = (DWORD_PTR)pItem;
	}
}
예제 #6
0
CXTPTabManager::~CXTPTabManager()
{
	for (int i = 0; i < m_arrItems.GetSize(); i++)
	{
		CXTPTabManagerItem* pItem = m_arrItems[i];
		pItem->OnRemoved();
		pItem->InternalRelease();
	}

	m_arrNavigateButtons.RemoveAll();

	delete m_pRowIndexer;

	XTPMarkupReleaseContext(m_pMarkupContext);
}
예제 #7
0
void CXTPTabPaintManager::CreateMultiRowIndexer(CXTPTabManager* pTabManager, CDC* pDC, int nWidth)
{
	int x = 0;
	int nRowCount = 1;
	int i;
	int nTotalLength = 0;
	int nItemCount = pTabManager->GetItemCount();
	CXTPTabManagerItem* pSelectedItem = 0;

	for (i = 0; i < nItemCount; i++)
	{
		CXTPTabManagerItem* pItem = pTabManager->GetItem(i);

		if (pItem->IsSelected())
		{
			pSelectedItem = pItem;
		}

		int nLength = pItem->m_nContentLength = pItem->m_nButtonLength =
			pItem->IsVisible() ? m_pAppearanceSet->GetButtonLength(pDC, pItem) : 0;

		if (x + nLength > nWidth && x != 0)
		{
			x = 0;
			nRowCount++;
		}
		x += nLength;
		nTotalLength += nLength;
	}

	CXTPTabManager::ROW_ITEMS* pRowItems = pTabManager->m_pRowIndexer->CreateIndexer(nRowCount);

	if (nRowCount == 1)
		return;

	pRowItems[0].nFirstItem = pRowItems[0].nLastItem = 0;
	VERIFY(_CreateMultiRowIndexerBestFit(pTabManager, nWidth, 0, nTotalLength));

	if (!m_bMultiRowFixedSelection && pSelectedItem)
	{
		int nSelectedRow = pSelectedItem->GetItemRow();

		CXTPTabManager::ROW_ITEMS selectedRow = pRowItems[nSelectedRow];
		pRowItems[nSelectedRow] = pRowItems[0];
		pRowItems[0] = selectedRow;
	}
}
예제 #8
0
CXTPTabManagerItem* CXTPTabManager::FindNextFocusable(int nIndex, int nDirection) const
{
	CXTPTabManagerItem* pItem = NULL;

	do
	{
		nIndex += nDirection;

		pItem = GetItem(nIndex);
		if (!pItem)
			return NULL;

	}
	while (!(pItem->IsVisible() && pItem->IsEnabled()));

	return pItem;
}
void CXTPDockingPaneTabbedContainer::OnTabsChanged()
{
	if (!m_hWnd)
		return;

	m_nLockReposition += 1;

	DeleteAllItems();

	m_bCloseItemButton = GetDockingPaneManager()->m_bShowCloseTabButton;

	POSITION pos = GetHeadPosition();
	while (pos)
	{
		CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);

		CXTPTabManagerItem* pItem = AddItem(GetItemCount());
		if (m_pSelectedPane == pPane) SetSelectedItem(pItem);

		pItem->SetCaption(pPane->GetTabCaption());
		pItem->SetColor(pPane->GetItemColor());
		pItem->SetTooltip(pPane->GetTitle());
		pItem->SetEnabled(pPane->GetEnabled() & xtpPaneEnableClient);
		pItem->SetClosable((pPane->GetOptions() & xtpPaneNoCloseable) == 0);

		pItem->SetData((DWORD_PTR)pPane);
	}
	//////////////////////////////////////////////////////////////////////////

	m_pCaptionButtons->CheckForMouseOver(CPoint(-1, -1));

	m_nLockReposition -= 1;
}
예제 #10
0
CXTPTabManagerNavigateButton* CXTPTabManager::HitTestNavigateButton(CPoint point, BOOL bHeaderOnly, int* pnIndex) const
{
	int i;
	for (i = 0; i < (int)m_arrNavigateButtons.GetSize(); i++)
	{
		CXTPTabManagerNavigateButton* pButton = m_arrNavigateButtons[i];
		if (pButton->m_rcButton.PtInRect(point))
		{
			if (!pButton->IsEnabled())
				return NULL;

			if (pnIndex)
			{
				*pnIndex = i;
			}
			return pButton;
		}
	}

	if (bHeaderOnly)
		return NULL;

	CXTPTabManagerItem* pItem = HitTest(point);
	if (!pItem)
		return NULL;

	for (i = 0; i < (int)pItem->GetNavigateButtons()->GetSize(); i++)
	{
		CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i);
		if (pButton->m_rcButton.PtInRect(point))
		{
			if (!pButton->IsEnabled())
				return NULL;

			if (pnIndex)
			{
				*pnIndex = i;
			}
			return pButton;
		}
	}

	return NULL;
}
	virtual DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* /*pDataObject*/, DWORD /*dwKeyState*/, CPoint point)
	{
		CXTPDockingPaneTabbedContainer* pControl = (CXTPDockingPaneTabbedContainer*)pWnd;
		ASSERT_VALID(pControl);

		if (!pControl->GetPaintManager()->m_bSelectOnDragOver)
			return DROPEFFECT_NONE;

		if (m_dwDragLastTick != (DWORD)-1 && pControl->GetPaintManager()->m_bSelectOnDragOver == 2)
		{
			DWORD dwTick = GetTickCount();

			if (point != m_ptDragLastPoint)
			{
				m_dwDragLastTick = dwTick;
				m_ptDragLastPoint = point;
			}

			if (dwTick - m_dwDragLastTick > CXTPTabPaintManager::m_nSelectOnDragOverDelay)
			{
				m_dwDragLastTick = (DWORD)-1;
			}
		}
		else
		{
			CXTPTabManagerItem* pItem = pControl->CXTPTabManager::HitTest(point);

			if (pItem)
			{
				CXTPDockingPane* pPane = pControl->GetItemPane(pItem->GetIndex());
				if (pControl->GetSelected() != pPane)
				{
					pControl->SelectPane(pPane, FALSE, FALSE);
				}
			}
			else
			{
				m_dwDragLastTick = 0;
			}
		}

		return DROPEFFECT_NONE;
	}
예제 #12
0
CXTPTabManagerItem* CXTPTabManager::HitTest(CPoint point) const
{
	if (!m_rcControl.PtInRect(point))
		return NULL;

	if (!m_rcHeaderRect.IsRectEmpty() && !m_rcHeaderRect.PtInRect(point))
		return NULL;

	for (int i = 0; i < GetItemCount(); i++)
	{
		CXTPTabManagerItem* pItem = GetItem(i);

		if (pItem->GetRect().PtInRect(point) && pItem->IsEnabled() && pItem->IsVisible())
		{
			return pItem;
		}
	}
	return NULL;
}
예제 #13
0
INT_PTR CXTPTabManager::PerformToolHitTest(HWND hWnd, CPoint point, TOOLINFO* pTI) const
{
	if (IsMouseLocked())
		return -1;

	int nIndex = -1;
	CXTPTabManagerNavigateButton* pNavigateButton = HitTestNavigateButton(point, FALSE, &nIndex);
	if (pNavigateButton)
	{
		ASSERT(nIndex != -1);
		CString strTip = pNavigateButton->GetTooltip();
		if (strTip.IsEmpty())
			return -1;

		CXTPToolTipContext::FillInToolInfo(pTI, hWnd, pNavigateButton->GetRect(), nIndex, strTip);

		return nIndex;
	}

	CXTPTabManagerItem* pItem = HitTest(point);

	if (pItem)
	{
		if (GetPaintManager()->m_toolBehaviour == xtpTabToolTipNever)
			return -1;

		if (GetPaintManager()->m_toolBehaviour == xtpTabToolTipShrinkedOnly && !pItem->IsItemShrinked())
			return -1;

		CString strTip = GetItemTooltip(pItem);
		if (strTip.IsEmpty())
			return -1;

		CXTPToolTipContext::FillInToolInfo(pTI, hWnd, pItem->GetRect(), pItem->GetIndex(), strTip, pItem->GetCaption(), strTip);

		return pItem->GetIndex();
	}
	return -1;
}
int CXTPDockingPaneTabbedContainer::HitTest(CPoint point) const
{
	CXTPClientRect rc(this);

	if (IsTitleVisible())
	{
		if (rc.PtInRect(point))
		{
			CXTPDockingPaneBase::GetPaintManager()->AdjustCaptionRect(this, rc);
			if (!rc.PtInRect(point))
			{
				return DOCKINGPANE_HITCAPTION;
			}
		}
	}

	if (IsTabsVisible())
	{
		CXTPTabManagerItem* pItem = CXTPTabManager::HitTest(point);
		return pItem ? pItem->GetIndex() : -1;
	}
	return -1;
}
예제 #15
0
void CXTPTabPaintManager::RepositionTabControlEx(CXTPTabManager* pTabManager, CDC* pDC, CRect rcClient)
{
	if (pTabManager->IsDrawStaticFrame())
	{
		CAppearanceSet::DeflateRectEx(rcClient, CRect(2, 1, 2, 2), pTabManager->GetPosition());
	}

	CAppearanceSet::DeflateRectEx(rcClient, m_rcControlMargin, pTabManager->GetPosition());

	int i;

	if (!m_bShowTabs)
	{
		pTabManager->m_rcHeaderRect.SetRectEmpty();
		for (i = 0; i < pTabManager->GetItemCount(); i++)
		{
			CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
			pItem->SetRect(CRect(0, 0, 0, 0));
		}

		for (i = pTabManager->GetNavigateButtonCount() - 1; i >= 0; i--)
			pTabManager->GetNavigateButton(i)->SetRect(CRect(0, 0, 0, 0));

		return;
	}
	if (pTabManager->GetLayout() == xtpTabLayoutMultiRow)
	{
		RepositionTabControlMultiRow(pTabManager, pDC, rcClient);
		return;
	}

	for (i = 0; i < pTabManager->GetItemCount(); i++)
	{
		CXTPTabManagerItem* pItem = pTabManager->GetItem(i);

		pItem->m_nButtonLength = pItem->m_nContentLength =
			pItem->IsVisible() ? m_pAppearanceSet->GetButtonLength(pDC, pItem) : 0;

		if (pItem->IsVisible())
			pItem->m_nButtonLength += m_nButtonExtraLength;
	}

	pTabManager->m_rcHeaderRect = m_pAppearanceSet->GetHeaderRect(rcClient, pTabManager);

	if (pTabManager->GetItemCount() == 0)
	{
		RepositionNavigateButtons(pTabManager, rcClient);
		return;
	}

	CRect rcHeaderMargin = m_pAppearanceSet->GetHeaderMargin();
	int nButtonHeight = m_pAppearanceSet->GetButtonHeight(pTabManager);


	if (pTabManager->IsHorizontalPosition())
	{
		int nTop = rcClient.top + rcHeaderMargin.top;

		if (pTabManager->GetPosition() == xtpTabPositionBottom)
		{
			nTop = rcClient.bottom - nButtonHeight - rcHeaderMargin.top;
		}

		int nBottom = nTop + nButtonHeight;


		if (pTabManager->GetLayout() == xtpTabLayoutSizeToFit)
		{
			int nWidth = rcClient.Width() - (rcHeaderMargin.right + rcHeaderMargin.left);

			for (i = pTabManager->GetNavigateButtonCount() - 1; i >= 0; i--)
				pTabManager->GetNavigateButton(i)->AdjustWidth(nWidth);

			SizeToFit(pTabManager, nWidth);
		}

		pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);

		if (pTabManager->m_nHeaderOffset < 0)
		{
			int nLength = pTabManager->GetItemsLength();
			int nNavigateButtonsWidth = pTabManager->m_rcHeaderRect.Width() - rcHeaderMargin.left - rcHeaderMargin.right;

			if (nLength + pTabManager->m_nHeaderOffset < nNavigateButtonsWidth)
			{
				pTabManager->m_nHeaderOffset = min(0, nNavigateButtonsWidth - nLength);
				pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);
			}
		}

		int x = pTabManager->m_rcHeaderRect.left + rcHeaderMargin.left + pTabManager->GetHeaderOffset();

		if (pTabManager->GetLayout() == xtpTabLayoutRotated)
		{
			if (pTabManager->GetPosition() == xtpTabPositionTop)
			{
				nBottom = pTabManager->m_rcHeaderRect.bottom - rcHeaderMargin.bottom;
			}
			else
			{
				nTop = pTabManager->m_rcHeaderRect.top + rcHeaderMargin.bottom;

			}

			for (i = 0; i < pTabManager->GetItemCount(); i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
				if (!pItem->IsVisible()) continue;

				if (pTabManager->GetPosition() == xtpTabPositionTop)
				{
					pItem->SetRect(CRect(x, nBottom - pItem->m_nButtonLength, x + nButtonHeight, nBottom));
				}
				else
				{
					pItem->SetRect(CRect(x, nTop, x + nButtonHeight, nTop + pItem->m_nButtonLength));

				}
				x += nButtonHeight;
			}
		}
		else
		{

			for (i = 0; i < pTabManager->GetItemCount(); i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(i);

				pItem->SetRect(CRect(x, nTop, x + pItem->m_nButtonLength, nBottom));
				x += pItem->m_nButtonLength;
			}
		}

	}
	else
	{
		int nLeft = rcClient.left + rcHeaderMargin.top;

		if (pTabManager->GetPosition() == xtpTabPositionRight)
		{
			nLeft = rcClient.right - nButtonHeight - rcHeaderMargin.top;
		}

		int nRight = nLeft + nButtonHeight;

		if (pTabManager->GetLayout() == xtpTabLayoutSizeToFit)
		{
			int nWidth = rcClient.Height() - (rcHeaderMargin.right + rcHeaderMargin.left);

			for (i = pTabManager->GetNavigateButtonCount() - 1; i >= 0; i--)
				pTabManager->GetNavigateButton(i)->AdjustWidth(nWidth);

			SizeToFit(pTabManager, nWidth);
		}

		pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);

		if (pTabManager->m_nHeaderOffset < 0)
		{
			int nLength = pTabManager->GetItemsLength();
			int nNavigateButtonsWidth = pTabManager->m_rcHeaderRect.Height() - rcHeaderMargin.left - rcHeaderMargin.right;

			if (nLength + pTabManager->m_nHeaderOffset < nNavigateButtonsWidth)
			{
				pTabManager->m_nHeaderOffset = min(0, nNavigateButtonsWidth - nLength);
				pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);
			}
		}

		int y = pTabManager->m_rcHeaderRect.top + rcHeaderMargin.left + pTabManager->GetHeaderOffset();

		if (pTabManager->GetLayout() == xtpTabLayoutRotated)
		{
			if (pTabManager->GetPosition() == xtpTabPositionLeft)
			{
				nRight = pTabManager->m_rcHeaderRect.right - rcHeaderMargin.bottom;
			}
			else
			{
				nLeft = pTabManager->m_rcHeaderRect.left + rcHeaderMargin.bottom;

			}

			for (i = 0; i < pTabManager->GetItemCount(); i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
				if (!pItem->IsVisible()) continue;

				if (pTabManager->GetPosition() == xtpTabPositionLeft)
				{
					pItem->SetRect(CRect(nRight - pItem->m_nButtonLength, y, nRight, y + nButtonHeight));
				}
				else
				{
					pItem->SetRect(CRect(nLeft, y, nLeft + pItem->m_nButtonLength, y + nButtonHeight));

				}
				y += nButtonHeight;
			}
		}
		else
		{
			for (i = 0; i < pTabManager->GetItemCount(); i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(i);

				pItem->SetRect(CRect(nLeft, y, nRight, y + pItem->m_nButtonLength));
				y += pItem->m_nButtonLength;
			}
		}
	}
}
예제 #16
0
void CXTPTabPaintManager::RepositionTabControlMultiRow(CXTPTabManager* pTabManager, CDC* pDC, CRect rcClient)
{

	pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);
	pTabManager->m_nHeaderOffset = 0;

	if (pTabManager->GetItemCount() == 0)
		return;

	CRect rcHeaderMargin = m_pAppearanceSet->GetHeaderMargin();
	int nButtonHeight = m_pAppearanceSet->GetButtonHeight(pTabManager);

	if (pTabManager->IsHorizontalPosition())
	{
		int nWidth = pTabManager->m_rcHeaderRect.Width() - (rcHeaderMargin.left + rcHeaderMargin.right);
		CreateMultiRowIndexer(pTabManager, pDC, nWidth);

		int nRowCount = pTabManager->GetRowCount();
		int nTop = 0;

		if (pTabManager->GetPosition() == xtpTabPositionBottom)
		{
			nTop = rcClient.bottom - (nButtonHeight * nRowCount + m_pAppearanceSet->m_nRowMargin * (nRowCount - 1))
				- rcHeaderMargin.top;
		}
		else
		{
			nTop = rcClient.top +  (nButtonHeight * (nRowCount - 1) + m_pAppearanceSet->m_nRowMargin * (nRowCount - 1))
				+ rcHeaderMargin.top;
		}

		int nBottom = nTop + nButtonHeight;

		int nOffset = pTabManager->GetPosition() == xtpTabPositionBottom ?
			nButtonHeight + m_pAppearanceSet->m_nRowMargin: -(nButtonHeight + m_pAppearanceSet->m_nRowMargin);


		CXTPTabManager::ROW_ITEMS* pRowItems = pTabManager->m_pRowIndexer->GetRowItems();
		int i;

		BOOL bSizeToFit = nRowCount > 1 && m_bMultiRowJustified;

		for (int nRow = 0; nRow < nRowCount; nRow++)
		{
			int nTotalLength = 0;

			int nItemInRow = pRowItems[nRow].nLastItem - pRowItems[nRow].nFirstItem + 1;
			int nFirstItem = pRowItems[nRow].nFirstItem;

			if (bSizeToFit)
			{
				for (i = 0; i < nItemInRow; i++)
				{
					nTotalLength += pTabManager->GetItem(nFirstItem + i)->GetButtonLength();
				}
			}

			int nTotalWidth = nWidth;

			int x = pTabManager->m_rcHeaderRect.left + rcHeaderMargin.left;

			for (i = 0; i < nItemInRow; i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(nFirstItem + i);
				ASSERT(pItem);
				if (!pItem)
					continue;
				int nButtonLength = pItem->m_nButtonLength;

				if (bSizeToFit)
				{
					int nLength = nButtonLength + (nTotalWidth - nTotalLength) / (nItemInRow - i);
					nTotalWidth -= nLength;
					nTotalLength -= nButtonLength;

					pItem->m_nButtonLength = nButtonLength = nLength;
				}

				pItem->SetRect(CRect(x, nTop, x + nButtonLength, nBottom));
				pItem->m_nItemRow = nRow;


				x += nButtonLength;
			}
			nTop += nOffset;
			nBottom += nOffset;
		}
	}
	else
	{
		int nWidth = pTabManager->m_rcHeaderRect.Height() - (rcHeaderMargin.left + rcHeaderMargin.right);
		CreateMultiRowIndexer(pTabManager, pDC, nWidth);


		int nRowCount = pTabManager->GetRowCount();
		int nLeft = 0;

		if (pTabManager->GetPosition() == xtpTabPositionRight)
		{
			nLeft = rcClient.right - (nButtonHeight * nRowCount + m_pAppearanceSet->m_nRowMargin * (nRowCount - 1))
				- rcHeaderMargin.top;
		}
		else
		{
			nLeft = rcClient.left +  (nButtonHeight * (nRowCount - 1) + m_pAppearanceSet->m_nRowMargin * (nRowCount - 1))
				+ rcHeaderMargin.top;
		}

		int nRight = nLeft + nButtonHeight;

		int nOffset = pTabManager->GetPosition() == xtpTabPositionRight ?
			nButtonHeight + m_pAppearanceSet->m_nRowMargin: -(nButtonHeight + m_pAppearanceSet->m_nRowMargin);


		CXTPTabManager::ROW_ITEMS* pRowItems = pTabManager->m_pRowIndexer->GetRowItems();
		int i;

		BOOL bSizeToFit = nRowCount > 1 && m_bMultiRowJustified;

		for (int nRow = 0; nRow < nRowCount; nRow++)
		{
			int nTotalLength = 0;

			int nItemInRow = pRowItems[nRow].nLastItem - pRowItems[nRow].nFirstItem + 1;
			int nFirstItem = pRowItems[nRow].nFirstItem;

			if (bSizeToFit)
			{
				for (i = 0; i < nItemInRow; i++)
				{
					nTotalLength += pTabManager->GetItem(nFirstItem + i)->GetButtonLength();
				}
			}

			int nTotalWidth = nWidth;

			int y = pTabManager->m_rcHeaderRect.top + rcHeaderMargin.left;

			for (i = 0; i < nItemInRow; i++)
			{
				CXTPTabManagerItem* pItem = pTabManager->GetItem(nFirstItem + i);
				ASSERT(pItem);
				if (!pItem)
					continue;
				int nButtonLength = pItem->m_nButtonLength;

				if (bSizeToFit)
				{
					int nLength = nButtonLength + (nTotalWidth - nTotalLength) / (nItemInRow - i);
					nTotalWidth -= nLength;
					nTotalLength -= nButtonLength;

					pItem->m_nButtonLength = nButtonLength = nLength;
				}

				pItem->SetRect(CRect(nLeft, y, nRight, y + nButtonLength));
				pItem->m_nItemRow = nRow;


				y += nButtonLength;
			}
			nLeft += nOffset;
			nRight += nOffset;
		}
	}
	pTabManager->m_rcHeaderRect = RepositionNavigateButtons(pTabManager, rcClient);
}
예제 #17
0
void CXTPTabPaintManager::DrawRowItems(CXTPTabManager* pTabManager, CDC* pDC, const CRect& rcClipBox, int nItemRow)
{
	CXTPTabManagerItem* pSelected = NULL;

	CXTPTabManager::ROW_ITEMS* pRowItems = pTabManager->m_pRowIndexer->GetRowItems();

	if (!pRowItems)
		return;

	if (nItemRow >= pTabManager->GetRowCount())
		return;

	int nFirstItem = pRowItems[nItemRow].nFirstItem;
	int nLastItem = pRowItems[nItemRow].nLastItem;
	BOOL bDrawRow = TRUE;

	if (m_pAppearanceSet->m_bButtonsReverseZOrder)
	{
		bDrawRow = FALSE;

		for (int i = nFirstItem; i <= nLastItem; i++)
		{
			CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
			if (!pItem)
				return;

			if (pItem->m_nItemRow != nItemRow)
				break;

			if (pItem->IsSelected())
			{
				nFirstItem = i;
				bDrawRow = TRUE;
				break;
			}

			if (pItem->IsVisible() && CRect().IntersectRect(rcClipBox, m_pAppearanceSet->GetButtonDrawRect(pItem)))
			{
				m_pAppearanceSet->DrawSingleButton(pDC, pItem);
			}
		}
	}

	if (bDrawRow)
	{
		for (int i = nLastItem; i >= nFirstItem; i--)
		{
			CXTPTabManagerItem* pItem = pTabManager->GetItem(i);
			if (!pItem)
				return;

			if (pItem->m_nItemRow != nItemRow)
				break;

			if (pItem->IsVisible() && CRect().IntersectRect(rcClipBox, m_pAppearanceSet->GetButtonDrawRect(pItem)))
			{
				if (pItem->IsSelected())
					pSelected = pItem;
				else
					m_pAppearanceSet->DrawSingleButton(pDC, pItem);
			}
		}
	}


	if (pSelected)
	{
		m_pAppearanceSet->DrawSingleButton(pDC, pSelected);
	}


}