本文整理汇总了C++中CControlBar::CalcDynamicLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ CControlBar::CalcDynamicLayout方法的具体用法?C++ CControlBar::CalcDynamicLayout怎么用?C++ CControlBar::CalcDynamicLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CControlBar
的用法示例。
在下文中一共展示了CControlBar::CalcDynamicLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcFixedLayout
CSize CGuiDocBarExten::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
ASSERT_VALID(this);
CSize sizeFixed = CControlBar::CalcFixedLayout(bStretch, bHorz);
// get max size
CSize sizeMax;
if (!m_rectLayout.IsRectEmpty())
{
CRect rect = m_rectLayout;
CalcInsideRect(rect, bHorz);
sizeMax = rect.Size();
}
else
{
CRect rectFrame;
CFrameWnd* pFrame = GetParentFrame();
pFrame->GetClientRect(&rectFrame);
sizeMax = rectFrame.Size();
}
// prepare for layout
AFX_SIZEPARENTPARAMS layout;
layout.hDWP = m_bLayoutQuery ?
NULL : ::BeginDeferWindowPos(m_arrBars.GetSize());
int cxBorder = 2, cyBorder = 2;
CPoint pt(-cxBorder, -cyBorder);
int nWidth = 0;
BOOL bWrapped = FALSE;
// layout all the control bars
for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++)
{
CControlBar* pBar = GetDockedControlBar(nPos);
void* pVoid = m_arrBars[nPos];
if (pBar != NULL)
{
if(pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd)) ||
pBar->IsKindOf(RUNTIME_CLASS(CMenuBar)) )
cxBorder = cyBorder = 0;
else
cxBorder = cyBorder = 2;
if (pBar->IsVisible())
{
// get ideal rect for bar
DWORD dwMode = 0;
if ((pBar->m_dwStyle & CBRS_SIZE_DYNAMIC) &&
(pBar->m_dwStyle & CBRS_FLOATING))
dwMode |= LM_HORZ | LM_MRUWIDTH;
else if (pBar->m_dwStyle & CBRS_ORIENT_HORZ)
dwMode |= LM_HORZ | LM_HORZDOCK;
else
dwMode |= LM_VERTDOCK;
CSize sizeBar = pBar->CalcDynamicLayout(-1, dwMode);
CRect rect(pt, sizeBar);
// get current rect for bar
CRect rectBar;
pBar->GetWindowRect(&rectBar);
ScreenToClient(&rectBar);
if (bHorz)
{
// Offset Calculated Rect out to Actual
if (rectBar.left > rect.left && !m_bFloating)
rect.OffsetRect(rectBar.left - rect.left, 0);
// If ControlBar goes off the right, then right justify
if (rect.right > sizeMax.cx && !m_bFloating)
{
int x = rect.Width() - cxBorder;
x = max(sizeMax.cx - x, pt.x);
rect.OffsetRect(x - rect.left, 0);
}
// If ControlBar has been wrapped, then left justify
if (bWrapped)
{
bWrapped = FALSE;
rect.OffsetRect(-(rect.left + cxBorder), 0);
}
// If ControlBar is completely invisible, then wrap it
else if ((rect.left >= (sizeMax.cx - cxBorder)) &&
(nPos > 0) && (m_arrBars[nPos - 1] != NULL))
{
m_arrBars.InsertAt(nPos, (CObject*)NULL);
pBar = NULL; pVoid = NULL;
bWrapped = TRUE;
}
if (!bWrapped)
{
if (rect != rectBar)
{
if (!m_bLayoutQuery &&
//.........这里部分代码省略.........
示例2: CalcFixedLayout
CSize CExtDockBar::CalcFixedLayout(
BOOL bStretch,
BOOL bHorz
)
{
// based on MFC's source of
// CDockBar::CalcFixedLayout()
ASSERT_VALID(this);
CSize sizeFixed =
CControlBar::CalcFixedLayout( bStretch, bHorz );
// get max size
CSize sizeMax;
if( !m_rectLayout.IsRectEmpty() )
sizeMax = m_rectLayout.Size();
else
{
CFrameWnd * pFrame = GetParentFrame();
CRect rcFrameWindow;
pFrame->GetClientRect( &rcFrameWindow );
sizeMax = rcFrameWindow.Size();
}
// prepare for layout
AFX_SIZEPARENTPARAMS layout;
layout.hDWP = m_bLayoutQuery ?
NULL : ::BeginDeferWindowPos( m_arrBars.GetSize() );
CPoint pt( 0, 0 );
int nWidth = 0;
BOOL bWrapped = FALSE;
for( int nPos = 0; nPos < m_arrBars.GetSize(); nPos++ )
{ // layout all the control bars
CControlBar * pBar = GetDockedControlBar(nPos);
void * pVoid = m_arrBars[nPos];
if( pBar != NULL )
{
CRect rcBarWin, rcBarClient;
pBar->GetWindowRect( &rcBarWin );
pBar->ScreenToClient( & rcBarWin );
pBar->GetClientRect( &rcBarClient );
CSize sizeBarMin =
rcBarWin.Size() - rcBarClient.Size();
if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
{
if( ! ((CExtControlBar*)pBar)->m_bFixedMode )
{
sizeBarMin =
CSize(
((CExtControlBar *)pBar)->_CalcDesiredMinHW(),
((CExtControlBar *)pBar)->_CalcDesiredMinVH()
);
} // if( ! ((CExtControlBar*)pBar)->m_bFixedMode )
} // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
if( pBar->IsVisible() )
{
// get ideal rect for bar
DWORD dwMode = 0;
if( (pBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
&&
(pBar->m_dwStyle & CBRS_FLOATING)
)
dwMode |= LM_HORZ | LM_MRUWIDTH;
else if(pBar->m_dwStyle & CBRS_ORIENT_HORZ)
dwMode |= LM_HORZ | LM_HORZDOCK;
else
dwMode |= LM_VERTDOCK;
CSize sizeBar =
pBar->CalcDynamicLayout(-1, dwMode);
BOOL bIsMenuBar = FALSE;
if( pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
{
bIsMenuBar = TRUE;
if(dwMode & LM_HORZDOCK)
sizeBar.cx = sizeMax.cx;
else if(dwMode & LM_VERTDOCK)
sizeBar.cy = sizeMax.cy;
}
CRect rc(pt, sizeBar);
// get current rect for bar
CRect rcBar;
pBar->GetWindowRect( &rcBar );
ScreenToClient( &rcBar );
BOOL bMenuIsCutted = FALSE;
if( bHorz )
{
// Offset Calculated Rect out to Actual
if( rcBar.left > rc.left
&& !m_bFloating
)
rc.OffsetRect(
rcBar.left - rc.left,
//.........这里部分代码省略.........