📄 bcgpbarcontainer.cpp
字号:
{
rectWndNew.left += sizeStretch.cx;
rectWndNew.top += sizeStretch.cy;
}
CSize sizeMin;
GetMinSize (sizeMin);
CSize sizeAvailable (sizeStretch.cx, sizeStretch.cy);
if (rectWndNew.Width () < sizeMin.cx)
{
sizeAvailable.cx = rectWndOrg.Width () - sizeMin.cx;
// if already less or eq. to minimum
if (sizeAvailable.cx < 0)
{
sizeAvailable.cx = 0;
}
// preserve direction
if (sizeStretch.cx < 0)
{
sizeAvailable.cx = -sizeAvailable.cx;
}
}
if (rectWndNew.Height () < sizeMin.cy)
{
sizeAvailable.cy = rectWndNew.Height () - sizeMin.cy;
if (sizeAvailable.cy < 0)
{
sizeAvailable.cy = 0;
}
// preserve direction
if (sizeStretch.cy < 0)
{
sizeAvailable.cy = -sizeAvailable.cy;
}
}
return sizeAvailable;
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsLeftContainer () const
{
ASSERT_VALID (this);
if (m_pParentContainer == NULL)
{
return TRUE;
}
if (m_pParentContainer->GetLeftContainer () == this)
{
return TRUE;
}
if (m_pParentContainer->GetRightContainer () == this)
{
return FALSE;
}
ASSERT (FALSE); // somehow we're at bad container!!!!
return FALSE;
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsLeftBar (CBCGPDockingControlBar* pBar) const
{
if (pBar == m_pBarLeftTop)
{
return TRUE;
}
if (pBar == m_pBarRightBottom)
{
return FALSE;
}
ASSERT (FALSE); // somehow we're at bad container!!!!
return FALSE;
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsContainerEmpty () const
{
ASSERT_VALID (this);
return (m_pBarLeftTop == NULL && m_pBarRightBottom == NULL &&
(m_pLeftContainer == NULL || m_pLeftContainer->IsContainerEmpty ()) &&
(m_pRightContainer == NULL || m_pRightContainer->IsContainerEmpty ()));
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsLeftPartEmpty (BOOL bCheckVisibility) const
{
ASSERT_VALID (this);
return ((m_pBarLeftTop == NULL ||
bCheckVisibility && m_pBarLeftTop != NULL && !m_pBarLeftTop->IsBarVisible ()) &&
(m_pLeftContainer == NULL || m_pLeftContainer->IsContainerEmpty () ||
bCheckVisibility && m_pLeftContainer != NULL && !m_pLeftContainer->IsContainerVisible ()));
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsRightPartEmpty (BOOL bCheckVisibility) const
{
ASSERT_VALID (this);
return ((m_pBarRightBottom == NULL ||
bCheckVisibility && m_pBarRightBottom != NULL && !m_pBarRightBottom->IsBarVisible ()) &&
(m_pRightContainer == NULL || m_pRightContainer->IsContainerEmpty () ||
bCheckVisibility && m_pRightContainer != NULL && !m_pRightContainer->IsContainerVisible ()));
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsContainerVisible () const
{
ASSERT_VALID (this);
return (m_pBarLeftTop != NULL && m_pBarLeftTop->IsBarVisible () ||
m_pBarRightBottom != NULL && m_pBarRightBottom->IsBarVisible () ||
m_pLeftContainer != NULL && m_pLeftContainer->IsContainerVisible () ||
m_pRightContainer != NULL && m_pRightContainer->IsContainerVisible ());
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::CheckSliderVisibility ()
{
ASSERT_VALID (this);
BOOL bLeftContainerVisible = FALSE;
BOOL bRightContainerVisible = FALSE;
BOOL bLeftBarVisible = m_pBarLeftTop != NULL && m_pBarLeftTop->IsBarVisible ();
BOOL bRightBarVisible = m_pBarRightBottom != NULL && m_pBarRightBottom->IsBarVisible ();
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->CheckSliderVisibility ();
bLeftContainerVisible = m_pLeftContainer->IsContainerVisible ();
}
if (m_pRightContainer != NULL)
{
m_pRightContainer->CheckSliderVisibility ();
bRightContainerVisible = m_pRightContainer->IsContainerVisible ();
}
if (m_pSlider == NULL)
{
return;
}
BOOL bShow = FALSE;
if (bLeftBarVisible && bRightBarVisible ||
bLeftBarVisible && bRightContainerVisible ||
bRightBarVisible && bLeftContainerVisible ||
bLeftContainerVisible && bRightContainerVisible)
{
bShow = TRUE;
}
m_pSlider->ShowWindow (bShow ? SW_SHOW : SW_HIDE);
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::Serialize (CArchive& ar)
{
CObject::Serialize (ar);
if (ar.IsStoring ())
{
if (m_pBarLeftTop != NULL)
{
int nBarID = m_pBarLeftTop->GetDlgCtrlID ();
if (nBarID != -1)
{
ar << nBarID;
}
else
{
SaveTabbedBar (ar, m_pBarLeftTop);
}
}
else
{
ar << (int) 0;
}
if (m_pBarRightBottom != NULL)
{
int nBarID = m_pBarRightBottom->GetDlgCtrlID ();
if (nBarID != -1)
{
ar << nBarID;
}
else
{
SaveTabbedBar (ar, m_pBarRightBottom);
}
}
else
{
ar << (int) 0;
}
if (m_pSlider != NULL)
{
ar << m_pSlider->GetDlgCtrlID ();
m_pSlider->Serialize (ar);
}
else
{
ar << (int) 0;
}
ar << (BOOL)(m_pLeftContainer != NULL);
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->Serialize (ar);
}
ar << (BOOL)(m_pRightContainer != NULL);
if (m_pRightContainer != NULL)
{
m_pRightContainer->Serialize (ar);
}
}
else
{
ar >> m_nSavedLeftBarID;
if (m_nSavedLeftBarID == -1)
{
m_pBarLeftTop = LoadTabbedBar (ar, m_lstSavedSiblingBarIDsLeft);
}
ar >> m_nSavedRightBarID;
if (m_nSavedRightBarID == -1)
{
m_pBarRightBottom = LoadTabbedBar (ar, m_lstSavedSiblingBarIDsRight);
}
ar >> m_nSavedSliderID;
if (m_nSavedSliderID != NULL)
{
m_pSlider = new CBCGPSlider (FALSE, m_pContainerManager->m_pDockSite);
m_pSlider->Serialize (ar);
m_pSlider->SetContainerManager (m_pContainerManager);
m_pContainerManager->m_lstSliders.AddTail (m_pSlider);
}
BOOL bLeftContainerPresent = FALSE;
ar >> bLeftContainerPresent;
if (bLeftContainerPresent)
{
m_pLeftContainer = new CBCGPBarContainer (m_pContainerManager);
m_pLeftContainer->Serialize (ar);
m_pLeftContainer->SetParentContainer (this);
}
BOOL bRightContainerPresent = FALSE;
ar >> bRightContainerPresent;
if (bRightContainerPresent)
{
m_pRightContainer = new CBCGPBarContainer (m_pContainerManager);
m_pRightContainer->Serialize (ar);
m_pRightContainer->SetParentContainer (this);
}
}
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::SetUpByID (UINT nID, CBCGPDockingControlBar* pBar)
{
ASSERT_KINDOF (CBCGPDockingControlBar, pBar);
if (m_nSavedLeftBarID == nID)
{
m_pBarLeftTop = pBar;
return TRUE;
}
if (m_nSavedRightBarID == nID)
{
m_pBarRightBottom = pBar;
return TRUE;
}
if (m_pLeftContainer != NULL &&
m_pLeftContainer->SetUpByID (nID, pBar))
{
return TRUE;
}
if (m_pRightContainer != NULL)
{
return m_pRightContainer->SetUpByID (nID, pBar);
}
return FALSE;
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::SaveTabbedBar (CArchive& ar, CBCGPDockingControlBar* pBar)
{
ASSERT_KINDOF (CBCGPBaseTabbedBar, pBar);
CBCGPBaseTabbedBar* pTabbedBar = DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, pBar);
ASSERT (ar.IsStoring ());
if (pTabbedBar->GetTabsNum () > 0)
{
ar << (int) -1;
pTabbedBar->SaveSiblingBarIDs (ar);
ar << pTabbedBar;
ar << pTabbedBar->GetStyle ();
pTabbedBar->SerializeTabWindow (ar);
}
}
//-----------------------------------------------------------------------------------//
CBCGPDockingControlBar* CBCGPBarContainer::LoadTabbedBar (CArchive& ar,
CList<UINT, UINT>& lstBarIDs)
{
ASSERT (ar.IsLoading ());
CBCGPDockingControlBar* pBar = NULL;
DWORD dwStyle = 0;
CBCGPBaseTabbedBar::LoadSiblingBarIDs (ar, lstBarIDs);
ar >> pBar;
ar >> dwStyle;
if (!pBar->Create (_T (""), m_pContainerManager->m_pDockSite,
pBar->m_rectSavedDockedRect, TRUE, (UINT) -1,
dwStyle, pBar->GetBCGStyle ()))
{
TRACE0 ("Failed to create tab docking bar");
ASSERT (FALSE);
lstBarIDs.RemoveAll ();
delete pBar;
return NULL;
}
ASSERT_KINDOF (CBCGPBaseTabbedBar, pBar);
((CBCGPBaseTabbedBar*) pBar)->SerializeTabWindow (ar);
return pBar;
}
//-----------------------------------------------------------------------------------//
CBCGPDockingControlBar* CBCGPBarContainer::FindTabbedBar (UINT nID)
{
ASSERT_VALID (this);
if (m_lstSavedSiblingBarIDsLeft.Find (nID) != NULL)
{
return m_pBarLeftTop;
}
if (m_lstSavedSiblingBarIDsRight.Find (nID) != NULL)
{
return m_pBarRightBottom;
}
if (m_pLeftContainer != NULL)
{
CBCGPDockingControlBar* pBar = m_pLeftContainer->FindTabbedBar (nID);
if (pBar != NULL)
{
return pBar;
}
}
if (m_pRightContainer != NULL)
{
return m_pRightContainer->FindTabbedBar (nID);
}
return NULL;
}
//-----------------------------------------------------------------------------------//
CList<UINT, UINT>* CBCGPBarContainer::GetAssociatedSiblingBarIDs (CBCGPDockingControlBar* pBar)
{
if (pBar == m_pBarLeftTop)
{
return &m_lstSavedSiblingBarIDsLeft;
}
if (pBar == m_pBarRightBottom)
{
return &m_lstSavedSiblingBarIDsRight;
}
return NULL;
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::SetContainerManager (CBCGPBarContainerManager* p, BOOL bDeep)
{
m_pContainerManager = p;
if (bDeep)
{
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->SetContainerManager (p, bDeep);
}
if (m_pRightContainer != NULL)
{
m_pRightContainer->SetContainerManager (p, bDeep);
}
}
}
//-----------------------------------------------------------------------------------//
int CBCGPBarContainer::GetNodeCount () const
{
int nCount = 1;
if (m_pLeftContainer != NULL)
{
nCount += m_pLeftContainer->GetNodeCount ();
}
if (m_pRightContainer != NULL)
{
nCount += m_pRightContainer->GetNodeCount ();
}
return nCount;
}
//-----------------------------------------------------------------------------------//
CBCGPBarContainer* CBCGPBarContainer::Copy (CBCGPBarContainer* pParentContainer)
{
// we should copy container and pointers to contained bars
// only if these bars are visible;
// unvisible parts of the new container shold be cleared
CBCGPBarContainer* pNewContainer = new CBCGPBarContainer (m_pContainerManager,
m_pBarLeftTop,
m_pBarRightBottom,
m_pSlider);
if (m_pBarLeftTop != NULL)
{
if (m_pBarLeftTop->GetStyle () & WS_VISIBLE)
{
m_pBarLeftTop = NULL;
}
else
{
pNewContainer->SetBar (NULL, TRUE);
}
}
if (m_pBarRightBottom != NULL)
{
if (m_pBarRightBottom->GetStyle () & WS_VISIBLE)
{
m_pBarRightBottom = NULL;
}
else
{
pNewContainer->SetBar (NULL, FALSE);
}
}
pNewContainer->SetParentContainer (pParentContainer);
if (m_pLeftContainer != NULL)
{
CBCGPBarContainer* pNewLeftContainer = m_pLeftContainer->Copy (pNewContainer);
pNewContainer->SetContainer (pNewLeftContainer, TRUE);
}
if (m_pRightContainer != NULL)
{
CBCGPBarContainer* pNewRightContainer = m_pRightContainer->Copy (pNewContainer);
pNewContainer->SetContainer (pNewRightContainer, FALSE);
}
if (m_pSlider != NULL)
{
if (m_pSlider->GetStyle () & WS_VISIBLE)
{
m_dwRecentSliderStyle = m_pSlider->GetSliderStyle ();
m_pSlider->GetClientRect (m_rectRecentSlider);
m_bIsRecentSliderHorz = m_pSlider->IsHorizontal ();
m_pSlider = NULL;
}
else
{
pNewContainer->SetSlider (NULL);
}
}
return pNewContainer;
}
//-----------------------------------------------------------------------------------//
BOOL CBCGPBarContainer::IsSliderHorz () const
{
return m_pSlider != NULL ? m_pSlider->IsHorizontal () :
m_bIsRecentSliderHorz;
}
//-----------------------------------------------------------------------------------//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -