void COXDockTabCtrl::ShowSelectedTab()
{
	int iSelected = GetCurSel();

	// Show first
	for (int i = 0; i < GetItemCount(); i++)
	{
		CControlBar* pBar = GetBar(i);
		if (iSelected == i)
		{
			pBar->GetDockingFrame()->ShowControlBar(pBar, TRUE, TRUE); // show
		}
		else
		{
			pBar->GetDockingFrame()->ShowControlBar(pBar, FALSE, TRUE); // hide
		}
	}

	CRect rect;
	m_pSizeDockBar->GetClientRect(rect);

	CControlBar* pBar = GetBar(iSelected);
	if (pBar != NULL)
	{
		COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, pBar);
		if (m_pSizeDockBar->IsBarHorizontal())
		{
			if (m_pLastSelectedBar != NULL)
			{
				pSizeBar->m_HorzDockSize.cx = m_pLastSelectedBar->m_HorzDockSize.cx;
			}
			m_pLastSelectedBar = pSizeBar;
		}
		else // vertical
		{
			CFrameWnd* pMF = (CFrameWnd*) GetParentFrame();//AfxGetMainWnd();
			if (pMF != NULL)
			{
				if (pMF->GetControlBar(AFX_IDW_DOCKBAR_LEFT) == m_pSizeDockBar)
					rect.right -= 3;

				if (pMF->GetControlBar(AFX_IDW_DOCKBAR_RIGHT) == m_pSizeDockBar)
					rect.left += 4;
			}
			
			rect.bottom -= m_pSizeDockBar->GetTabHeight();

			pBar->MoveWindow(rect, TRUE);

			COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, pBar);
			if (pSizeBar)
			{
				pSizeBar->m_VertDockSize.cx = rect.Width();
				pSizeBar->m_VertDockSize.cy = rect.Height() + 5;
			}
		}
	}
}
// Inserts the given control bar as a new tab
void COXDockTabCtrl::InsertTab(CControlBar* pBar, int iIndex, BOOL bShowSelectedTab)
{
	// If this is the only control bar in the dock bar do nothing
	int iSizeControlBarCount = m_pSizeDockBar->GetSizeControlBarCount(pBar);
	if (iSizeControlBarCount == 0)
		return;

	// Add a tab for all other size control bars that are docked but not tabbed

	int i = 0;
	for (i = 0; i < m_pSizeDockBar->m_arrBars.GetSize(); i++)
	{
		COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, m_pSizeDockBar->GetDockedControlBar(i));
		if (pSizeBar != NULL && pSizeBar != pBar && FindTab(pSizeBar) == -1)
		{
			CString strTextOther;
			pSizeBar->GetWindowText(strTextOther);

			TCITEM tciOther;
			tciOther.mask = TCIF_TEXT | TCIF_PARAM;
			tciOther.pszText = strTextOther.GetBuffer(strTextOther.GetLength());
			tciOther.lParam = (LPARAM) pSizeBar;
		
			//Check added for visibility so that hidden control
			//bars don't get shown - Nish - Feb 15th 2005
			if(pSizeBar->IsWindowVisible())
				InsertItem(0, &tciOther);
		}
	}

	// Insert this control bar to the tab control
	CString strText;
	pBar->GetWindowText(strText);

	TCITEM tci;
	tci.mask = TCIF_TEXT | TCIF_PARAM;
	tci.pszText = strText.GetBuffer(strText.GetLength());
	tci.lParam = (LPARAM) pBar;

	InsertItem(iIndex, &tci);
	SetCurSel(iIndex);

	// Reshresh the tab control
	m_pSizeDockBar->PositionTabCtrl();

	if (bShowSelectedTab)
		ShowSelectedTab();
	else
	{
		int iSelected = GetCurSel();
		for (i = 0; i < GetItemCount(); i++)
		{
			CControlBar* pBar = GetBar(i);
			if (iSelected != i)
				pBar->GetDockingFrame()->ShowControlBar(pBar, FALSE, TRUE); // hide
		}
	}
}
Exemplo n.º 3
0
void CDockBar::ShowAll(BOOL bShow)
{
	for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++)
	{
		CControlBar* pBar = (CControlBar*)m_arrBars[nPos];
		if (pBar != NULL)
		{
			CFrameWnd* pFrameWnd = pBar->GetDockingFrame();
			pFrameWnd->ShowControlBar(pBar, bShow, TRUE);
		}
	}
}