ExtDockBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:241k
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- LONG & nRowMetricRef = bHorz
- ? pExtBar->m_sizeDockedH.cy
- : pExtBar->m_sizeDockedV.cx;
- nRowMetricRef = pVLI->m_nRowMetric;
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- } // for( INT nRow = 0; nRow < nRowsCount; nRow ++ )
- } // if( bResetRowMetrics )
- // align direction 2 (row extents)
- nDesiredMetric = bHorz ? _size.cx : _size.cy;
- INT nRow = 0;
- bool bFinish = false;
- for( nRow = 0; nRow < nRowsCount; nRow ++ )
- {
- VisibleLayoutItem_t * pVLI = _vl.m_vRows[ nRow ];
- ASSERT( pVLI != NULL );
- if( pVLI->IsEmpty() )
- continue;
- INT nIncrement = ( pVLI->m_nRowExtent < nDesiredMetric ) ? 1 : -1;
- INT nDiff = abs( pVLI->m_nRowExtent - nDesiredMetric );
- bool bHaveDisplayingBars = false;
- for( int nDisplaying = 0; nDisplaying < 2 && nDiff != 0; nDisplaying++ )
- {
- bool bAllMinSized = false;
- INT nPass = 0;
- for( ; nDiff != 0; nPass ++ )
- {
- ASSERT( nDiff >= 0 );
- INT nRowSize = (INT)pVLI->m_vRow.GetSize();
- if( nRowSize == 0 )
- continue;
- ASSERT( nRowSize > 0 );
- INT nBarsMinSized = 0;
- INT nCountDisplaying = 0;
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- if( pExtBar->_DisplayingGet() )
- {
- nCountDisplaying ++;
- if( nCountDisplaying == nRowSize
- || nPass > nRowSize
- )
- {
- bHaveDisplayingBars = false;
- bFinish = true;
- INT nRowSize = (INT)pVLI->m_vRow.GetSize();
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- if( pExtBar->_DisplayingGet() )
- {
- if( nPass <= nRowSize )
- bFinish = false;
- pExtBar->_DisplayingSet( false );
- }
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- if( bFinish )
- break;
- }
- if( nDisplaying == 0
- && nRowSize > 1
- )
- {
- bHaveDisplayingBars = true;
- continue;
- }
- } // if( pExtBar->_DisplayingGet() )
- LONG & nBarMetricRef = bHorz
- ? pExtBar->m_sizeDockedH.cx
- : pExtBar->m_sizeDockedV.cy;
- if( nIncrement < 0 )
- {
- LONG nBarMinMetric = bHorz
- ? pExtBar->_CalcDesiredMinHW()
- : pExtBar->_CalcDesiredMinVH();
- //ASSERT( nBarMetricRef >= nBarMinMetric );
- if( nBarMetricRef < nBarMinMetric )
- nBarMetricRef = nBarMinMetric;
- if( nBarMetricRef <= nBarMinMetric )
- {
- nBarsMinSized ++;
- if( nBarsMinSized == nRowSize )
- {
- if( nDisplaying > 0 )
- bAllMinSized = true;
- break;
- }
- continue;
- }
- } // if( nIncrement < 0 )
- nBarMetricRef += nIncrement;
- nDiff --;
- if( nDiff == 0 )
- break;
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- if( bFinish )
- break;
- if( nBarsMinSized == nRowSize )
- {
- if( nDisplaying > 0 )
- bAllMinSized = true;
- break;
- }
- // if( nDisplaying == 0 )
- // break;
- } // for( ; nDiff != 0; nPass ++ )
- if( bFinish )
- break;
- if( bAllMinSized && nDisplaying > 0 )
- break;
- if( bHaveDisplayingBars && nDisplaying == 0 )
- {
- INT nRowSize = (INT)pVLI->m_vRow.GetSize();
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- pExtBar->_DisplayingSet( false );
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- bHaveDisplayingBars = false;
- } // if( bHaveDisplayingBars && nDisplaying == 0 )
- } // for( int nDisplaying = 0; nDisplaying < 2 && nDiff != 0; nDisplaying++ )
- } // for( nRow = 0; nRow < nRowsCount; nRow ++ )
- ASSERT( _vl.m_nTotalBarsCount > 0 );
- HANDLE hDWP = ::BeginDeferWindowPos( _vl.m_nTotalBarsCount );
- ASSERT( hDWP != NULL );
-
- // apply new layout
- CPoint ptOffs( 0, 0 );
- for( nRow = 0; nRow < nRowsCount; nRow ++ )
- {
- VisibleLayoutItem_t * pVLI = _vl.m_vRows[ nRow ];
- ASSERT( pVLI != NULL );
- //ASSERT( !pVLI->IsEmpty() );
- INT nRowSize = (INT)pVLI->m_vRow.GetSize();
- if( nRowSize == 0 )
- continue;
- ASSERT( nRowSize > 0 );
- INT nRowOffset = 0;
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- if( nBar == 0 )
- nRowOffset = bHorz
- ? pExtBar->m_sizeDockedH.cy
- : pExtBar->m_sizeDockedV.cx;
- CRect rcBar(
- ptOffs,
- bHorz
- ? pExtBar->m_sizeDockedH
- : pExtBar->m_sizeDockedV
- );
- if( hDWP != NULL )
- {
- hDWP =
- ::DeferWindowPos(
- hDWP,
- pExtBar->GetSafeHwnd(),
- NULL,
- rcBar.left, rcBar.top,
- rcBar.Width(), rcBar.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_FRAMECHANGED
- );
- ASSERT( hDWP != NULL );
- }
- if( hDWP == NULL )
- pExtBar->MoveWindow( &rcBar );
- if( bHorz )
- ptOffs.x += pExtBar->m_sizeDockedH.cx;
- else
- ptOffs.y += pExtBar->m_sizeDockedV.cy;
- pExtBar->m_bDelayShowInvoked = false;
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- if( bHorz )
- {
- ptOffs.x = 0;
- ptOffs.y += nRowOffset;
- }
- else
- {
- ptOffs.x += nRowOffset;
- ptOffs.y = 0;
- }
- } // for( nRow = 0; nRow < nRowsCount; nRow ++ )
- ASSERT( hDWP != NULL );
- if( hDWP != NULL )
- ::EndDeferWindowPos( hDWP );
- for( nRow = 0; nRow < nRowsCount; nRow ++ )
- {
- VisibleLayoutItem_t * pVLI = _vl.m_vRows[ nRow ];
- ASSERT( pVLI != NULL );
- INT nRowSize = (INT)pVLI->m_vRow.GetSize();
- if( nRowSize == 0 )
- continue;
- ASSERT( nRowSize > 0 );
- for( INT nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- pExtBar->_DisplayingSet( false );
- //if( bHorz )
- // pExtBar->m_pDockContext->m_sizeLast = pExtBar->m_sizeDockedH;
- //else
- // pExtBar->m_pDockContext->m_sizeLast = pExtBar->m_sizeDockedV;
- // HWND hWnd = pExtBar->GetParent()->GetSafeHwnd();
- // for( ; hWnd != NULL; hWnd = ::GetParent( hWnd ) )
- // {
- // if( ((::__EXT_MFC_GetWindowLong(hWnd,GWL_STYLE))&WS_CHILD) == 0 )
- // break;
- // CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- // if( pWnd == NULL
- // || pWnd->IsKindOf( RUNTIME_CLASS( CFrameWnd ) )
- // )
- // break;
- // CExtControlBar * pBar = DYNAMIC_DOWNCAST( CExtControlBar, pWnd );
- // if( pBar == NULL )
- // continue;
- // pBar->_DisplayingSet( false );
- // }
- pExtBar->OnRepositionSingleChild();
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- } // for( nRow = 0; nRow < nRowsCount; nRow ++ )
- }
- IMPLEMENT_DYNCREATE(CExtDynControlBar, CExtControlBar);
- BEGIN_MESSAGE_MAP(CExtDynControlBar, CExtControlBar)
- //{{AFX_MSG_MAP(CExtDynControlBar)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- CExtDynControlBar::CExtDynControlBar()
- : m_pWndDynDocker( NULL )
- , m_bHelperDockSiteModified( false )
- , m_nDelVisUpdateCounter( 0 )
- {
- m_bAppearInDockSiteControlBarPopupMenu = false;
- m_bAutoDelete = TRUE;
- }
- CExtDockDynBar * CExtDynControlBar::OnCreateDynamicDockBarObject()
- {
- return ( new CExtDockDynBar( 0 ) );
- }
- void CExtDynControlBar::PostNcDestroy()
- {
- CExtControlBar::PostNcDestroy();
- }
- BOOL CExtDynControlBar::DestroyWindow()
- {
- return CExtControlBar::DestroyWindow();
- }
- LRESULT CExtDynControlBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- // if( m_pDockSite != NULL
- // && m_pDockSite->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
- // )
- // {
- // if( message == WM_DESTROY )
- // {
- // //#ifdef _DEBUG
- // // if( m_pDockSite != NULL )
- // // {
- // // ASSERT( m_pDockSite->m_listControlBars.Find(this) == NULL );
- // // }
- // //#endif
- // if( m_pDockContext != NULL )
- // {
- // m_pDockBar = NULL;
- // delete m_pDockContext;
- // m_pDockContext = NULL;
- // }
- // if( m_pWndDynDocker->GetSafeHwnd() != NULL )
- // {
- // m_pWndDynDocker->m_arrBars.RemoveAll();
- // m_pWndDynDocker->m_arrBars.Add( NULL );
- // }
- // }
- // else if( message == WM_SIZE || WM_WINDOWPOSCHANGED )
- // {
- // if(! m_bHelperDockSiteModified )
- // {
- // if( m_pDockSite != NULL )
- // {
- // POSITION pos = m_pDockSite->m_listControlBars.Find( this );
- // if( pos != NULL )
- // {
- // m_pDockSite->m_listControlBars.RemoveAt( pos );
- // m_bHelperDockSiteModified = true;
- // }
- // CFrameWnd * pFrame = GetParentFrame();
- // if( pFrame != m_pDockSite )
- // {
- // pos = pFrame->m_listControlBars.Find( this );
- // if( pos != NULL )
- // pFrame->m_listControlBars.RemoveAt( pos );
- // }
- // }
- // }
- // }
- // }
- LRESULT lResult =
- CExtControlBar::WindowProc( message, wParam, lParam );
- return lResult;
- }
- int CExtDynControlBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if( CExtControlBar::OnCreate(lpCreateStruct) == -1 )
- {
- ASSERT( FALSE );
- return -1;
- }
- UINT nOwnID = GetDlgCtrlID();
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( IsKindOf( RUNTIME_CLASS(CExtDynTabControlBar) )
- && nOwnID == AFX_IDW_DOCKBAR_FLOAT
- )
- {
- nOwnID = AFX_IDW_DOCKBAR_TOP;
- SetDlgCtrlID( nOwnID );
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- ASSERT( m_pWndDynDocker == NULL );
- m_pWndDynDocker = OnCreateDynamicDockBarObject();
- ASSERT( m_pWndDynDocker != NULL );
-
- CFrameWnd * pParentFrame =
- STATIC_DOWNCAST( CFrameWnd, GetParent() );
- ASSERT_VALID( pParentFrame );
- if( !m_pWndDynDocker->Create(
- pParentFrame,
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN
- |CBRS_ALIGN_TOP //|CBRS_ALIGN_ANY
- |CBRS_BORDER_ANY
- ,
- nOwnID
- )
- )
- {
- ASSERT( FALSE );
- return -1;
- }
- m_pWndDynDocker->SetParent( this );
- EnableToolTips();
- return 0;
- }
- bool CExtDynControlBar::NcButtons_HandleClick(
- CExtBarNcAreaButton * pNcAreaButton,
- CPoint point,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pNcAreaButton );
- }
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pBarEventSource );
- }
- #endif // _DEBUG
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtControlBar * pActiveInTabbedBar = NULL;
- CExtDynTabControlBar * pTabbedBar = NULL;
- if( CExtControlBar::g_bCloseOnlyOneBarInTabGroup )
- {
- pTabbedBar =
- DYNAMIC_DOWNCAST( CExtDynTabControlBar, this );
- if( pTabbedBar != NULL )
- {
- LONG nTabSel = pTabbedBar->GetSwitcherSelection();
- if( nTabSel >= 0 )
- pActiveInTabbedBar = pTabbedBar->GetBarAt( nTabSel, true );
- } // if( pTabbedBar != NULL )
- } // if( CExtControlBar::g_bCloseOnlyOneBarInTabGroup )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool bRetVal = false;
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL && ::IsWindow( hWndOwn ) );
- CExtDockDynBar * _pWndDynDocker = m_pWndDynDocker;
- ASSERT_VALID( _pWndDynDocker );
- HWND hWndDynDocker = _pWndDynDocker->GetSafeHwnd();
- ASSERT( hWndDynDocker != NULL && ::IsWindow( hWndDynDocker ) );
- INT nBar, nCount = (INT)_pWndDynDocker->m_arrBars.GetSize();
- CList < HWND, HWND > _listWndsToNotify;
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- _pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( CExtControlBar::g_bCloseOnlyOneBarInTabGroup && pTabbedBar != NULL )
- {
- if( pExtBar != pActiveInTabbedBar )
- continue;
- } // if( CExtControlBar::g_bCloseOnlyOneBarInTabGroup && pTabbedBar != NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ASSERT( pExtBar->GetSafeHwnd() != NULL );
- _listWndsToNotify.AddTail( pExtBar->m_hWnd );
- } // for( nBar = 0; nBar < nCount; nBar++ )
- POSITION pos = _listWndsToNotify.GetHeadPosition();
- HWND hWndBarEventSource = pBarEventSource->GetSafeHwnd();
- for( ; pos != NULL; )
- {
- HWND hWnd = _listWndsToNotify.GetNext( pos );
- if( ! ::IsWindow( hWnd ) )
- continue;
- CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- if( pWnd == NULL )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pWnd );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- bRetVal = true;
- if( ! :: IsWindow( hWndBarEventSource ) )
- {
- pNcAreaButton = NULL;
- pBarEventSource = NULL;
- pBarActiveInContainer = NULL;
- }
- } // for( ; pos != NULL; )
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- if( CWnd::FromHandlePermanent( hWndOwn ) != this )
- return true;
- if( ! ::IsWindow( hWndDynDocker ) )
- return true;
- if( CWnd::FromHandlePermanent( hWndDynDocker ) != _pWndDynDocker )
- return true;
- if( ! bRetVal )
- {
- if( ! CExtControlBar::NcButtons_HandleClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- bRetVal = false;
- } // if( ! bRetVal )
- return bRetVal;
- }
- void CExtDynControlBar::OnRepositionSingleChild(
- int cx, // = -1 // if negative - get from client area
- int cy, // = -1
- bool bRedraw // = true
- )
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( m_pWndDynDocker );
- CRect rcCurrent;
- m_pWndDynDocker->GetWindowRect( &rcCurrent );
- ScreenToClient( &rcCurrent );
- CRect rcClient;
- if( cx < 0 || cy < 0 )
- GetClientRect( &rcClient );
- else
- rcClient.SetRect( 0, 0, cx, cy );
- if( rcCurrent != rcClient )
- m_pWndDynDocker->MoveWindow( &rcClient, bRedraw ? TRUE : FALSE );
- else if( bRedraw )
- {
- CExtDockDynBar::VisibleLayout_t _vl;
- m_pWndDynDocker->_VisibleLayoutBuild( _vl );
- CSize _size = rcClient.Size();
- if( (! _vl.IsEmpty() ) && _size.cx > 0 && _size.cy > 0 )
- {
- m_pWndDynDocker->m_bHelperSizing = true;
- m_pWndDynDocker->_VisibleLayoutAlign( _vl, _size );
- }
- }
- m_pWndDynDocker->OnDynamicLayoutUpdate();
- }
- void CExtDynControlBar::NcButtons_PostClick(
- CExtBarNcAreaButton * pNcAreaButton,
- CPoint point,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pNcAreaButton );
- }
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pBarEventSource );
- }
- #endif // _DEBUG
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL && ::IsWindow( hWndOwn ) );
- CExtDockDynBar * _pWndDynDocker = m_pWndDynDocker;
- ASSERT_VALID( _pWndDynDocker );
- HWND hWndDynDocker = _pWndDynDocker->GetSafeHwnd();
- ASSERT( hWndDynDocker != NULL && ::IsWindow( hWndDynDocker ) );
- INT nBar, nCount = (INT)_pWndDynDocker->m_arrBars.GetSize();
- CList < HWND, HWND > _listWndsToNotify;
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- _pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- ASSERT( pExtBar->GetSafeHwnd() != NULL );
- _listWndsToNotify.AddTail( pExtBar->m_hWnd );
- } // for( nBar = 0; nBar < nCount; nBar++ )
- POSITION pos = _listWndsToNotify.GetHeadPosition();
- HWND hWndBarEventSource = pBarEventSource->GetSafeHwnd();
- for( ; pos != NULL; )
- {
- HWND hWnd = _listWndsToNotify.GetNext( pos );
- if( ! ::IsWindow( hWnd ) )
- continue;
- CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- if( pWnd == NULL )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pWnd );
- if( pExtBar == NULL )
- continue;
- pExtBar->NcButtons_PostClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- if( CWnd::FromHandlePermanent( hWndOwn ) != this )
- return;
- if( ! ::IsWindow( hWndDynDocker ) )
- return;
- if( CWnd::FromHandlePermanent( hWndDynDocker ) != _pWndDynDocker )
- return;
- if( ! :: IsWindow( hWndBarEventSource ) )
- {
- pNcAreaButton = NULL;
- pBarEventSource = NULL;
- pBarActiveInContainer = NULL;
- }
- } // for( ; pos != NULL; )
- if( ! ::IsWindow( hWndOwn ) )
- return;
- if( CWnd::FromHandlePermanent( hWndOwn ) != this )
- return;
- if( ! ::IsWindow( hWndDynDocker ) )
- return;
- if( CWnd::FromHandlePermanent( hWndDynDocker ) != _pWndDynDocker )
- return;
- CExtControlBar::NcButtons_PostClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleQueryVisibility(
- bool & bButtonIsVisible,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleQueryVisibility(
- bButtonIsVisible,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleQueryVisibility(
- bButtonIsVisible,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleDraw(
- CDC & dc,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleDraw(
- dc,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleDraw(
- dc,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleHitTest(
- UINT & nExternalHT,
- CPoint point,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleHitTest(
- nExternalHT,
- point,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleHitTest(
- nExternalHT,
- point,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleQueryCursor(
- HCURSOR & hExternalCursor,
- CPoint point,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleQueryCursor(
- hExternalCursor,
- point,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleQueryCursor(
- hExternalCursor,
- point,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleReposition(
- CExtBarNcAreaButton * pPrevBtn,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pPrevBtn != NULL )
- {
- ASSERT_VALID( pPrevBtn );
- }
- #endif // (defined _DEBUG)
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleReposition(
- pPrevBtn,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleReposition(
- pPrevBtn,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::NcButtons_HandleToolHitTest(
- __EXT_MFC_INT_PTR & hExternalToolHT,
- CPoint point,
- TOOLINFO * pTI,
- CExtBarNcAreaButton * pNcAreaButton,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNcAreaButton );
- ASSERT_VALID( pBarEventSource );
- #if (defined _DEBUG)
- if( pBarActiveInContainer != NULL )
- {
- ASSERT_VALID( pBarActiveInContainer );
- }
- #endif // (defined _DEBUG)
- ASSERT_VALID( m_pWndDynDocker );
- INT nBar, nCount = (INT)m_pWndDynDocker->m_arrBars.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( pExtBar->NcButtons_HandleToolHitTest(
- hExternalToolHT,
- point,
- pTI,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- )
- )
- return true;
- } // for( nBar = 0; nBar < nCount; nBar++ )
- return
- CExtControlBar::NcButtons_HandleToolHitTest(
- hExternalToolHT,
- point,
- pTI,
- pNcAreaButton,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- bool CExtDynControlBar::FlashCaption(
- INT nFlashCount, // = -1 // negative value cancels current flashing
- INT nStepMilliseconds, // = 250
- COLORREF clrFlashText, // = RGB(255,255,255),
- COLORREF clrFlashBackground // = RGB(255,0,0)
- )
- {
- ASSERT_VALID( this );
- nFlashCount;
- nStepMilliseconds;
- clrFlashText;
- clrFlashBackground;
- // control bar containers should not flash their captions
- return false;
- }
- UINT CExtDynControlBar::TearOffCommandGet() const
- {
- ASSERT_VALID( this );
- return 0;
- }
- void CExtDynControlBar::TearOffCommandSet( UINT nCmdID )
- {
- ASSERT_VALID( this );
- nCmdID;
- ASSERT( FALSE );
- }
- bool CExtDynControlBar::_FloatStateChangingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_FloatStateChangingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_FloatStateChangingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_FloatStateChangingIsEnabled( pBarQuerySrc );
- }
- bool CExtDynControlBar::_NcMenuButtonIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_NcMenuButtonIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_NcMenuButtonIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_NcMenuButtonIsEnabled( pBarQuerySrc );
- }
- bool CExtDynControlBar::_ClosingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_ClosingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_ClosingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_ClosingIsEnabled( pBarQuerySrc );
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtDynControlBar::_AutoHidingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_AutoHidingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_AutoHidingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_AutoHidingIsEnabled( pBarQuerySrc );
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtDynControlBar::_DraggingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_DraggingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_DraggingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_DraggingIsEnabled( pBarQuerySrc );
- }
- bool CExtDynControlBar::_RowResizingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_RowResizingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_RowResizingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_RowResizingIsEnabled( pBarQuerySrc );
- }
- bool CExtDynControlBar::_RowRecalcingIsEnabled(
- const CExtControlBar * pBarQuerySrc
- ) const
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return CExtControlBar::_RowRecalcingIsEnabled( pBarQuerySrc );
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT_VALID( pBarQuerySrc );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- if( ! pExtBar->_RowRecalcingIsEnabled( pBarQuerySrc ) )
- return false;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return CExtControlBar::_RowRecalcingIsEnabled( pBarQuerySrc );
- }
- bool CExtDynControlBar::IsBarWithGripper(
- bool * pbGripperAtTop, // = NULL
- bool * pbTextOnGripper // = NULL
- ) const
- {
- ASSERT_VALID( this );
- if( pbGripperAtTop != NULL )
- *pbGripperAtTop = false;
- if( pbTextOnGripper != NULL )
- *pbTextOnGripper = false;
- return false;
- }
- bool CExtDynControlBar::_DisplayingGet() const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pWndDynDocker );
- if( CExtControlBar::_DisplayingGet() )
- return true;
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL
- && pExtBar->_DisplayingGet()
- )
- return true;
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- return false;
- }
- void CExtDynControlBar::_DisplayingSet( bool bDisplaying )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pWndDynDocker );
- CExtControlBar::_DisplayingSet( bDisplaying );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL )
- pExtBar->_DisplayingSet( bDisplaying );
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- }
- void CExtDynControlBar::OnShowControlBarChain(
- bool bShow,
- bool bDelay,
- bool bOnlyOneBar // = false
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pWndDynDocker );
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL )
- pExtBar->OnShowControlBarChain(
- bShow,
- true, //bDelay
- bOnlyOneBar
- );
- else
- pFrame->ShowControlBar(
- pBar,
- bShow ? TRUE : FALSE,
- true //bDelay ? TRUE : FALSE
- );
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- _DisplayingSet( false );
- CExtControlBar::_DisplayingSet( true );
- pFrame->ShowControlBar(
- this,
- bShow ? TRUE : FALSE,
- true // bDelay ? TRUE : FALSE
- );
- if( ! bDelay )
- {
- CFrameWnd * pFrame = GetParentFrame();
- pFrame->RecalcLayout();
- }
- }
- void CExtDynControlBar::OnControlBarPositionChange(
- CExtControlBar * pBarEventSrc,
- e_control_bar_position_changing_t eCBPC,
- bool bInitial,
- bool bFinal
- )
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker != NULL )
- {
- ASSERT_VALID( m_pWndDynDocker );
- int nCount = (int)m_pWndDynDocker->m_arrBars.GetSize();
- for( int nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)
- m_pWndDynDocker->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- pExtBar->OnControlBarPositionChange(
- pBarEventSrc,
- eCBPC,
- bInitial,
- bFinal
- );
- } // for( int nBar = 0; nBar < nCount; nBar++ )
- } // if( m_pWndDynDocker != NULL )
- CExtControlBar::OnControlBarPositionChange(
- pBarEventSrc,
- eCBPC,
- bInitial,
- bFinal
- );
- }
- void CExtDynControlBar::DoPaintNC( CDC * pDC )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDC );
- ASSERT( pDC->GetSafeHdc() != NULL );
- CWnd * pWnd = GetParent();
- if( pWnd->IsKindOf( RUNTIME_CLASS( CExtDockBar ) ) )
- {
- CExtControlBar::DoPaintNC( pDC );
- return;
- }
- CRect rcClient, rcBar;
- GetClientRect( rcClient );
- ClientToScreen( rcClient );
- GetWindowRect( rcBar );
- rcClient.OffsetRect( -rcBar.TopLeft() );
- rcBar.OffsetRect( -rcBar.TopLeft() );
- pDC->ExcludeClipRect( rcClient );
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( false, *pDC, this ) )
- )
- pDC->FillSolidRect(
- &rcBar,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- }
- void CExtDynControlBar::DoPaint( CDC * pDC )
- {
- CWnd * pWnd = GetParent();
- if( pWnd->IsKindOf( RUNTIME_CLASS( CExtDockBar ) ) )
- {
- CExtControlBar::DoPaint( pDC );
- return;
- }
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( true, *pDC, this ) )
- )
- {
- CRect rc;
- GetClientRect( &rc );
- pDC->FillSolidRect(
- &rc,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- }
- }
- void CExtDynControlBar::DoEraseBk( CDC * pDC )
- {
- CWnd * pWnd = GetParent();
- if( pWnd->IsKindOf( RUNTIME_CLASS( CExtDockBar ) ) )
- {
- CExtControlBar::DoEraseBk( pDC );
- return;
- }
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( true, *pDC, this ) )
- )
- {
- CRect rc;
- GetClientRect( &rc );
- pDC->FillSolidRect(
- &rc,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- }
- }
- bool CExtDynControlBar::_CanDockToTabbedContainers(
- CExtControlBar * pDestBar
- ) const
- {
- ASSERT_VALID( this );
- if( ! CExtControlBar::_CanDockToTabbedContainers( pDestBar ) )
- return false;
- if( m_pWndDynDocker == NULL )
- return false;
- for( int i = 0; i < m_pWndDynDocker->m_arrBars.GetSize(); i++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)
- m_pWndDynDocker->m_arrBars[i];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- if( !pBar->_CanDockToTabbedContainers(pDestBar) )
- return false;
- } // for( int i = 0; i < m_pWndDynDocker->m_arrBars.GetSize(); i++ )
- return true;
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynTabControlBar * CExtDynControlBar::_GetNearestTabbedContainer()
- {
- ASSERT_VALID( this );
- return CExtControlBar::_GetNearestTabbedContainer();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- void CExtDynControlBar::_OnNcMiniFrameActivate( bool bActive )
- {
- ASSERT_VALID( this );
- if( m_pWndDynDocker == NULL )
- return;
- for( int i = 0; i < m_pWndDynDocker->m_arrBars.GetSize(); i++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)
- m_pWndDynDocker->m_arrBars[i];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- pBar->_OnNcMiniFrameActivate( bActive );
- } // for( int i = 0; i < m_pWndDynDocker->m_arrBars.GetSize(); i++ )
- }
- CSize CExtDynControlBar::_CalcLayoutMinSize() const
- {
- ASSERT_VALID( this );
- CExtDockDynBar * pDockBar =
- STATIC_DOWNCAST( CExtDockDynBar, GetWindow(GW_CHILD) );
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CExtDockDynBar, pDockBar );
- CExtDockDynBar::VisibleLayout_t _vl;
- pDockBar->_VisibleLayoutBuild( _vl );
- UINT nDockBarID = pDockBar->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- BOOL bHorz = ( nDockBarID == AFX_IDW_DOCKBAR_TOP || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM );
- CSize _size(
- bHorz ? _vl.m_nTotalMinMetric : _vl.m_nTotalMinExtent,
- bHorz ? _vl.m_nTotalMinExtent : _vl.m_nTotalMinExtent
- );
- return _size;
- }
- INT CExtDynControlBar::_CalcDesiredMinHW() const
- {
- //return _CalcLayoutMinSize().cx;
- if( GetSafeHwnd() == NULL )
- return 0;
- CExtDockDynBar * pDockBar =
- STATIC_DOWNCAST( CExtDockDynBar, GetWindow(GW_CHILD) );
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CExtDockDynBar, pDockBar );
- INT nRetVal = 0;
- LONG nBarIdx, nBarCount = LONG( pDockBar->m_arrBars.GetSize() );
- for( nBarIdx = 0; nBarIdx < nBarCount; nBarIdx++ )
- {
- CControlBar * pBar = (CControlBar *)
- pDockBar->m_arrBars[ nBarIdx ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- ASSERT( pBar->m_pDockBar == pDockBar );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- INT nMetric = pExtBar->_CalcDesiredMinHW();
- nRetVal = max( nRetVal, nMetric );
- } // for( nBarIdx = 0; nBarIdx < nBarCount; nBarIdx++ )
- return nRetVal;
- }
- INT CExtDynControlBar::_CalcDesiredMinVH() const
- {
- //return _CalcLayoutMinSize().cy;
- CExtDockDynBar * pDockBar =
- STATIC_DOWNCAST( CExtDockDynBar, GetWindow(GW_CHILD) );
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CExtDockDynBar, pDockBar );
- INT nRetVal = 0;
- LONG nBarIdx, nBarCount = LONG( pDockBar->m_arrBars.GetSize() );
- for( nBarIdx = 0; nBarIdx < nBarCount; nBarIdx++ )
- {
- CControlBar * pBar = (CControlBar *)
- pDockBar->m_arrBars[ nBarIdx ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- ASSERT( pBar->m_pDockBar == pDockBar );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar == NULL )
- continue;
- INT nMetric = pExtBar->_CalcDesiredMinVH();
- nRetVal = max( nRetVal, nMetric );
- } // for( nBarIdx = 0; nBarIdx < nBarCount; nBarIdx++ )
- return nRetVal;
- }
- CSize CExtDynControlBar::_CalcDesiredMinFloatedSize() const
- {
- return _CalcLayoutMinSize();
- }
- bool CExtDynControlBar::_IsDelayedVisibilityUpdateEnabled() const
- {
- ASSERT_VALID( this );
- // return ( m_nDelVisUpdateCounter != 0 ) ? true : false;
- return false;
- }
- void CExtDynControlBar::DelayShow( BOOL bShow )
- {
- ASSERT_VALID( this );
- CExtControlBar::DelayShow( bShow );
- // if( m_bUpdatingChain )
- // return;
- // m_nDelVisUpdateCounter ++;
- // _UpdateVisibilityInChain();
- // _UpdateVisibilityInRow();
- // m_nDelVisUpdateCounter --;
- }
- CSize CExtDynControlBar::CalcDynamicLayout(
- int nLength,
- DWORD nMode
- )
- {
- CSize _size = CExtControlBar::CalcDynamicLayout( nLength, nMode );
- if( m_pDockBar == NULL ) // (+ v.2.23) - shutdown mode
- return _size;
- ASSERT_VALID( m_pDockBar );
- if( ((CExtDockBar *)m_pDockBar)->m_bLayoutQuery )
- return _size;
- if( m_pWndDynDocker->GetSafeHwnd() == NULL )
- return _size;
- INT nDockedVisibleCount = m_pWndDynDocker->GetDockedVisibleCount();
- if( nDockedVisibleCount == 0 )
- {
- m_pDockSite->ShowControlBar( this, FALSE, FALSE );
- _size.cx = _size.cy = 0;
- }
- CFrameWnd * pParentFrame = GetParentFrame();
- if( pParentFrame->IsKindOf( RUNTIME_CLASS( CMiniFrameWnd ) ) )
- {
- ASSERT_VALID( m_pWndDynDocker );
- ASSERT( ::IsWindow( m_pWndDynDocker->GetSafeHwnd() ) );
- //!!//
- // m_pWndDynDocker->OnDynamicLayoutUpdate();
- // pParentFrame->SetWindowPos(
- // NULL, 0, 0, 0, 0,
- // SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- // |SWP_FRAMECHANGED
- // );
- // pParentFrame->SendMessage( WM_NCPAINT );
- ASSERT_VALID( m_pDockBar );
- if( ( ! m_pWndDynDocker->m_bLockedOptimize )
- && pParentFrame == m_pDockBar->GetParent()
- )
- m_pWndDynDocker->OnDynamicLayoutUpdate();
- } // if( ....
-
- return _size;
- }
- void CExtDockDynBar::OnDynamicLayoutUpdate()
- {
- ASSERT_VALID( this );
- ASSERT_KINDOF( CExtDockDynBar, this );
- if( m_bLockedOptimize )
- return;
- if( m_bInDynamicLayoutUpdate )
- return;
- m_bInDynamicLayoutUpdate = true;
- UINT nDockBarID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- BOOL bHorz = ( nDockBarID == AFX_IDW_DOCKBAR_TOP || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM );
-
- CalcFixedLayout( TRUE, bHorz );
- m_bInDynamicLayoutUpdate = false;
- CExtDockBar::OnDynamicLayoutUpdate();
- }
- void CExtDockDynBar::OnDynamicLayoutOptimize()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pDockSite );
- if( m_bLockedOptimize )
- {
- #ifdef _DEBUG
- #ifdef __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- INT nDockedCount = GetDockedCount();
- ASSERT( nDockedCount != 0 );
- #endif // __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- #endif // _DEBUG
- return;
- }
- bool bOptimizeChilds = false;
- INT nSinglePos = -1;
- bool bPlaceHolder = false;
- ASSERT( m_arrBars.GetSize() >= 1 );
- INT nDockedCount = GetDockedCount();
- if( nDockedCount != 0 )
- {
- ASSERT( nDockedCount >= 1 );
- for( INT nBar = 1; nBar < m_arrBars.GetSize(); nBar++ )
- {
- CControlBar * pBar = (CControlBar *)m_arrBars[ nBar ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- {
- if( nSinglePos >= 0 && !bPlaceHolder )
- {
- bOptimizeChilds = true;
- break;
- }
- nSinglePos = nBar;
- bPlaceHolder = true;
- continue;
- }
- else
- {
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( nSinglePos >= 0 )
- {
- bOptimizeChilds = true;
- break;
- }
- nSinglePos = nBar;
- }
- } // for( INT nBar = 1; nBar < m_arrBars.GetSize(); nBar++ )
- } // if( nDockedCount != 0 )
-
- if( bOptimizeChilds )
- {
- CExtDockBar::OnDynamicLayoutOptimize();
- return;
- }
- CFrameWnd * pDockSite = m_pDockSite;
- CMiniFrameWnd * pMiniFrame =
- DYNAMIC_DOWNCAST(
- CMiniFrameWnd,
- GetParentFrame()
- );
- if( pMiniFrame != NULL )
- pMiniFrame->DelayRecalcLayout();
- CExtDynControlBar * pDynBar =
- STATIC_DOWNCAST( CExtDynControlBar, GetParent() );
- ASSERT_VALID( pDynBar );
- ASSERT( pDockSite == pDynBar->m_pDockSite );
- CDockBar * pDockBarParent =
- STATIC_DOWNCAST( CDockBar, pDynBar->GetParent() );
- ASSERT_VALID( pDockBarParent );
- ASSERT( pDockSite == pDockBarParent->m_pDockSite );
- HWND hWndOwn = GetSafeHwnd();
- if( nSinglePos == -1 )
- { // optimizing empty dynamic docker
- pDynBar->m_pDockBar = NULL;
- // pDockSite->RemoveControlBar( pDynBar );
- pDockSite->RemoveControlBar( this );
- ASSERT( pDynBar->m_bAutoDelete );
- HWND hWndDynBar = pDynBar->GetSafeHwnd();
- pDockBarParent->RemoveControlBar( pDynBar );
- if( ::IsWindow(hWndDynBar) )
- pDynBar->DestroyWindow();
-
- if( pMiniFrame == NULL )
- pDockSite->DelayRecalcLayout();
- ASSERT( pDockSite->m_listControlBars.Find(pDynBar) == NULL );
- if( ! ( ::IsWindow(hWndOwn) ) )
- return;
- if( pDockBarParent->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- ((CExtDockBar *)pDockBarParent)->OnDynamicLayoutUpdate();
- return;
- } // optimizing empty dynamic docker
- if( bPlaceHolder )
- { // optimizing placeholder dynamic docker
- return;
- } // optimizing placeholder dynamic docker
- // optimizing singlebar dynamic docker
- CExtControlBar * pSingleBar = (CExtControlBar *)m_arrBars[ nSinglePos ];
- ASSERT_VALID( pSingleBar );
- ASSERT_KINDOF( CExtControlBar, pSingleBar );
- ASSERT( !pSingleBar->IsFixedMode() );
- CRect wrSingleBar;
- pDynBar->GetWindowRect( &wrSingleBar );
- CSize sizeSingleBar = wrSingleBar.Size();
- INT nDynPos = pDockBarParent->FindBar( pDynBar );
- ASSERT( nDynPos > 0 );
- pDockBarParent->m_arrBars[ nDynPos ] = pSingleBar;
- pSingleBar->m_pDockBar = pDockBarParent;
- if( pSingleBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && !((CExtControlBar*)pSingleBar)->IsFixedMode()
- )
- {
- if( pDockBarParent->GetBarStyle() & CBRS_ORIENT_HORZ )
- ((CExtControlBar*)pSingleBar)->
- SetInitDesiredSizeHorizontal( sizeSingleBar );
- else
- ((CExtControlBar*)pSingleBar)->
- SetInitDesiredSizeVertical( sizeSingleBar );
- DWORD dwStyle = pSingleBar->GetBarStyle();
- dwStyle &= ~(CBRS_ALIGN_ANY);
- dwStyle |= (pDynBar->m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY;
- pSingleBar->SetBarStyle( dwStyle );
- }
- m_arrBars.RemoveAll();
- m_arrBars.Add( (CControlBar *)NULL );
- pSingleBar->SetParent( pDockBarParent );
- pSingleBar->m_pDockBar = pDockBarParent;
- pDynBar->m_pDockBar = NULL;
- // pDockSite->RemoveControlBar( pDynBar );
- pDockSite->RemoveControlBar( this );
- ASSERT( pDynBar->m_bAutoDelete );
- pDynBar->DestroyWindow();
- /*
- // pSingleBar->m_bUpdatingChain = true;
- pDockBarParent->ScreenToClient( &wrSingleBar );
- pSingleBar->SetWindowPos(
- NULL,
- wrSingleBar.left, wrSingleBar.top,
- sizeSingleBar.cx, sizeSingleBar.cy,
- SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE
- |SWP_FRAMECHANGED
- //|SWP_NOREDRAW
- );
- // pSingleBar->m_bUpdatingChain = false;
- */
- if( pMiniFrame == NULL )
- pDockSite->DelayRecalcLayout();
- ASSERT( pDockSite->m_listControlBars.Find(pDynBar) == NULL );
- if( pDockBarParent->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- ((CExtDockBar *)pDockBarParent)->OnDynamicLayoutUpdate();
- }
- CSize CExtDockDynBar::CalcFixedLayout(
- BOOL bStretch,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- ASSERT( ! m_bFloating );
- bHorz;
- VisibleLayout_t _vl;
- _VisibleLayoutBuild( _vl );
- CRect rect;
- GetWindowRect( &rect );
- CSize _size = rect.Size();
- if( (! _vl.IsEmpty() ) && bStretch && _size.cx > 0 && _size.cy > 0 )
- _VisibleLayoutAlign( _vl, _size );
- return _size;
- }
- void CExtDockDynBar::CalcOrderedVector(
- ExtControlBarVector_t & vBars
- )
- {
- ASSERT_VALID( this );
- INT nCount = (INT)m_arrBars.GetSize();
- ASSERT( nCount > 0 );
- ASSERT( m_arrBars[0] == NULL );
- for( INT nBar = 1; nBar < nCount; nBar++ )
- {
- CExtControlBar * pBar = (CExtControlBar *) m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR( pBar ) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- ASSERT( !pBar->IsFixedMode() );
- vBars.Add( pBar );
- } // for( INT nBar = 1; nBar < nCount; nBar++ )
- }
- void CExtDockDynBar::OnSize(UINT nType, int cx, int cy)
- {
- m_bHelperSizing = true;
- CExtDockBar::OnSize(nType, cx, cy);
- if( (! m_bHelperDockSiteModified )
- && m_pDockSite != NULL
- )
- {
- POSITION pos = m_pDockSite->m_listControlBars.Find( this );
- if( pos != NULL )
- {
- m_pDockSite->m_listControlBars.RemoveAt( pos );
- m_bHelperDockSiteModified = true;
- }
- }
- /*
- if( nType == SIZE_MINIMIZED )
- return;
- if( cx <= 0 || cy <= 0 )
- return;
- OnDynamicLayoutUpdate();
- */
- }
- BOOL CExtDockDynBar::PreTranslateMessage(MSG* pMsg)
- {
- return CExtDockBar::PreTranslateMessage(pMsg);
- }
- /////////////////////////////////////////////////////////////////////////
- // CExtDockOuterBar::OuterLayoutItemData
- void CExtDockOuterBar::OuterLayoutItemData::_AssignFromOther(
- const CExtDockOuterBar::OuterLayoutItemData & other
- )
- {
- m_pBar = other.m_pBar;
- m_bVisible = other.m_bVisible;
- m_sizeCalcDynamic = other.m_sizeCalcDynamic;
- m_sizeBarMin = other.m_sizeBarMin;
- m_rcPreCalc = other.m_rcPreCalc;
- m_rcReal = other.m_rcReal;
- }
- CExtDockOuterBar::OuterLayoutItemData::OuterLayoutItemData()
- : m_pBar( NULL )
- , m_bVisible( false )
- , m_sizeCalcDynamic( 0, 0 )
- , m_sizeBarMin( 0, 0 )
- , m_rcPreCalc( 0, 0, 0, 0 )
- , m_rcReal( 0, 0, 0, 0 )
- {
- }
- CExtDockOuterBar::OuterLayoutItemData::OuterLayoutItemData(
- CControlBar * pBar,
- BOOL bHorz,
- const SIZE & sizeMax
- )
- : m_pBar( pBar )
- , m_sizeCalcDynamic( 0, 0 )
- , m_sizeBarMin( 0, 0 )
- , m_rcPreCalc( 0, 0, 0, 0 )
- , m_rcReal( 0, 0, 0, 0 )
- {
- ASSERT_VALID( m_pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- m_bVisible = pBar->IsVisible() ? true : false;
- // if( m_bVisible
- // && (pBar->m_nStateFlags & CControlBar::delayHide) != 0
- // )
- // m_bVisible = false;
- // if( (!m_bVisible)
- // && (pBar->m_nStateFlags & CControlBar::delayShow) != 0
- // )
- // m_bVisible = true;
- if( !m_bVisible )
- return;
- // for _CalcFixedRowLayout
- CRect rcBarWin, rcBarClient;
- pBar->GetWindowRect( &rcBarWin );
- pBar->ScreenToClient( & rcBarWin );
- pBar->GetClientRect( &rcBarClient );
- m_sizeBarMin = rcBarWin.Size() - rcBarClient.Size();
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- m_sizeBarMin +=
- ((CExtControlBar *)pBar)->
- _CalcDesiredMinOuterSize( bHorz );
- } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- // 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;
- m_sizeCalcDynamic = pBar->CalcDynamicLayout(-1, dwMode);
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && ((CExtControlBar *)pBar)->_GetFullRowMode()
- )
- {
- if(dwMode & LM_HORZDOCK)
- m_sizeCalcDynamic.cx = sizeMax.cx;
- else if(dwMode & LM_VERTDOCK)
- m_sizeCalcDynamic.cy = sizeMax.cy;
- }
- }
- /////////////////////////////////////////////////////////////////////////
- // CExtDockOuterBar window
- IMPLEMENT_DYNCREATE(CExtDockOuterBar, CExtDockBar);
- BEGIN_MESSAGE_MAP(CExtDockOuterBar, CExtDockBar)
- //{{AFX_MSG_MAP(CExtDockOuterBar)
- ON_WM_TIMER()
- ON_WM_LBUTTONDBLCLK()
- //}}AFX_MSG_MAP
- ON_WM_SYSCOLORCHANGE()
- __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
- ON_MESSAGE(__ExtMfc_WM_THEMECHANGED, OnThemeChanged)
- END_MESSAGE_MAP()
- CExtDockOuterBar::CExtDockOuterBar()
- : CExtDockBar( 0 )
- , m_bInDockSiteDelayedRecalc( false )
- , m_bDockSiteRecalcIsDelayed( false )
- {
- }
- void CExtDockOuterBar::OnSysColorChange()
- {
- CExtDockBar::OnSysColorChange();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnSysColorChange( this );
- // g_CmdManager.OnSysColorChange( pPM, this );
- }
- void CExtDockOuterBar::OnSettingChange(UINT uFlags, __EXT_MFC_SAFE_LPCTSTR lpszSection)
- {
- CExtDockBar::OnSettingChange( uFlags, lpszSection );
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnSettingChange( this, uFlags, lpszSection );
- // g_CmdManager.OnSettingChange( pPM, this, uFlags, lpszSection );
- }
- LRESULT CExtDockOuterBar::OnDisplayChange( WPARAM wParam, LPARAM lParam )
- {
- LRESULT lResult = CExtDockBar::OnDisplayChange( wParam, lParam );
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnDisplayChange( this, (INT)wParam, CPoint(lParam) );
- // g_CmdManager.OnDisplayChange( pPM, this, (INT)wParam, CPoint(lParam) );
- return lResult;
- }
- void CExtDockOuterBar::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- if( CExtControlBar::FindHelpMode(this) )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( m_hWnd );
- if( pSite != NULL )
- {
- if( pSite->IsCustomizeMode() )
- return;
- pSite->DoFormCustomization();
- return;
- } // if( pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtDockBar::OnLButtonDblClk(nFlags, point);
- }
- LRESULT CExtDockOuterBar::OnThemeChanged( WPARAM wParam, LPARAM lParam )
- {
- wParam;
- lParam;
- LRESULT lResult = Default();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnThemeChanged( this, wParam, lParam );
- // g_CmdManager.OnThemeChanged( pPM, this, wParam, lParam );
- return lResult;
- }
- void CExtDockOuterBar::OnDynamicLayoutUpdate()
- {
- CExtDockBar::OnDynamicLayoutUpdate();
- }
- void CExtDockOuterBar::OnDynamicLayoutOptimize()
- {
- CExtDockBar::OnDynamicLayoutOptimize();
- }
- void CExtDockOuterBar::_DelayDockSiteRecalc()
- {
- ASSERT_VALID( this );
- if( m_bDockSiteRecalcIsDelayed )
- return;
- CExtDockOuterBar * pDocker = this;
- if( GetDlgCtrlID() != AFX_IDW_DOCKBAR_TOP )
- {
- CFrameWnd * pFrame = STATIC_DOWNCAST( CFrameWnd, GetParent() );
- ASSERT_VALID( pFrame );
- CControlBar * pTempBar = pFrame->GetControlBar( AFX_IDW_DOCKBAR_TOP );
- if( pTempBar == NULL )
- pTempBar = pFrame->GetControlBar( AFX_IDW_DOCKBAR_BOTTOM );
- if( pTempBar == NULL )
- pTempBar = pFrame->GetControlBar( AFX_IDW_DOCKBAR_LEFT );
- if( pTempBar == NULL )
- pTempBar = pFrame->GetControlBar( AFX_IDW_DOCKBAR_RIGHT );
- if( pTempBar != NULL )
- pDocker = STATIC_DOWNCAST( CExtDockOuterBar, pTempBar );
- } // if( GetDlgCtrlID() != AFX_IDW_DOCKBAR_TOP )
- pDocker->_DelayDockSiteRecalc_Start();
- }
- void CExtDockOuterBar::_DelayDockSiteRecalc_Start()
- {
- ASSERT_VALID( this );
- if( m_bDockSiteRecalcIsDelayed )
- return;
- m_bDockSiteRecalcIsDelayed = true;
- if( _DelayDockSiteRecalc_Update() )
- {
- KillTimer( 901 );
- m_bDockSiteRecalcIsDelayed = false;
- }
- else
- SetTimer( 901, 1, NULL );
- }
- bool CExtDockOuterBar::_DelayDockSiteRecalc_Update()
- {
- ASSERT_VALID( this );
- if( m_bInDockSiteDelayedRecalc )
- return false;
- CExtControlBar::InternalFriendlyFrameWnd * pFrame =
- (CExtControlBar::InternalFriendlyFrameWnd *)
- STATIC_DOWNCAST( CFrameWnd, GetParent() );
- ASSERT_VALID( pFrame );
- if( pFrame->IsInRecalcLayout()
- || CExtControlBar::ProfileBarStateIsSerializing( pFrame )
- || (pFrame->GetStyle()&WS_VISIBLE) == 0
- )
- return false;
- m_bInDockSiteDelayedRecalc = true;
- pFrame->RecalcLayout();
- m_bInDockSiteDelayedRecalc = false;
- return true;
- }
- void CExtDockOuterBar::OnTimer(__EXT_MFC_UINT_PTR nIDEvent)
- {
- if( nIDEvent == 901 )
- {
- if( _DelayDockSiteRecalc_Update() )
- {
- KillTimer( 901 );
- m_bDockSiteRecalcIsDelayed = false;
- }
- return;
- } // if( nIDEvent == 901 )
- CExtDockBar::OnTimer(nIDEvent);
- }
- void CExtDockOuterBar::_AffixmentBringToTop( CExtControlBar * pBar )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- CExtControlBar::InternalAffixmentData * pAffixmentDataSrc =
- pBar->_AffixmentGetOuter();
- ASSERT( pAffixmentDataSrc != NULL );
- ASSERT( FindBar(pBar) >= 0 );
- ExtControlBarVector_t vBars;
- pBar->_GetRowExtBars( vBars, false );
- int nCount = (int)vBars.GetSize();
- ASSERT( nCount > 0 );
- pAffixmentDataSrc->m_nAffixmentWeight = 1;
- /// pAffixmentDataSrc->m_rcAffixment.SetRectEmpty();
- if( nCount == 1 )
- return;
- int nResetWeight = (int)m_arrBars.GetSize() * 4;
- int nBar = 0;
- for( nBar = 0; nBar < nCount; )
- {
- CExtControlBar * pBar2 = vBars[nBar];
- ASSERT_VALID( pBar2 );
- if( pBar2 == pBar )
- {
- nBar++;
- continue;
- }
- CExtControlBar::InternalAffixmentData * pAffixmentData2 =
- pBar2->_AffixmentGetOuter();
- if( pAffixmentData2 == NULL )
- {
- vBars.RemoveAt(nBar);
- nCount--;
- continue;
- }
- if( pAffixmentData2->IsEmpty() )
- pAffixmentData2->m_nAffixmentWeight = nResetWeight++;
- else
- pAffixmentData2->m_nAffixmentWeight++;
- nBar++;
- } // for( nBar = 0; nBar < nCount; )
- if( nCount <= 1 )
- return;
- // reset affixment weights
- ExtControlBarVector_t vBars2;
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CExtControlBar * pBarX = vBars[nBar];
- int nCount2 = (int)vBars2.GetSize();
- if( nCount2 == 0 )
- {
- vBars2.Add( pBarX );
- continue;
- }
- CExtControlBar::InternalAffixmentData * pAffixmentDataX =
- pBarX->_AffixmentGetOuter();
- ASSERT( pAffixmentDataX != NULL );
- int nWeightX = pAffixmentDataX->m_nAffixmentWeight;
- for( int nBar2 = 0; nBar2 < nCount2; nBar2++ )
- {
- CExtControlBar * pBar2 = vBars2[nBar2];
- ASSERT( pBar2 != pBarX );
- CExtControlBar::InternalAffixmentData * pAffixmentData2 =
- pBar2->_AffixmentGetOuter();
- ASSERT( pAffixmentData2 != NULL );
- int nWeight2 = pAffixmentData2->m_nAffixmentWeight;
- ASSERT( nWeight2 != nWeightX );
- if( nWeight2 > nWeightX )
- {
- vBars2.InsertAt( nBar2, pBarX );
- break;
- }
- if( nBar2 == nCount2-1 )
- {
- vBars2.Add( pBarX );
- break;
- }
- } // for( int nBar2 = 0; nBar2 < nCount2; nBar2++ )
- } // for( nBar = 0; nBar < nCount; nBar++ )
- ASSERT( vBars2.GetSize() == nCount );
- ASSERT( vBars2[0]->_AffixmentGetOuter()->m_nAffixmentWeight == 1 );
- // if( nCount == 2 )
- // return;
- for( nBar = 1; nBar < nCount; nBar++ )
- {
- CExtControlBar * pBarX = vBars2[nBar];
- CExtControlBar::InternalAffixmentData * pAffixmentDataX =
- pBarX->_AffixmentGetOuter();
- ASSERT( pAffixmentDataX != NULL );
- pAffixmentDataX->m_nAffixmentWeight = nBar + 1;
- }
- }
- //#define __DEBUG_CExtDockOuterBar_CompressSubRow_ASSERT_CRITICAL_MINSIZE
- bool CExtDockOuterBar::_CompressSubRow(
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- int nSubRowStartPos,
- int nSubRowEndPos,
- int nExtentMax,
- bool bHorz,
- bool & bAdjustWithAffixment,
- bool * p_bFullyOccupiedLayout // = NULL
- )
- {
- ASSERT_VALID(this);
- ASSERT( dbol.GetSize() > 0 );
- ASSERT( nSubRowStartPos <= nSubRowEndPos );
- ASSERT( 0 <= nSubRowStartPos && nSubRowStartPos < dbol.GetSize() );
- ASSERT( 0 <= nSubRowEndPos && nSubRowEndPos < dbol.GetSize() );
- CArray < CRect, CRect > arrRcPreCalc;
- int nPossibleBetween = 0;
- //int nPossibleCs = 0;
- int nExtentReal = 0;
- int nBar = 0;
- for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CRect rcPreCalc( olid.m_rcPreCalc );
- ASSERT( rcPreCalc.left >= 0 );
- ASSERT( rcPreCalc.top >= 0 );
- ASSERT( rcPreCalc.left <= rcPreCalc.right );
- ASSERT( rcPreCalc.top <= rcPreCalc.bottom );
- #ifdef __DEBUG_CExtDockOuterBar_CompressSubRow_ASSERT_CRITICAL_MINSIZE
- ASSERT( rcPreCalc.Width() >= olid.m_sizeBarMin.cx );
- ASSERT( rcPreCalc.Height() >= olid.m_sizeBarMin.cy );
- #endif // __DEBUG_CExtDockOuterBar_CompressSubRow_ASSERT_CRITICAL_MINSIZE
- int nBetween = 0;
- if( nBar == nSubRowStartPos )
- {
- nBetween += bHorz
- ? rcPreCalc.left
- : rcPreCalc.top
- ;
- ASSERT( nBetween >= 0 );
- } // if( nBar == nSubRowStartPos )
- else
- {
- if( bHorz )
- {
- nBetween +=
- rcPreCalc.left
- - arrRcPreCalc.ElementAt(nBar-1-nSubRowStartPos).right
- ;
- ASSERT( nBetween >= 0 );
- if( nBar == nSubRowEndPos )
- nBetween += nExtentMax - rcPreCalc.right;
- } // if( bHorz )
- else
- {
- nBetween +=
- rcPreCalc.top
- - arrRcPreCalc.ElementAt(nBar-1-nSubRowStartPos).bottom
- ;
- ASSERT( nBetween >= 0 );
- if( nBar == nSubRowEndPos )
- nBetween += nExtentMax - rcPreCalc.bottom;
- } // else from if( bHorz )
- } // else from if( nBar == nSubRowStartPos )
- // int nCsAvail = bHorz
- // ? (rcPreCalc.Width() - olid.m_sizeBarMin.cx)
- // : (rcPreCalc.Height() - olid.m_sizeBarMin.cy)
- // ;
- // ASSERT( nCsAvail >= 0 );
- // nPossibleCs += nCsAvail;
- nPossibleBetween += nBetween;
- arrRcPreCalc.Add( rcPreCalc );
- nExtentReal += bHorz
- ? rcPreCalc.Width()
- : rcPreCalc.Height()
- ;
- } // for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- ASSERT( arrRcPreCalc.GetSize() == (nSubRowEndPos-nSubRowStartPos+1) );
- //int nPossible = nPossibleBetween + nPossibleCs;
- bool bRetVal = false;
- int nCsRow = nExtentReal - nExtentMax /*- nPossibleBetween*/; //nPossibleCs;
- if( nPossibleBetween > 0 )
- nCsRow -= nPossibleBetween;
- if( nPossibleBetween > 0 )
- {
- int nLeftPrev = nExtentMax;
- for( int nBar = nSubRowEndPos; nBar >= nSubRowStartPos; nBar-- )
- {
- CRect & rcPreCalc = arrRcPreCalc.ElementAt( nBar-nSubRowStartPos );
- int nShift =
- nLeftPrev
- - (bHorz ? rcPreCalc.right : rcPreCalc.bottom)
- ;
- if( nShift < 0 )
- rcPreCalc.OffsetRect(
- bHorz ? nShift : 0,
- bHorz ? 0 : nShift
- );
- nLeftPrev = bHorz
- ? rcPreCalc.left
- : rcPreCalc.top
- ;
- } // for( int nBar = nSubRowEndPos; nBar >= nSubRowStartPos; nBar-- )
- if( nLeftPrev >= 0 )
- bRetVal = true;
- // else
- // nCsRow = -nLeftPrev;
- } // if( nPossibleBetween > 0 )
- bool bCompressionPassed = false;
- if( (!bRetVal) && nCsRow >= 0 )
- {
- int nLeftPrev = nExtentMax;
- for( int nBar = nSubRowEndPos; nBar >= nSubRowStartPos; nBar-- )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- CRect & rcPreCalc = arrRcPreCalc.ElementAt( nBar-nSubRowStartPos );
- int nCsAvail = bHorz
- ? (rcPreCalc.Width() - olid.m_sizeBarMin.cx)
- : (rcPreCalc.Height() - olid.m_sizeBarMin.cy)
- ;
- if( nCsAvail < 0 )
- nCsAvail = 0;
- //ASSERT( nCsAvail >= 0 );
- if( nCsAvail > nCsRow )
- nCsAvail = nCsRow;
- bool bAdjust = false;
- if( nCsRow > 0 )
- {
- nCsRow -= nCsAvail;
- ASSERT( nCsRow >= 0 );
- bAdjust = true;
- }
- int nShift =
- nLeftPrev
- - (bHorz ? rcPreCalc.right : rcPreCalc.bottom )
- ;
- //ASSERT( nShift >= 0 );
- rcPreCalc.OffsetRect(
- bHorz ? nShift : 0,
- bHorz ? 0 : nShift
- );
- //if( nCsRow > 0 )
- if( bAdjust )
- (bHorz ? rcPreCalc.left : rcPreCalc.top) += nCsAvail;
- nLeftPrev = bHorz ? rcPreCalc.left : rcPreCalc.top;
- } // for( nBar = nSubRowEndPos; nBar >= nSubRowStartPos; nBar-- )
- if( nCsRow == 0 && nLeftPrev >= 0 )
- {
- bRetVal = true;
- if( nLeftPrev == 0
- && (nSubRowStartPos < nSubRowEndPos)
- )
- { // if compression passed with full row layout with more than 1 bar
- bCompressionPassed = true;
- // re-compress with affixment
- AffixmentOrderVector_t arrAffixmentOrder;
- _CalcAffixmentOrderVector(
- bHorz,
- arrAffixmentOrder,
- dbol,
- false,
- nSubRowStartPos,
- nSubRowEndPos
- );
- ASSERT( arrAffixmentOrder.GetSize() == (nSubRowEndPos-nSubRowStartPos+1) );
- bool bPerformReShift = false;
- // last is not reviewed
- for( int nOrderT = (int)arrAffixmentOrder.GetSize()-1; nOrderT > 0; nOrderT-- )
- {
- int nReviewIdx = arrAffixmentOrder[ nOrderT - 1 ];
- OuterLayoutItemData & olidReview = dbol.ElementAt( nReviewIdx );
- CExtControlBar * pExtBarReview =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olidReview.m_pBar
- );
- if( pExtBarReview == NULL )
- continue;
- CExtControlBar::InternalAffixmentData * pAffixmentDataReview =
- pExtBarReview->_AffixmentGetOuter();
- if( pAffixmentDataReview == NULL
- || pAffixmentDataReview->IsEmpty()
- )
- continue;
- CRect & rcPreCalcReview = arrRcPreCalc.ElementAt( nReviewIdx-nSubRowStartPos );
- int nExtentBarReview = bHorz
- ? rcPreCalcReview.Width()
- : rcPreCalcReview.Height()
- ;
- int nExtentCompressedAffixmentReview = bHorz
- ? pAffixmentDataReview->m_sizeCompressed.cx
- : pAffixmentDataReview->m_sizeCompressed.cy
- ;
- if( nExtentCompressedAffixmentReview < nExtentBarReview )
- continue;
- int nCsExt = nExtentCompressedAffixmentReview - nExtentBarReview;
- int nCsSrc = nCsExt;
- for( int nCmpxIdx = (int)arrAffixmentOrder.GetSize(); nCmpxIdx > nOrderT ; nCmpxIdx-- )
- {
- int nCmpxIdxEffective = arrAffixmentOrder[ nCmpxIdx - 1 ];
- OuterLayoutItemData & olidCmpx = dbol.ElementAt( nCmpxIdxEffective );
- CExtControlBar * pExtBarCmpx =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olidCmpx.m_pBar
- );
- if( pExtBarCmpx == NULL )
- continue;
- CExtControlBar::InternalAffixmentData * pAffixmentDataCmpx =
- pExtBarCmpx->_AffixmentGetOuter();
- if( pAffixmentDataCmpx == NULL
- || pAffixmentDataCmpx->IsEmpty()
- )
- continue;
- ASSERT( pAffixmentDataReview->m_nAffixmentWeight <= pAffixmentDataCmpx->m_nAffixmentWeight );
- CRect & rcPreCalcCmpx = arrRcPreCalc.ElementAt( nCmpxIdxEffective-nSubRowStartPos );
- int nCsAvail = bHorz
- ? (rcPreCalcCmpx.Width() - olidCmpx.m_sizeBarMin.cx)
- : (rcPreCalcCmpx.Height() - olidCmpx.m_sizeBarMin.cy)
- ;
- //ASSERT( nCsAvail >= 0 );
- if( nCsAvail < 0 )
- continue;
- nCsAvail = min( nCsAvail, nCsExt );
- ASSERT( nCsAvail >= 0 );
- if( nCsAvail == 0 )
- continue;
- (bHorz ? rcPreCalcCmpx.right : rcPreCalcCmpx.bottom ) -=
- nCsAvail;
- nCsExt -= nCsAvail;
- bPerformReShift = true;
- ASSERT( nCsExt >= 0 );
- if( nCsExt == 0 )
- break;
- } // for( int nCmpxIdx = arrAffixmentOrder.GetSize(); nCmpxIdx > nOrderT ; nCmpxIdx-- )
- ASSERT( 0 <= nCsExt && nCsExt <= nCsSrc );
- if( nCsExt == nCsSrc )
- continue;
- ASSERT( bPerformReShift );
- (bHorz ? rcPreCalcReview.right : rcPreCalcReview.bottom ) +=
- (nCsSrc - nCsExt);
- } // for( int nOrderT = arrAffixmentOrder.GetSize()-1; nOrderT > 0; nOrderT-- )
- if( bPerformReShift )
- {
- int nRightPrev = 0;
- for( int nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- {
- // OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- CRect & rcPreCalc = arrRcPreCalc.ElementAt( nBar-nSubRowStartPos );
- int nShift =
- nRightPrev
- - (bHorz ? rcPreCalc.left : rcPreCalc.top )
- ;
- if( nShift != 0 )
- rcPreCalc.OffsetRect(
- bHorz ? nShift : 0,
- bHorz ? 0 : nShift
- );
- nRightPrev = bHorz ? rcPreCalc.right : rcPreCalc.bottom;
- } // for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- } // if( bPerformReShift )
- } // if compression passed with full row layout with more than 1 bar
- } // if( nCsRow == 0 && nLeftPrev >= 0 )
- } // if( (!bRetVal) && nCsRow >= 0 )
- if( !bRetVal )
- {
- bAdjustWithAffixment = false;
- return false;
- } // if( !bRetVal )
- bool bCalcFullyOccupiedLayout =
- (p_bFullyOccupiedLayout != NULL) ? true : false;
- if( bCalcFullyOccupiedLayout
- && (*p_bFullyOccupiedLayout)
- )
- bCalcFullyOccupiedLayout = false;
- if( bCalcFullyOccupiedLayout
- && nSubRowStartPos > 0
- && nSubRowEndPos < (dbol.GetSize() - 1)
- )
- bCalcFullyOccupiedLayout = false;
- if( bCalcFullyOccupiedLayout
- && bCompressionPassed
- )
- {
- bCalcFullyOccupiedLayout = false;
- *p_bFullyOccupiedLayout = true;
- }
- int nPosRightPrev = 0;
- for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- olid.m_rcPreCalc = arrRcPreCalc.ElementAt( nBar-nSubRowStartPos );
- ASSERT( olid.m_rcPreCalc.left >= 0 );
- ASSERT( olid.m_rcPreCalc.right >= 0 );
- ASSERT( olid.m_rcPreCalc.left <= olid.m_rcPreCalc.right );
- ASSERT( olid.m_rcPreCalc.top <= olid.m_rcPreCalc.bottom );
- #ifdef __DEBUG_CExtDockOuterBar_CompressSubRow_ASSERT_CRITICAL_MINSIZE
- ASSERT( olid.m_rcPreCalc.Width() >= olid.m_sizeBarMin.cx );
- ASSERT( olid.m_rcPreCalc.Height() >= olid.m_sizeBarMin.cy );
- #endif // __DEBUG_CExtDockOuterBar_CompressSubRow_ASSERT_CRITICAL_MINSIZE
- if( !bCalcFullyOccupiedLayout )
- continue;
- int nPosLeft = bHorz
- ? olid.m_rcPreCalc.left
- : olid.m_rcPreCalc.top
- ;
- if( nBar == nSubRowStartPos )
- {
- ASSERT( nPosLeft >= 0 );
- if( nPosLeft > 0 )
- {
- bCalcFullyOccupiedLayout = false;
- continue;
- }
- } // if( nBar == nSubRowStartPos )
- ASSERT( nPosLeft >= nPosRightPrev );
- if( nPosLeft > nPosRightPrev )
- {
- bCalcFullyOccupiedLayout = false;
- continue;
- }
- nPosRightPrev = bHorz
- ? olid.m_rcPreCalc.right
- : olid.m_rcPreCalc.bottom
- ;
- if( nBar == nSubRowEndPos )
- {
- if( nPosRightPrev < nExtentMax )
- {
- bCalcFullyOccupiedLayout = false;
- continue;
- }
- } // if( nBar == nSubRowEndPos )
- } // for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- if( bCalcFullyOccupiedLayout )
- {
- ASSERT( p_bFullyOccupiedLayout != NULL );
- *p_bFullyOccupiedLayout = true;
- }
- return true;
- }
- void CExtDockOuterBar::_CalcFixedRowLayout(
- CSize & sizeFixed,
- CSize & sizeMax,
- CPoint & pt,
- BOOL bHorz,
- AFX_SIZEPARENTPARAMS & layout,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- int * p_nSubRowCount, // = NULL
- bool * p_bFullyOccupiedLayout // = NULL
- )
- {
- ASSERT_VALID(this);
- if( p_nSubRowCount != NULL )
- *p_nSubRowCount = 1;
- if( p_bFullyOccupiedLayout != NULL )
- *p_bFullyOccupiedLayout = false;
- int nCountOfBars = (int)dbol.GetSize();
- ASSERT( nCountOfBars > 0 );
- // pre-process hidden bars
- int nBar = 0;
- for( nBar = 0; nBar < nCountOfBars; )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- if( !olid.m_bVisible )
- {
- olid.m_pBar->RecalcDelayShow( &layout );
- dbol.RemoveAt( nBar );
- nCountOfBars--;
- continue;
- }
- olid.m_pBar->GetWindowRect( &olid.m_rcReal );
- ScreenToClient( &olid.m_rcReal );
- nBar++;
- } // for( nBar = 0; nBar < nCountOfBars; )
- // precalc layout (1), move according to affixement
- AffixmentOrderVector_t arrAffixmentOrder;
- _CalcAffixmentOrderVector(
- bHorz ? true : false,
- arrAffixmentOrder,
- dbol,
- true
- );
- ASSERT( arrAffixmentOrder.GetSize() == nCountOfBars );
- // precalc layout (2), split to subrows
- int nTotalRowExtent = 0;
- int nSubRowStartPos = 0;
- bool bAdjustWithAffixment = true;
- bool bAlignSubRowAffixmentHW = true;
- for( nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- olid.m_rcPreCalc = CRect( pt, olid.m_sizeCalcDynamic );
- if( bHorz )
- {
- if( olid.m_rcReal.left > olid.m_rcPreCalc.left
- && (!m_bFloating)
- )
- olid.m_rcPreCalc.OffsetRect(
- olid.m_rcReal.left - olid.m_rcPreCalc.left,
- 0
- );
- int nRest = olid.m_rcPreCalc.right - sizeMax.cx;
- /// int nRest = sizeMax.cx - olid.m_rcPreCalc.left + olid.m_sizeBarMin.cx;
- if( nRest >= 0
- && ( !olid.m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- || ( olid.m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && ((CExtControlBar*)olid.m_pBar)->IsFixedMode()
- )
- )
- )
- { // trying to make one multi-row or compress it
- if( !_CompressSubRow(
- dbol,
- nSubRowStartPos,
- nBar,
- sizeMax.cx,
- bHorz ? true : false,
- bAdjustWithAffixment,
- p_bFullyOccupiedLayout
- )
- )
- {
- if( p_nSubRowCount != NULL )
- (*p_nSubRowCount)++;
- if( p_bFullyOccupiedLayout != NULL )
- *p_bFullyOccupiedLayout = true;
- // ASSERT( bAlignSubRowAffixmentHW );
- bAlignSubRowAffixmentHW = false;
- _AlignSubRowAffixmentHW(
- bHorz ? true : false,
- dbol,
- nSubRowStartPos,
- nBar
- );
- bAdjustWithAffixment = false;
- nSubRowStartPos = nBar;
- _AdjustByTotalRowExtent(
- nTotalRowExtent,
- sizeFixed,
- pt,
- bHorz
- );
- ASSERT( pt.x == 0 );
- olid.m_rcPreCalc = CRect( pt, olid.m_sizeCalcDynamic );
- }
- else
- bAlignSubRowAffixmentHW = true;
- } // trying to make one multi-row or compress it
- pt.x =
- //olid.m_rcPreCalc.left + olid.m_sizeCalcDynamic.cx
- olid.m_rcPreCalc.right
- ;
- nTotalRowExtent = max( nTotalRowExtent, olid.m_sizeCalcDynamic.cy );
- } // if( bHorz )
- else
- {
- // offset calculated rect out to actual
- if( olid.m_rcReal.top > olid.m_rcPreCalc.top
- && (!m_bFloating)
- )
- olid.m_rcPreCalc.OffsetRect(
- 0,
- olid.m_rcReal.top - olid.m_rcPreCalc.top
- );
- int nRest = olid.m_rcPreCalc.bottom - sizeMax.cy;
- /// int nRest = sizeMax.cy - olid.m_rcPreCalc.top + olid.m_sizeBarMin.cy;
- if( nRest >= 0
- && ( !olid.m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- || ( olid.m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && ((CExtControlBar*)olid.m_pBar)->IsFixedMode()
- )
- )
- )
- { // trying to make one multi-row or compress it
- if( !_CompressSubRow(
- dbol,
- nSubRowStartPos,
- nBar,
- sizeMax.cy,
- bHorz ? true : false,
- bAdjustWithAffixment,
- p_bFullyOccupiedLayout
- )
- )
- {
- if( p_nSubRowCount != NULL )
- (*p_nSubRowCount)++;
- if( p_bFullyOccupiedLayout != NULL )
- *p_bFullyOccupiedLayout = true;
- // ASSERT( bAlignSubRowAffixmentHW );
- bAlignSubRowAffixmentHW = false;
- _AlignSubRowAffixmentHW(
- bHorz ? true : false,
- dbol,
- nSubRowStartPos,
- nBar
- );
- bAdjustWithAffixment = false;
- nSubRowStartPos = nBar;
- _AdjustByTotalRowExtent(
- nTotalRowExtent,
- sizeFixed,
- pt,
- bHorz
- );
- ASSERT( pt.y == 0 );
- olid.m_rcPreCalc = CRect( pt, olid.m_sizeCalcDynamic );
- }
- else
- bAlignSubRowAffixmentHW = true;
- } // trying to make one multi-row or compress it
- pt.y =
- //olid.m_rcPreCalc.top + olid.m_sizeCalcDynamic.cy
- olid.m_rcPreCalc.bottom
- ;
- nTotalRowExtent = max( nTotalRowExtent, olid.m_sizeCalcDynamic.cx );
- } // else from if( bHorz )
- } // for( nBar = 0; nBar < nCountOfBars; nBar++ )
- if( bAlignSubRowAffixmentHW && (nCountOfBars > 0) )
- {
- ASSERT( nBar <= nCountOfBars );
- if( nBar == nCountOfBars )
- nBar = nCountOfBars - 1;
- ASSERT( nSubRowStartPos <= nBar );
- _AlignSubRowAffixmentHW(
- bHorz ? true : false,
- dbol,
- nSubRowStartPos,
- nBar
- );
- } // if( bAlignSubRowAffixmentHW && (nCountOfBars > 0) )
- /* DEBUG **
- *********************************************
- *********************************************
- int nPosLastTest = 0;
- for( nBar = 0; bAdjustWithAffixment && nBar < nCountOfBars; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- int nPosCurrTest = bHorz
- ? olid.m_rcPreCalc.left
- : olid.m_rcPreCalc.top
- ;
- ASSERT( nPosLastTest <= nPosCurrTest );
- if( nPosLastTest < nPosCurrTest )
- break;
- nPosLastTest = bHorz
- ? olid.m_rcPreCalc.right
- : olid.m_rcPreCalc.bottom
- ;
- } // for( nBar = 0; bAdjustWithAffixment && nBar < nCountOfBars; nBar++ )
- int bMaxTest = bHorz ? sizeMax.cx : sizeMax.cy;
- if( nBar == nCountOfBars
- && nPosLastTest >= bMaxTest
- )
- bAdjustWithAffixment = false;
- *********************************************
- *********************************************
- ** DEBUG */
- if( bAdjustWithAffixment )
- {
- // pre adjust affixment
- int nOrder = 0;
- for( nOrder = nCountOfBars; nOrder > 0; nOrder-- )
- {
- int nBarAtOrder = arrAffixmentOrder[nOrder-1];
- ASSERT( 0 <= nBarAtOrder && nBarAtOrder < nCountOfBars );
- OuterLayoutItemData & olid = dbol.ElementAt( nBarAtOrder );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid.m_pBar
- );
- if( pExtBar == NULL )
- continue;
- CExtControlBar::InternalAffixmentData * pAffixmentData =
- pExtBar->_AffixmentGetOuter();
- // if( pAffixmentData == NULL )
- // continue;
- // ASSERT( !pAffixmentData->IsEmpty() );
- // ASSERT( !pAffixmentData->m_rcAffixment.IsRectEmpty() );
- // if( olid.m_rcPreCalc == pAffixmentData->m_rcAffixment )
- // continue;
- if( pAffixmentData == NULL
- || pAffixmentData->IsEmpty()
- || pAffixmentData->m_rcAffixment.IsRectEmpty()
- || olid.m_rcPreCalc == pAffixmentData->m_rcAffixment
- )
- continue;
- _PreAdjustWithAffixment(
- bHorz ? true : false,
- dbol,
- olid,
- nBarAtOrder,
- pAffixmentData,
- bHorz ? sizeMax.cx : sizeMax.cy
- );
- } // for( nOrder = nCountOfBars; nOrder > 0; nOrder-- )
- // post adjust affixment
- for( nOrder = nCountOfBars; nOrder > 0; nOrder-- )
- {
- int nBarAtOrder = arrAffixmentOrder[nOrder-1];
- ASSERT( 0 <= nBarAtOrder && nBarAtOrder < nCountOfBars );
- OuterLayoutItemData & olid = dbol.ElementAt( nBarAtOrder );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid.m_pBar
- );
- if( pExtBar == NULL )
- continue;
- CExtControlBar::InternalAffixmentData * pAffixmentData =
- pExtBar->_AffixmentGetOuter();
- // if( pAffixmentData == NULL )
- // continue;
- // ASSERT( !pAffixmentData->IsEmpty() );
- // ASSERT( !pAffixmentData->m_rcAffixment.IsRectEmpty() );
- // if( olid.m_rcPreCalc == pAffixmentData->m_rcAffixment )
- // continue;
- if( pAffixmentData == NULL
- || pAffixmentData->IsEmpty()
- || pAffixmentData->m_rcAffixment.IsRectEmpty()
- || olid.m_rcPreCalc == pAffixmentData->m_rcAffixment
- )
- continue;
- _PostAdjustWithAffixment(
- bHorz ? true : false,
- dbol,
- olid,
- nBarAtOrder,
- pAffixmentData,
- bHorz ? sizeMax.cx : sizeMax.cy
- );
- } // for( int nOrder = nCountOfBars; nOrder > 0; nOrder-- )
- } // if( bAdjustWithAffixment )
- // verify for minimal layouts
- for( nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- if( bHorz )
- {
- int nRest = sizeMax.cx - olid.m_rcPreCalc.right;
- if( nRest >= 0 )
- continue;
- olid.m_rcPreCalc.right = sizeMax.cx;
- if( olid.m_rcPreCalc.Width() < olid.m_sizeBarMin.cx )
- olid.m_rcPreCalc.right = olid.m_rcPreCalc.left + olid.m_sizeBarMin.cx;
- } // if( bHorz )
- else
- {
- int nRest = sizeMax.cy - olid.m_rcPreCalc.bottom;
- if( nRest >= 0 )
- continue;
- olid.m_rcPreCalc.bottom = sizeMax.cy;
- if( olid.m_rcPreCalc.Height() < olid.m_sizeBarMin.cy )
- olid.m_rcPreCalc.bottom = olid.m_rcPreCalc.top + olid.m_sizeBarMin.cy;
- } // else from if( bHorz )
- }
- // apply layout
- if( !m_bLayoutQuery )
- {
- for( nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- if( olid.m_rcPreCalc == olid.m_rcReal )
- continue;
- if( (olid.m_pBar->m_dwStyle & CBRS_FLOATING) == 0 )
- olid.m_pBar->m_pDockContext->
- m_rectMRUDockPos = olid.m_rcPreCalc;
- AfxRepositionWindow(
- &layout,
- olid.m_pBar->m_hWnd,
- &olid.m_rcPreCalc
- );
- } // for( nBar = 0; nBar < nCountOfBars; nBar++ )
- } // if( !m_bLayoutQuery )
- _AdjustByTotalRowExtent(
- nTotalRowExtent,
- sizeFixed,
- pt,
- bHorz
- );
- }
- void CExtDockOuterBar::_PreAdjustWithAffixment(
- bool bHorz,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- CExtDockOuterBar::OuterLayoutItemData & olidAdjustedSrc,
- int nBarAdjustedSrc,
- CExtControlBar::InternalAffixmentData * pAffixmentDataAdjustedSrc,
- int nExtentMax
- )
- {
- if( nExtentMax <= 0 )
- return;
- int nCountOfBars = (int)dbol.GetSize();
- ASSERT( 0 <= nBarAdjustedSrc && nBarAdjustedSrc < nCountOfBars );
- ASSERT( dbol.ElementAt(nBarAdjustedSrc).m_pBar == olidAdjustedSrc.m_pBar );
- ASSERT( pAffixmentDataAdjustedSrc != NULL );
- ASSERT( !pAffixmentDataAdjustedSrc->IsEmpty() );
- int nPosAffixment = bHorz
- ? pAffixmentDataAdjustedSrc->m_rcAffixment.left
- : pAffixmentDataAdjustedSrc->m_rcAffixment.top
- ;
- int nPosPreCalc = bHorz
- ? olidAdjustedSrc.m_rcPreCalc.left
- : olidAdjustedSrc.m_rcPreCalc.top
- ;
- int nAdjustShift = nPosAffixment - nPosPreCalc;
- if( nAdjustShift == 0 )
- return;
- // TRACE3(
- // " Bar 0x%08X weight = %d nAdjustShift = %dn",
- // long(olidAdjustedSrc.m_pBar),
- // pAffixmentDataAdjustedSrc->m_nAffixmentWeight,
- // nAdjustShift
- // );
- _ShiftSubRowWithAffixment(
- bHorz,
- dbol,
- ( nAdjustShift > 0 )
- ? nBarAdjustedSrc
- : 0
- ,
- ( nAdjustShift > 0 )
- ? (nCountOfBars - 1)
- : nBarAdjustedSrc
- ,
- nAdjustShift,
- nExtentMax
- );
- }
- void CExtDockOuterBar::_PostAdjustWithAffixment(
- bool bHorz,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- CExtDockOuterBar::OuterLayoutItemData & olidAdjustedSrc,
- int nBarAdjustedSrc,
- CExtControlBar::InternalAffixmentData * pAffixmentDataAdjustedSrc,
- int nExtentMax
- )
- {
- if( nExtentMax <= 0 )
- return;
- int nCountOfBars = (int)dbol.GetSize();
- ASSERT( 0 <= nBarAdjustedSrc && nBarAdjustedSrc < nCountOfBars );
- ASSERT( dbol.ElementAt(nBarAdjustedSrc).m_pBar == olidAdjustedSrc.m_pBar );
- ASSERT( pAffixmentDataAdjustedSrc != NULL );
- ASSERT( !pAffixmentDataAdjustedSrc->IsEmpty() );
- int nPosAffixment = bHorz
- ? pAffixmentDataAdjustedSrc->m_rcAffixment.left
- : pAffixmentDataAdjustedSrc->m_rcAffixment.top
- ;
- int nPosPreCalc = bHorz
- ? olidAdjustedSrc.m_rcPreCalc.left
- : olidAdjustedSrc.m_rcPreCalc.top
- ;
- int nPosPossibleToFix = nPosPreCalc;
- int nAdjustShift = nPosAffixment - nPosPreCalc;
- if( nAdjustShift == 0 )
- return;
- if( nAdjustShift < 0 )
- {
- if( nBarAdjustedSrc == 0 )
- {
- nPosPossibleToFix =
- max( nPosPossibleToFix, 0 );
- } // if( nBarAdjustedSrc == 0 )
- else
- {
- OuterLayoutItemData & olid2 = dbol.ElementAt( nBarAdjustedSrc-1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- nPosPossibleToFix = bHorz
- ? olid2.m_rcPreCalc.right
- : olid2.m_rcPreCalc.bottom
- ;
- } // else from if( nBarAdjustedSrc == 0 )
- int nPossibleShift = nPosPossibleToFix - nPosPreCalc;
- nAdjustShift = max( nAdjustShift, nPossibleShift );
- } // if( nAdjustShift < 0 )
- else
- {
- nPosPreCalc += bHorz
- ? olidAdjustedSrc.m_rcPreCalc.Width()
- : olidAdjustedSrc.m_rcPreCalc.Height()
- ;
- nPosPossibleToFix = nPosPreCalc;
- if( nBarAdjustedSrc == (nCountOfBars-1) )
- {
- nPosPossibleToFix =
- min( nPosPossibleToFix, nExtentMax );
- } // if( nBarAdjustedSrc == (nCountOfBars-1) )
- else
- {
- OuterLayoutItemData & olid2 = dbol.ElementAt( nBarAdjustedSrc+1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- nPosPossibleToFix = bHorz
- ? olid2.m_rcPreCalc.left
- : olid2.m_rcPreCalc.top
- ;
- } // else from if( nBarAdjustedSrc == (nCountOfBars-1) )
- int nPossibleShift = nPosPossibleToFix - nPosPreCalc;
- nAdjustShift = min( nAdjustShift, nPossibleShift );
- } // else from if( nAdjustShift < 0 )
- if( nAdjustShift == 0 )
- return;
- olidAdjustedSrc.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- }
- int CExtDockOuterBar::_ShiftSubRowWithAffixment(
- bool bHorz,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- int nReviewStart,
- int nReviewEnd,
- int nAdjustShift,
- int nExtentMax
- )
- {
- ASSERT( dbol.GetSize() > 0 );
- ASSERT( 0 <= nReviewStart && nReviewStart < dbol.GetSize() );
- ASSERT( 0 <= nReviewEnd && nReviewEnd < dbol.GetSize() );
- ASSERT( nReviewStart <= nReviewEnd );
- ASSERT( nAdjustShift != 0 );
- ASSERT( nExtentMax > 0 );
- if( nReviewStart == nReviewEnd )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nReviewStart );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- int nPosPreCalc = bHorz
- ? olid.m_rcPreCalc.left
- : olid.m_rcPreCalc.top
- ;
- ASSERT( nPosPreCalc >= 0 );
- if( nAdjustShift > 0 )
- {
- ASSERT( nReviewStart == dbol.GetSize()-1 );
- nPosPreCalc += bHorz
- ? olid.m_rcPreCalc.Width()
- : olid.m_rcPreCalc.Height()
- ;
- ASSERT( nPosPreCalc >= 0 );
- ASSERT( nPosPreCalc <= nExtentMax );
- if( nPosPreCalc == nExtentMax )
- return 0;
- int nRest = nExtentMax - nPosPreCalc;
- ASSERT( nRest >= 0 );
- nAdjustShift = min( nAdjustShift, nRest );
- ASSERT( nAdjustShift >= 0 );
- } // if( nAdjustShift > 0 )
- else
- {
- ASSERT( nReviewStart == 0 );
- // if( nPosPreCalc == 0 )
- // return 0;
- //if( nPosPreCalc < 0 )
- // return 0;
- nAdjustShift = max( (-nPosPreCalc), nAdjustShift );
- ASSERT( nAdjustShift <= 0 );
- } // else from if( nAdjustShift > 0 )
- olid.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- ASSERT( olid.m_rcPreCalc.left >= 0 );
- ASSERT( olid.m_rcPreCalc.top >= 0 );
- return nAdjustShift;
- } // if( nReviewStart == nReviewEnd )
- if( nAdjustShift > 0 )
- {
- OuterLayoutItemData & olid1 = dbol.ElementAt( nReviewStart );
- ASSERT_VALID( olid1.m_pBar );
- ASSERT_KINDOF( CControlBar, olid1.m_pBar );
- ASSERT( olid1.m_bVisible );
- ASSERT( olid1.m_rcPreCalc.left >= 0 );
- ASSERT( olid1.m_rcPreCalc.top >= 0 );
- int nPosPreCalc1 = bHorz
- ? olid1.m_rcPreCalc.right // (olid1.m_rcPreCalc.left + olid1.m_rcPreCalc.Width())
- : olid1.m_rcPreCalc.bottom // (olid1.m_rcPreCalc.top + olid1.m_rcPreCalc.Height())
- ;
- ASSERT( nPosPreCalc1 >= 0 );
- OuterLayoutItemData & olid2 = dbol.ElementAt( nReviewStart + 1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- ASSERT( olid2.m_rcPreCalc.left >= 0 );
- ASSERT( olid2.m_rcPreCalc.top >= 0 );
- int nPosPreCalc2 = bHorz
- ? olid2.m_rcPreCalc.left
- : olid2.m_rcPreCalc.top
- ;
- ASSERT( nPosPreCalc2 >= 0 );
- int nDist = nPosPreCalc2 - nPosPreCalc1;
- ASSERT( nDist >= 0 );
- nDist = min( nAdjustShift, nDist );
- ASSERT( nDist <= nAdjustShift );
- if( nDist == nAdjustShift )
- {
- olid1.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- ASSERT( olid1.m_rcPreCalc.left >= 0 );
- ASSERT( olid1.m_rcPreCalc.top >= 0 );
- return nAdjustShift;
- }
- int nSpaceToCompress = nAdjustShift - nDist;
- ASSERT( nSpaceToCompress > 0 );
- int nSpaceReallyCompressed =
- _ShiftSubRowWithAffixment(
- bHorz,
- dbol,
- nReviewStart + 1,
- nReviewEnd,
- nSpaceToCompress,
- nExtentMax
- );
- ASSERT( nSpaceReallyCompressed >= 0 );
- ASSERT( nSpaceReallyCompressed <= nSpaceToCompress );
- /*?????*/ nAdjustShift = nSpaceReallyCompressed + nDist;
- olid1.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- ASSERT( olid1.m_rcPreCalc.left >= 0 );
- ASSERT( olid1.m_rcPreCalc.top >= 0 );
- } // if( nAdjustShift > 0 )
- else
- {
- OuterLayoutItemData & olid1 = dbol.ElementAt( nReviewEnd );
- ASSERT_VALID( olid1.m_pBar );
- ASSERT_KINDOF( CControlBar, olid1.m_pBar );
- ASSERT( olid1.m_bVisible );
- ASSERT( olid1.m_rcPreCalc.left >= 0 );
- ASSERT( olid1.m_rcPreCalc.top >= 0 );
- int nPosPreCalc1 = bHorz
- ? olid1.m_rcPreCalc.left
- : olid1.m_rcPreCalc.top
- ;
- ASSERT( nPosPreCalc1 >= 0 );
- OuterLayoutItemData & olid2 = dbol.ElementAt( nReviewEnd - 1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- ASSERT( olid2.m_rcPreCalc.left >= 0 );
- ASSERT( olid2.m_rcPreCalc.top >= 0 );
- int nPosPreCalc2 = bHorz
- ? olid2.m_rcPreCalc.right // (olid2.m_rcPreCalc.left + olid2.m_rcPreCalc.Width())
- : olid2.m_rcPreCalc.bottom // (olid2.m_rcPreCalc.top + olid2.m_rcPreCalc.Height())
- ;
- ASSERT( nPosPreCalc2 >= 0 );
- int nDist = nPosPreCalc2 - nPosPreCalc1;
- ASSERT( nDist <= 0 );
- nDist = max( nAdjustShift, nDist );
- ASSERT( nDist >= nAdjustShift );
- if( nDist == nAdjustShift )
- {
- olid1.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- ASSERT( olid1.m_rcPreCalc.left >= 0 );
- ASSERT( olid1.m_rcPreCalc.top >= 0 );
- return nAdjustShift;
- }
- int nSpaceToCompress = nAdjustShift - nDist;
- ASSERT( nSpaceToCompress < 0 );
- int nSpaceReallyCompressed =
- _ShiftSubRowWithAffixment(
- bHorz,
- dbol,
- nReviewStart,
- nReviewEnd - 1,
- nSpaceToCompress,
- nExtentMax
- );
- ASSERT( nSpaceReallyCompressed <= 0 );
- ASSERT( nSpaceReallyCompressed >= nSpaceToCompress );
- /*?????*/ nAdjustShift = nSpaceReallyCompressed + nDist;
- olid1.m_rcPreCalc.OffsetRect(
- bHorz ? nAdjustShift : 0,
- bHorz ? 0 : nAdjustShift
- );
- ASSERT( olid2.m_rcPreCalc.left >= 0 );
- ASSERT( olid2.m_rcPreCalc.top >= 0 );
- } // else from if( nAdjustShift > 0 )
- return nAdjustShift;
- }
- void CExtDockOuterBar::_AdjustByTotalRowExtent(
- int & nTotalRowExtent,
- CSize & sizeFixed,
- CPoint & pt,
- BOOL bHorz
- )
- {
- if( nTotalRowExtent == 0 )
- return;
- if( bHorz )
- {
- pt.y += nTotalRowExtent;
- sizeFixed.cx = max(sizeFixed.cx, pt.x);
- sizeFixed.cy = max(sizeFixed.cy, pt.y);
- pt.x = 0;
- sizeFixed.cy--;
- } // if( bHorz )
- else
- {
- pt.x += nTotalRowExtent;
- sizeFixed.cx = max(sizeFixed.cx, pt.x);
- sizeFixed.cy = max(sizeFixed.cy, pt.y);
- pt.y = 0;
- sizeFixed.cx--;
- } // else from if( bHorz )
- nTotalRowExtent = 0;
- }
- CSize CExtDockOuterBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
- {
- ASSERT_VALID(this);
- CSize sizeFixed =
- CControlBar::CalcFixedLayout( bStretch, bHorz );
- CSize sizeMax;
- if( !m_rectLayout.IsRectEmpty() )
- sizeMax = m_rectLayout.Size();
- else
- {
- CFrameWnd * pFrame = GetParentFrame();
- CRect rcFrameWindow;
- pFrame->GetClientRect( &rcFrameWindow );
- sizeMax = rcFrameWindow.Size();
- }
- CPoint pt( 0, 0 );
- int nCountOfBars = (int)m_arrBars.GetSize();
- AFX_SIZEPARENTPARAMS layout;
- layout.hDWP =
- m_bLayoutQuery
- ? NULL
- : ( ::BeginDeferWindowPos(nCountOfBars) )
- ;
- dockbar_outer_layout_t dbol;
- for( int nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)m_arrBars[nBar];
- if( pBar != NULL
- && (!(__PLACEHODLER_BAR_PTR(pBar)))
- )
- {
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- dbol.Add(
- OuterLayoutItemData(
- pBar,
- bHorz,
- sizeMax
- )
- );
- } // if( pBar != NULL && ...
- if( pBar == NULL || nBar == (nCountOfBars-1) )
- {
- if( dbol.GetSize() == 0 )
- continue;
- _CalcFixedRowLayout(
- sizeFixed,
- sizeMax,
- pt,
- bHorz,
- layout,
- dbol
- );
- dbol.RemoveAll();
- } // if( pBar == NULL || nBar == (nCountOfBars-1) )
- } // for( int nBar = 0; nBar < nCountOfBars; nBar++ )
- ASSERT( dbol.GetSize() == 0 );
- if( !m_bLayoutQuery )
- {
- ASSERT( layout.hDWP != NULL );
- if( layout.hDWP != NULL )
- {
- VERIFY( ::EndDeferWindowPos(layout.hDWP) );
- }
- } // if( !m_bLayoutQuery )
- // adjust size for borders on the dock bar itself
- CRect rc( 0, 0, 0, 0 );
- CalcInsideRect(rc, bHorz);
- if( (!bStretch || !bHorz) && sizeFixed.cx != 0 )
- sizeFixed.cx +=
- -rc.right + rc.left
- + g_bControlBarFixSizePixel ? 1 : 0;
- if( (!bStretch || bHorz) && sizeFixed.cy != 0 )
- sizeFixed.cy +=
- -rc.bottom + rc.top
- + g_bControlBarFixSizePixel ? 1 : 0;
- if( ! m_bLayoutQuery )
- OnDynamicLayoutUpdate();
- return sizeFixed;
- }
- void CExtDockOuterBar::_RedockInRow(
- CExtControlBar * pBarSlide,
- int nShiftDesired,
- bool * p_bInplaceResizing // = NULL
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarSlide );
- ASSERT( this == pBarSlide->GetParent() );
- if( p_bInplaceResizing != NULL )
- *p_bInplaceResizing = false;
- if( nShiftDesired == 0 )
- return;
- int nCountOfBars = (int)m_arrBars.GetSize();
- ASSERT( nCountOfBars > 1 );
- int nSlideBarPos = FindBar( pBarSlide );
- ASSERT( 0 < nSlideBarPos && nSlideBarPos < nCountOfBars );
- CControlBar * pFirstBar =
- pBarSlide->_GetFirstControlBarInRow(
- pBarSlide,
- false,
- false,
- false
- );
- ASSERT_VALID( pFirstBar );
- int nFirstBarPos = FindBar( pFirstBar );
- ASSERT( 0 < nFirstBarPos && nFirstBarPos < nCountOfBars );
- ASSERT( nFirstBarPos <= nSlideBarPos );
- UINT nDockBarID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- BOOL bHorz =
- ( nDockBarID == AFX_IDW_DOCKBAR_TOP
- || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM )
- ? TRUE : FALSE;
- CRect rcSlideBarWnd;
- pBarSlide->GetWindowRect( &rcSlideBarWnd );
- ScreenToClient( &rcSlideBarWnd );
- CSize sizeMax, sizeFakeFixed( 0, 0 );
- if( !m_rectLayout.IsRectEmpty() )
- sizeMax = m_rectLayout.Size();
- else
- {
- CFrameWnd * pFrame = GetParentFrame();
- CRect rcFrameWindow;
- pFrame->GetClientRect( &rcFrameWindow );
- sizeMax = rcFrameWindow.Size();
- }
- CPoint pt( 0, 0 );
- if( bHorz )
- pt.y = rcSlideBarWnd.top;
- else
- pt.x = rcSlideBarWnd.left;
- CExtControlBar::InternalAffixmentData * pAffixmentData =
- pBarSlide->_AffixmentGetOuter();
- if( pAffixmentData != NULL )
- {
- ASSERT( !pAffixmentData->IsEmpty() );
- if( pAffixmentData->m_rcAffixment.IsRectEmpty() )
- {
- pBarSlide->GetWindowRect( &pAffixmentData->m_rcAffixment );
- ScreenToClient( &pAffixmentData->m_rcAffixment );
- }
- pAffixmentData->m_rcAffixment.OffsetRect(
- bHorz ? nShiftDesired : 0,
- bHorz ? 0 : nShiftDesired
- );
- if( bHorz )
- {
- if( pAffixmentData->m_rcAffixment.right >= sizeMax.cx )
- pAffixmentData->m_rcAffixment.OffsetRect(
- sizeMax.cx - pAffixmentData->m_rcAffixment.right,
- 0
- );
- if( pAffixmentData->m_rcAffixment.left < 0 )
- pAffixmentData->m_rcAffixment.OffsetRect(
- - pAffixmentData->m_rcAffixment.left,
- 0
- );
- } // if( bHorz )
- else
- {
- if( pAffixmentData->m_rcAffixment.bottom >= sizeMax.cy )
- pAffixmentData->m_rcAffixment.OffsetRect(
- 0,
- sizeMax.cy - pAffixmentData->m_rcAffixment.bottom
- );
- if( pAffixmentData->m_rcAffixment.top < 0 )
- pAffixmentData->m_rcAffixment.OffsetRect(
- 0,
- - pAffixmentData->m_rcAffixment.top
- );
- } // else from if( bHorz )
- }
- dockbar_outer_layout_t dbol;
- int nBar = 0;
- for( nBar = nFirstBarPos; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = (CControlBar *)m_arrBars[nBar];
- if( pBar != NULL
- && (!(__PLACEHODLER_BAR_PTR(pBar)))
- )
- {
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- OuterLayoutItemData olid(
- pBar,
- bHorz,
- sizeMax
- );
- if( pBar == pBarSlide )
- {
- if( pAffixmentData == NULL )
- olid.m_rcPreCalc.OffsetRect(
- bHorz ? nShiftDesired : 0,
- bHorz ? 0 : nShiftDesired
- );
- } // if( pBar == pBarSlide )
- dbol.Add( olid );
- } // if( pBar != NULL && ...
- if( pBar == NULL || nBar == (nCountOfBars-1) )
- break;
- } // for( nBar = nFirstBarPos; nBar < nCountOfBars; nBar++ )
- ASSERT( dbol.GetSize() != 0 );
- int nSubRowCount = 0;
- bool bFullyOccupiedLayout = false;
- BOOL bLayoutQueryOld = m_bLayoutQuery;
- CSize sizeFakeFixedOld( sizeFakeFixed ), sizeMaxOld( sizeMax );
- CPoint ptOld( pt );
- AFX_SIZEPARENTPARAMS layout;
- layout.hDWP = NULL;
- _CalcFixedRowLayout(
- sizeFakeFixed,
- sizeMax,
- pt,
- bHorz,
- layout,
- dbol,
- &nSubRowCount,
- &bFullyOccupiedLayout
- );
- m_bLayoutQuery = bLayoutQueryOld;
- ASSERT( nSubRowCount >= 1 );
- if( m_bLayoutQuery )
- return;
- ASSERT( (nCountOfBars - nFirstBarPos) > 0 );
- sizeFakeFixed = sizeFakeFixedOld;
- sizeMax = sizeMaxOld;
- pt = ptOld;
- nCountOfBars = (int)dbol.GetSize();
- ASSERT( nCountOfBars > 0 );
- layout.hDWP =
- ::BeginDeferWindowPos(nCountOfBars);
- // reasonable row shift offset
- const int nRsOffset = 1; //2;
- if( nCountOfBars > 1 && pAffixmentData != NULL )
- {
- int nSlideBarIdxInArray = -1;
- for( int nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- if( olid.m_pBar == pBarSlide )
- {
- ASSERT( nSlideBarIdxInArray < 0 );
- nSlideBarIdxInArray = nBar;
- break;
- }
- } // for( nBar = 0; nBar < nCountOfBars; nBar++ )
- ASSERT( 0 <= nSlideBarIdxInArray && nSlideBarIdxInArray < nCountOfBars );
- OuterLayoutItemData & olid =
- dbol.ElementAt( nSlideBarIdxInArray );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- bool bTrySwapping = bFullyOccupiedLayout; // true; (+ v.2.22)
- bool bUpAffxOnSwapping = true;
- if( bFullyOccupiedLayout
- && (nSubRowCount == 1)
- )
- { // if can analyze resizing in row
- ASSERT( pAffixmentData != NULL );
- if( nSlideBarIdxInArray > 0 )
- { // do resizing pre-affixment, do not resize first in row
- CSize sizeBarCalc = olid.m_rcPreCalc.Size();
- if( nShiftDesired > 0 )
- {
- //ASSERT( (!bHorz) || sizeBarCalc.cx >= olid.m_sizeBarMin.cx );
- //ASSERT( ( bHorz) || sizeBarCalc.cy >= olid.m_sizeBarMin.cy );
- int nExtentPossibleByBar = bHorz
- ? (sizeBarCalc.cx - olid.m_sizeBarMin.cx)
- : (sizeBarCalc.cy - olid.m_sizeBarMin.cy)
- ;
- nExtentPossibleByBar =
- min( nExtentPossibleByBar, nShiftDesired );
- if( nExtentPossibleByBar > 0 )
- {
- bTrySwapping = false;
- if( pAffixmentData->m_nAffixmentWeight != 1 )
- _AffixmentBringToTop( pBarSlide );
- if( bHorz )
- {
- int nNewAffixment = sizeBarCalc.cx - nExtentPossibleByBar;
- if( nNewAffixment > olid.m_sizeCalcDynamic.cx )
- nNewAffixment = olid.m_sizeCalcDynamic.cx;
- if( pAffixmentData->m_sizeCompressed.cx != nNewAffixment )
- pAffixmentData->m_sizeCompressed.cx = nNewAffixment;
- else
- bTrySwapping = true;
- } // if( bHorz )
- else
- {
- int nNewAffixment = sizeBarCalc.cy - nExtentPossibleByBar;
- if( nNewAffixment > olid.m_sizeCalcDynamic.cy )
- nNewAffixment = olid.m_sizeCalcDynamic.cy;
- if( pAffixmentData->m_sizeCompressed.cy != nNewAffixment )
- pAffixmentData->m_sizeCompressed.cy = nNewAffixment;
- else
- bTrySwapping = true;
- } // else from if( bHorz )
- } // if( nExtentPossibleByBar > 0 )
- } // if( nShiftDesired > 0 )
- else
- {
- //ASSERT( (!bHorz) || sizeBarCalc.cx >= olid.m_sizeBarMin.cx );
- //ASSERT( ( bHorz) || sizeBarCalc.cy >= olid.m_sizeBarMin.cy );
- int nExtentPossibleByBar = bHorz
- ? (olid.m_sizeCalcDynamic.cx - sizeBarCalc.cx)
- : (olid.m_sizeCalcDynamic.cy - sizeBarCalc.cy)
- ;
- nExtentPossibleByBar =
- min( nExtentPossibleByBar, (-nShiftDesired) );
- ASSERT( nExtentPossibleByBar >= 0 );
- if( nExtentPossibleByBar > 0 )
- {
- bTrySwapping = false;
- if( pAffixmentData->m_nAffixmentWeight != 1 )
- _AffixmentBringToTop( pBarSlide );
- if( bHorz )
- {
- int nNewAffixment = sizeBarCalc.cx + nExtentPossibleByBar;
- if( nNewAffixment > olid.m_sizeCalcDynamic.cx )
- nNewAffixment = olid.m_sizeCalcDynamic.cx;
- if( pAffixmentData->m_sizeCompressed.cx != nNewAffixment )
- pAffixmentData->m_sizeCompressed.cx = nNewAffixment;
- else
- bTrySwapping = true;
- }
- else
- {
- int nNewAffixment = sizeBarCalc.cy + nExtentPossibleByBar;
- if( nNewAffixment > olid.m_sizeCalcDynamic.cy )
- nNewAffixment = olid.m_sizeCalcDynamic.cy;
- if( pAffixmentData->m_sizeCompressed.cy != nNewAffixment )
- pAffixmentData->m_sizeCompressed.cy = nNewAffixment;
- else
- bTrySwapping = true;
- }
- } // if( nExtentPossibleByBar > 0 )
- } // else from if( nShiftDesired > 0 )
- } // do resizing pre-affixment, do not resize first in row
- else
- bUpAffxOnSwapping = false;
- } // if can analyze resizing in row
- else if( (!bTrySwapping) && (nSubRowCount == 1) )
- { // analyze left/right free space between bars is available (+ v.2.22)
- ASSERT( !bFullyOccupiedLayout );
- ASSERT( 0 <= nSlideBarIdxInArray && nSlideBarIdxInArray < nCountOfBars );
- int nStartBar = nSlideBarIdxInArray + 1;
- int nEndBar = nCountOfBars - 1;
- if( nShiftDesired < 0 )
- {
- nStartBar = 0;
- nEndBar = nSlideBarIdxInArray;
- }
- for( int nBarXSP = nStartBar; nBarXSP <= nEndBar; nBarXSP++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBarXSP );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- int nFreeBefore = 0;
- CRect rcBarLocal( olid.m_rcReal );
- if( nBarXSP == 0 )
- nFreeBefore = bHorz ? rcBarLocal.left : rcBarLocal.top;
- else
- {
- OuterLayoutItemData & olidPrev = dbol.ElementAt( nBarXSP-1 );
- ASSERT_VALID( olidPrev.m_pBar );
- ASSERT_KINDOF( CControlBar, olidPrev.m_pBar );
- ASSERT( olidPrev.m_bVisible );
- CRect rcBarLocalPrev( olidPrev.m_rcReal );
- nFreeBefore = bHorz
- ? (rcBarLocal.left - rcBarLocalPrev.right)
- : (rcBarLocal.top - rcBarLocalPrev.bottom)
- ;
- } // else from if( nBarXSP == 0 )
- if( nFreeBefore < 0 )
- nFreeBefore = 0;
- if( nShiftDesired < 0 && nFreeBefore == 0 )
- {
- if( nBarXSP == nEndBar )
- {
- bTrySwapping = true;
- break;
- }
- continue;
- } // if( nShiftDesired < 0 )
- if( nShiftDesired > 0 && nFreeBefore > 0 )
- break; // no swapping to right/bottom (have some space to slide)
- if( nBarXSP == nEndBar && nShiftDesired > 0 )
- {
- CRect rcThisDocker;
- GetClientRect( &rcThisDocker );
- ASSERT( rcThisDocker.left == 0 && rcThisDocker.top == 0 );
- if( rcThisDocker.right <= 0 || rcThisDocker.bottom <= 0 )
- break; // empty space for anything
- int nFreeAfter = bHorz
- ? (rcThisDocker.right - rcBarLocal.right)
- : (rcThisDocker.bottom - rcBarLocal.bottom)
- ;
- if( nFreeAfter <= 0 )
- {
- bTrySwapping = true;
- break;
- }
- } // if( nBarXSP == nEndBar && nShiftDesired > 0 )
- } // for( int nBarXSP = nStartBar; nBarXSP <= nEndBar; nBarXSP++ )
- } // analyze left/right free space between bars is available (+ v.2.22)
- if( bTrySwapping )
- {
- if( bUpAffxOnSwapping )
- _AffixmentBringToTop( pBarSlide );
- pAffixmentData->m_rcAffixment = olid.m_rcPreCalc;
-
- if( nShiftDesired > 0 )
- {
- if( nSlideBarIdxInArray != (nCountOfBars-1) )
- {
- OuterLayoutItemData & olid2 =
- dbol.ElementAt( nSlideBarIdxInArray + 1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- CExtControlBar * pExtBar2 =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid2.m_pBar
- );
- if( pExtBar2 != NULL )
- {
- CExtControlBar::InternalAffixmentData * pAffixmentData2 =
- pExtBar2->_AffixmentGetOuter();
- if( pAffixmentData2 != NULL )
- {
- int nPosAffx2 = bHorz
- ? pAffixmentData2->m_rcAffixment.left
- : pAffixmentData2->m_rcAffixment.top
- ;
- int nPosReal2 = bHorz
- ? olid2.m_rcPreCalc.left
- : olid2.m_rcPreCalc.top
- ;
- int n1stExtent = bHorz
- ? olid.m_rcPreCalc.Width()
- : olid.m_rcPreCalc.Height()
- ;
- // nPosReal2 += nRsOffset;
- // nPosReal2 += nShiftDesired;
- if( (nPosReal2 - n1stExtent) > nPosAffx2 )
- _SwapInRowWithAffixment(
- dbol,
- nSlideBarIdxInArray,
- nSlideBarIdxInArray + 1
- );
- else
- {
- int nPosReal = bHorz
- ? olid.m_rcPreCalc.left
- : olid.m_rcPreCalc.top
- ;
- int n2ndExtent = bHorz
- ? olid2.m_rcPreCalc.Width()
- : olid2.m_rcPreCalc.Height()
- ;
- if( ( (nPosReal2+n2ndExtent)
- - (nPosReal+n1stExtent)
- - nShiftDesired
- - nRsOffset
- )
- <= 0
- )
- _SwapInRowWithAffixment(
- dbol,
- nSlideBarIdxInArray,
- nSlideBarIdxInArray + 1
- );
- }
- } // if( pAffixmentData2 != NULL )
- } // if( pExtBar2 != NULL )
- } // if( nSlideBarIdxInArray != (nCountOfBars-1) )
- } // if( nShiftDesired > 0 )
- else
- {
- if( nSlideBarIdxInArray != 0 )
- {
- OuterLayoutItemData & olid2 =
- dbol.ElementAt( nSlideBarIdxInArray - 1 );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- CExtControlBar * pExtBar2 =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid2.m_pBar
- );
- if( pExtBar2 != NULL )
- {
- CExtControlBar::InternalAffixmentData * pAffixmentData2 =
- pExtBar2->_AffixmentGetOuter();
- if( pAffixmentData2 != NULL )
- {
- int nPosReal = bHorz
- ? olid.m_rcPreCalc.left
- : olid.m_rcPreCalc.top
- ;
- int nPosAffx2 = bHorz
- ? pAffixmentData2->m_rcAffixment.left
- : pAffixmentData2->m_rcAffixment.top
- ;
- // nPosReal -= nRsOffset;
- // nPosReal += nShiftDesired;
- if( nPosReal <= nPosAffx2 )
- _SwapInRowWithAffixment(
- dbol,
- nSlideBarIdxInArray - 1,
- nSlideBarIdxInArray
- );
- else
- {
- int nPosReal2 = bHorz
- ? olid2.m_rcPreCalc.left
- : olid2.m_rcPreCalc.top
- ;
- // int n1stExtent = bHorz
- // ? olid.m_rcPreCalc.Width()
- // : olid.m_rcPreCalc.Height()
- // ;
- // int n2ndExtent = bHorz
- // ? olid2.m_rcPreCalc.Width()
- // : olid2.m_rcPreCalc.Height()
- // ;
- if( ( (nPosReal /*+n1stExtent*/ )
- - (nPosReal2 /*+n2ndExtent*/ )
- + nShiftDesired
- - nRsOffset
- )
- <= 0
- )
- _SwapInRowWithAffixment(
- dbol,
- nSlideBarIdxInArray - 1,
- nSlideBarIdxInArray
- );
- }
- } // if( pAffixmentData2 != NULL )
- } // if( pExtBar2 != NULL )
- } // if( nSlideBarIdxInArray != 0 )
- } // else from if( nShiftDesired > 0 )
- } // if( bTrySwapping )
- else
- {
- if( p_bInplaceResizing != NULL )
- *p_bInplaceResizing = bFullyOccupiedLayout; //true; (+ v.2.22)
- } // else from if( bTrySwapping )
- } // if( nCountOfBars > 1 && pAffixmentData != NULL )
- _CalcFixedRowLayout(
- sizeFakeFixed,
- sizeMax,
- pt,
- bHorz,
- layout,
- dbol
- );
- ASSERT( layout.hDWP != NULL );
- if( layout.hDWP != NULL )
- {
- VERIFY( ::EndDeferWindowPos(layout.hDWP) );
- }
- for( nBar = 0; nBar < dbol.GetSize(); nBar++ )
- {
- OuterLayoutItemData & olid =
- dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- if( !olid.m_bVisible )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST( CExtControlBar, olid.m_pBar );
- if( pExtBar == NULL )
- continue;
- pExtBar->RedrawWindow(
- NULL, NULL,
- RDW_INVALIDATE|RDW_UPDATENOW
- |RDW_ERASE|RDW_ERASENOW
- |RDW_ALLCHILDREN|RDW_NOFRAME
- );
- } // for( nBar = 0; nBar < dbol.GetSize(); nBar++ )
- }
- void CExtDockOuterBar::_SwapInRowWithAffixment(
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- int nIdxLess,
- int nIdxGreater
- )
- {
- ASSERT( dbol.GetSize() > 1 );
- ASSERT( 0 <= nIdxLess && nIdxLess <= dbol.GetSize() );
- ASSERT( 0 <= nIdxGreater && nIdxGreater <= dbol.GetSize() );
- ASSERT( (nIdxLess+1) == nIdxGreater );
- OuterLayoutItemData & olid1 = dbol.ElementAt( nIdxLess );
- ASSERT_VALID( olid1.m_pBar );
- ASSERT_KINDOF( CControlBar, olid1.m_pBar );
- ASSERT( olid1.m_bVisible );
- CControlBar * pBar1 = olid1.m_pBar;
- int nPosInternal1 = FindBar( pBar1 );
- ASSERT( 0 < nPosInternal1 && nPosInternal1 < m_arrBars.GetSize() );
- OuterLayoutItemData & olid2 = dbol.ElementAt( nIdxGreater );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- CControlBar * pBar2 = olid2.m_pBar;
- int nPosInternal2 = FindBar( pBar2 );
- ASSERT( 0 < nPosInternal2 && nPosInternal2 < m_arrBars.GetSize() );
- ASSERT( pBar1 != pBar2 );
- ASSERT( nPosInternal1 != nPosInternal2 );
- m_arrBars[ nPosInternal1 ] = pBar2;
- m_arrBars[ nPosInternal2 ] = pBar1;
- OuterLayoutItemData olid = dbol.ElementAt( nIdxGreater );
- dbol.RemoveAt( nIdxGreater );
- dbol.InsertAt( nIdxLess, olid );
- }
- bool CExtDockOuterBar::_ReDockToNewRow(
- CControlBar * pBarSlide,
- MfcControlBarVector_t & vRow,
- int nShiftDesired
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBarSlide );
- ASSERT( pBarSlide->m_pDockBar == this );
- ASSERT( pBarSlide->IsVisible() );
- int nCountOfBars = (int)vRow.GetSize();
- ASSERT( nCountOfBars > 0 );
- UINT nDockBarID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- bool bHorz =
- ( nDockBarID == AFX_IDW_DOCKBAR_TOP
- || nDockBarID == AFX_IDW_DOCKBAR_BOTTOM )
- ? TRUE : FALSE;
- CRect rcBarSlide, rcBarSlideOrg, rcBarInsertBefore;
- pBarSlide->GetWindowRect( &rcBarSlide );
- ScreenToClient( &rcBarSlide );
- rcBarSlideOrg = rcBarSlide;
- int nExtentBarSlideMinPossible = 0;
- if( pBarSlide->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- CSize sizeBarSlideMinPossible =
- ((CExtControlBar*)pBarSlide)->_CalcDesiredMinOuterSize(
- bHorz ? TRUE : FALSE );
- nExtentBarSlideMinPossible = bHorz
- ? sizeBarSlideMinPossible.cx
- : sizeBarSlideMinPossible.cy
- ;
- } // if( pBarSlide->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- else
- {
- CRect rcBar;
- pBarSlide->GetWindowRect( &rcBar );
- nExtentBarSlideMinPossible = bHorz
- ? rcBar.Width()
- : rcBar.Height()
- ;
- } // else from if( pBarSlide->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- int nExtentRowMinPossible = 0;
- int nBar = 0;
- for( nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = vRow[nBar];
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- ASSERT( pBar->IsVisible() );
- ASSERT( pBar != pBarSlide );
- int nExtentBarMinPossible = 0;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- CSize sizeBarMinPossible =
- ((CExtControlBar*)pBar)->_CalcDesiredMinOuterSize(
- bHorz ? TRUE : FALSE );
- nExtentBarMinPossible = bHorz
- ? sizeBarMinPossible.cx
- : sizeBarMinPossible.cy
- ;
- } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- else
- {
- CRect rcBar;
- pBar->GetWindowRect( &rcBar );
- nExtentBarMinPossible = bHorz
- ? rcBar.Width()
- : rcBar.Height()
- ;
- } // else from if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- nExtentRowMinPossible += nExtentBarMinPossible;
- } // for( nBar = 0; nBar < nCountOfBars; nBar++ )
- CRect rcThisDockerClient;
- GetClientRect( &rcThisDockerClient );
- int nMaxExtent = bHorz
- ? rcThisDockerClient.Width()
- : rcThisDockerClient.Height()
- ;
- int nExtentRest = nMaxExtent - nExtentRowMinPossible;
- if( nExtentRest < nExtentBarSlideMinPossible )
- return false;
- int nSlidePosStart = bHorz
- ? rcBarSlide.left
- : rcBarSlide.top
- ;
- nSlidePosStart += nShiftDesired;
- int nSlidePosEnd = bHorz
- ? rcBarSlide.right
- : rcBarSlide.bottom
- ;
- nSlidePosEnd += nShiftDesired;
- if( nSlidePosStart < 0 )
- {
- nShiftDesired += nSlidePosStart;
- nSlidePosStart = 0;
- }
- CControlBar * pBarInsertBefore = NULL;
- bool bAppendMode = false;
- for( nBar = 0; nBar < nCountOfBars; nBar++ )
- {
- CControlBar * pBar = vRow[nBar];
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- ASSERT( pBar->IsVisible() );
- CRect rcBar;
- pBar->GetWindowRect( &rcBar );
- ScreenToClient( &rcBar );
- int nBarInRowPosStart = bHorz
- ? rcBar.left
- : rcBar.top
- ;
- int nBarInRowPosEnd = bHorz
- ? rcBar.right
- : rcBar.bottom
- ;
- if( nSlidePosEnd <= nBarInRowPosStart )
- {
- rcBarInsertBefore = rcBar;
- pBarInsertBefore = pBar;
- } // if( nSlidePosEnd <= nBarInRowPosStart )
- else
- {
- if( nSlidePosStart <= nBarInRowPosEnd )
- {
- int nBarInRowPosMid =
- (nBarInRowPosEnd + nBarInRowPosStart) / 2;
- if( nSlidePosStart <= nBarInRowPosMid )
- {
- rcBarInsertBefore = rcBar;
- pBarInsertBefore = pBar;
- break;
- }
- bAppendMode = true;
- break;
- } // if( nSlidePosStart <= nBarInRowPosEnd )
- else
- {
- if( pBarInsertBefore != NULL )
- break;
- bAppendMode = true;
- } // else from if( nSlidePosStart <= nBarInRowPosEnd )
- } // else from if( nSlidePosStart <= nBarInRowPosStart )
- } // for( nBar = 0; nBar < nCountOfBars; nBar++ )
- if( pBarInsertBefore == NULL
- && (!bAppendMode)
- )
- return false;
- int nBarPos = FindBar( pBarSlide );
- ASSERT( 0 < nBarPos && nBarPos < m_arrBars.GetSize() );
- if( m_arrBars[nBarPos-1] == NULL
- && m_arrBars[nBarPos+1] == NULL
- )
- m_arrBars.RemoveAt( nBarPos+1 );
- m_arrBars.RemoveAt( nBarPos );
- if( pBarInsertBefore != NULL )
- {
- if( bHorz )
- {
- rcBarSlide.OffsetRect(
- nShiftDesired,
- rcBarInsertBefore.top - rcBarSlide.top
- );
- if( rcBarInsertBefore.left < rcBarSlide.left )
- rcBarSlide.OffsetRect(
- rcBarInsertBefore.left - rcBarSlide.left,
- 0
- );
- } // if( bHorz )
- else
- {
- rcBarSlide.OffsetRect(
- rcBarInsertBefore.left - rcBarSlide.left,
- nShiftDesired
- );
- if( rcBarInsertBefore.top < rcBarSlide.top )
- rcBarSlide.OffsetRect(
- 0,
- rcBarInsertBefore.top - rcBarSlide.top
- );
- } // else from if( bHorz )
- nBarPos = FindBar( pBarInsertBefore );
- ASSERT( 0 < nBarPos && nBarPos < m_arrBars.GetSize() );
- m_arrBars.InsertAt( nBarPos, pBarSlide );
- ASSERT_VALID( this );
- } // if( pBarInsertBefore != NULL )
- else
- {
- ASSERT( bAppendMode );
- pBarInsertBefore = vRow[nCountOfBars-1];
- ASSERT_VALID( pBarInsertBefore );
- ASSERT_KINDOF( CControlBar, pBarInsertBefore );
- ASSERT( pBarInsertBefore->IsVisible() );
- pBarInsertBefore->GetWindowRect( &rcBarInsertBefore );
- ScreenToClient( &rcBarInsertBefore );
- if( bHorz )
- {
- rcBarSlide.OffsetRect(
- nShiftDesired,
- rcBarInsertBefore.top - rcBarSlide.top
- );
- if( rcBarSlide.left < rcBarInsertBefore.right )
- rcBarSlide.OffsetRect(
- rcBarInsertBefore.right - rcBarSlide.left,
- 0
- );
- } // if( bHorz )
- else
- {
- rcBarSlide.OffsetRect(
- rcBarInsertBefore.left - rcBarSlide.left,
- nShiftDesired
- );
- if( rcBarSlide.top < rcBarInsertBefore.bottom )
- rcBarSlide.OffsetRect(
- 0,
- rcBarInsertBefore.bottom - rcBarSlide.top
- );
- } // else from if( bHorz )
- nBarPos = FindBar( pBarInsertBefore );
- ASSERT( 0 < nBarPos && nBarPos < m_arrBars.GetSize() );
- for( nBarPos ++; m_arrBars[nBarPos] != NULL; nBarPos ++ )
- {
- ASSERT( nBarPos < m_arrBars.GetSize() );
- }
- m_arrBars.InsertAt( nBarPos, pBarSlide );
- ASSERT_VALID( this );
- } // else from if( pBarInsertBefore != NULL )
- if( rcBarSlideOrg != rcBarSlide )
- pBarSlide->SetWindowPos(
- NULL,
- rcBarSlide.left, rcBarSlide.top,
- rcBarSlide.Width(), rcBarSlide.Height(),
- SWP_NOZORDER|SWP_NOACTIVATE
- ////|SWP_NOSENDCHANGING
- |SWP_NOREDRAW|SWP_NOCOPYBITS
- );
- return true;
- }
- void CExtDockOuterBar::_AlignSubRowAffixmentHW(
- bool bHorz,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- int nSubRowStartPos,
- int nSubRowEndPos
- )
- {
- ASSERT_VALID(this);
- ASSERT( dbol.GetSize() > 0 );
- ASSERT( nSubRowStartPos <= nSubRowEndPos );
- ASSERT( 0 <= nSubRowStartPos && nSubRowStartPos < dbol.GetSize() );
- ASSERT( 0 <= nSubRowEndPos && nSubRowEndPos < dbol.GetSize() );
- if( nSubRowStartPos == nSubRowEndPos )
- return;
- int nIdxToAlignFirst = -1;
- int nIdxToAlignLast = -1;
- int nTotalAffixmentExtentHW = -1;
- int nBar = 0;
- for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid.m_pBar
- );
- if( pExtBar == NULL )
- continue;
- if( !pExtBar->_AffixmentIsAlignedHW() )
- continue;
- ASSERT( pExtBar->_AffixmentGetOuter() != NULL );
- int nBarAffixmentExtentHW = bHorz
- ? olid.m_rcPreCalc.Height()
- : olid.m_rcPreCalc.Width()
- ;
- nTotalAffixmentExtentHW =
- max( nTotalAffixmentExtentHW, nBarAffixmentExtentHW );
- if( nIdxToAlignFirst < 0 )
- {
- ASSERT( nIdxToAlignLast < 0 );
- nIdxToAlignFirst = nIdxToAlignLast = nBar;
- continue;
- }
- ASSERT( nIdxToAlignFirst >= nSubRowStartPos );
- ASSERT( nIdxToAlignFirst <= nIdxToAlignLast );
- nIdxToAlignLast = nBar;
- } // for( nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- ASSERT( nIdxToAlignFirst <= nIdxToAlignLast );
- if( nTotalAffixmentExtentHW < 0
- || nIdxToAlignFirst == nIdxToAlignLast
- )
- return;
- ASSERT( nSubRowStartPos <= nIdxToAlignFirst && nIdxToAlignFirst <= nSubRowEndPos );
- ASSERT( nSubRowStartPos <= nIdxToAlignLast && nIdxToAlignLast <= nSubRowEndPos );
- for( nBar = nIdxToAlignFirst; nBar <= nIdxToAlignLast; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid.m_pBar
- );
- if( pExtBar == NULL )
- continue;
- if( !pExtBar->_AffixmentIsAlignedHW() )
- continue;
- ASSERT( pExtBar->_AffixmentGetOuter() != NULL );
- CRect & rcPreCalc = olid.m_rcPreCalc;
- if( bHorz )
- rcPreCalc.bottom = rcPreCalc.top + nTotalAffixmentExtentHW;
- else
- rcPreCalc.right = rcPreCalc.left + nTotalAffixmentExtentHW;
- } // for( nBar = nIdxToAlignFirst; nBar <= nIdxToAlignLast; nBar++ )
- }
- void CExtDockOuterBar::_CalcAffixmentOrderVector(
- bool bHorz,
- AffixmentOrderVector_t & arrAffixmentOrder,
- CExtDockOuterBar::dockbar_outer_layout_t & dbol,
- bool bResetAffixmentDataIfNeeded, // = false
- int nSubRowStartPos, // = 0
- int nSubRowEndPos // = -1
- )
- {
- ASSERT_VALID(this);
- if( arrAffixmentOrder.GetSize() > 0 )
- arrAffixmentOrder.RemoveAll();
- if( dbol.GetSize() == 0 )
- return;
- ASSERT( 0 <= nSubRowStartPos && nSubRowStartPos < dbol.GetSize() );
- if( nSubRowEndPos < 0 )
- nSubRowEndPos = int(dbol.GetSize()) - 1;
- ASSERT( 0 <= nSubRowEndPos && nSubRowEndPos < dbol.GetSize() );
- ASSERT( nSubRowStartPos <= nSubRowEndPos );
- int nResetAffixmentWeight =
- int(dbol.GetSize()) + nSubRowStartPos + 1;
- for( int nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- {
- OuterLayoutItemData & olid = dbol.ElementAt( nBar );
- ASSERT_VALID( olid.m_pBar );
- ASSERT_KINDOF( CControlBar, olid.m_pBar );
- ASSERT( olid.m_bVisible );
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid.m_pBar
- );
- if( pExtBar == NULL )
- {
- arrAffixmentOrder.Add( nBar );
- continue;
- }
- CExtControlBar::InternalAffixmentData * pAffixmentData =
- pExtBar->_AffixmentGetOuter();
- if( pAffixmentData == NULL )
- {
- arrAffixmentOrder.Add( nBar );
- continue;
- }
- if( pAffixmentData->IsEmpty() )
- {
- if( bResetAffixmentDataIfNeeded )
- pAffixmentData->m_nAffixmentWeight = nResetAffixmentWeight++;
- else
- {
- arrAffixmentOrder.Add( nBar );
- continue;
- } // else from if( bResetAffixmentDataIfNeeded )
- } // if( pAffixmentData->IsEmpty() )
- if( pAffixmentData->m_rcAffixment.IsRectEmpty() )
- {
- if( bResetAffixmentDataIfNeeded )
- pAffixmentData->m_rcAffixment = olid.m_rcReal;
- else
- {
- arrAffixmentOrder.Add( nBar );
- continue;
- } // else from if( bResetAffixmentDataIfNeeded )
- } // if( pAffixmentData->m_rcAffixment.IsRectEmpty() )
- if( bResetAffixmentDataIfNeeded )
- {
- if( bHorz )
- {
- if( pAffixmentData->m_sizeCompressed.cx == 0 )
- pAffixmentData->m_sizeCompressed.cx =
- olid.m_rcReal.Width();
- if( pAffixmentData->m_sizeCompressed.cx > olid.m_sizeCalcDynamic.cx )
- pAffixmentData->m_sizeCompressed.cx = olid.m_sizeCalcDynamic.cx;
- } // if( bHorz )
- else
- {
- if( pAffixmentData->m_sizeCompressed.cy == 0 )
- pAffixmentData->m_sizeCompressed.cy =
- olid.m_rcReal.Height();
- if( pAffixmentData->m_sizeCompressed.cy > olid.m_sizeCalcDynamic.cy )
- pAffixmentData->m_sizeCompressed.cy = olid.m_sizeCalcDynamic.cy;
- } // else from if( bHorz )
- } // if( bResetAffixmentDataIfNeeded )
- if( arrAffixmentOrder.GetSize() == 0 )
- {
- arrAffixmentOrder.Add( nBar );
- continue;
- }
- int nReviewCount = nBar - nSubRowStartPos;
- ASSERT( nReviewCount > 0 );
- ASSERT( arrAffixmentOrder.GetSize() == nReviewCount );
- for( int nOrder = 0; nOrder < nReviewCount; nOrder++ )
- {
- int nBarAtOrder = arrAffixmentOrder[nOrder];
- ASSERT( nBarAtOrder < nBar );
- OuterLayoutItemData & olid2 = dbol.ElementAt( nBarAtOrder );
- ASSERT_VALID( olid2.m_pBar );
- ASSERT( olid.m_pBar != olid2.m_pBar );
- ASSERT_KINDOF( CControlBar, olid2.m_pBar );
- ASSERT( olid2.m_bVisible );
- CExtControlBar * pExtBar2 =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- olid2.m_pBar
- );
- if( pExtBar2 == NULL )
- {
- arrAffixmentOrder.InsertAt( nOrder, nBar );
- break;
- }
- CExtControlBar::InternalAffixmentData * pAffixmentData2 =
- pExtBar2->_AffixmentGetOuter();
- if( pAffixmentData2 == NULL )
- {
- arrAffixmentOrder.InsertAt( nOrder, nBar );
- break;
- }
- ASSERT( !pAffixmentData2->IsEmpty() );
- // TO FIX: affixment recalc afrer tooggling docked/floating state
- // ASSERT(
- // pAffixmentData2->m_nAffixmentWeight
- // != pAffixmentData->m_nAffixmentWeight
- // );
- if( pAffixmentData2->m_nAffixmentWeight
- > pAffixmentData->m_nAffixmentWeight
- )
- {
- arrAffixmentOrder.InsertAt( nOrder, nBar );
- break;
- }
- if( nOrder == (nReviewCount - 1) )
- {
- arrAffixmentOrder.Add( nBar );
- break;
- }
- } // for( int nOrder = 0; nOrder < nReviewCount; nOrder++ )
- ASSERT( arrAffixmentOrder.GetSize() == (nReviewCount + 1) );
- } // for( int nBar = nSubRowStartPos; nBar <= nSubRowEndPos; nBar++ )
- ASSERT( arrAffixmentOrder.GetSize() == (nSubRowEndPos-nSubRowStartPos+1) );
- }