예제 #1
0
void CGenDockablePane::ShowAndUnroll()
{
	if (!IsWindowVisible())
		ShowPane(TRUE, FALSE, TRUE);

	CPaneFrameWnd * pFrm;
	if ((pFrm = DYNAMIC_DOWNCAST(CPaneFrameWnd, GetParentMiniFrame())) != NULL)
	{
		((CGenPaneFrameWnd *)pFrm)->Unroll();
	}

	SetFocus();
}
//**************************************************************************************
BOOL CBCGPBaseTabbedBar::FloatControlBar (CRect rectFloat, 
											 BCGP_DOCK_METHOD dockMethod,
											 bool bShow)
{
	ASSERT_VALID (this);
	ASSERT_VALID (m_pTabWnd);

	if (!CBCGPDockingControlBar::FloatControlBar (rectFloat, dockMethod, bShow))
	{
		return FALSE;
	}

	CBCGPMiniFrameWnd* pParentFrame = GetParentMiniFrame ();
	if (pParentFrame != NULL)
	{
		pParentFrame->SetIcon (m_pTabWnd->GetTabHicon (m_pTabWnd->GetActiveTab ()), FALSE);
	}

	return TRUE;
}
//*******************************************************************************
BOOL CBCGPBaseTabbedBar::RemoveControlBar (CWnd* pBar)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);
	ASSERT_VALID (m_pTabWnd);

	int nTabNumber = m_pTabWnd->GetTabFromHwnd (pBar->GetSafeHwnd ());

	if (nTabNumber < 0 || nTabNumber >= m_pTabWnd->GetTabsNum ())
	{
		return FALSE;
	}

	m_pTabWnd->RemoveTab (nTabNumber);

	if (m_pTabWnd->GetTabsNum () == 0)
	{
		if (AllowDestroyEmptyTabbedBar ())
		{
			if (IsDocked ())
			{
				UnDockControlBar ();
			}
			else
			{
				CBCGPMiniFrameWnd* pMiniFrame = GetParentMiniFrame ();
				pMiniFrame->RemoveControlBar (this);
			}

			DestroyWindow ();
			return FALSE;
		}
		else 
		{
			m_pTabWnd->ShowWindow (SW_HIDE);
		}
	}

	return TRUE;
}
//*******************************************************************************
BOOL CBCGPBaseTabbedBar::FloatTab (CWnd* pBar, int nTabID, 
									  BCGP_DOCK_METHOD dockMethod, 
									  BOOL bHide)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pBar);
	ASSERT_VALID (m_pTabWnd);

	CString strWndText;
	pBar->GetWindowText (strWndText);

	if (strWndText.IsEmpty ())
	{
		if (m_pTabWnd->GetTabLabel (nTabID, strWndText))
		{
			pBar->SetWindowText (strWndText);
		}
	}

	m_pTabWnd->RemoveTab (nTabID);
	
	if (dockMethod == BCGP_DM_MOUSE)
	{
		m_pTabWnd->SendMessage (WM_LBUTTONUP, 0, 0);
	}

	CBCGPDockingControlBar* pDockingBar = 
			DYNAMIC_DOWNCAST (CBCGPDockingControlBar, pBar);

	if (pDockingBar != NULL)
	{
		pDockingBar->StoreRecentTabRelatedInfo ();
	}

	if (dockMethod == BCGP_DM_DBL_CLICK && pDockingBar != NULL)
	{
		CBCGPMultiMiniFrameWnd* pParentMiniFrame = 
				DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd, GetParentMiniFrame ());

		if (pParentMiniFrame != NULL)
		{
			pParentMiniFrame->DockRecentControlBarToMainFrame (pDockingBar);
			return TRUE;
		}
		else if (m_hDefaultSlider != NULL && IsWindow (m_hDefaultSlider))
		{
			CBCGPMultiMiniFrameWnd* pRecentMiniFrame = 
				DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd,
					CWnd::FromHandlePermanent (pDockingBar->m_recentDockInfo.m_hRecentMiniFrame));
			if (pRecentMiniFrame != NULL && 
				pRecentMiniFrame->AddRecentControlBar (pDockingBar))
			{
				return TRUE;
			}
		}
	}

	if (pBar->IsKindOf (RUNTIME_CLASS (CBCGPControlBar)))
	{
		CBCGPControlBar* pControlBar = 
			DYNAMIC_DOWNCAST (CBCGPControlBar, pBar);
		ASSERT_VALID (pControlBar);
		pControlBar->FloatControlBar (pControlBar->m_recentDockInfo.m_rectRecentFloatingRect, 
									  dockMethod, !bHide);
		return TRUE;
	}
	return FALSE;
}
//***********************************************************************************
BOOL CBCGPBaseTabbedBar::AddTab (CWnd* pNewBar, BOOL bVisible, BOOL bSetActive, 
								 BOOL bDetachable)
{
	ASSERT_VALID (this);
	ASSERT_VALID (m_pTabWnd);
	ASSERT_VALID (pNewBar);

	if (pNewBar->IsKindOf (RUNTIME_CLASS (CBCGPBaseTabbedBar)))
	{
		CBCGPBaseTabbedBar* pTabbedControlBar = 
			DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, pNewBar);

		// it's false when the tabbed bar is added from miniframe to docksite
		BOOL bSetInfoForSlider = (GetParentMiniFrame () != NULL);

		ASSERT_VALID (pTabbedControlBar);

		CBCGPBaseTabWnd* pWndTab = pTabbedControlBar->GetUnderlinedWindow ();
		
		ASSERT_VALID (pWndTab);

		int nTabsNum = pWndTab->GetTabsNum ();
		ASSERT (nTabsNum > 0);

		for (int i = 0; i < nTabsNum; i++)
		{
			CBCGPBaseControlBar* pWnd = 
				DYNAMIC_DOWNCAST (CBCGPBaseControlBar, pWndTab->GetTabWnd (i));
			ASSERT_VALID (pWnd);

			BOOL bVisible = pWndTab->IsTabVisible (i);
			BOOL bDetachable = pWndTab->IsTabDetachable (i);

			pWnd->EnableGripper (FALSE);

			if (!AddTab (pWnd, bVisible, bVisible, bDetachable))
			{
				ASSERT (FALSE);
			}

			CBCGPDockingControlBar* pDockingBar = 
				DYNAMIC_DOWNCAST (CBCGPDockingControlBar, pWnd);
			if (pDockingBar != NULL)
			{
				pDockingBar->m_recentDockInfo.SetInfo (bSetInfoForSlider, 
														pTabbedControlBar->m_recentDockInfo);
			}
		}

		pWndTab->RemoveAllTabs ();
		pNewBar->DestroyWindow ();

		// stop processing - this function will be called 
		// from AttachToTabWnd

		return FALSE;
	}
	else
	{
		if (pNewBar->IsKindOf (RUNTIME_CLASS (CBCGPControlBar)))
		{
			CBCGPControlBar* pNewControlBar = 
				DYNAMIC_DOWNCAST (CBCGPControlBar, pNewBar);
			ASSERT_VALID (pNewControlBar);

			CWnd* pOldParent = pNewControlBar->GetParent ();
			pNewControlBar->OnBeforeChangeParent (m_pTabWnd, TRUE);
			pNewControlBar->SetParent (m_pTabWnd);
			pNewControlBar->OnAfterChangeParent (pOldParent);

			if (pNewControlBar->IsKindOf (RUNTIME_CLASS (CBCGPDockingControlBar)))
			{
				((CBCGPDockingControlBar*) pNewControlBar)->EnableGripper (FALSE);
			}
		}

		CString strText; 
		pNewBar->GetWindowText (strText);

		m_pTabWnd->AddTab (pNewBar, strText, bSetActive, bDetachable);

		int iTab = m_pTabWnd->GetTabsNum () - 1;
		m_pTabWnd->SetTabHicon (iTab, pNewBar->GetIcon (FALSE));
		m_pTabWnd->EnableTabDetach (iTab, bDetachable);

		if (bVisible)
		{
			if (bSetActive)
			{
				m_pTabWnd->SetActiveTab (iTab);
			}
		}
		else
		{
			ASSERT (!bSetActive);
			m_pTabWnd->ShowTab (iTab, FALSE);
		}
	}
	return TRUE;
}