📄 bcgpbarcontainer.cpp
字号:
StretchContainer (-nExpandOffset, !IsSliderHorz (),
TRUE, TRUE, hdwp);
}
}
else if (m_pParentContainer != NULL)
{
bNeedToExpandParentContainer = TRUE;
}
m_pBarRightBottom = NULL;
}
else
{
ASSERT (FALSE);
}
if (bNeedToExpandParentContainer)
{
// find the first parent container that has non-empty rectangly and
// whose left/right bar/containre should be expanded
CBCGPBarContainer* pNextContainer = m_pParentContainer;
while (pNextContainer != NULL)
{
if (!pNextContainer->IsContainerEmpty ())
{
break;
}
pNextContainer = pNextContainer->GetParentContainer ();
}
if (pNextContainer != NULL)
{
CBCGPSlider* pParentSlider = (CBCGPSlider*) pNextContainer->GetSlider ();
if (pParentSlider != NULL)
{
int nExpandParentContainerOffset = pParentSlider->IsHorizontal () ?
rectBar.Height () : rectBar.Width ();
nExpandParentContainerOffset *= 2;
nExpandParentContainerOffset += pParentSlider->GetWidth () +2;
if (pNextContainer->IsLeftPartEmpty ())
{
pNextContainer->StretchContainer (-nExpandParentContainerOffset,
!pParentSlider->IsHorizontal (),
FALSE, TRUE, hdwp);
}
else if (pNextContainer->IsRightPartEmpty ())
{
pNextContainer->StretchContainer (nExpandParentContainerOffset,
!pParentSlider->IsHorizontal (),
TRUE, TRUE, hdwp);
}
}
}
}
EndDeferWindowPos (hdwp);
if (m_pSlider == NULL)
{
// it was last bar/container here
m_pBarLeftTop = m_pBarRightBottom = NULL;
m_pLeftContainer = m_pRightContainer = NULL;
}
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::StoreRecentDockInfo (CBCGPDockingControlBar* pBar)
{
ASSERT_VALID (this);
ASSERT_VALID (pBar);
//-------------- set recent dock info
CBCGPSlider* pSlider = pBar->GetDefaultSlider ();
// default slider is NULL when the bar is float_multi on miniframe
if (pSlider == NULL || pBar->GetParentMiniFrame () != NULL)
{
pBar->m_recentDockInfo.StoreDockInfo (this);
return;
}
// DO NOT SAVE recent dock info during transition from autohide mode
// to the regular dock mode! (because it's transition from dock to dock state)
if (!pSlider->IsAutoHideMode ())
{
pBar->m_recentDockInfo.StoreDockInfo (this);
}
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::SetBar (CBCGPDockingControlBar* pBar, BOOL bLeft)
{
ASSERT_VALID (this);
// pBar can be NULL
if (bLeft)
{
m_pBarLeftTop = pBar;
}
else
{
m_pBarRightBottom = pBar;
}
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::SetContainer (CBCGPBarContainer* pContainer, BOOL bLeft)
{
ASSERT_VALID (this);
if (bLeft)
{
m_pLeftContainer = pContainer;
}
else
{
m_pRightContainer = pContainer;
}
if (pContainer != NULL)
{
pContainer->SetParentContainer (this);
}
}
//-----------------------------------------------------------------------------------//
CBCGPBarContainer* CBCGPBarContainer::FindSubContainer (const CObject* pObject,
BC_FIND_CRITERIA findCriteria)
{
ASSERT_VALID (this);
ASSERT (pObject != NULL);
switch (findCriteria)
{
case BC_FIND_BY_LEFT_BAR:
if (m_pBarLeftTop == pObject)
{
return this;
}
break;
case BC_FIND_BY_RIGHT_BAR:
if (m_pBarRightBottom == pObject)
{
return this;
}
break;
case BC_FIND_BY_SLIDER:
if (m_pSlider == pObject)
{
return this;
}
break;
case BC_FIND_BY_CONTAINER:
if (this == pObject)
{
return this;
}
break;
}
CBCGPBarContainer* pSubContainer = NULL;
if (m_pLeftContainer != NULL)
{
pSubContainer = m_pLeftContainer->FindSubContainer (pObject, findCriteria);
}
if (pSubContainer == NULL && m_pRightContainer != NULL)
{
pSubContainer = m_pRightContainer->FindSubContainer (pObject, findCriteria);
}
return pSubContainer;
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::CalculateRecentSize ()
{
CRect rectContainer; rectContainer.SetRectEmpty ();
BOOL bAutoHideMode = m_pContainerManager->IsAutoHideMode ();
GetWindowRect (rectContainer);
CRect rectLeft; rectLeft.SetRectEmpty ();
CRect rectRight; rectRight.SetRectEmpty ();
CSize sizeMinLeft;
CSize sizeMinRight;
double dLeftPercent = 0.;
if (m_pBarLeftTop != NULL && (m_pBarLeftTop->IsBarVisible () || bAutoHideMode))
{
m_pBarLeftTop->GetWindowRect (rectLeft);
m_pBarLeftTop->GetMinSize (sizeMinLeft);
}
if (m_pLeftContainer != NULL && (m_pLeftContainer->IsContainerVisible () || bAutoHideMode))
{
m_pLeftContainer->GetWindowRect (rectLeft);
m_pLeftContainer->GetMinSize (sizeMinLeft);
}
if (m_pBarRightBottom != NULL && (m_pBarRightBottom->IsBarVisible () || bAutoHideMode))
{
m_pBarRightBottom->GetWindowRect (rectRight);
m_pBarRightBottom->GetMinSize (sizeMinRight);
}
if (m_pRightContainer != NULL && (m_pRightContainer->IsContainerVisible () || bAutoHideMode))
{
m_pRightContainer->GetWindowRect (rectRight);
m_pRightContainer->GetMinSize (sizeMinRight);
}
BOOL bCheckVisibility = !bAutoHideMode;
if (!IsLeftPartEmpty (bCheckVisibility) && IsRightPartEmpty (bCheckVisibility))
{
if (m_pBarLeftTop != NULL)
{
m_pBarLeftTop->SetLastPercentInContainer (100);
}
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->CalculateRecentSize ();
m_pLeftContainer->SetRecentPercent (100);
}
}
else if (IsLeftPartEmpty (bCheckVisibility) && !IsRightPartEmpty (bCheckVisibility))
{
if (m_pBarRightBottom != NULL)
{
m_pBarRightBottom->SetLastPercentInContainer (100);
}
if (m_pRightContainer != NULL)
{
m_pRightContainer->CalculateRecentSize ();
m_pRightContainer->SetRecentPercent (100);
}
}
else if (!IsLeftPartEmpty (bCheckVisibility) && !IsRightPartEmpty (bCheckVisibility))
{
ASSERT (m_pSlider != NULL);
if (IsSliderHorz ())
{
int nPercent = -1;
if ((rectLeft.Height () + rectRight.Height ()) > rectContainer.Height ())
{
nPercent = 50;
if (rectLeft.Height () == rectContainer.Height ())
{
if (m_pBarRightBottom != NULL)
{
nPercent = m_pBarRightBottom->GetLastPercentInContainer ();
}
else if (m_pRightContainer != NULL)
{
nPercent = m_pRightContainer->GetRecentPercent ();
}
rectLeft.bottom = rectLeft.top +
rectContainer.Height () -
((rectContainer.Height () * nPercent) / 100);
nPercent = 100 - nPercent;
}
else if (rectRight.Height () == rectContainer.Height ())
{
if (m_pBarLeftTop != NULL)
{
nPercent = m_pBarLeftTop->GetLastPercentInContainer ();
}
else if (m_pLeftContainer != NULL)
{
nPercent = m_pLeftContainer->GetRecentPercent ();
}
rectLeft.bottom = rectLeft.top +
((rectContainer.Height () * nPercent) / 100);
}
}
dLeftPercent = ((double) rectLeft.Height ()) /
rectContainer.Height () * 100;
if (nPercent != -1)
{
dLeftPercent = nPercent;
}
}
else
{
int nPercent = -1;
if ((rectLeft.Width () + rectRight.Width ()) > rectContainer.Width ())
{
if (rectLeft.Width () == rectContainer.Width ())
{
nPercent = 50;
if (m_pBarRightBottom != NULL)
{
nPercent = m_pBarRightBottom->GetLastPercentInContainer ();
}
else if (m_pRightContainer != NULL)
{
nPercent = m_pRightContainer->GetRecentPercent ();
}
rectLeft.right = rectLeft.left +
rectContainer.Width () -
((rectContainer.Width () * nPercent) / 100);
nPercent = 100 - nPercent;
}
else if (rectRight.Width () == rectContainer.Width ())
{
nPercent = 50;
if (m_pBarLeftTop != NULL)
{
nPercent = m_pBarLeftTop->GetLastPercentInContainer ();
}
else if (m_pLeftContainer != NULL)
{
nPercent = m_pLeftContainer->GetRecentPercent ();
}
rectLeft.right = rectLeft.left +
((rectContainer.Width () * nPercent) / 100);
}
}
dLeftPercent = ((double) rectLeft.Width ()) /
rectContainer.Width () * 100;
if (nPercent != -1)
{
dLeftPercent = nPercent;
}
}
if (m_pBarLeftTop != NULL)
{
m_pBarLeftTop->SetLastPercentInContainer ((int) dLeftPercent);
}
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->CalculateRecentSize ();
m_pLeftContainer->SetRecentPercent ((int) dLeftPercent);
}
if (m_pBarRightBottom != NULL)
{
m_pBarRightBottom->SetLastPercentInContainer (100 - (int) dLeftPercent);
}
if (m_pRightContainer != NULL)
{
m_pRightContainer->CalculateRecentSize ();
m_pRightContainer->SetRecentPercent (100 - (int) dLeftPercent);
}
}
}
//-----------------------------------------------------------------------------------//
void CBCGPBarContainer::ResizeContainer (CRect rect, HDWP& hdwp, BOOL bRedraw)
{
CRect rectContainer; rectContainer.SetRectEmpty ();
CRect rectSlider; rectSlider.SetRectEmpty ();
BOOL bAutoHideMode = m_pContainerManager->IsAutoHideMode ();
// VCheck
if (m_pSlider != NULL && (m_pSlider->IsBarVisible () || bAutoHideMode))
{
m_pSlider->GetWindowRect (rectSlider);
}
GetWindowRect (rectContainer);
CRect rectLeft; rectLeft.SetRectEmpty ();
CRect rectRight; rectRight.SetRectEmpty ();
CSize sizeMinLeft;
CSize sizeMinRight;
double dLeftPercent = 0.;
if (m_pBarLeftTop != NULL && (m_pBarLeftTop->IsBarVisible () || bAutoHideMode))
{
m_pBarLeftTop->GetWindowRect (rectLeft);
m_pBarLeftTop->GetMinSize (sizeMinLeft);
}
if (m_pLeftContainer != NULL && (m_pLeftContainer->IsContainerVisible () || bAutoHideMode))
{
m_pLeftContainer->GetWindowRect (rectLeft);
m_pLeftContainer->GetMinSize (sizeMinLeft);
}
if (m_pBarRightBottom != NULL && (m_pBarRightBottom->IsBarVisible () || bAutoHideMode))
{
m_pBarRightBottom->GetWindowRect (rectRight);
m_pBarRightBottom->GetMinSize (sizeMinRight);
}
if (m_pRightContainer != NULL && (m_pRightContainer->IsContainerVisible () || bAutoHideMode))
{
m_pRightContainer->GetWindowRect (rectRight);
m_pRightContainer->GetMinSize (sizeMinRight);
}
BOOL bCheckVisibility = !bAutoHideMode;
if (!IsLeftPartEmpty (bCheckVisibility) && IsRightPartEmpty (bCheckVisibility))
{
if (m_pBarLeftTop != NULL)
{
hdwp = m_pBarLeftTop->MoveWindow (rect, bRedraw, hdwp);
}
if (m_pLeftContainer != NULL)
{
m_pLeftContainer->ResizeContainer (rect, hdwp, bRedraw);
}
}
else if (IsLeftPartEmpty (bCheckVisibility) && !IsRightPartEmpty (bCheckVisibility))
{
if (m_pBarRightBottom != NULL)
{
hdwp = m_pBarRightBottom->MoveWindow (rect, bRedraw, hdwp);
}
if (m_pRightContainer != NULL)
{
m_pRightContainer->ResizeContainer (rect, hdwp, bRedraw);
}
}
else if (!IsLeftPartEmpty (bCheckVisibility) && !IsRightPartEmpty (bCheckVisibility))
{
CRect rectFinalLeft = rect;
CRect rectFinalRight = rect;
CRect rectFinalSlider = rect;
ASSERT (m_pSlider != NULL);
if (IsSliderHorz ())
{
int nPercent = -1;
if ((rectLeft.Height () + rectRight.Height ()) > rectContainer.Height () ||
rectLeft.IsRectEmpty () || rectRight.IsRectEmpty ())
{
nPercent = 50;
if (rectLeft.Height () == rectContainer.Height ())
{
if (m_pBarRightBottom != NULL)
{
nPercent = m_pBarRightBottom->GetLastPercentInContainer ();
}
else if (m_pRightContainer != NULL)
{
nPercent = m_pRightContainer->GetRecentPercent ();
}
if (nPercent == 100 || nPercent == 0)
{
nPercent = 50;
}
rectLeft.bottom = rectLeft.top +
rectContainer.Height () -
((rectContainer.Height () * nPercent) / 100);
nPercent = 100 - nPercent;
}
else if (rectRight.Height () == rectContainer.Height ())
{
if (m_pBarLeftTop != NULL)
{
nPercent = m_pBarLeftTop->GetLastPercentInContainer ();
}
else if (m_pLeftContainer != NULL)
{
nPercent = m_pLeftContainer->GetRecentPercent ();
}
if (nPercent == 100 || nPercent == 0)
{
nPercent = 50;
}
rectLeft.bottom = rectLeft.top +
((rectContainer.Height () * nPercent) / 100);
}
}
int nDelta = rect.Height () - rectContainer.Height ();
dLeftPercent = ((double) rectLeft.Height ()) /
rectContainer.Height () * 100;
if (dLeftPercent == 100 || dLeftPercent == 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -