ExtDockBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:241k
- // This is part of the Professional User Interface Suite library.
- // Copyright (C) 2001-2009 FOSS Software, Inc.
- // All rights reserved.
- //
- // http://www.prof-uis.com
- // mailto:support@prof-uis.com
- //
- // This source code can be used, modified and redistributed
- // under the terms of the license agreement that is included
- // in the Professional User Interface Suite package.
- //
- // Warranties and Disclaimers:
- // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
- // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
- // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
- // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- #include "stdafx.h"
- #if (!defined __EXTDOCKBAR_H)
- #include "ExtDockBar.h"
- #endif
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if (!defined __EXT_CONTROLBAR_TABBED_FEATURES_H)
- #include "ExtControlBarTabbedFeatures.h"
- #endif // __EXT_CONTROLBAR_TABBED_FEATURES_H
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if _MFC_VER < 0x700
- #include <../src/AfxImpl.h>
- #else
- #include <../src/mfc/AfxImpl.h>
- #endif
- #if (!defined __EXT_MEMORY_DC_H)
- #include <../Src/ExtMemoryDC.h>
- #endif
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXTCUSTOMIZE_H)
- #include <ExtCustomize.h>
- #endif
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- #include <Resources/Resource.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////
- // CExtDockBar window
- IMPLEMENT_DYNCREATE( CExtDockBar, CDockBar );
- IMPLEMENT_CExtPmBridge_MEMBERS( CExtDockBar );
- BEGIN_MESSAGE_MAP(CExtDockBar, CDockBar)
- //{{AFX_MSG_MAP(CExtDockBar)
- //}}AFX_MSG_MAP
- ON_WM_CONTEXTMENU()
- ON_WM_CANCELMODE()
- ON_WM_ERASEBKGND()
- ON_MESSAGE( WM_SIZEPARENT, OnSizeParent )
- ON_WM_NCCALCSIZE()
- ON_WM_NCPAINT()
- ON_WM_DESTROY()
- ON_MESSAGE( WM_HELPHITTEST, OnHelpHitTest )
- END_MESSAGE_MAP()
- bool CExtDockBar::g_bControlBarFixSizePixel = true;
- bool CExtDockBar::g_bExtendedRepositioning = false;
- bool CExtDockBar::g_bDockBarClassRegistered = false;
- CExtDockBar::CExtDockBar(
- UINT nCircleNo // = 0
- )
- : m_nCircleNo( nCircleNo )
- , m_bLockedOptimize( false )
- , m_pDockBarOuter( NULL )
- , m_pDockBarInner( NULL )
- , m_rcLastInvisiblePreCalc( 0, 0, 0, 0 )
- , m_bInDynamicLayoutUpdate( false )
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- , m_pWndAutoHideArea( NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- VERIFY( RegisterDockBarClass() );
- PmBridge_Install();
- }
- CExtDockBar::~CExtDockBar()
- {
- PmBridge_Uninstall();
- }
- bool CExtDockBar::RegisterDockBarClass()
- {
- if( g_bDockBarClassRegistered )
- return true;
- WNDCLASS _wndClassInfo;
- HINSTANCE hInst = ::AfxGetInstanceHandle();
- if( ! ::GetClassInfo( hInst, __EXT_DOCKBAR_CLASS_NAME, &_wndClassInfo ) )
- {
- _wndClassInfo.style = CS_GLOBALCLASS|CS_DBLCLKS;
- _wndClassInfo.lpfnWndProc = ::DefWindowProc;
- _wndClassInfo.cbClsExtra = _wndClassInfo.cbWndExtra = 0;
- _wndClassInfo.hInstance = hInst;
- _wndClassInfo.hIcon = NULL;
- _wndClassInfo.hCursor = ::LoadCursor( NULL, IDC_ARROW );
- ASSERT( _wndClassInfo.hCursor != NULL );
- _wndClassInfo.hbrBackground = NULL;
- _wndClassInfo.lpszMenuName = NULL;
- _wndClassInfo.lpszClassName = __EXT_DOCKBAR_CLASS_NAME;
- if( !::AfxRegisterClass( &_wndClassInfo ) )
- {
- ASSERT( FALSE );
- //AfxThrowResourceException();
- return false;
- }
- }
- g_bDockBarClassRegistered = true;
- return true;
- }
- void CExtDockBar::PreSubclassWindow()
- {
- CDockBar::PreSubclassWindow();
- }
- BOOL CExtDockBar::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( ( !RegisterDockBarClass() )
- || ( !CWnd::PreCreateWindow(cs) )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
-
- cs.lpszClass = __EXT_DOCKBAR_CLASS_NAME;
- return TRUE;
- }
- LRESULT CExtDockBar::OnHelpHitTest(WPARAM wParam, LPARAM lParam)
- {
- wParam;
- lParam;
- return 0L;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtDockBar::OnCustomizeModeEnter()
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( _GetCircleNo() > 0 )
- return;
- if( m_pWndAutoHideArea == NULL )
- return;
- ASSERT_VALID( m_pWndAutoHideArea );
- m_pWndAutoHideArea->OnCustomizeModeEnter();
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- void CExtDockBar::OnCustomizeModeLeave()
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( _GetCircleNo() > 0 )
- return;
- if( m_pWndAutoHideArea == NULL )
- return;
- ASSERT_VALID( m_pWndAutoHideArea );
- m_pWndAutoHideArea->OnCustomizeModeLeave();
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtDockBar::OnCancelMode()
- {
- ASSERT_VALID( this );
- CDockBar::OnCancelMode();
- BOOL bHelpMode =
- ::AfxGetApp()->m_bHelpMode
- || CExtControlBar::FindHelpMode( this )
- ;
- if( !bHelpMode )
- CExtPopupMenuWnd::CancelMenuTracking();
- CWnd::CancelToolTips();
- //ASSERT( !CExtPopupMenuWnd::IsMenuTracking() );
- }
- CFrameWnd * CExtDockBar::_GetDockingFrameImpl()
- {
- ASSERT_VALID( this );
- return
- CExtControlBar::_GetDockingFrameImpl( (CControlBar *)this );
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtDockBar::_AppendAddRemoveButtonsCustomizeMenu(
- CExtPopupMenuWnd * pPopup,
- CControlBar * pBarEventSrc
- )
- {
- ASSERT_VALID( pPopup );
- ASSERT_VALID( pBarEventSrc );
- ASSERT( pBarEventSrc->GetSafeHwnd() != NULL && ::IsWindow(pBarEventSrc->GetSafeHwnd()) );
- if( ! pBarEventSrc->IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) )
- {
- ASSERT( FALSE );
- return false;
- }
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( pBarEventSrc->m_hWnd );
- if( pSite == NULL )
- return true;
- if( ! pSite->BarIsRegistered((CExtToolControlBar*)pBarEventSrc) )
- return true;
- CExtSafeString strProfileName =
- g_CmdManager->ProfileNameFromWnd( pBarEventSrc->m_hWnd );
- ASSERT( !strProfileName.IsEmpty() );
- VERIFY(
- g_CmdManager->UpdateFromMenu(
- strProfileName,
- IDR_MENU_CUSTOMIZE_CMDS,
- true
- )
- );
- pSite->BarDefCmdTargetSet((CExtToolControlBar*)pBarEventSrc);
- bool bUserBar = false;
- VERIFY(
- pSite->GetToolbarCustomizeInfo(
- (CExtToolControlBar*)pBarEventSrc, NULL, NULL, NULL,
- &bUserBar
- )
- );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- strProfileName,
- ID_EXT_ADD_REMOVE_BUTTONS
- );
- CExtSafeString strAddRemoveButtons;
- if( pCmdItem )
- strAddRemoveButtons = pCmdItem->m_sMenuText;
- if( strAddRemoveButtons.IsEmpty() )
- strAddRemoveButtons = _T("&Add/remove buttons");
- VERIFY(
- pPopup->ItemInsert(
- (UINT)CExtPopupMenuWnd::TYPE_POPUP,
- -1,
- strAddRemoveButtons
- )
- );
- CExtPopupMenuWnd::MENUITEMDATA & miARB =
- pPopup->ItemGetInfo( pPopup->ItemGetCount() - 1 );
- miARB.SetChildCombine();
- miARB.SetToolButton();
- miARB.SetToolWrap();
- CExtPopupMenuWnd * pAddRemoveButtons = miARB.GetPopup();
- ASSERT( pAddRemoveButtons != NULL );
-
- VERIFY( pAddRemoveButtons->ItemInsert( ID_EXT_CUSTOMIZE ) );
- CExtPopupMenuWnd::MENUITEMDATA & miCustomize =
- pAddRemoveButtons->ItemGetInfo(
- pAddRemoveButtons->ItemGetCount() - 1
- );
- miCustomize.SetForceEnabled();
- if( ! bUserBar )
- {
- bool bAddResetBarHere = true;
- if( pBarEventSrc->m_pDockBar != NULL )
- {
- ASSERT_VALID( pBarEventSrc->m_pDockBar );
- MfcControlBarVector_t vBars;
- if( pBarEventSrc->IsFloating() )
- vBars.Add( pBarEventSrc );
- else
- {
- int nPos = pBarEventSrc->m_pDockBar->FindBar( pBarEventSrc );
- ASSERT( nPos >= 0 && nPos < pBarEventSrc->m_pDockBar->m_arrBars.GetSize() );
- for( nPos--; nPos >= 0 && pBarEventSrc->m_pDockBar->m_arrBars[nPos] != NULL; nPos-- );
- nPos++;
- ASSERT( nPos >= 0 && nPos < pBarEventSrc->m_pDockBar->m_arrBars.GetSize() );
- for( ; pBarEventSrc->m_pDockBar->m_arrBars[nPos] != NULL && nPos < pBarEventSrc->m_pDockBar->m_arrBars.GetSize(); nPos++ )
- {
- CControlBar * pBarInRow = (CControlBar *)pBarEventSrc->m_pDockBar->m_arrBars[nPos];
- if( pBarInRow == NULL || __PLACEHODLER_BAR_PTR(pBarInRow) )
- continue;
- ASSERT_VALID( pBarInRow );
- ASSERT_KINDOF( CControlBar, pBarInRow );
- if( !pBarInRow->IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) )
- continue;
- vBars.Add( pBarInRow );
- }
- } // else from if( pBarEventSrc->IsFloating() )
- int nCount = (int)vBars.GetSize();
- ASSERT( nCount >= 1 );
- for( int i = 0; i < nCount; )
- {
- CExtToolControlBar * pBar = (CExtToolControlBar*)vBars[i];
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtToolControlBar, pBar );
- if( ( !pSite->BarIsRegistered(pBar) )
- || ( !pBar->OnCustomizeCanShowHideButtons() )
- )
- {
- vBars.RemoveAt( i );
- nCount--;
- continue;
- }
- bool bUserItem = false;
- VERIFY(
- pSite->GetToolbarCustomizeInfo(
- pBar, NULL, NULL, NULL,
- &bUserItem
- )
- );
- if( bUserItem )
- {
- vBars.RemoveAt( i );
- nCount--;
- continue;
- }
- i++;
- } // for( int i = 0; i < nCount; i++ )
- ASSERT( nCount == vBars.GetSize() );
- if( nCount > 0 )
- {
- bAddResetBarHere = false;
- int i = 0;
- for( i = 0; i < nCount; i++ )
- {
- CExtToolControlBar * pBar = (CExtToolControlBar*)vBars[i];
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtToolControlBar, pBar );
- CString sBarName;
- pBar->GetWindowText( sBarName );
- VERIFY(
- pAddRemoveButtons->ItemInsert(
- (UINT)CExtPopupMenuWnd::TYPE_POPUP,
- i,
- (LPCTSTR)sBarName
- )
- );
- CExtPopupMenuWnd::MENUITEMDATA & mi = pAddRemoveButtons->ItemGetInfo(i);
- CExtPopupMenuWnd * pFolder = mi.GetPopup();
- ASSERT_VALID( pFolder );
- pBar->OnCustomizeInitShowHideButtonMenu( pFolder );
- ASSERT( pFolder->ItemGetCount() > 0 );
- VERIFY( pFolder->ItemInsert() );
- VERIFY( pFolder->ItemInsert( ID_EXT_RESET_TOOLBAR ) );
- CExtPopupMenuWnd::MENUITEMDATA & miResetToolbar =
- pFolder->ItemGetInfo(
- pFolder->ItemGetCount() - 1
- );
- miResetToolbar.SetForceEnabled();
- miResetToolbar.SetCmdDeliverCb(
- (CExtPopupMenuWnd::MENUITEMDATA::pCbItemClick)
- CExtToolControlBar::stat_CbCmdDeliver
- );
- miResetToolbar.LParamSet( (LPARAM)pBar );
- } // for( i = 0; i < nCount; i++ )
- VERIFY(
- pAddRemoveButtons->ItemInsert(
- (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR,
- i
- )
- );
- } // if( nCount > 0 )
- } // if( pBarEventSrc->m_pDockBar != NULL )
- if( bAddResetBarHere )
- {
- VERIFY( pAddRemoveButtons->ItemInsert( ID_EXT_RESET_TOOLBAR ) );
- CExtPopupMenuWnd::MENUITEMDATA & miResetToolbar =
- pAddRemoveButtons->ItemGetInfo(
- pAddRemoveButtons->ItemGetCount() - 1
- );
- miResetToolbar.SetForceEnabled();
- miResetToolbar.SetCmdDeliverCb(
- (CExtPopupMenuWnd::MENUITEMDATA::pCbItemClick)
- CExtToolControlBar::stat_CbCmdDeliver
- );
- miResetToolbar.LParamSet( (LPARAM)pBarEventSrc );
- } // if( bAddResetBarHere )
- } // if( ! bUserBar )
-
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
- CFrameWnd * pFrame,
- CExtPopupMenuWnd * pPopup,
- SHORT nHelperNotificationType,
- CControlBar * pBarEventSrc,
- UINT nMsgID, // = WM_NULL
- CObject * pObjectSrc // = NULL
- )
- {
- ASSERT_VALID( pFrame );
- ASSERT( pPopup != NULL );
- CExtControlBar::POPUP_MENU_EVENT_DATA _pmed(
- nHelperNotificationType,
- pPopup,
- pBarEventSrc,
- CPoint( -1, -1 ),
- nMsgID,
- pObjectSrc
- );
- bool bPreNotificationPassed = _pmed.NotifyTarget( false );
- if( !bPreNotificationPassed )
- {
- ExtControlBarVector_t vBars;
- CExtControlBar::_GetFrameControlBars(
- NULL,
- pFrame,
- vBars
- );
- bool bOleInplaceItemActivated =
- CExtControlBar::IsOleIpObjActive( pFrame );
- int nBarsCount = (int)vBars.GetSize();
- CExtControlBar * pPrevBar = NULL;
- for( int i=0; i<nBarsCount; i++ )
- {
- CExtControlBar * pBar = vBars[i];
- ASSERT_VALID( pBar );
- if( pBar->GetSafeHwnd() == NULL
- || ( ! ::IsWindow(pBar->GetSafeHwnd()) )
- )
- continue;
- // do not include dynamic bars
- if( pBar->IsKindOf( RUNTIME_CLASS(CExtDynControlBar) ) )
- continue;
- // do not include temporary hidden bars
- if( pBar->m_nStateFlags &
- //(CControlBar::delayHide | CControlBar::tempHide)
- CControlBar::tempHide
- )
- continue;
- // do not include some bars when OLE inplace object active
- if( bOleInplaceItemActivated &&
- (pBar->m_dwStyle & CBRS_HIDE_INPLACE)
- )
- continue;
- // do not include bars without caption
- CString sBarText;
- pBar->GetWindowText( sBarText );
- if( sBarText.IsEmpty() )
- {
- // do not include bars without window text to menu
- // ASSERT( FALSE );
- continue;
- }
- if( pPrevBar != NULL
- &&
- pPrevBar->IsFixedDockStyle() != pBar->IsFixedDockStyle()
- )
- {
- VERIFY(
- pPopup->ItemInsert(
- CExtPopupMenuWnd::TYPE_SEPARATOR
- )
- );
- }
- int nBarID = pBar->GetDlgCtrlID();
- ASSERT( CExtCmdManager::IsCommand(nBarID) );
-
- CExtCmdItem _cmd;
- _cmd.m_nCmdID = nBarID;
- _cmd.m_sMenuText = sBarText;
- _cmd.TipsLoad();
- g_CmdManager->CmdSetup(
- g_CmdManager->ProfileNameFromWnd( pFrame->GetSafeHwnd() ),
- _cmd
- );
- if( pBar->OnConstructDockSiteControlBarPopupMenu(pPopup) )
- pPrevBar = pBar;
- } // for( int i=0; i<nBarsCount; i++ )
- } // if( !bPreNotificationPassed )
- // remove double separators
- INT nCount = pPopup->ItemGetCount();
- for( INT nItem = 1; nItem < nCount; )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _miiPrev =
- pPopup->ItemGetInfo( nItem - 1 );
- if( !_miiPrev.IsSeparator() )
- {
- nItem++;
- continue;
- }
- CExtPopupMenuWnd::MENUITEMDATA & _miiCurr =
- pPopup->ItemGetInfo( nItem );
- if( !_miiCurr.IsSeparator() )
- {
- nItem++;
- continue;
- }
- pPopup->ItemRemove( nItem );
- nCount--;
- } // for( INT nItem = 1; nItem < nCount; )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool bAddCustomizeCmd = false;
- if( (!bPreNotificationPassed)
- && ( nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX
- || nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX
- || nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_DOCKBAR_CTX
- || nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_STATUSBAR_CTX
- || nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MINIFRAME_NC_CTX
- )
- && CExtCustomizeSite::GetCustomizeSite( pBarEventSrc->GetSafeHwnd() ) != NULL
- )
- bAddCustomizeCmd = true;
- if( bAddCustomizeCmd
- && pBarEventSrc->GetSafeHwnd() != NULL
- && pBarEventSrc->IsKindOf( RUNTIME_CLASS( CExtToolControlBar ) )
- && ( ! ((CExtToolControlBar*)pBarEventSrc)->m_bCustomizationAllowed )
- )
- bAddCustomizeCmd = false;
- if( bAddCustomizeCmd )
- { // add customize command
- LPCTSTR strCmdProfile = g_CmdManager->ProfileNameFromWnd( pFrame->m_hWnd );
- if( strCmdProfile != NULL
- && g_CmdManager->CmdGetPtr( strCmdProfile, ID_EXT_CUSTOMIZE ) != NULL
- )
- {
- // add tail separator
- nCount = pPopup->ItemGetCount();
- if( nCount > 0 )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _mii =
- pPopup->ItemGetInfo( nCount - 1 );
- if( !_mii.IsSeparator() )
- pPopup->ItemInsert();
- } // if( nCount > 0 )
- VERIFY( pPopup->ItemInsert( ID_EXT_CUSTOMIZE ) );
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pPopup->ItemGetInfo(
- pPopup->ItemGetCount() - 1
- );
- mi.SetForceEnabled();
- } // if( strCmdProfile != NULL ...
- } // add customize command
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- _pmed.NotifyTarget( true );
- // remove tail separator
- nCount = pPopup->ItemGetCount();
- if( nCount > 0 )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _mii =
- pPopup->ItemGetInfo( nCount - 1 );
- if( _mii.IsSeparator() )
- pPopup->ItemRemove( nCount - 1 );
- } // if( nCount > 0 )
- return true;
- }
- void CExtDockBar::OnContextMenu(CWnd* pWnd, CPoint point)
- {
- ASSERT_VALID( this );
- pWnd;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( m_hWnd );
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- return;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( CExtControlBar::FindHelpMode(this) )
- return;
- // find any control bar
- CControlBar * pBar = NULL;
- for( int nPos = 0; nPos < m_arrBars.GetSize(); nPos++ )
- {
- pBar = GetDockedControlBar(nPos);
- if( pBar != NULL )
- {
- ASSERT_VALID( pBar );
- break;
- }
- }
- if( pBar == NULL )
- return;
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- HWND hWndTrack = pBar->GetOwner()->GetSafeHwnd();
- ASSERT( hWndTrack != NULL && ::IsWindow(hWndTrack) );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- VERIFY( pPopup->CreatePopupMenu(hWndTrack) );
- if( ! _ConstructDockSiteControlBarPopupMenu(
- pFrame,
- pPopup,
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_DOCKBAR_CTX,
- this,
- WM_CONTEXTMENU,
- NULL
- )
- )
- {
- delete pPopup;
- return;
- }
- if( pPopup->ItemGetCount() == 0 )
- {
- delete pPopup;
- return;
- }
- ::SetFocus( hWndTrack );
- if( ! pPopup->TrackPopupMenu(
- TPMX_OWNERDRAW_FIXED,
- point.x,
- point.y,
- NULL,
- this,
- NULL,
- NULL,
- true
- )
- )
- {
- //delete pPopup;
- }
- }
- void CExtDockBar::DoPaint( CDC * pDC )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDC );
- CExtPaintManager::stat_ExcludeChildAreas(
- pDC->GetSafeHdc(),
- GetSafeHwnd()
- );
- CRect rcClient;
- GetClientRect( &rcClient );
- CExtMemoryDC dc( pDC, &rcClient );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( dc.GetSafeHdc() != NULL )
- pDC = &dc;
- PmBridge_GetPM()->PaintDockBarClientArea(
- *pDC,
- rcClient,
- this
- );
- PmBridge_GetPM()->OnPaintSessionComplete( this );
- }
- BOOL CExtDockBar::OnEraseBkgnd( CDC* pDC )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDC );
- pDC;
- // CExtPaintManager::stat_ExcludeChildAreas(
- // *pDC,
- // *this
- // );
- // return CDockBar::OnEraseBkgnd(pDC);
- return TRUE;
- }
- void CExtDockBar::OnDynamicLayoutUpdate()
- {
- ASSERT_VALID( this );
- ASSERT_KINDOF( CExtDockBar, this );
- if( m_bLockedOptimize )
- return;
- if( m_bInDynamicLayoutUpdate )
- return;
- m_bInDynamicLayoutUpdate = true;
- ASSERT( m_arrBars.GetSize() >= 1 );
- for( INT nBar = 1; nBar < m_arrBars.GetSize(); nBar++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)
- m_arrBars[ nBar ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- if( pBar->IsFixedMode() || pBar->IsFixedDockStyle() )
- continue;
- if( !pBar->IsVisible() )
- continue;
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- continue;
- ASSERT_VALID( ((CExtDynControlBar *)pBar)->m_pWndDynDocker );
- ((CExtDynControlBar *)pBar)->m_pWndDynDocker->OnDynamicLayoutUpdate();
- }
- m_bInDynamicLayoutUpdate = false;
- }
- void CExtDockBar::OnDynamicLayoutOptimize()
- {
- if( m_bLockedOptimize )
- return;
- ASSERT( m_arrBars.GetSize() >= 1 );
- for( INT nBar = 1; nBar < m_arrBars.GetSize(); nBar++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)
- m_arrBars[ nBar ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- if( pBar->IsFixedMode() || pBar->IsFixedDockStyle() )
- continue;
- if( !pBar->IsVisible() )
- continue;
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- continue;
- ASSERT_VALID( ((CExtDynControlBar *)pBar)->m_pWndDynDocker );
- ((CExtDynControlBar *)pBar)->m_pWndDynDocker->OnDynamicLayoutOptimize();
- }
- }
- CSize CExtDockBar::CalcFixedLayout(
- BOOL bStretch,
- BOOL bHorz
- )
- {
- // based on MFC's source of
- // CDockBar::CalcFixedLayout()
- ASSERT_VALID(this);
- CSize sizeFixed =
- CControlBar::CalcFixedLayout( bStretch, bHorz );
- // get max size
- CSize sizeMax;
- if( !m_rectLayout.IsRectEmpty() )
- sizeMax = m_rectLayout.Size();
- else
- {
- CFrameWnd * pFrame = GetParentFrame();
- CRect rcFrameWindow;
- pFrame->GetClientRect( &rcFrameWindow );
- sizeMax = rcFrameWindow.Size();
- }
- // prepare for layout
- AFX_SIZEPARENTPARAMS layout;
- layout.hDWP = m_bLayoutQuery ?
- NULL : ::BeginDeferWindowPos( (int)m_arrBars.GetSize() );
- CPoint pt( 0, 0 );
- int nWidth = 0;
- BOOL bWrapped = FALSE;
- for( int nPos = 0; nPos < m_arrBars.GetSize(); nPos++ )
- { // layout all the control bars
- CControlBar * pBar = GetDockedControlBar(nPos);
- void * pVoid = m_arrBars[nPos];
- if( pBar != NULL )
- {
- CRect rcBarWin, rcBarClient;
- pBar->GetWindowRect( &rcBarWin );
- pBar->ScreenToClient( & rcBarWin );
- pBar->GetClientRect( &rcBarClient );
- CSize sizeBarMin =
- rcBarWin.Size() - rcBarClient.Size();
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- if( ! ((CExtControlBar*)pBar)->IsFixedMode() )
- {
- sizeBarMin =
- CSize(
- ((CExtControlBar *)pBar)->_CalcDesiredMinHW(),
- ((CExtControlBar *)pBar)->_CalcDesiredMinVH()
- );
- } // if( ! ((CExtControlBar*)pBar)->IsFixedMode() )
- } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- if( pBar->IsVisible() )
- {
- // get ideal rect for bar
- DWORD dwMode = 0;
- if( (pBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
- &&
- (pBar->m_dwStyle & CBRS_FLOATING)
- )
- dwMode |= LM_HORZ | LM_MRUWIDTH;
- else if(pBar->m_dwStyle & CBRS_ORIENT_HORZ)
- dwMode |= LM_HORZ | LM_HORZDOCK;
- else
- dwMode |= LM_VERTDOCK;
- CSize sizeBar =
- pBar->CalcDynamicLayout(-1, dwMode);
- CRect rc(pt, sizeBar);
- // get current rect for bar
- CRect rcBar;
- pBar->GetWindowRect( &rcBar );
- ScreenToClient( &rcBar );
- if( bHorz )
- {
- // Offset Calculated Rect out to Actual
- if( rcBar.left > rc.left
- && !m_bFloating
- )
- rc.OffsetRect(
- rcBar.left - rc.left,
- 0
- );
- // If ControlBar goes off the right, then right justify
- if( rc.right > sizeMax.cx
- && !m_bFloating
- )
- {
- int x = rc.Width();
- x = max(sizeMax.cx - x, pt.x);
- rc.OffsetRect(
- x - rc.left,
- 0
- );
- if( rc.right > sizeMax.cx )
- rc.right -= rc.right - sizeMax.cx;
- }
- // If ControlBar has been wrapped, then left justify
- if( bWrapped )
- {
- bWrapped = FALSE;
- rc.OffsetRect( - rc.left, 0 );
- }
- // If ControlBar is completely invisible, then wrap it
- else if(
- rc.Width() < sizeBarMin.cx
- ||
- (rc.left >= sizeMax.cx)
- && (nPos > 0) && (m_arrBars[nPos - 1] != NULL)
- )
- {
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- || (
- pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- &&
- ((CExtControlBar*)pBar)->IsFixedMode()
- )
- )
- {
- m_arrBars.InsertAt(
- nPos,
- (CObject*)NULL
- );
- pBar = NULL;
- pVoid = NULL;
- bWrapped = TRUE;
- }
- }
- if( !bWrapped )
- {
- if(rc != rcBar)
- {
- if( !m_bLayoutQuery &&
- !(pBar->m_dwStyle & CBRS_FLOATING)
- )
- pBar->m_pDockContext->
- m_rectMRUDockPos = rc;
- AfxRepositionWindow(
- &layout,
- pBar->m_hWnd,
- &rc
- );
- }
- pt.x = rc.left + sizeBar.cx;
- nWidth = max(nWidth, sizeBar.cy);
- } // if( !bWrapped )
- } // if( bHorz )
- else
- {
- // Offset Calculated Rect out to Actual
- if( rcBar.top > rc.top
- && !m_bFloating
- )
- rc.OffsetRect(
- 0,
- rcBar.top - rc.top
- );
- // If ControlBar goes off the bottom, then bottom justify
- if( rc.bottom > sizeMax.cy
- && !m_bFloating
- )
- {
- int y = rc.Height();
- y = max(sizeMax.cy - y, pt.y);
- rc.OffsetRect(
- 0,
- y - rc.top
- );
- if( rc.bottom > sizeMax.cy )
- rc.bottom -= rc.bottom - sizeMax.cy;
- }
- // If ControlBar has been wrapped, then top justify
- if( bWrapped )
- {
- bWrapped = FALSE;
- rc.OffsetRect( 0, - rc.top );
- }
- // If ControlBar is completely invisible, then wrap it
- else if(
- rc.Height() < sizeBarMin.cy
- ||
- (rc.top >= sizeMax.cy)
- && (nPos > 0) && (m_arrBars[nPos - 1] != NULL)
- )
- {
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- || (
- pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- &&
- ((CExtControlBar*)pBar)->IsFixedMode()
- )
- )
- {
- m_arrBars.InsertAt(
- nPos,
- (CObject*)NULL
- );
- pBar = NULL;
- pVoid = NULL;
- bWrapped = TRUE;
- }
- }
- if( !bWrapped )
- {
- if(rc != rcBar)
- {
- if( !m_bLayoutQuery
- && !(pBar->m_dwStyle & CBRS_FLOATING)
- && pBar->m_pDockContext != NULL
- )
- pBar->m_pDockContext->
- m_rectMRUDockPos = rc;
- AfxRepositionWindow(
- &layout,
- pBar->m_hWnd,
- &rc
- );
- }
- pt.y = rc.top + sizeBar.cy;
- nWidth = max(nWidth, sizeBar.cx);
- } // if( !bWrapped )
- } // else from if( bHorz )
-
- // if( !m_bLayoutQuery && pBar != NULL )
- // {
- // if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- // {
- // ASSERT_VALID( ((CExtDynControlBar *)pBar)->m_pWndDynDocker );
- // ((CExtDynControlBar *)pBar)->m_pWndDynDocker->OnDynamicLayoutUpdate();
- // }
- // }
- } // if( pBar->IsVisible() )
- if( !bWrapped )
- // handle any delay/show hide for the bar
- pBar->RecalcDelayShow( &layout );
- } // if( pBar != NULL )
- else
- {
- if( g_bExtendedRepositioning )
- {
- // try to remove wrapping:
- // are we have free space in the end of previous row?
- if( nPos > 0 && nPos != m_arrBars.GetSize()-1 )
- {
- int nPosPrev = nPos-1;
- CControlBar * pPrevBar = NULL;
- do
- {
- pPrevBar = GetDockedControlBar(nPosPrev--);
- if( pPrevBar != NULL
- && pPrevBar->IsVisible()
- && (!pPrevBar->IsFloating())
- )
- {
- // get ideal rect for prev bar
- DWORD dwMode = 0;
- if( (pPrevBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
- &&
- (pPrevBar->m_dwStyle & CBRS_FLOATING)
- )
- dwMode |= LM_HORZ | LM_MRUWIDTH;
- else if(pPrevBar->m_dwStyle & CBRS_ORIENT_HORZ)
- dwMode |= LM_HORZ | LM_HORZDOCK;
- else
- dwMode |= LM_VERTDOCK;
- CSize sizePrevBar =
- pPrevBar->CalcDynamicLayout(-1, dwMode);
- CRect rcPrev(pt, sizePrevBar);
- if( bHorz )
- {
- if( rcPrev.right > sizeMax.cx
- && !m_bFloating
- )
- pPrevBar = NULL;
- }
- else
- {
- if( rcPrev.bottom > sizeMax.cy
- && !m_bFloating
- )
- pPrevBar = NULL;
- }
- if( pPrevBar != NULL )
- break;
- }
- pPrevBar = NULL;
- } while( nPosPrev >= 0 );
- if( pPrevBar != NULL )
- {
- m_arrBars.RemoveAt(nPos);
- nPos--;
- continue;
- }
- } // if( nPos > 0 && nPos != m_arrBars.GetSize()-1 )
- } // if( g_bExtendedRepositioning )
- } // else from if( pBar != NULL )
- if( pBar == NULL && pVoid == NULL && nWidth != 0 )
- {
- // end of row because pBar == NULL
- if( bHorz )
- {
- pt.y += nWidth;
- sizeFixed.cx = max(sizeFixed.cx, pt.x);
- sizeFixed.cy = max(sizeFixed.cy, pt.y);
- pt.x = 0;
- sizeFixed.cy--;
- }
- else
- {
- pt.x += nWidth;
- sizeFixed.cx = max(sizeFixed.cx, pt.x);
- sizeFixed.cy = max(sizeFixed.cy, pt.y);
- pt.y = 0;
- sizeFixed.cx--;
- }
- nWidth = 0;
- }
- } // layout all the control bars
- 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 CExtDockBar::RemoveAllPlaceHolders(
- bool bSearchPlaceHolder // = true
- )
- {
- ASSERT_VALID( this );
- INT nCount = (INT)m_arrBars.GetSize();
- ASSERT( nCount > 0 );
- ASSERT( m_arrBars[0] == NULL );
- MfcControlBarVector_t vPlaceHolders;
- INT nBar = 0;
- for( nBar = 1; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = (CControlBar *) m_arrBars[ nBar ];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- {
- vPlaceHolders.Add( pBar );
- continue;
- }
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- } // for( nBar = 1; nBar < nCount; nBar++ )
- nCount = (INT)vPlaceHolders.GetSize();
- for( nBar = 0; nBar < nCount; nBar++ )
- {
- CControlBar * pBar = vPlaceHolders[nBar];
- RemovePlaceHolder( pBar, bSearchPlaceHolder );
- } // for( nBar = 0; nBar < nCount; nBar++ )
- }
- void CExtDockBar::RemovePlaceHolder(
- CControlBar * pBar,
- bool bSearchPlaceHolder, // = true
- bool * p_bRemoved // = NULL
- )
- {
- if( p_bRemoved != NULL )
- *p_bRemoved = false;
- // remove remembered docking position
- #if _MFC_VER >= 0x710
- if (DWORD_PTR(pBar) > 0x0FFFF)
- pBar = (CControlBar*)(DWORD_PTR)_AfxGetDlgCtrlID(pBar->m_hWnd);
- #else
- if( HIWORD(pBar) != 0 )
- pBar = (CControlBar*)_AfxGetDlgCtrlID(pBar->m_hWnd);
- #endif
- int nOldPos = FindBar(pBar);
- if( nOldPos > 0)
- {
- m_arrBars.RemoveAt(nOldPos);
- // remove section indicator (NULL) if nothing else in section
- if( m_arrBars[nOldPos-1] == NULL
- && m_arrBars[nOldPos] == NULL
- )
- m_arrBars.RemoveAt(nOldPos);
- if( p_bRemoved != NULL )
- *p_bRemoved = true;
- return;
- }
- if( !bSearchPlaceHolder )
- return;
- _RemovePlaceHolder(
- m_pDockSite,
- pBar,
- p_bRemoved
- );
- }
- void CExtDockBar::_RemovePlaceHolder(
- CFrameWnd * pFrame,
- CControlBar * pBar,
- bool * p_bRemoved // = NULL
- )
- {
- ASSERT_VALID( pFrame );
- ASSERT( pBar != NULL ); // may be placeholder ID
- POSITION pos = pFrame->m_listControlBars.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CControlBar * pTestBar = (CControlBar *)
- pFrame->m_listControlBars.GetNext( pos );
- ASSERT_VALID( pTestBar );
- ASSERT_KINDOF( CControlBar, pTestBar );
- if( !pTestBar->IsDockBar() )
- {
- if( pTestBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- {
- CExtDockDynBar * pDynDocker =
- ((CExtDynControlBar*)pTestBar)->
- m_pWndDynDocker;
- ASSERT_VALID( pDynDocker );
- bool bRemoved = false;
- pDynDocker->RemovePlaceHolder(
- pBar,
- false,
- &bRemoved
- );
- if( bRemoved )
- {
- if( p_bRemoved != NULL )
- *p_bRemoved = true;
- return;
- }
- }
- continue;
- }
- ASSERT_KINDOF( CDockBar, pTestBar );
- // dirty, but safe
- bool bRemoved = false;
- ((CExtDockBar *)pTestBar)->RemovePlaceHolder(
- pBar,
- false,
- &bRemoved
- );
- if( bRemoved )
- {
- if( p_bRemoved != NULL )
- *p_bRemoved = true;
- return;
- }
- }
- }
- void CExtDockBar::_SlideDockControlBar(
- CControlBar* pBar,
- LPCRECT lpRect,
- BOOL bMovingEnabled,
- const POINT * ptDesiredMid // = NULL
- )
- {
- ASSERT_VALID( this);
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- CRect rcBar;
- pBar->GetWindowRect( &rcBar );
- if( pBar->m_pDockBar == this
- && (lpRect == NULL || rcBar == *lpRect)
- )
- {
- // already docked and no change in position
- return;
- }
- // set CBRS_FLOAT_MULTI style if docking bar has it
- if( m_bFloating
- && (pBar->m_dwDockStyle & CBRS_FLOAT_MULTI)
- )
- m_dwStyle |= CBRS_FLOAT_MULTI;
- m_dwStyle &= ~(CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC);
- m_dwStyle |=
- pBar->m_dwStyle & (CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC);
- if( !(m_dwStyle & CBRS_FLOAT_MULTI) )
- {
- CString sTitle;
- pBar->GetWindowText( sTitle );
- AfxSetWindowText( m_hWnd, (LPCTSTR)sTitle );
- }
- // align correctly and turn on all borders
- DWORD dwStyle = pBar->GetBarStyle();
- dwStyle &= ~(CBRS_ALIGN_ANY);
- dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY;
- if( m_bFloating )
- dwStyle |= CBRS_FLOATING;
- else
- dwStyle &= ~CBRS_FLOATING;
- pBar->SetBarStyle( dwStyle );
- // hide first if changing to a new docking site to avoid flashing
- bool bShow = false;
- if( bMovingEnabled &&
- pBar->m_pDockBar != this && pBar->IsWindowVisible() )
- {
- pBar->SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_HIDEWINDOW);
- bShow = true;
- }
- int nPos = -1;
- if( lpRect != NULL )
- {
- // insert into appropriate row
- CRect rc( lpRect );
- ScreenToClient( &rc );
- CPoint ptMid(
- (ptDesiredMid == NULL) ?
- rc.left + rc.Width()/2 : ptDesiredMid->x,
- (ptDesiredMid == NULL) ?
- rc.top + rc.Height()/2 : ptDesiredMid->y
- );
- nPos = _InsertByPointImpl( pBar, rc, ptMid );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBar );
- // position at requested position
- if( bMovingEnabled )
- pBar->SetWindowPos(
- NULL,
- rc.left, rc.top, rc.Width(), rc.Height(),
- SWP_NOREDRAW ////|SWP_NOSENDCHANGING
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_NOCOPYBITS
- );
- }
- else
- {
- // always add on current row, then create new one
- m_arrBars.Add(pBar);
- m_arrBars.Add(NULL);
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBar );
- // align off the edge initially
- if( bMovingEnabled )
- pBar->SetWindowPos(
- NULL,
- -afxData.cxBorder2, -afxData.cyBorder2,
- 0, 0,
- SWP_NOREDRAW ////|SWP_NOSENDCHANGING
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_NOCOPYBITS
- |SWP_NOSIZE
- );
- }
- // attach it to the docking site
- if( pBar->GetParent() != this )
- pBar->SetParent(this);
- if( pBar->m_pDockBar == this )
- {
- //pBar->m_pDockBar->
- RemoveControlBar(
- pBar,
- nPos,
- 0,
- false // (!bMovingEnabled) ? true : false
- );
- ASSERT_VALID( this );
- } // if( pBar->m_pDockBar == this )
- else if( pBar->m_pDockBar != NULL )
- {
- ASSERT_KINDOF( CDockBar, pBar->m_pDockBar );
- if( pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- {
- bool bOptimizeDockBarLayout = false;
- if( !((CExtDockBar *)(pBar->m_pDockBar))->m_bFloating )
- bOptimizeDockBarLayout = true;
- ((CExtDockBar *)(pBar->m_pDockBar))->
- RemoveControlBar(
- pBar,
- -1,
- m_bFloating && !pBar->m_pDockBar->m_bFloating,
- false // (!bMovingEnabled) ? true : false
- );
- ASSERT_VALID( this );
- if( bOptimizeDockBarLayout )
- ((CExtDockBar *)(pBar->m_pDockBar))->OnDynamicLayoutOptimize();
- }
- else
- {
- pBar->m_pDockBar->
- RemoveControlBar(
- pBar,
- //ph//
- 0, //-1,
- m_bFloating && !pBar->m_pDockBar->m_bFloating
- );
- ASSERT_VALID( this );
- }
- } // else if( pBar->m_pDockBar != NULL )
- pBar->m_pDockBar = this;
- ASSERT( pBar->m_pDockContext != NULL );
- pBar->m_pDockContext->m_uMRUDockID = GetDlgCtrlID();
- if( lpRect != NULL )
- pBar->m_pDockContext->m_rectMRUDockPos = *lpRect;
- if( bShow )
- {
- ASSERT(!pBar->IsWindowVisible());
- //pBar->SetWindowPos(NULL, 0, 0, 0, 0,
- // SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
- pBar->SetWindowPos(NULL,
- lpRect->left,
- lpRect->top,
- lpRect->right-lpRect->left,
- lpRect->bottom-lpRect->top,
- SWP_NOSIZE/*|SWP_NOMOVE*/|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
- }
- // remove any place holder for pBar in this dockbar
- RemovePlaceHolder( pBar, true );
- ASSERT_VALID( this );
- // // get parent frame for recalc layout
- //CFrameWnd* pFrameWnd = GetDockingFrame();
- // pFrameWnd->DelayRecalcLayout();
- _OptimizeCircles();
- }
- void CExtDockBar::_NewRowDockControlBar(
- CControlBar * pExtBarDocked,
- CControlBar * pExtBarNew,
- bool bLessIndex
- )
- {
- ASSERT_VALID( this);
- ASSERT_VALID( pExtBarDocked );
- ASSERT_KINDOF( CControlBar, pExtBarDocked );
- ASSERT_VALID( pExtBarNew );
- ASSERT_KINDOF( CControlBar, pExtBarNew );
- CFrameWnd * pNewDockingFrameWnd = pExtBarNew->GetDockingFrame();
- INT nNewDockBarGetDockedVisibleCount = -1;
- BOOL bNewFloating = pExtBarNew->IsFloating();
- BOOL bNewExt = pExtBarNew->IsKindOf( RUNTIME_CLASS(CExtControlBar) );
- if( pExtBarNew->GetParent() != this )
- {
- if( bNewExt )
- ((CExtControlBar *)pExtBarNew)->m_bUpdatingChain = true;
- pExtBarNew->SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_HIDEWINDOW
- );
- pExtBarNew->SetParent( this );
- if( bNewExt )
- ((CExtControlBar *)pExtBarNew)->m_bUpdatingChain = false;
- }
- // align correctly and turn on all borders
- DWORD dwStyle = pExtBarNew->GetBarStyle();
- dwStyle &= ~(CBRS_ALIGN_ANY);
- dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY;
- if( m_bFloating )
- dwStyle |= CBRS_FLOATING;
- else
- dwStyle &= ~CBRS_FLOATING;
- pExtBarNew->SetBarStyle( dwStyle );
- INT nCountOfSideBars = (INT)m_arrBars.GetSize();
- CControlBar * pRemoveBar = NULL;
- HWND hWndDockBarOld = NULL;
- if( pExtBarNew->m_pDockBar != this )
- {
- if( pExtBarNew->m_pDockBar != NULL )
- {
- nNewDockBarGetDockedVisibleCount =
- GetDockedVisibleCount();
- ASSERT_VALID( pExtBarNew->m_pDockBar );
- ASSERT_KINDOF( CDockBar, pExtBarNew->m_pDockBar );
- if( pExtBarNew->IsWindowVisible() )
- pExtBarNew->SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_HIDEWINDOW
- );
- ASSERT_VALID( pExtBarNew->m_pDockBar );
- if( !pExtBarNew->m_pDockBar->m_bFloating
- && pExtBarNew->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar))
- )
- {
- hWndDockBarOld = pExtBarNew->m_pDockBar->GetSafeHwnd();
- ((CExtDockBar *)pExtBarNew->m_pDockBar)->RemoveControlBar( pExtBarNew );
- // optimized at final state with all circles
- // ((CExtDockBar *)pExtBarNew->m_pDockBar)->OnDynamicLayoutOptimize();
- }
- else
- pExtBarNew->m_pDockBar->RemoveControlBar( pExtBarNew );
- //ASSERT_VALID( pExtBarNew->m_pDockBar ); this may be already destroyed floating dockbar
- } // if( pExtBarNew->m_pDockBar != NULL )
- } // if( pExtBarNew->m_pDockBar != this )
- else
- {
- if( pExtBarDocked != pExtBarNew )
- {
- INT nPos = FindBar( pExtBarNew );
- ASSERT( nPos >= 0 && nPos < nCountOfSideBars );
- m_arrBars.RemoveAt( nPos );
- nCountOfSideBars --;
- ASSERT( nCountOfSideBars > 1 );
- if( ( nCountOfSideBars == nPos
- && m_arrBars[nPos-1] == NULL )
- ||
- ( nCountOfSideBars > nPos
- && m_arrBars[nPos-1] == NULL
- && m_arrBars[nPos] == NULL
- )
- )
- {
- // remove empty row
- m_arrBars.RemoveAt( nPos-1 );
- nCountOfSideBars --;
- }
- ASSERT_VALID( this );
- } // if( pExtBarDocked != pExtBarNew )
- else
- pRemoveBar = pExtBarNew;
- } // else from if( pExtBarNew->m_pDockBar != this )
- INT nIdxDockedBar = FindBar( pExtBarDocked );
- ASSERT( nIdxDockedBar >= 0 && nIdxDockedBar < nCountOfSideBars );
- INT nIncrement = bLessIndex ? -1 : 1;
- INT nIdx = 0;
- for( nIdx = nIdxDockedBar; true; nIdx += nIncrement )
- {
- CControlBar * pBar = (CControlBar *) m_arrBars[ nIdx ];
- if( nIdx == 0
- || nIdx == (nCountOfSideBars-1)
- || pBar == NULL
- )
- {
- ASSERT( m_arrBars[0] == NULL );
- m_arrBars.InsertAt( nIdx, pExtBarNew );
- m_arrBars.InsertAt( nIdx, (CControlBar *)NULL );
- ASSERT_VALID( this );
- break;
- }
- #ifdef _DEBUG
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- #endif // _DEBUG
- } // for( nIdx = nIdxDockedBar; true; nIdx += nIncrement )
- CDockBar * pOldDockBar = pExtBarNew->m_pDockBar;
- pExtBarNew->m_pDockBar = this;
- ASSERT_BAR_LOCATION_IN_ROW( this, pExtBarNew );
-
- ASSERT( pExtBarNew->m_pDockContext != NULL );
- pExtBarNew->m_pDockContext->m_uMRUDockID = GetDlgCtrlID();
- if( pRemoveBar != NULL )
- {
- INT nPos = FindBar( pRemoveBar, nIdx+1 );
- nCountOfSideBars = (INT)m_arrBars.GetSize();
- ASSERT( nPos >= 0 && nPos < nCountOfSideBars );
- m_arrBars.RemoveAt( nPos );
- nCountOfSideBars --;
- ASSERT( nCountOfSideBars > 1 );
- if( ( nCountOfSideBars == nPos
- && m_arrBars[nPos-1] == NULL )
- ||
- ( nCountOfSideBars > nPos
- && m_arrBars[nPos-1] == NULL
- && m_arrBars[nPos] == NULL
- )
- )
- {
- // remove empty row
- m_arrBars.RemoveAt( nPos-1 );
- // nCountOfSideBars --;
- }
- ASSERT_VALID( this );
- }
- if( bNewFloating && nNewDockBarGetDockedVisibleCount == 0 )
- {
- if( pOldDockBar->GetDockedCount() == 0 )
- pNewDockingFrameWnd->DestroyWindow();
- else
- pNewDockingFrameWnd->ShowWindow( SW_HIDE );
- }
- // else
- // pNewDockingFrameWnd->DelayRecalcLayout();
- // ASSERT( !pExtBarNew->IsWindowVisible() );
- pExtBarNew->SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_SHOWWINDOW|SWP_FRAMECHANGED
- );
- OnDynamicLayoutUpdate();
- if( hWndDockBarOld != NULL
- && hWndDockBarOld != GetSafeHwnd()
- && ::IsWindow(hWndDockBarOld)
- )
- {
- CWnd * pWndDockBar = FromHandlePermanent( hWndDockBarOld );
- if( pWndDockBar != NULL
- && pWndDockBar->GetSafeHwnd() == hWndDockBarOld
- )
- {
- ASSERT( pWndDockBar != this );
- ASSERT_KINDOF( CExtDockBar, pWndDockBar );
- ((CExtDockBar *)pWndDockBar)->OnDynamicLayoutUpdate();
- }
- }
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT_VALID( pFrame );
- if( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
- _OptimizeCircles();
- }
- void CExtDockBar::_InnerOuterDockControlBar(
- CControlBar * pBar,
- bool bInner
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- UINT nOwnID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- bool bDockAtStartIdx = false;
- if( nOwnID == AFX_IDW_DOCKBAR_RIGHT
- || nOwnID == AFX_IDW_DOCKBAR_BOTTOM
- )
- bDockAtStartIdx = true;
- if( !bInner )
- bDockAtStartIdx = false;
- if( pBar->m_pDockBar == this )
- {
- INT nCountOfBars = (INT)m_arrBars.GetSize();
- ASSERT( nCountOfBars > 2 );
- if( m_arrBars[1] == pBar )
- return;
- INT nBarPos = FindBar( pBar );
- ASSERT( nBarPos > 0 && nBarPos < nCountOfBars );
- m_arrBars.RemoveAt( nBarPos );
- nCountOfBars --;
- if( m_arrBars[nBarPos - 1] == NULL
- && m_arrBars[ nBarPos ] == NULL
- )
- {
- m_arrBars.RemoveAt( nBarPos );
- nCountOfBars --;
- }
- //ASSERT_VALID( this );
- if( bDockAtStartIdx )
- {
- m_arrBars.InsertAt( 1, pBar );
- nCountOfBars++;
- ASSERT( nCountOfBars == m_arrBars.GetSize() );
- if( nCountOfBars < 3 || m_arrBars[2] != NULL )
- m_arrBars.InsertAt( 2, (CControlBar *)NULL );
- ASSERT_VALID( this );
- } // if( bDockAtStartIdx )
- else
- {
- m_arrBars.InsertAt( nCountOfBars, (CControlBar *)NULL );
- m_arrBars.InsertAt( nCountOfBars, pBar );
- ASSERT_VALID( this );
- } // else from if( bDockAtStartIdx )
- } // if( pBar->m_pDockBar == this )
- else
- {
- CFrameWnd * pDockingFrameWnd = pBar->GetDockingFrame();
- INT nDockBarGetDockedVisibleCount = -1;
- BOOL bFloating = pBar->IsFloating();
- ASSERT( pBar->GetParent() != this );
- pBar->SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_HIDEWINDOW
- );
- pBar->SetParent( this );
- // align correctly and turn on all borders
- DWORD dwStyle = pBar->GetBarStyle();
- dwStyle &= ~(CBRS_ALIGN_ANY);
- dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY;
- if( m_bFloating )
- dwStyle |= CBRS_FLOATING;
- else
- dwStyle &= ~CBRS_FLOATING;
- pBar->SetBarStyle( dwStyle );
- ASSERT( pBar->m_pDockBar != this );
- if( pBar->IsWindowVisible() )
- pBar->SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_HIDEWINDOW
- );
- if( pBar->m_pDockBar != NULL )
- {
- ASSERT_VALID( pBar->m_pDockBar );
- ASSERT_KINDOF( CDockBar, pBar->m_pDockBar );
- if( !pBar->m_pDockBar->m_bFloating
- && pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar))
- )
- {
- ((CExtDockBar *)pBar->m_pDockBar)->RemoveControlBar( pBar );
- ((CExtDockBar *)pBar->m_pDockBar)->OnDynamicLayoutOptimize();
- }
- else
- pBar->m_pDockBar->RemoveControlBar( pBar );
- //ASSERT_VALID( pBar->m_pDockBar ); this may be already destroyed floating dockbar
- }
-
- //ASSERT_VALID( this );
- INT nCountOfBars = (INT)m_arrBars.GetSize();
- ASSERT( nCountOfBars > 0 );
- if( bDockAtStartIdx )
- {
- m_arrBars.InsertAt( 1, pBar );
- nCountOfBars++;
- if( nCountOfBars < 3 || m_arrBars[2] != NULL )
- m_arrBars.InsertAt( 2, (CControlBar *)NULL );
- ASSERT_VALID( this );
- } // if( bDockAtStartIdx )
- else
- {
- m_arrBars.InsertAt( nCountOfBars, (CControlBar *)NULL );
- m_arrBars.InsertAt( nCountOfBars, pBar );
- if( nCountOfBars > 1 // (+ v.2.24) - fixes initial mutual sizes in row/col problem
- && m_arrBars[nCountOfBars-1] == NULL
- )
- m_arrBars.RemoveAt( nCountOfBars-1, 1 );
- ASSERT_VALID( this );
- } // else from if( bDockAtStartIdx )
- CDockBar * pOldDockBar = pBar->m_pDockBar;
- pBar->m_pDockBar = this;
- ASSERT_BAR_LOCATION_IN_ROW( this, pBar );
-
- ASSERT( pBar->m_pDockContext != NULL );
- pBar->m_pDockContext->m_uMRUDockID = GetDlgCtrlID();
- if( bFloating && nDockBarGetDockedVisibleCount == 0 )
- {
- if( pOldDockBar->GetDockedCount() == 0 )
- pDockingFrameWnd->DestroyWindow();
- else
- pDockingFrameWnd->ShowWindow( SW_HIDE );
- }
- // else
- // pDockingFrameWnd->DelayRecalcLayout();
- // ASSERT( !pBar->IsWindowVisible() );
- pBar->SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE
- |SWP_SHOWWINDOW|SWP_FRAMECHANGED
- );
- ASSERT_VALID( this );
- } // else from if( pBar->m_pDockBar == this )
- _OptimizeCircles();
- }
- void CExtDockBar::_LockSequenceOptimization( bool bLock )
- {
- ASSERT_VALID( this );
- ASSERT_KINDOF( CExtDockBar, this );
- m_bLockedOptimize = bLock;
- }
- void CExtDockDynBar::_LockSequenceOptimization( bool bLock )
- {
- ASSERT_VALID( this );
- ASSERT_KINDOF( CExtDockDynBar, this );
- m_bLockedOptimize = bLock;
- CExtDynControlBar * pDynBar =
- STATIC_DOWNCAST(
- CExtDynControlBar,
- GetParent()
- );
- ASSERT( pDynBar->m_pWndDynDocker == this );
- ASSERT_VALID( pDynBar->m_pDockBar );
- if( pDynBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- ((CExtDockBar *)pDynBar->m_pDockBar)->_LockSequenceOptimization( bLock );
- }
- void CExtDockBar::DockControlBar(
- CControlBar * pBar,
- LPCRECT lpRect, // = NULL
- bool bSmoothMode, // = false
- bool bForceNoOptimize // = false
- )
- {
- ASSERT_VALID(this);
- ASSERT_VALID(pBar);
- ASSERT_KINDOF(CControlBar, pBar);
- CRect rectBar;
- pBar->GetWindowRect( &rectBar );
- if( pBar->m_pDockBar == this
- && (lpRect == NULL || rectBar == *lpRect)
- )
- return; // already docked and no change in position
- // set CBRS_FLOAT_MULTI style if docking bar has it
- if( m_bFloating && (pBar->m_dwDockStyle & CBRS_FLOAT_MULTI) )
- m_dwStyle |= CBRS_FLOAT_MULTI;
- m_dwStyle &= ~(CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC);
- m_dwStyle |= pBar->m_dwStyle & (CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC);
- if( ( m_dwStyle & CBRS_FLOAT_MULTI ) != 0 )
- {
- CString sTitle;
- pBar->GetWindowText( sTitle );
- AfxSetWindowText( m_hWnd, (LPCTSTR)sTitle );
- }
- // align correctly and turn on all borders
- DWORD dwStyle = pBar->GetBarStyle();
- dwStyle &= ~(CBRS_ALIGN_ANY);
- dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY;
- if( m_bFloating )
- dwStyle |= CBRS_FLOATING;
- else
- dwStyle &= ~CBRS_FLOATING;
- pBar->SetBarStyle(dwStyle);
- // hide first if changing to a new docking site to avoid flashing
- BOOL bShow = FALSE;
- if( pBar->m_pDockBar != this && pBar->IsWindowVisible() )
- {
- pBar->SetWindowPos(
- NULL,
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_HIDEWINDOW
- );
- bShow = TRUE;
- }
- int nPos = -1;
- if( lpRect != NULL )
- {
- // insert into appropriate row
- CRect rect(lpRect);
- ScreenToClient(&rect);
- CPoint ptMid(rect.left + rect.Width()/2, rect.top + rect.Height()/2);
- //nPos = Insert(pBar, rect, ptMid);
- nPos = CDockBar::Insert(pBar, rect, ptMid);
- ASSERT( nPos > 0 && nPos < (m_arrBars.GetSize()-1) );
- // adjust with the previous full-row-mode neiborhood
- // based on the fixed-style docking algorithm
- CControlBar * pBarNeiborhood =
- (CControlBar *)(m_arrBars[nPos-1]);
- if( pBarNeiborhood != NULL
- && (! (__PLACEHODLER_BAR_PTR(pBarNeiborhood)) )
- )
- {
- ASSERT_VALID( pBarNeiborhood );
- CExtControlBar * pExtBarNeiborhood =
- DYNAMIC_DOWNCAST( CExtControlBar, pBarNeiborhood );
- if( pExtBarNeiborhood != NULL
- && pExtBarNeiborhood->IsFixedDockStyle()
- && pExtBarNeiborhood->_GetFullRowMode()
- )
- m_arrBars.InsertAt( nPos++, (CControlBar *)NULL );
- }
- // adjust with the next full-row-mode neiborhood
- // based on the fixed-style docking algorithm
- pBarNeiborhood =
- (CControlBar *)(m_arrBars[nPos+1]);
- if( pBarNeiborhood != NULL
- && (! (__PLACEHODLER_BAR_PTR(pBarNeiborhood)) )
- )
- {
- ASSERT_VALID( pBarNeiborhood );
- CExtControlBar * pExtBarNeiborhood =
- DYNAMIC_DOWNCAST( CExtControlBar, pBarNeiborhood );
- if( pExtBarNeiborhood != NULL
- && pExtBarNeiborhood->IsFixedDockStyle()
- && pExtBarNeiborhood->_GetFullRowMode()
- )
- m_arrBars.InsertAt( nPos+1, (CControlBar *)NULL );
- }
- // position at requested position
- pBar->SetWindowPos(NULL, rect.left, rect.top, rect.Width(),
- rect.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS);
- }
- else
- {
- // always add on current row, then create new one
- m_arrBars.Add(pBar);
- m_arrBars.Add(NULL);
- // align off the edge initially
- pBar->SetWindowPos(
- NULL,
- -afxData.cxBorder2, -afxData.cyBorder2, 0, 0,
- SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS
- );
- }
- // attach it to the docking site
- if( pBar->GetParent() != this )
- {
- CExtControlBar * pExtBar = DYNAMIC_DOWNCAST( CExtControlBar, pBar );
- if( pExtBar != NULL
- && pExtBar->IsFixedMode()
- && pExtBar->IsFixedDockStyle()
- )
- {
- CFrameWnd * pFrame = pExtBar->GetParentFrame();
- ASSERT_VALID( pFrame );
- if( pFrame != pExtBar->m_pDockSite )
- {
- ASSERT_KINDOF( CMiniDockFrameWnd, pFrame );
- pFrame->ShowWindow( SW_HIDE );
- CExtPaintManager::stat_PassPaintMessages();
- } // if( pFrame != pBar->m_pDockSite )
- }
- pBar->SetParent(this);
- }
- if( pBar->m_pDockBar == this )
- RemoveControlBar(pBar, nPos);
- else if( pBar->m_pDockBar != NULL )
- {
- ASSERT_KINDOF( CDockBar, pBar->m_pDockBar );
- if( pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- {
- bool bOptimizeDockBarLayout = false;
- if( !((CExtDockBar *)(pBar->m_pDockBar))->m_bFloating )
- bOptimizeDockBarLayout = true;
- ((CExtDockBar *)(pBar->m_pDockBar))->RemoveControlBar( pBar, -1, m_bFloating && (!pBar->m_pDockBar->m_bFloating), false );
- ASSERT_VALID( this );
- if( bOptimizeDockBarLayout && (!bForceNoOptimize) && ( IsKindOf(RUNTIME_CLASS(CExtDockBar)) && (! m_bLockedOptimize ) ) )
- ((CExtDockBar *)(pBar->m_pDockBar))->OnDynamicLayoutOptimize();
- }
- else
- {
- pBar->m_pDockBar->RemoveControlBar( pBar, 0, m_bFloating && (!pBar->m_pDockBar->m_bFloating) );
- ASSERT_VALID( this );
- }
- }
- pBar->m_pDockBar = this;
- if( bShow )
- {
- ASSERT(!pBar->IsWindowVisible());
- pBar->SetWindowPos(
- NULL,
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW
- );
- }
- else if( bSmoothMode && lpRect != NULL )
- {
- CRect rcSmooth( *lpRect );
- ScreenToClient( &rcSmooth );
- pBar->SetWindowPos(
- NULL,
- rcSmooth.left, rcSmooth.top,
- rcSmooth.Width(), rcSmooth.Height(),
- SWP_NOZORDER|SWP_NOACTIVATE
- ////|SWP_NOSENDCHANGING
- |SWP_NOREDRAW
- );
- } // else if( bSmoothMode && lpRect != NULL )
- // remove any place holder for pBar in this dockbar
- if( (! m_bFloating ) )
- RemovePlaceHolder( pBar, true );
- ASSERT_VALID( this );
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && ((CExtControlBar*)pBar)->_GetFullRowMode()
- )
- {
- nPos = FindBar( pBar );
- ASSERT( nPos > 0 && nPos < (m_arrBars.GetSize()-1) );
- if( m_arrBars[nPos+1] == NULL )
- {
- if( m_arrBars[nPos-1] != NULL )
- {
- m_arrBars.InsertAt( nPos, (CControlBar *)NULL );
- ASSERT_VALID( this );
- }
- } // if( m_arrBars[nPos+1] == NULL )
- else
- {
- if( m_arrBars[nPos-1] == NULL )
- {
- m_arrBars.InsertAt( nPos+1, (CControlBar *)NULL );
- ASSERT_VALID( this );
- }
- else
- {
- int nPos2 = nPos-1;
- for( ; m_arrBars[nPos2] != NULL; nPos2-- );
- ASSERT( nPos2 >= 0 );
- m_arrBars.RemoveAt( nPos );
- m_arrBars.InsertAt( nPos2, pBar );
- m_arrBars.InsertAt( nPos2, (CControlBar *)NULL );
- ASSERT_VALID( this );
- }
- } // else from if( m_arrBars[nPos+1] == NULL )
- }
- // get parent frame for recalc layout
- CFrameWnd* pFrameWnd = GetDockingFrame();
- pFrameWnd->DelayRecalcLayout();
- // OPTFIX:
- // if( (!bForceNoOptimize) && (! pFrameWnd->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) ) )
- // _OptimizeCircles();
- }
- void CExtDockBar::DrawBorders(CDC* pDC, CRect& rect)
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDC );
- CExtPaintManager::PAINTCONTROLBARBORDERSDATA _pcbbd(
- this,
- CExtPaintManager::__CB_OUTER_DOCKBAR,
- m_dwStyle, // |CBRS_BORDER_ANY|CBRS_BORDER_3D
- rect
- );
- PmBridge_GetPM()->PaintControlBarBorders( *pDC, _pcbbd );
- }
- void CExtDockBar::DrawGripper(CDC* pDC, const CRect& rect)
- {
- ASSERT_VALID( this );
- pDC,
- rect;
- }
- LRESULT CExtDockBar::OnSizeParent(WPARAM wParam, LPARAM lParam)
- {
- ASSERT_VALID( this );
- wParam;
- // if( CExtControlBar::g_bUpdatingDragState )
- // return 0;
- if( m_bLockedOptimize )
- return 0;
- LRESULT lResult = 0L;
- AFX_SIZEPARENTPARAMS * lpLayout =
- (AFX_SIZEPARENTPARAMS *) lParam;
- ASSERT( lpLayout != NULL );
- BOOL bLayoutQuery = m_bLayoutQuery;
- CRect rectLayout = m_rectLayout;
- m_bLayoutQuery = (lpLayout->hDWP == NULL);
- m_rectLayout = lpLayout->rect;
- DWORD dwStyle = RecalcDelayShow( lpLayout );
- if( ( (dwStyle&WS_VISIBLE) != 0 )
- && ( (dwStyle&CBRS_ALIGN_ANY) != 0 )
- )
- {
- CRect rect = lpLayout->rect;
- CSize sizeAvail = rect.Size();
- DWORD dwMode = lpLayout->bStretch ? LM_STRETCH : 0;
- if( ( (m_dwStyle&CBRS_SIZE_DYNAMIC) != 0 )
- && ( (m_dwStyle&CBRS_FLOATING ) != 0 )
- )
- dwMode |= LM_HORZ|LM_MRUWIDTH;
- else if( (dwStyle&CBRS_ORIENT_HORZ) != 0 )
- dwMode |= LM_HORZ|LM_HORZDOCK;
- else
- dwMode |= LM_VERTDOCK;
- CSize size = CalcDynamicLayout( -1, dwMode );
- size.cx = min( size.cx, sizeAvail.cx );
- size.cy = min( size.cy, sizeAvail.cy );
- if( (dwStyle&CBRS_ORIENT_HORZ) != 0 )
- {
- lpLayout->sizeTotal.cy += size.cy;
- lpLayout->sizeTotal.cx = max( lpLayout->sizeTotal.cx, size.cx );
- if( (dwStyle&CBRS_ALIGN_TOP) != 0 )
- lpLayout->rect.top += size.cy;
- else if( (dwStyle&CBRS_ALIGN_BOTTOM) != 0 )
- {
- rect.top = rect.bottom - size.cy;
- lpLayout->rect.bottom -= size.cy;
- }
- }
- else if( (dwStyle&CBRS_ORIENT_VERT) != 0 )
- {
- lpLayout->sizeTotal.cx += size.cx;
- lpLayout->sizeTotal.cy = max( lpLayout->sizeTotal.cy, size.cy );
- HWND hWndParent = ::GetParent( m_hWnd );
- ASSERT( hWndParent != NULL && ::IsWindow(hWndParent) );
- __EXT_MFC_LONG_PTR dwStyleEx = ::__EXT_MFC_GetWindowLong( hWndParent, GWL_EXSTYLE );
- bool bParentRTL = ( (dwStyleEx&WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- if( bParentRTL )
- {
- if( (dwStyle&CBRS_ALIGN_RIGHT) != 0 )
- lpLayout->rect.left += size.cx;
- else if( (dwStyle&CBRS_ALIGN_LEFT) != 0 )
- {
- rect.left = rect.right - size.cx;
- lpLayout->rect.right -= size.cx;
- }
- } // if( bParentRTL )
- else
- {
- if( (dwStyle&CBRS_ALIGN_LEFT) != 0 )
- lpLayout->rect.left += size.cx;
- else if( (dwStyle&CBRS_ALIGN_RIGHT) != 0 )
- {
- rect.left = rect.right - size.cx;
- lpLayout->rect.right -= size.cx;
- }
- } // else from if( bParentRTL )
- }
- #ifdef _DEBUG
- else
- {
- ASSERT(FALSE);
- }
- #endif // _DEBUG
- rect.right = rect.left + size.cx;
- rect.bottom = rect.top + size.cy;
- if( lpLayout->hDWP != NULL )
- AfxRepositionWindow( lpLayout, m_hWnd, &rect );
- }
- m_bLayoutQuery = bLayoutQuery;
- m_rectLayout = rectLayout;
- if( (m_dwStyle & CBRS_ALIGN_ANY) == 0 )
- return lResult;
- UINT nOwnID = GetDlgCtrlID();
- if( nOwnID == AFX_IDW_DOCKBAR_FLOAT )
- return lResult;
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- if( lpLayout->hDWP != NULL )
- Invalidate();
- m_rcLastInvisiblePreCalc = lpLayout->rect;
- if( nOwnID == AFX_IDW_DOCKBAR_LEFT
- || nOwnID == AFX_IDW_DOCKBAR_RIGHT
- )
- {
- HWND hWndParent = ::GetParent( m_hWnd );
- ASSERT( hWndParent != NULL && ::IsWindow(hWndParent) );
- __EXT_MFC_LONG_PTR dwStyleEx = ::__EXT_MFC_GetWindowLong( hWndParent, GWL_EXSTYLE );
- bool bParentRTL = ( (dwStyleEx&WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- if( bParentRTL )
- {
- if( nOwnID == AFX_IDW_DOCKBAR_LEFT )
- nOwnID = AFX_IDW_DOCKBAR_RIGHT;
- else
- nOwnID = AFX_IDW_DOCKBAR_LEFT;
- } // if( bParentRTL )
- }
- switch( nOwnID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- m_rcLastInvisiblePreCalc.bottom = m_rcLastInvisiblePreCalc.top;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- m_rcLastInvisiblePreCalc.top = m_rcLastInvisiblePreCalc.bottom;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- m_rcLastInvisiblePreCalc.right = m_rcLastInvisiblePreCalc.left;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- m_rcLastInvisiblePreCalc.left = m_rcLastInvisiblePreCalc.right;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nOwnID )
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- ASSERT_KINDOF( CFrameWnd, pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- pFrame->ClientToScreen( &m_rcLastInvisiblePreCalc );
- return lResult;
- }
- BOOL CExtDockBar::RemoveControlBar(
- CControlBar * pBar,
- int nPosExclude, // -1
- int nAddPlaceHolder, // = 0
- bool bEnableFrameDelayRecalcLayout // = true
- )
- {
- //ph//
- // temp
- if( pBar->IsKindOf( RUNTIME_CLASS(CExtControlBar) )
- && (! ((CExtControlBar*)pBar)->IsFixedDockStyle() )
- )
- nAddPlaceHolder = 0;
- ASSERT_VALID( this );
- ASSERT(
- nAddPlaceHolder == 1
- || nAddPlaceHolder == 0
- || nAddPlaceHolder == -1
- );
- ASSERT_VALID( this );
- ASSERT( pBar != NULL );
- int nPos = FindBar( pBar, nPosExclude );
- ASSERT( nPos > 0 );
- if( nAddPlaceHolder == 1 )
- {
- m_arrBars[ nPos ] = (void*) (__EXT_MFC_UINT_PTR)
- _AfxGetDlgCtrlID( pBar->m_hWnd );
- // check for already existing place holder
- int nPosOld =
- FindBar(
- (CControlBar *) m_arrBars[ nPos ],
- nPos
- );
- if( nPosOld > 0 )
- {
- m_arrBars.RemoveAt( nPos );
- // remove section indicator (NULL) if nothing
- // else in section
- if( m_arrBars[ nPos - 1 ] == NULL
- && m_arrBars[ nPos ] == NULL
- )
- m_arrBars.RemoveAt( nPos );
- } // if( nPosOld > 0 )
- } // if( nAddPlaceHolder == 1 )
- else
- {
- m_arrBars.RemoveAt( nPos );
- if( m_arrBars[nPos-1] == NULL
- && m_arrBars[nPos] == NULL
- )
- m_arrBars.RemoveAt( nPos );
- // Remove any pre-existing place holders.
- if( nAddPlaceHolder != -1 )
- RemovePlaceHolder( pBar, true );
- } // else from if( nAddPlaceHolder == 1 )
- // don't do anything more in the shutdown case!
- if( pBar->m_pDockContext == NULL )
- return FALSE;
- // get parent frame for recalc layout/frame destroy
- CFrameWnd * pFrameWnd = GetDockingFrame();
- if( m_bFloating && GetDockedVisibleCount() == 0 )
- {
- if( GetDockedCount() == 0 )
- {
- pFrameWnd->DestroyWindow();
- return TRUE; // Self-Destruct
- }
- else
- pFrameWnd->ShowWindow( SW_HIDE );
- } // if( m_bFloating && GetDockedVisibleCount() == 0 )
- else
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( IsKindOf(RUNTIME_CLASS(CExtDockDynTabBar)) )
- {
- CExtDynTabControlBar * pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynTabControlBar,
- GetParent()
- );
- //pTabbedBar->SyncSwitcher();
- pTabbedBar->OnRepositionSingleChild();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( bEnableFrameDelayRecalcLayout )
- pFrameWnd->DelayRecalcLayout();
- } // else from if( m_bFloating && GetDockedVisibleCount() == 0 )
- return TRUE;
- }
- int CExtDockBar::Insert(
- CControlBar * pBarIns,
- CRect rect,
- CPoint ptMid
- )
- {
- return _InsertByPointImpl( pBarIns, rect, ptMid );
- }
- int CExtDockBar::_InsertByPointImpl(
- CControlBar * pBarIns,
- CRect rect,
- CPoint ptMid
- )
- {
- ASSERT_VALID( this );
- ASSERT( pBarIns != NULL );
-
- // ASSERT( pBarIns->m_pDockBar == this );
- BOOL bExtBar = pBarIns->IsKindOf(RUNTIME_CLASS(CExtControlBar));
- BOOL bExtFixedBar = FALSE;
- if( bExtBar )
- bExtFixedBar = ((CExtControlBar *)pBarIns)->IsFixedMode();
- BOOL bFixedBar = !bExtBar || bExtFixedBar;
- INT nPos = 0, nPosInsAfter = -1, nWidth = 0, nTotalWidth = 0;
- INT nCountOfSideBars = (INT)m_arrBars.GetSize();
- BOOL bHorz = m_dwStyle & CBRS_ORIENT_HORZ;
- CRect rcDockBarWnd;
- GetWindowRect( &rcDockBarWnd );
- if( rcDockBarWnd.PtInRect(ptMid) )
- {
- for( ; nPos < nCountOfSideBars; nPos++ )
- {
- CControlBar * pBar = GetDockedControlBar( nPos );
- if( pBar != NULL && pBar->IsVisible() )
- {
- CRect rcBar;
- pBar->GetWindowRect( &rcBar );
- //ScreenToClient( &rcBar );
- nWidth =
- max(
- nWidth,
- bHorz ? rcBar.Size().cy : rcBar.Size().cx - 1
- );
- if( bHorz
- ? ( rect.left > rcBar.left )
- : ( rect.top > rcBar.top )
- )
- {
- //nPosInsAfter = nPos; // orig
- if( bFixedBar )
- {
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- nPosInsAfter = nPos;
- else if(
- ((CExtControlBar *)pBar)->IsFixedMode()
- )
- nPosInsAfter = nPos;
- }
- else
- nPosInsAfter = nPos;
- }
- if( bFixedBar
- && rcBar.PtInRect( ptMid )
- )
- {
- INT nDistUp = 0, nDistDown = 0;
- if( bHorz )
- {
- nDistUp = ptMid.y - rcBar.top;
- nDistDown = rcBar.bottom - ptMid.y;
- } // if( bHorz )
- else
- {
- nDistUp = ptMid.x - rcBar.left;
- nDistDown = rcBar.right - ptMid.x;
- } // else from if( bHorz )
- bool bNextRow = ( nDistUp < nDistDown ) ? false : true;
- CControlBar * pFirstBar =
- CExtControlBar::_GetFirstControlBarInRow(
- pBar,
- bNextRow
- );
- ASSERT_VALID( pFirstBar );
- nPosInsAfter = FindBar( pFirstBar );
- ASSERT( nPosInsAfter > 0 && nPosInsAfter < nCountOfSideBars );
- if( bNextRow )
- {
- m_arrBars.InsertAt( nPosInsAfter+1, pBarIns );
- m_arrBars.InsertAt( nPosInsAfter+1, (CObject*)NULL );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return nPosInsAfter+2;
- }
- else
- {
- m_arrBars.InsertAt( nPosInsAfter, (CObject*)NULL );
- m_arrBars.InsertAt( nPosInsAfter, pBarIns );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return nPosInsAfter+1;
- }
- // if( !bNextRow )
- /// nPosInsAfter --;
- // break;
- }
- } // if( pBar != NULL && pBar->IsVisible() )
- else
- {
- if( pBar != NULL )
- continue;
- // end of row because pBar == NULL
- nTotalWidth += nWidth - afxData.cyBorder2;
- nWidth = 0;
- if( (bHorz ? ptMid.y : ptMid.x) < nTotalWidth )
- {
- if( nPos == 0 ) // first section
- {
- m_arrBars.InsertAt( 1, (CObject*)NULL );
- m_arrBars.InsertAt( 1, pBarIns );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return 1;
- } // if( nPos == 0 )
- else
- {
- if( !bFixedBar )
- {
- m_arrBars.InsertAt( nPos, pBarIns );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- }
- //if( nPosInsAfter < 0 || !bFixedBar )
- if( nPosInsAfter < 0 )
- break;
- ASSERT( nPosInsAfter >= 0 && nPosInsAfter <= nCountOfSideBars );
- CControlBar * pBar2 = (CControlBar *)m_arrBars[ nPosInsAfter ];
- if( pBar2 == NULL )
- break;
- if( __PLACEHODLER_BAR_PTR(pBar2) )
- break;
- CRect rcBar2;
- pBar2->GetWindowRect( &rcBar2 );
- INT nDistUp = 0, nDistDown = 0;
- if( bHorz )
- {
- nDistUp = ptMid.y - rcBar2.top;
- nDistDown = rcBar2.bottom - ptMid.y;
- } // if( bHorz )
- else
- {
- nDistUp = ptMid.x - rcBar2.left;
- nDistDown = rcBar2.right - ptMid.x;
- } // else from if( bHorz )
- bool bNextRow = ( nDistUp < nDistDown ) ? false : true;
- CControlBar * pFirstBar =
- CExtControlBar::_GetFirstControlBarInRow(
- pBar2,
- bNextRow
- );
- ASSERT_VALID( pFirstBar );
- nPosInsAfter = FindBar( pFirstBar );
- ASSERT( nPosInsAfter > 0 && nPosInsAfter < nCountOfSideBars );
- if( bNextRow )
- {
- m_arrBars.InsertAt( nPosInsAfter+1, pBarIns );
- m_arrBars.InsertAt( nPosInsAfter+1, (CObject*)NULL );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return nPosInsAfter+2;
- }
- else
- {
- m_arrBars.InsertAt( nPosInsAfter, (CObject*)NULL );
- m_arrBars.InsertAt( nPosInsAfter, pBarIns );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return nPosInsAfter+1;
- }
- } // else from if( nPos == 0 )
- }
- // nPosInsAfter = nPos;
- } // else from if( pBar != NULL && pBar->IsVisible() )
- } // for( ; nPos < nCountOfSideBars; nPos++ )
- } // if( rcDockBarWnd.PtInRect(ptMid) )
- if( nPosInsAfter < 0 )
- {
- INT nDistUp = 0, nDistDown = 0;
- if( bHorz )
- {
- nDistUp = ptMid.y - rcDockBarWnd.top;
- nDistDown = rcDockBarWnd.bottom - ptMid.y;
- } // if( bHorz )
- else
- {
- nDistUp = ptMid.x - rcDockBarWnd.left;
- nDistDown = rcDockBarWnd.right - ptMid.x;
- } // else from if( bHorz )
- bool bNextRow =
- ( abs(nDistUp) < abs(nDistDown) )
- ? false : true;
- nPosInsAfter = bNextRow ? (nCountOfSideBars-1) : 1;
- }
- ASSERT( nPosInsAfter < nCountOfSideBars );
- if( nPosInsAfter == nCountOfSideBars-1 )
- m_arrBars.InsertAt( nCountOfSideBars, (CObject*)NULL ); // upper bound NULL
- if( m_arrBars[ nPosInsAfter ] != NULL )
- {
- if( nPosInsAfter+1 < nCountOfSideBars
- && m_arrBars[nPosInsAfter+1] != NULL
- )
- m_arrBars.InsertAt( nPosInsAfter+1, (CObject*)NULL );
- }
- m_arrBars.InsertAt( nPosInsAfter+1, pBarIns );
- for( nPos = nPosInsAfter; nPos > 0; nPos-- )
- {
- CControlBar * pBar = (CControlBar *)m_arrBars[nPos];
- if( pBar == NULL )
- break;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- {
- pBar = _GetDockingFrameImpl()->GetControlBar( LOWORD( DWORD( (__EXT_MFC_DWORD_PTR) pBar ) ) );
- if( pBar == NULL )
- continue;
- }
-
- BOOL bPrevFixedCheck = TRUE;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && !((CExtControlBar *)pBar)->IsFixedMode()
- )
- bPrevFixedCheck = FALSE;
- if( bFixedBar != bPrevFixedCheck )
- {
- m_arrBars.InsertAt( nPosInsAfter+1, (CObject*)NULL );
- nPosInsAfter++;
- }
- break;
- } // for( INT nPos = nPosInsAfter; nPos > 0; nPos-- )
-
- // ASSERT( FindBar(pBarIns) == (nPosInsAfter+1) );
- ASSERT_VALID( this );
- ASSERT_BAR_LOCATION_IN_ROW( this, pBarIns );
- return nPosInsAfter+1;
- }
- #ifdef _DEBUG
- void CExtDockBar::_AssertValid_CheckBarRows() const
- {
- ASSERT( this != NULL );
- if( m_hWnd == NULL )
- return;
- if( ! ::IsWindow(m_hWnd) )
- return;
- CRect rcMyWnd;
- GetWindowRect( &rcMyWnd );
- CSize sizeMyWnd = rcMyWnd.Size();
- if( sizeMyWnd.cx < 40 || sizeMyWnd.cy < 40 )
- return;
- INT nCountOfSideBars = (INT)m_arrBars.GetSize();
- ASSERT( nCountOfSideBars >= 0 );
- if( nCountOfSideBars > 0 )
- {
- // first should be NULL
- CControlBar * pFirstPosBar = (CControlBar *) m_arrBars[ 0 ];
- ASSERT( pFirstPosBar == NULL );
- if( m_nCircleNo == 0 )
- return;
- // walk all rows and verify no empty rows
- INT nRowEntryCount = 0; // including placeholders
- INT nBar = 1;
- if( nCountOfSideBars > 2 )
- {
- for( ; nBar < nCountOfSideBars; nBar++ )
- {
- CControlBar * pBar = (CControlBar *) m_arrBars[ nBar ];
- if( pBar == NULL )
- {
- ASSERT( nRowEntryCount > 0 );
- nRowEntryCount = 0;
- continue;
- }
- nRowEntryCount++;
- } // for( ; nBar < nCountOfSideBars; nBar++ )
- }
- }
- }
- void CExtDockBar::_AssertValid_FixedBarNotInNonfixedRow(
- CDockBar * pDockBar,
- CControlBar * pBar
- )
- {
- // verify bar and its dockbar
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar->m_pDockBar );
- ASSERT( !pBar->IsDockBar() );
- ASSERT( !pBar->IsKindOf(RUNTIME_CLASS(CDockBar)) );
- // ASSERT( !pBar->IsFloating() );
-
- // ASSERT( pBar->m_pDockBar != NULL );
- // ASSERT_VALID( pBar->m_pDockBar );
- // ASSERT_KINDOF( CExtDockBar, pBar->m_pDockBar );
- //CExtDockBar * pDockBar = (CExtDockBar *)pBar->m_pDockBar;
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CDockBar, pDockBar );
- bool bCheckingFixedBar = true;
- // verify bar is not a kind of resizable bar
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- CExtControlBar * pExtBar = (CExtControlBar *)pBar;
- if( !pExtBar->IsFixedDockStyle() )
- bCheckingFixedBar = false;
- }
- INT nCountOfSideBars = (INT)pDockBar->m_arrBars.GetSize();
- ASSERT( nCountOfSideBars > 0 );
- INT nBarPosInDockBar = pDockBar->FindBar( pBar );
- ASSERT( nBarPosInDockBar > 0 && nBarPosInDockBar < nCountOfSideBars );
- // walk to begin of row
- INT nBar = nBarPosInDockBar-1;
- for( ; nBar > 0; nBar-- )
- {
- CControlBar * pBarExamine = (CControlBar *)
- pDockBar->m_arrBars[ nBar ];
- if( pBarExamine == NULL )
- break; // ok
- if( __PLACEHODLER_BAR_PTR(pBarExamine) )
- continue;
- ASSERT_VALID( pBarExamine );
- ASSERT_KINDOF( CControlBar, pBarExamine );
- ASSERT( pBarExamine->m_pDockBar == pDockBar );
-
- bool bFixedBar = true;
- if( pBarExamine->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- CExtControlBar * pExtBar = (CExtControlBar *)pBarExamine;
- //ASSERT( pExtBar->IsFixedMode() );
- if( !pExtBar->IsFixedDockStyle() )
- bFixedBar = false;
- }
- ASSERT( bCheckingFixedBar == bFixedBar );
- }
-
- // walk to end of row
- for( nBar = nBarPosInDockBar+1; nBar < nCountOfSideBars; nBar++ )
- {
- CControlBar * pBarExamine = (CControlBar *)
- pDockBar->m_arrBars[ nBar ];
- if( pBarExamine == NULL )
- break; // ok
- if( __PLACEHODLER_BAR_PTR(pBarExamine) )
- continue;
- ASSERT_VALID( pBarExamine );
- ASSERT_KINDOF( CControlBar, pBarExamine );
- ASSERT( pBarExamine->m_pDockBar == pDockBar );
- bool bFixedBar = true;
- if( pBarExamine->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- CExtControlBar * pExtBar = (CExtControlBar *)pBarExamine;
- //ASSERT( pExtBar->IsFixedMode() );
- if( !pExtBar->IsFixedDockStyle() )
- bFixedBar = false;
- }
- ASSERT( bCheckingFixedBar == bFixedBar );
- }
-
- }
- #endif // _DEBUG
- void CExtDockBar::OnNcCalcSize(
- BOOL bCalcValidRects,
- NCCALCSIZE_PARAMS * lpncsp
- )
- {
- ASSERT_VALID( this );
- bCalcValidRects;
- lpncsp;
- #if (defined __DEBUG_PAINTING_AREAS_DOCKBAR__ )
- CRect & rcClientLoc =
- reinterpret_cast < CRect & > ( lpncsp->rgrc[0] );
- rcClientLoc.DeflateRect( 0, 0, 1, 1 );
- #endif // __DEBUG_PAINTING_AREAS_DOCKBAR__
- }
- void CExtDockBar::OnNcPaint()
- {
- ASSERT_VALID( this );
- #if (defined __DEBUG_PAINTING_AREAS_DOCKBAR__ )
- CRect rcBarWnd, rcBarClient;
- GetWindowRect( &rcBarWnd );
- GetClientRect( &rcBarClient );
- ClientToScreen( &rcBarClient );
- if( rcBarWnd == rcBarClient )
- return;
- CPoint ptDevOffset = -rcBarWnd.TopLeft();
- rcBarWnd.OffsetRect( ptDevOffset );
- rcBarClient.OffsetRect( ptDevOffset );
- CWindowDC dcBarWnd( this );
- ASSERT( dcBarWnd.GetSafeHdc() != NULL );
- dcBarWnd.ExcludeClipRect( &rcBarClient );
- BOOL bDynamicDockBar = IsKindOf( RUNTIME_CLASS(CExtDockDynBar) );
- COLORREF clrDebugMargin = bDynamicDockBar
- ? RGB( 255, 255, 0 )
- : RGB( 255, 0, 255 );
- dcBarWnd.FillSolidRect( &rcBarWnd, clrDebugMargin );
- #endif // __DEBUG_PAINTING_AREAS_DOCKBAR__
- }
- CExtDockBar * CExtDockBar::_GetInCircle(
- UINT nDockBarID,
- bool bEnableCreateNew // = true
- )
- {
- ASSERT_VALID( this );
- UINT nOwnID = GetDlgCtrlID();
- if( nDockBarID == nOwnID )
- return this;
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- return
- _GetInCircle(
- pFrame,
- m_nCircleNo,
- nDockBarID,
- bEnableCreateNew
- );
- }
- CExtDockBar * CExtDockBar::_GetInCircle(
- CFrameWnd * pFrame,
- UINT nCircleNo,
- UINT nDockBarID,
- bool bEnableCreateNew // = true
- )
- {
- ASSERT_VALID( pFrame );
- POSITION pos = pFrame->m_listControlBars.GetHeadPosition();
- ASSERT( pos != NULL );
- while( pos != NULL )
- {
- CControlBar * pBar = (CControlBar *)
- pFrame->m_listControlBars.GetNext( pos );
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- continue;
- UINT nID = pBar->GetDlgCtrlID();
- if( nID != nDockBarID )
- continue;
- UINT nCircleNo2 = ((CExtDockBar *)pBar)->_GetCircleNo();
- if( nCircleNo == nCircleNo2 )
- return ((CExtDockBar *)pBar);
- } // while( pos != NULL )
- if( !bEnableCreateNew )
- return NULL;
- _CreateInnerCircle( pFrame );
- CExtDockBar * pDockBar =
- _GetInCircle(
- pFrame,
- nCircleNo,
- nDockBarID,
- bEnableCreateNew
- );
- ASSERT_VALID( pDockBar );
- return pDockBar;
- }
- UINT CExtDockBar::_CreateInnerCircle()
- {
- ASSERT_VALID( this );
- if( _GetDockBarInner() != NULL )
- {
- ASSERT_VALID( _GetDockBarInner() );
- return ( _GetCircleNo() + 1 );
- }
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- return _CreateInnerCircle( pFrame );
- }
- UINT CExtDockBar::_CreateInnerCircle( CFrameWnd * pFrame )
- {
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- UINT nCircleNo = 0;
- CExtDockBar * vInnerCircle[4] = { NULL, NULL, NULL, NULL };
- CExtDockBar * vCreatingCircle[4] = { NULL, NULL, NULL, NULL };
- POSITION pos = pFrame->m_listControlBars.GetHeadPosition();
- ASSERT( pos != NULL );
- while( pos != NULL )
- {
- CControlBar * pBar = (CControlBar *)
- pFrame->m_listControlBars.GetNext( pos );
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CControlBar, pBar );
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- continue;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar)) )
- continue;
- UINT nCircleNo2 = ((CExtDockBar *)pBar)->_GetCircleNo();
- if( nCircleNo2 < nCircleNo )
- continue;
- nCircleNo = nCircleNo2;
- UINT nID = pBar->GetDlgCtrlID();
- //if( nID == AFX_IDW_DOCKBAR_FLOAT )
- // continue;
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nID );
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- vInnerCircle[0] = ((CExtDockBar *)pBar);
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- vInnerCircle[1] = ((CExtDockBar *)pBar);
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- vInnerCircle[2] = ((CExtDockBar *)pBar);
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- vInnerCircle[3] = ((CExtDockBar *)pBar);
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nID )
- } // while( pos != NULL )
- ASSERT( vInnerCircle[0] != NULL );
- ASSERT( vInnerCircle[1] != NULL );
- ASSERT( vInnerCircle[2] != NULL );
- ASSERT( vInnerCircle[3] != NULL );
- #ifdef _DEBUG
- if( vInnerCircle[0]->m_pDockBarInner == NULL )
- {
- ASSERT( vInnerCircle[1]->m_pDockBarInner == NULL );
- ASSERT( vInnerCircle[2]->m_pDockBarInner == NULL );
- ASSERT( vInnerCircle[3]->m_pDockBarInner == NULL );
- }
- else
- {
- ASSERT( vInnerCircle[1]->m_pDockBarInner != NULL );
- ASSERT( vInnerCircle[2]->m_pDockBarInner != NULL );
- ASSERT( vInnerCircle[3]->m_pDockBarInner != NULL );
- }
- if( vInnerCircle[0]->m_pDockBarOuter == NULL )
- {
- ASSERT( vInnerCircle[1]->m_pDockBarOuter == NULL );
- ASSERT( vInnerCircle[2]->m_pDockBarOuter == NULL );
- ASSERT( vInnerCircle[3]->m_pDockBarOuter == NULL );
- }
- else
- {
- ASSERT( vInnerCircle[1]->m_pDockBarOuter != NULL );
- ASSERT( vInnerCircle[2]->m_pDockBarOuter != NULL );
- ASSERT( vInnerCircle[3]->m_pDockBarOuter != NULL );
- }
- #endif // _DEBUG
- nCircleNo ++;
- for( INT i = 0; i<4; i++ )
- {
- CExtDockBar * pBar = vInnerCircle[i];
- UINT nID = pBar->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nID );
- ASSERT( vCreatingCircle[i] == NULL );
- vCreatingCircle[i] =
- new CExtDockBar( nCircleNo );
- static const DWORD dwAlignFlags[4] =
- {
- CBRS_ALIGN_TOP,
- CBRS_ALIGN_BOTTOM,
- CBRS_ALIGN_LEFT,
- CBRS_ALIGN_RIGHT
- };
- DWORD dwStyle =
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN
- |dwAlignFlags[i] // |CBRS_ALIGN_ANY
- ;
- VERIFY(
- vCreatingCircle[i]->Create( pFrame, dwStyle, nID )
- );
- ASSERT( pBar->m_pDockBarInner == NULL );
- ASSERT( vCreatingCircle[i]->m_pDockBarInner == NULL );
- ASSERT( vCreatingCircle[i]->m_pDockBarOuter == NULL );
- pBar->m_pDockBarInner = vCreatingCircle[i];
- vCreatingCircle[i]->m_pDockBarOuter = pBar;
- vCreatingCircle[i]->SetBarStyle( pBar->GetBarStyle() );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- vCreatingCircle[i]->m_pWndAutoHideArea =
- pBar->m_pWndAutoHideArea;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
-
-
- if( (pBar->GetStyle() & WS_VISIBLE) != NULL
- && pBar->GetDockedVisibleCount() != 0
- )
- {
- pBar->GetWindowRect( &vCreatingCircle[i]->m_rcLastInvisiblePreCalc );
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- ASSERT( vCreatingCircle[i]->m_rcLastInvisiblePreCalc.left <= vCreatingCircle[i]->m_rcLastInvisiblePreCalc.right );
- vCreatingCircle[i]->m_rcLastInvisiblePreCalc.bottom = vCreatingCircle[i]->m_rcLastInvisiblePreCalc.top; // + 1;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- ASSERT( vCreatingCircle[i]->m_rcLastInvisiblePreCalc.left <= vCreatingCircle[i]->m_rcLastInvisiblePreCalc.right );
- vCreatingCircle[i]->m_rcLastInvisiblePreCalc.top = vCreatingCircle[i]->m_rcLastInvisiblePreCalc.bottom; // - 1;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- ASSERT( vCreatingCircle[i]->m_rcLastInvisiblePreCalc.top <= vCreatingCircle[i]->m_rcLastInvisiblePreCalc.bottom );
- vCreatingCircle[i]->m_rcLastInvisiblePreCalc.right = vCreatingCircle[i]->m_rcLastInvisiblePreCalc.left; // + 1;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- ASSERT( vCreatingCircle[i]->m_rcLastInvisiblePreCalc.top <= vCreatingCircle[i]->m_rcLastInvisiblePreCalc.bottom );
- vCreatingCircle[i]->m_rcLastInvisiblePreCalc.left = vCreatingCircle[i]->m_rcLastInvisiblePreCalc.right; // - 1;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nID )
- } // if( (pBar->GetStyle()&WS_VISIBLE) != NULL .....
- else
- vCreatingCircle[i]->m_rcLastInvisiblePreCalc = pBar->m_rcLastInvisiblePreCalc;
- // reposition created circle in parent HWND list
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- ASSERT( i == 0 );
- ASSERT( vCreatingCircle[i] != NULL );
- ASSERT( vCreatingCircle[i]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCreatingCircle[i]->GetSafeHwnd() ) );
- ASSERT( vInnerCircle[3] != NULL );
- ASSERT( vInnerCircle[3]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vInnerCircle[3]->GetSafeHwnd() ) );
- VERIFY(
- ::SetWindowPos(
- vCreatingCircle[i]->GetSafeHwnd(),
- vInnerCircle[3]->GetSafeHwnd(),
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCOPYBITS
- ////|SWP_NOSENDCHANGING
- )
- );
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- case AFX_IDW_DOCKBAR_LEFT:
- case AFX_IDW_DOCKBAR_RIGHT:
- ASSERT( i >= 1 && i <= 3 );
- ASSERT( vCreatingCircle[i] != NULL );
- ASSERT( vCreatingCircle[i]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCreatingCircle[i]->GetSafeHwnd() ) );
- ASSERT( vCreatingCircle[i-1] != NULL );
- ASSERT( vCreatingCircle[i-1]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCreatingCircle[i-1]->GetSafeHwnd() ) );
- VERIFY(
- ::SetWindowPos(
- vCreatingCircle[i]->GetSafeHwnd(),
- vCreatingCircle[i-1]->GetSafeHwnd(),
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCOPYBITS
- ////|SWP_NOSENDCHANGING
- )
- );
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nID )
-
- }
- ASSERT( vInnerCircle[0]->m_pDockBarInner != NULL );
- ASSERT( vInnerCircle[1]->m_pDockBarInner != NULL );
- ASSERT( vInnerCircle[2]->m_pDockBarInner != NULL );
- ASSERT( vInnerCircle[3]->m_pDockBarInner != NULL );
-
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( vInnerCircle[0]->m_pWndAutoHideArea != NULL )
- {
- vInnerCircle[0]->m_pWndAutoHideArea->AdjustOrder();
- vInnerCircle[1]->m_pWndAutoHideArea->AdjustOrder();
- vInnerCircle[2]->m_pWndAutoHideArea->AdjustOrder();
- vInnerCircle[3]->m_pWndAutoHideArea->AdjustOrder();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ASSERT( nCircleNo > 0 );
- return nCircleNo;
- }
- void CExtDockBar::_InjectInnerCircle()
- {
- ASSERT_VALID( this );
- _InjectCircle( m_nCircleNo + 1 );
- }
- void CExtDockBar::_InjectCircle( UINT nCircleNo )
- {
- ASSERT_VALID( this );
- ASSERT( nCircleNo > 0 );
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- _InjectCircle( pFrame, nCircleNo );
- }
- void CExtDockBar::_InjectCircle( CFrameWnd * pFrame, UINT nCircleNo )
- {
- ASSERT_VALID( pFrame );
- ASSERT( nCircleNo > 0 );
- CExtDockBar * vCircleOld[4];
- vCircleOld[0] = (CExtDockBar *)pFrame->GetControlBar( AFX_IDW_DOCKBAR_TOP );
- vCircleOld[1] = (CExtDockBar *)pFrame->GetControlBar( AFX_IDW_DOCKBAR_BOTTOM );
- vCircleOld[2] = (CExtDockBar *)pFrame->GetControlBar( AFX_IDW_DOCKBAR_LEFT );
- vCircleOld[3] = (CExtDockBar *)pFrame->GetControlBar( AFX_IDW_DOCKBAR_RIGHT );
- bool bEmptyCircleExist = true;
- INT nDockSide = 0;
- for( nDockSide = 0; nDockSide < 4; nDockSide++ )
- {
- ASSERT_VALID( vCircleOld[nDockSide] );
- ASSERT_KINDOF( CExtDockBar, vCircleOld[nDockSide] );
- ASSERT( vCircleOld[nDockSide]->_GetCircleNo() == 0 );
- vCircleOld[nDockSide] = vCircleOld[nDockSide]->_GetBarByCircleNo( nCircleNo );
- ASSERT_VALID( vCircleOld[nDockSide] );
- ASSERT( vCircleOld[nDockSide]->_GetCircleNo() == nCircleNo );
- if( ! vCircleOld[nDockSide]->_CanBeSafeOptimized() )
- bEmptyCircleExist = false;
- } // for( nDockSide = 0; nDockSide < 4; nDockSide++ )
- if( bEmptyCircleExist )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( vCircleOld[0]->m_pWndAutoHideArea != NULL )
- {
- vCircleOld[0]->m_pWndAutoHideArea->AdjustOrder();
- vCircleOld[1]->m_pWndAutoHideArea->AdjustOrder();
- vCircleOld[2]->m_pWndAutoHideArea->AdjustOrder();
- vCircleOld[3]->m_pWndAutoHideArea->AdjustOrder();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- return;
- }
- CExtDockBar * vCircleNew[4] = { NULL, NULL, NULL, NULL };
- for( nDockSide = 0; nDockSide < 4; nDockSide++ )
- {
- ASSERT_VALID( vCircleOld[nDockSide] );
- ASSERT( vCircleOld[nDockSide]->_GetCircleNo() == nCircleNo );
- UINT nID = vCircleOld[nDockSide]->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nID );
- vCircleNew[nDockSide] =
- new CExtDockBar( nCircleNo );
-
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- vCircleNew[nDockSide]->m_pWndAutoHideArea =
- vCircleOld[nDockSide]->m_pWndAutoHideArea;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
-
- static const DWORD dwAlignFlags[4] =
- {
- CBRS_ALIGN_TOP,
- CBRS_ALIGN_BOTTOM,
- CBRS_ALIGN_LEFT,
- CBRS_ALIGN_RIGHT
- };
- DWORD dwStyle =
- WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN
- |dwAlignFlags[nDockSide] // |CBRS_ALIGN_ANY
- ;
- VERIFY(
- vCircleNew[nDockSide]->Create( pFrame, dwStyle, nID )
- );
- ASSERT( vCircleNew[nDockSide]->m_pDockBarInner == NULL );
- ASSERT( vCircleNew[nDockSide]->m_pDockBarOuter == NULL );
- ASSERT( vCircleOld[nDockSide]->m_pDockBarOuter != NULL );
- ASSERT( vCircleOld[nDockSide]->m_pDockBarOuter->m_pDockBarInner == vCircleOld[nDockSide] );
-
- vCircleOld[nDockSide]->m_pDockBarOuter->m_pDockBarInner = vCircleNew[nDockSide];
- vCircleNew[nDockSide]->m_pDockBarOuter = vCircleOld[nDockSide]->m_pDockBarOuter;
- vCircleOld[nDockSide]->m_pDockBarOuter = vCircleNew[nDockSide];
- vCircleNew[nDockSide]->m_pDockBarInner = vCircleOld[nDockSide];
- vCircleNew[nDockSide]->SetBarStyle(
- vCircleOld[nDockSide]->GetBarStyle()
- );
- if( (vCircleOld[nDockSide]->GetStyle() & WS_VISIBLE) != NULL
- && vCircleOld[nDockSide]->GetDockedVisibleCount() != 0
- )
- {
- vCircleOld[nDockSide]->GetWindowRect(
- &(vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc)
- );
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- ASSERT( vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.left <= vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.right );
- vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.bottom = vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.top; // + 1;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- ASSERT( vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.left <= vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.right );
- vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.top = vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.bottom; // - 1;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- ASSERT( vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.top <= vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.bottom );
- vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.right = vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.left; // + 1;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- ASSERT( vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.top <= vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.bottom );
- vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.left = vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc.right; // - 1;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nID )
- } // if( (vCircleOld[nDockSide]->GetStyle()&WS_VISIBLE) != NULL .....
- else
- vCircleNew[nDockSide]->m_rcLastInvisiblePreCalc =
- vCircleOld[nDockSide]->m_rcLastInvisiblePreCalc;
-
- for( CExtDockBar * pResetNoBar = vCircleOld[nDockSide];
- pResetNoBar != NULL;
- pResetNoBar = pResetNoBar->m_pDockBarInner
- )
- pResetNoBar->m_nCircleNo++;
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- ASSERT( nDockSide == 0 );
- ASSERT( vCircleOld[3]->m_pDockBarOuter != NULL );
- ASSERT( vCircleOld[3]->m_pDockBarOuter->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCircleOld[3]->m_pDockBarOuter->GetSafeHwnd() ) );
- ASSERT( vCircleNew[nDockSide] != NULL );
- ASSERT( vCircleNew[nDockSide]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCircleNew[nDockSide]->GetSafeHwnd() ) );
- VERIFY(
- ::SetWindowPos(
- vCircleNew[nDockSide]->GetSafeHwnd(),
- vCircleOld[3]->m_pDockBarOuter->GetSafeHwnd(),
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCOPYBITS
- ////|SWP_NOSENDCHANGING
- )
- );
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- case AFX_IDW_DOCKBAR_LEFT:
- case AFX_IDW_DOCKBAR_RIGHT:
- ASSERT( nDockSide > 0 );
- ASSERT( vCircleNew[nDockSide-1] != NULL );
- ASSERT( vCircleNew[nDockSide-1]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCircleNew[nDockSide-1]->GetSafeHwnd() ) );
- ASSERT( vCircleNew[nDockSide] != NULL );
- ASSERT( vCircleNew[nDockSide]->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( vCircleNew[nDockSide]->GetSafeHwnd() ) );
- VERIFY(
- ::SetWindowPos(
- vCircleNew[nDockSide]->GetSafeHwnd(),
- vCircleNew[nDockSide-1]->GetSafeHwnd(),
- 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCOPYBITS
- ////|SWP_NOSENDCHANGING
- )
- );
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nID )
- // VERIFY(
- // ::SetWindowPos(
- // vCircleNew[nDockSide]->GetSafeHwnd(),
- // vCircleOld[nDockSide]->m_pDockBarOuter->_GetHwndForInjectingAfter(),
- // 0, 0, 0, 0,
- // SWP_NOSIZE|SWP_NOMOVE
- // |SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCOPYBITS
- // ////|SWP_NOSENDCHANGING
- // )
- // );
- } // for( nDockSide = 0; nDockSide < 4; nDockSide++ )
- ASSERT_VALID( vCircleNew[0] );
- ASSERT_VALID( vCircleNew[1] );
- ASSERT_VALID( vCircleNew[2] );
- ASSERT_VALID( vCircleNew[3] );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( vCircleNew[0]->m_pWndAutoHideArea != NULL )
- {
- vCircleNew[0]->m_pWndAutoHideArea->AdjustOrder();
- vCircleNew[1]->m_pWndAutoHideArea->AdjustOrder();
- vCircleNew[2]->m_pWndAutoHideArea->AdjustOrder();
- vCircleNew[3]->m_pWndAutoHideArea->AdjustOrder();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- #ifdef _DEBUG
- void CExtDockBar::_Assert_HwndIsDockbar(
- HWND hWndDockBar,
- UINT nDockBarID,
- UINT nCircleNo
- )
- {
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nDockBarID );
- ASSERT( hWndDockBar != NULL );
- ASSERT( ::IsWindow( hWndDockBar ) );
- CWnd * pWndDockBar = CWnd::FromHandlePermanent( hWndDockBar );
- ASSERT_VALID( pWndDockBar );
- CExtDockBar * pDockBar =
- STATIC_DOWNCAST( CExtDockBar, pWndDockBar );
- UINT nRealDockBarID = pDockBar->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nRealDockBarID );
- ASSERT( nDockBarID == nRealDockBarID );
- UINT nRealCircleNo = pDockBar->_GetCircleNo();
- ASSERT( nRealCircleNo == nCircleNo );
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- void CExtDockBar::_Assert_HwndIsAutoHider(
- HWND hWndAutoHider,
- UINT nAutoHiderID
- )
- {
- ASSERT( hWndAutoHider != NULL );
- ASSERT( ::IsWindow( hWndAutoHider ) );
- CWnd * pWndAutoHider = CWnd::FromHandlePermanent( hWndAutoHider );
- ASSERT_VALID( pWndAutoHider );
- CExtDynAutoHideArea * pAutoHider =
- STATIC_DOWNCAST( CExtDynAutoHideArea, pWndAutoHider );
- UINT nRealAutoHiderID = pAutoHider->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nRealAutoHiderID );
- ASSERT( nAutoHiderID == nRealAutoHiderID );
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #endif // _DEBUG
- //HWND CExtDockBar::_GetHwndForInjectingAfter()
- //{
- // ASSERT_VALID( this );
- //HWND hWndOwn = GetSafeHwnd();
- // ASSERT( hWndOwn != NULL );
- // ASSERT( ::IsWindow( hWndOwn ) );
- //
- //UINT nOwnID = GetDlgCtrlID();
- // ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- //
- //HWND hWndAutoHideArea = m_pWndAutoHideArea->GetSafeHwnd();
- //UINT nOwnCircleNo = _GetCircleNo();
- //
- //HWND hWndInsertAfter =
- // (hWndAutoHideArea != NULL && nOwnCircleNo == 0)
- // ? hWndAutoHideArea
- // : hWndOwn
- // ;
- // switch( nOwnID )
- // {
- // case AFX_IDW_DOCKBAR_TOP:
- // {
- // // get dockbar in same circle (nOwnCircleNo) - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM, nOwnCircleNo );
- // // get dockbar in same circle (nOwnCircleNo) - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT, nOwnCircleNo );
- // // get dockbar in same circle (nOwnCircleNo) - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT, nOwnCircleNo );
- // if( nOwnCircleNo == 0 && hWndAutoHideArea != NULL )
- // {
- // // get autohider - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP );
- // // get autohider - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM );
- // // get autohider - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT );
- // // get autohider - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT );
- // }
- // }
- // break; // case AFX_IDW_DOCKBAR_TOP
- // case AFX_IDW_DOCKBAR_BOTTOM:
- // {
- // // get dockbar in same circle (nOwnCircleNo) - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT, nOwnCircleNo );
- // // get dockbar in same circle (nOwnCircleNo) - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT, nOwnCircleNo );
- // if( nOwnCircleNo == 0 && hWndAutoHideArea != NULL )
- // {
- // // get autohider - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP );
- // // get autohider - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM );
- // // get autohider - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT );
- // // get autohider - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT );
- // }
- // // get dockbar in next circle (nOwnCircleNo+1) - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP, (nOwnCircleNo+1) );
- // }
- // break; // case AFX_IDW_DOCKBAR_BOTTOM
- // case AFX_IDW_DOCKBAR_LEFT:
- // {
- // // get dockbar in same circle (nOwnCircleNo) - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT, nOwnCircleNo );
- // if( nOwnCircleNo == 0 && hWndAutoHideArea != NULL )
- // {
- // // get autohider - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP );
- // // get autohider - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM );
- // // get autohider - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT );
- // // get autohider - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT );
- // }
- // // get dockbar in next circle (nOwnCircleNo+1) - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP, (nOwnCircleNo+1) );
- // // get dockbar in next circle (nOwnCircleNo+1) - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM, (nOwnCircleNo+1) );
- // }
- // break; // case AFX_IDW_DOCKBAR_LEFT
- // case AFX_IDW_DOCKBAR_RIGHT:
- // {
- // if( nOwnCircleNo == 0 && hWndAutoHideArea != NULL )
- // {
- // // get autohider - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP );
- // // get autohider - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM );
- // // get autohider - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT );
- // // get autohider - right
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_AUTOHIDER( hWndInsertAfter, AFX_IDW_DOCKBAR_RIGHT );
- // }
- // // get dockbar in next circle (nOwnCircleNo+1) - top
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_TOP, (nOwnCircleNo+1) );
- // // get dockbar in next circle (nOwnCircleNo+1) - bottom
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_BOTTOM, (nOwnCircleNo+1) );
- // // get dockbar in next circle (nOwnCircleNo+1) - left
- // hWndInsertAfter = ::GetWindow( hWndInsertAfter, GW_HWNDNEXT );
- // ASSERT_HWND_IS_DOCKBAR( hWndInsertAfter, AFX_IDW_DOCKBAR_LEFT, (nOwnCircleNo+1) );
- // }
- // break; // case AFX_IDW_DOCKBAR_RIGHT
- //#ifdef _DEBUG
- // default:
- // ASSERT( FALSE );
- // break;
- //#endif // _DEBUG
- // } // switch( nOwnID )
- //
- //
- // ASSERT( hWndInsertAfter != NULL );
- // return hWndInsertAfter;
- //}
- CExtDockBar * CExtDockBar::_GetBarByCircleNo( UINT nCircleNo )
- {
- ASSERT_VALID( this );
- if( nCircleNo == m_nCircleNo )
- return this;
- if( nCircleNo < m_nCircleNo )
- {
- ASSERT( m_nCircleNo > 0 );
- ASSERT( m_pDockBarOuter != NULL );
- return m_pDockBarOuter->_GetBarByCircleNo( nCircleNo );
- }
- if( m_pDockBarInner == NULL )
- {
- #ifdef _DEBUG
- UINT nNewCircle =
- #endif // _DEBUG
- _CreateInnerCircle();
- ASSERT( nNewCircle == (m_nCircleNo + 1) );
- }
- ASSERT( m_pDockBarInner != NULL );
- ASSERT( m_pDockBarInner->m_nCircleNo == (m_nCircleNo + 1) );
- return m_pDockBarInner->_GetBarByCircleNo( nCircleNo );
- }
- LRESULT CExtDockBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if( message == WM_PRINT
- || message == WM_PRINTCLIENT
- )
- {
- CDC * pDC = CDC::FromHandle( (HDC) wParam );
-
- CRect rcWnd, rcClient;
- GetWindowRect( &rcWnd );
- GetClientRect( &rcClient );
- ClientToScreen( rcClient );
- rcClient.OffsetRect( -rcWnd.TopLeft() );
- rcWnd.OffsetRect( -rcWnd.TopLeft() );
- // if( (lParam&PRF_NONCLIENT) != 0 )
- // {
- // pDC->ExcludeClipRect(rcClient);
- // // draw borders in non-client area
- // DrawBorders( pDC, rcWnd );
- // // draw gripper in non-client area
- // DrawGripper( pDC, rcWnd );
- // pDC->SelectClipRgn( NULL );
- // }
- if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
- {
- CPoint ptVpOffset( 0, 0 );
- if( (lParam&PRF_NONCLIENT) != 0 )
- {
- ptVpOffset.x = rcWnd.left - rcClient.left;
- ptVpOffset.y = rcWnd.top - rcClient.top;
- }
- if( ptVpOffset.x != 0
- || ptVpOffset.y != 0
- )
- pDC->OffsetViewportOrg(
- -ptVpOffset.x,
- -ptVpOffset.y
- );
- DoPaint( pDC );
- if( ptVpOffset.x != 0
- || ptVpOffset.y != 0
- )
- pDC->OffsetViewportOrg(
- ptVpOffset.x,
- ptVpOffset.y
- );
- } // if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
-
- if( (lParam&PRF_CHILDREN) != 0 )
- CExtPaintManager::stat_PrintChildren(
- m_hWnd,
- message,
- pDC->GetSafeHdc(),
- lParam,
- false
- );
- return (!0);
- }
-
- switch( message )
- {
- case WM_CREATE:
- EnableToolTips();
- break;
- case WM_DESTROY:
- case WM_NCDESTROY:
- if( m_pDockBarInner != NULL )
- {
- ASSERT( m_pDockBarInner->m_pDockBarOuter == this );
- m_pDockBarInner->m_pDockBarOuter = NULL;
- m_pDockBarInner = NULL;
- }
- if( m_pDockBarOuter != NULL )
- {
- ASSERT( m_pDockBarOuter->m_pDockBarInner == this );
- m_pDockBarOuter->m_pDockBarInner = NULL;
- m_pDockBarOuter = NULL;
- }
- break;
- } // switch( message )
- return CControlBar::WindowProc(message, wParam, lParam);
- }
- BOOL CExtDockBar::PreTranslateMessage(MSG* pMsg)
- {
- // return CDockBar::PreTranslateMessage( pMsg );
- pMsg;
- return FALSE;
- }
- void CExtDockBar::_OptimizeCircles()
- {
- ASSERT_VALID( this );
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT_VALID( pFrame );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- if( !m_bLockedOptimize )
- _OptimizeCircles( pFrame );
- }
- void CExtDockBar::_OptimizeCircles( CFrameWnd * pFrame )
- {
- ASSERT_VALID( pFrame );
- CExtDockBar * vCircle[4];
- vCircle[0] = (CExtDockBar*)pFrame->GetControlBar( AFX_IDW_DOCKBAR_TOP );
- if( vCircle[0] == NULL )
- return;
- ASSERT_VALID( vCircle[0] );
- ASSERT_KINDOF( CExtDockBar, vCircle[0] );
- ASSERT( vCircle[0]->_GetCircleNo() == 0 );
- vCircle[1] = (CExtDockBar*)pFrame->GetControlBar( AFX_IDW_DOCKBAR_BOTTOM );
- ASSERT_VALID( vCircle[1] );
- ASSERT_KINDOF( CExtDockBar, vCircle[1] );
- ASSERT( vCircle[1]->_GetCircleNo() == 0 );
- vCircle[2] = (CExtDockBar*)pFrame->GetControlBar( AFX_IDW_DOCKBAR_LEFT );
- ASSERT_VALID( vCircle[2] );
- ASSERT_KINDOF( CExtDockBar, vCircle[2] );
- ASSERT( vCircle[2]->_GetCircleNo() == 0 );
- vCircle[3] = (CExtDockBar*)pFrame->GetControlBar( AFX_IDW_DOCKBAR_RIGHT );
- ASSERT_VALID( vCircle[3] );
- ASSERT_KINDOF( CExtDockBar, vCircle[3] );
- ASSERT( vCircle[3]->_GetCircleNo() == 0 );
- if( vCircle[0]->_GetDockBarInner() == NULL )
- return;
- vCircle[0] = vCircle[0]->_GetDockBarInner();
- ASSERT( vCircle[0] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[0] );
- ASSERT( vCircle[0]->_GetCircleNo() == 1 );
-
- vCircle[1] = vCircle[1]->_GetDockBarInner();
- ASSERT( vCircle[1] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[1] );
- ASSERT( vCircle[1]->_GetCircleNo() == 1 );
-
- vCircle[2] = vCircle[2]->_GetDockBarInner();
- ASSERT( vCircle[2] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[2] );
- ASSERT( vCircle[2]->_GetCircleNo() == 1 );
-
- vCircle[3] = vCircle[3]->_GetDockBarInner();
- ASSERT( vCircle[3] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[3] );
- ASSERT( vCircle[3]->_GetCircleNo() == 1 );
- //bool bCreateInnerCircle = true;
- UINT nCircleShift = 0;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool bAutoHidersPassed = false;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- while( vCircle[0] != NULL )
- {
- ASSERT( vCircle[0] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[0] );
- ASSERT( vCircle[1] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[1] );
- ASSERT( vCircle[2] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[2] );
- ASSERT( vCircle[3] != NULL );
- ASSERT_KINDOF( CExtDockBar, vCircle[3] );
- ASSERT( vCircle[0]->m_nCircleNo == vCircle[1]->m_nCircleNo );
- ASSERT( vCircle[0]->m_nCircleNo == vCircle[2]->m_nCircleNo );
- ASSERT( vCircle[0]->m_nCircleNo == vCircle[3]->m_nCircleNo );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( !bAutoHidersPassed )
- {
- bAutoHidersPassed = true;
- if( vCircle[0]->m_pWndAutoHideArea != NULL )
- {
- vCircle[0]->m_pWndAutoHideArea->AdjustOrder();
- vCircle[1]->m_pWndAutoHideArea->AdjustOrder();
- vCircle[2]->m_pWndAutoHideArea->AdjustOrder();
- vCircle[3]->m_pWndAutoHideArea->AdjustOrder();
- }
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( nCircleShift != 0 )
- {
- ASSERT( vCircle[0]->m_nCircleNo > nCircleShift );
- vCircle[0]->m_nCircleNo -= nCircleShift;
- vCircle[1]->m_nCircleNo -= nCircleShift;
- vCircle[2]->m_nCircleNo -= nCircleShift;
- vCircle[3]->m_nCircleNo -= nCircleShift;
- }
- CExtDockBar * vCircleOptimize[4];
-
- vCircleOptimize[0] = vCircle[0];
- vCircleOptimize[1] = vCircle[1];
- vCircleOptimize[2] = vCircle[2];
- vCircleOptimize[3] = vCircle[3];
- // bool bLastCircle =
- // ( vCircle[0]->_GetDockBarInner() != NULL ) ? true : false;
- vCircle[0] = vCircle[0]->_GetDockBarInner();
- vCircle[1] = vCircle[1]->_GetDockBarInner();
- vCircle[2] = vCircle[2]->_GetDockBarInner();
- vCircle[3] = vCircle[3]->_GetDockBarInner();
- if( vCircleOptimize[0]->_CanBeSafeOptimized()
- && vCircleOptimize[1]->_CanBeSafeOptimized()
- && vCircleOptimize[2]->_CanBeSafeOptimized()
- && vCircleOptimize[3]->_CanBeSafeOptimized()
- )
- {
- // if( bLastCircle )
- // {
- // bCreateInnerCircle = false;
- // break;
- // }
- #ifdef __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- ASSERT( !vCircleOptimize[0]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[1]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[2]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[3]->m_bLockedOptimize );
- #endif // __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
-
- vCircleOptimize[0]->_SafeOptimizeInnerOuterChain();
- vCircleOptimize[1]->_SafeOptimizeInnerOuterChain();
- vCircleOptimize[2]->_SafeOptimizeInnerOuterChain();
- vCircleOptimize[3]->_SafeOptimizeInnerOuterChain();
-
- nCircleShift++;
- }
- else
- {
- #ifdef __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- ASSERT( !vCircleOptimize[0]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[1]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[2]->m_bLockedOptimize );
- ASSERT( !vCircleOptimize[3]->m_bLockedOptimize );
- #endif // __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
-
- vCircleOptimize[0]->OnDynamicLayoutOptimize();
- vCircleOptimize[1]->OnDynamicLayoutOptimize();
- vCircleOptimize[2]->OnDynamicLayoutOptimize();
- vCircleOptimize[3]->OnDynamicLayoutOptimize();
- }
- } // while( vCircle[0] != NULL )
- // if( bCreateInnerCircle )
- // _CreateInnerCircle( pFrame );
- CArray < HWND, HWND > arrHwndsToDynOptimize;
- bool bDeepOptimize = false;
- POSITION pos = pFrame->m_listControlBars.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CExtDynControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtDynControlBar,
- ((CObject *)(pFrame->m_listControlBars.GetNext(pos)))
- );
- if( pBar == NULL )
- continue;
- ASSERT( !pBar->IsFixedMode() );
- HWND hWnd = pBar->m_pWndDynDocker->GetSafeHwnd();
- if( hWnd == NULL
- || ! ::IsWindow( hWnd )
- )
- continue;
- //if( !pBar->IsFloating() )
- {
- INT nDockedCount =
- pBar->m_pWndDynDocker->GetDockedCount();
- if( nDockedCount > 0 )
- continue;
- bDeepOptimize = true;
- } // if( !pBar->IsFloating() )
- arrHwndsToDynOptimize.Add( hWnd );
- }
- for( INT nHwndIdx = 0; nHwndIdx < arrHwndsToDynOptimize.GetSize(); nHwndIdx++ )
- {
- HWND hWnd = arrHwndsToDynOptimize[ nHwndIdx ];
- ASSERT( hWnd != NULL );
- if( !::IsWindow( hWnd ) )
- continue;
- CWnd * pWndChild = CWnd::FromHandlePermanent( hWnd );
- if( pWndChild == NULL )
- continue;
- CExtDockDynBar * pDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockDynBar,
- pWndChild
- );
- if( pDockBar == NULL )
- continue;
- #ifdef __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- ASSERT( !pDockBar->m_bLockedOptimize );
- #endif // __DEBUG_LOCKING_OPTIMIZATION_ASSERTS__
- pDockBar->OnDynamicLayoutOptimize();
- }
- if( bDeepOptimize )
- _OptimizeCircles( pFrame );
- }
- void CExtDockBar::_SafeOptimizeInnerOuterChain()
- {
- ASSERT( this != NULL );
- ASSERT_KINDOF( CExtDockBar, this );
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(GetSafeHwnd()) );
- if( m_pDockBarInner != NULL )
- {
- ASSERT( m_pDockBarInner->m_pDockBarOuter == this );
- m_pDockBarInner->m_pDockBarOuter = m_pDockBarOuter;
- }
- if( m_pDockBarOuter != NULL )
- {
- ASSERT( m_pDockBarOuter->m_pDockBarInner == this );
- m_pDockBarOuter->m_pDockBarInner = m_pDockBarInner;
- }
- m_pDockBarInner = NULL;
- m_pDockBarOuter = NULL;
- CFrameWnd * pFrame = GetParentFrame();
- ASSERT( pFrame != NULL );
- ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- POSITION pos = pFrame->m_listControlBars.Find( this );
- ASSERT( pos != NULL );
- pFrame->m_listControlBars.RemoveAt( pos );
- BOOL bAutoDelete = m_bAutoDelete;
- DestroyWindow();
- if( !bAutoDelete )
- delete this;
- }
- bool CExtDockBar::_CanBeSafeOptimized()
- {
- ASSERT( this != NULL );
- ASSERT_KINDOF( CExtDockBar, this );
- for( INT nPos = 0; nPos < m_arrBars.GetSize(); nPos++ )
- {
- void * pBar = m_arrBars[ nPos ];
- if( pBar != NULL ) // placeholer or child control bar
- return false;
- }
- return true;
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynAutoHideArea * CExtDockBar::_GetAutoHideArea()
- {
- return m_pWndAutoHideArea;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- void CExtDockBar::_HandleDestruction()
- {
- __PROF_UIS_MANAGE_STATE;
- m_bLockedOptimize = true;
- bool bFirstDestroyed = true;
- for( int nBar = int(m_arrBars.GetSize()) - 1; nBar > 0 ; nBar-- )
- {
- ASSERT( m_arrBars[0] == NULL );
- CExtControlBar * pBar = (CExtControlBar *)
- m_arrBars[ nBar ];
- if( bFirstDestroyed )
- {
- ASSERT( pBar == NULL );
- bFirstDestroyed = false;
- continue;
- }
- if( pBar == NULL )
- {
- m_arrBars.RemoveAt( nBar );
- continue;
- }
- if( __PLACEHODLER_BAR_PTR(pBar) )
- {
- m_arrBars.RemoveAt( nBar );
- continue;
- }
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- ASSERT_VALID( pBar->m_pDockSite );
- ASSERT( pBar->m_pDockContext != NULL );
- ASSERT( pBar->m_pDockBar == this );
- pBar->m_bUpdatingChain = true;
- pBar->m_pDockBar = NULL;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- {
- CExtDockDynBar * pDynDocker =
- ((CExtDynControlBar*)pBar)->m_pWndDynDocker;
- ASSERT_VALID( pDynDocker );
- pDynDocker->_HandleDestruction();
- }
- ASSERT( pBar->m_bUpdatingChain );
- if( pBar->GetParent() != pBar->m_pDockSite )
- pBar->SetParent( pBar->m_pDockSite );
- pBar->m_bUpdatingChain = false;
- m_arrBars.RemoveAt( nBar );
- }
- m_bLockedOptimize = false;
- }
- void CExtDockBar::OnDestroy()
- {
- __PROF_UIS_MANAGE_STATE;
- _HandleDestruction();
- CDockBar::OnDestroy();
- }
- BOOL CExtDockBar::Create( CWnd * pParentWnd, DWORD dwStyle, UINT nID )
- {
- if( ! CDockBar::Create( pParentWnd, dwStyle, nID ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- CRect rc;
- pParentWnd->GetClientRect( &rc );
- switch( nID )
- {
- case AFX_IDW_DOCKBAR_TOP:
- rc.bottom = rc.top;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- rc.top = rc.bottom;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- rc.right = rc.left;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- rc.left = rc.right;
- break;
- } // switch( nID )
- MoveWindow( &rc, FALSE );
- if( ( (CWnd::GetExStyle()&(WS_EX_LAYOUTRTL|WS_EX_RTLREADING)) != 0 ) )
- {
- CWnd::ModifyStyleEx(
- WS_EX_LAYOUTRTL|WS_EX_RTLREADING,
- 0,
- SWP_FRAMECHANGED
- );
- ASSERT( (CWnd::GetExStyle()&(WS_EX_LAYOUTRTL|WS_EX_RTLREADING)) == 0 );
- } // if( ( (CWnd::GetExStyle()&(WS_EX_LAYOUTRTL|WS_EX_RTLREADING)) != 0 ) )
- return TRUE;
- }
- BOOL CExtDockBar::DestroyWindow()
- {
- __PROF_UIS_MANAGE_STATE;
- _HandleDestruction();
- return CDockBar::DestroyWindow();
- }
- /////////////////////////////////////////////////////////////////////////
- // CExtDockDynBar window
- IMPLEMENT_DYNCREATE(CExtDockDynBar, CExtDockBar);
- BEGIN_MESSAGE_MAP(CExtDockDynBar, CExtDockBar)
- //{{AFX_MSG_MAP(CExtDockDynBar)
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- CExtDockDynBar::CExtDockDynBar(
- UINT nCircleNo
- )
- : CExtDockBar( nCircleNo )
- , m_bHelperDockSiteModified( false )
- , m_bHelperSizing( false )
- {
- m_bAutoDelete = TRUE;
- }
- /////////////////////////////////////////////////////////////////////////
- // CExtDynControlBar window
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynAutoHideArea * CExtDockDynBar::_GetAutoHideArea()
- {
- CExtControlBar * pExtBar =
- STATIC_DOWNCAST(
- CExtControlBar,
- GetParent()
- );
- ASSERT( pExtBar->m_pDockBar != NULL );
- CExtDockBar * pDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockBar,
- pExtBar->m_pDockBar
- );
- if( pDockBar == NULL )
- return NULL;
- return pDockBar->_GetAutoHideArea();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- void CExtDockDynBar::VisibleLayoutItem_t::_AssignFromOther(
- const CExtDockDynBar::VisibleLayoutItem_t & other
- )
- {
- m_vRow.RemoveAll();
- INT nSize = (INT)other.m_vRow.GetSize();
- if( nSize == 0 )
- {
- m_vRow.FreeExtra();
- return;
- }
- m_vRow.SetSize( nSize );
- for( INT nBar = 0; nBar < nSize; nBar++ )
- {
- CExtControlBar * pExtBar = other.m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- ASSERT( !pExtBar->IsFixedMode() );
- #ifdef _DEBUG
- if( __PLACEHODLER_BAR_PTR(pExtBar) )
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- m_vRow.SetAt( nBar, pExtBar );
- } // for( INT nBar = 0; nBar < nSize; nBar++ )
- }
- CExtDockDynBar::VisibleLayoutItem_t::VisibleLayoutItem_t()
- : m_nRowMetric( 0 )
- , m_nRowMinMetric( 0 )
- , m_nRowExtent( 0 )
- , m_nRowMinExtent( 0 )
- , m_bOverflowMode( false )
- {
- }
- CExtDockDynBar::VisibleLayoutItem_t::VisibleLayoutItem_t(
- const CExtDockDynBar::VisibleLayoutItem_t & other
- )
- {
- _AssignFromOther( other );
- }
- CExtDockDynBar::VisibleLayoutItem_t::~VisibleLayoutItem_t()
- {
- }
- CExtDockDynBar::VisibleLayoutItem_t &
- CExtDockDynBar::VisibleLayoutItem_t::operator = (
- const CExtDockDynBar::VisibleLayoutItem_t & other
- )
- {
- _AssignFromOther( other );
- return * this;
- }
- bool CExtDockDynBar::VisibleLayoutItem_t::IsEmpty() const
- {
- if( m_vRow.GetSize() == 0 )
- return true;
- return false;
- }
- bool CExtDockDynBar::VisibleLayoutItem_t::IsRowMinSized() const
- {
- ASSERT( m_nRowMetric >= m_nRowMinMetric );
- return (m_nRowMetric == m_nRowMinMetric ) ? true : false;
- }
- void CExtDockDynBar::VisibleLayout_t::_Clean()
- {
- INT nSize = (INT)m_vRows.GetSize();
- for( INT nRow = 0; nRow < nSize; nRow++ )
- {
- VisibleLayoutItem_t * pVLI = m_vRows.GetAt( nRow );
- ASSERT( pVLI != NULL );
- delete pVLI;
- }
- m_vRows.RemoveAll();
- m_vRows.FreeExtra();
- }
- CExtDockDynBar::VisibleLayout_t::VisibleLayout_t()
- : m_nTotalMetric( 0 )
- , m_nTotalMinMetric( 0 )
- , m_nTotalMinExtent( 0 )
- , m_nTotalBarsCount( 0 )
- , m_nDelayShowCount( 0 )
- {
- }
- CExtDockDynBar::VisibleLayout_t::~VisibleLayout_t()
- {
- _Clean();
- }
- void CExtDockDynBar::VisibleLayout_t::AddBarPointer(
- CExtControlBar * pExtBar
- )
- {
- ASSERT_VALID( pExtBar );
- ASSERT( !pExtBar->IsFixedMode() );
- if( !pExtBar->IsVisible() )
- return;
- #ifdef _DEBUG
- if( __PLACEHODLER_BAR_PTR(pExtBar) )
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- VisibleLayoutItem_t * pVLI = NULL;
- INT nRowCount = (INT)m_vRows.GetSize();
- if( nRowCount == 0 )
- {
- pVLI = new VisibleLayoutItem_t;
- m_vRows.Add( pVLI );
- }
- else
- pVLI = m_vRows[ nRowCount - 1 ];
- ASSERT( pVLI != NULL );
- pVLI->m_vRow.Add( pExtBar );
- m_nTotalBarsCount++;
- }
- void CExtDockDynBar::VisibleLayout_t::MakeNewRow()
- {
- INT nRowCount = (INT)m_vRows.GetSize();
- if( nRowCount == 0 )
- {
- VisibleLayoutItem_t * pVLI = new VisibleLayoutItem_t;
- m_vRows.Add( pVLI );
- return;
- }
- VisibleLayoutItem_t * pVLI = m_vRows.GetAt( nRowCount - 1 );
- ASSERT( pVLI != NULL );
- if( pVLI->IsEmpty() )
- return;
- pVLI = new VisibleLayoutItem_t;
- m_vRows.Add( pVLI );
- }
- bool CExtDockDynBar::VisibleLayout_t::IsEmpty() const
- {
- INT nRowCount = (INT)m_vRows.GetSize();
- if( nRowCount == 0 )
- return true;
- if( nRowCount == 1 )
- {
- VisibleLayoutItem_t * pVLI = m_vRows.GetAt( 0 );
- if( pVLI->IsEmpty() )
- return true;
- }
- #ifdef _DEBUG
- else
- {
- VisibleLayoutItem_t * pVLI = m_vRows.GetAt( 0 );
- ASSERT( !pVLI->IsEmpty() );
-
- }
- #endif // _DEBUG
- return false;
- }
- void CExtDockDynBar::_VisibleLayoutBuild(
- VisibleLayout_t & _vl
- )
- {
- ASSERT_VALID( this );
- ASSERT( _vl.IsEmpty() );
- CRect rcDockBarReal;
- GetClientRect( &rcDockBarReal );
- CSize _size = rcDockBarReal.Size();
- INT nCount = (INT)m_arrBars.GetSize();
- ASSERT( nCount > 0 );
- ASSERT( m_arrBars[0] == NULL );
- UINT nOwnID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- BOOL bHorz = ( nOwnID == AFX_IDW_DOCKBAR_TOP || nOwnID == AFX_IDW_DOCKBAR_BOTTOM );
- ASSERT( m_arrBars[0] == NULL );
- for( INT nBar = 1; nBar < nCount; nBar++ )
- {
- CExtControlBar * pExtBar = (CExtControlBar *) m_arrBars[nBar];
- if( pExtBar == NULL )
- {
- if( nBar == (nCount-1) )
- break;
- _vl.MakeNewRow();
- continue;
- }
- if( __PLACEHODLER_BAR_PTR(pExtBar) )
- continue;
- ASSERT_VALID( pExtBar );
- ASSERT_KINDOF( CExtControlBar, pExtBar );
- ASSERT( !pExtBar->IsFixedMode() );
- if( pExtBar->m_bDelayShowInvoked )
- _vl.m_nDelayShowCount ++;
- if( ! pExtBar->IsVisible() )
- {
- pExtBar->m_bDelayShowInvoked = false;
- continue;
- }
- _vl.AddBarPointer( pExtBar );
- } // for( INT nBar = 1; nBar < nCount; nBar++ )
- INT nRowsCount = (INT)_vl.m_vRows.GetSize(), nRow;
- if( nRowsCount == 0 )
- return;
- for( nRow = 0; nRow < nRowsCount; nRow ++ )
- {
- VisibleLayoutItem_t * pVLI = _vl.m_vRows[ nRow ];
- ASSERT( pVLI != NULL );
- pVLI->m_bOverflowMode = false;
- INT nRowSize = (INT)pVLI->m_vRow.GetSize(), nBar;
- if( nRowSize <= 1 )
- continue;
- for( nBar = 0; nBar < nRowSize; nBar++ )
- {
- CExtControlBar * pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- if( bHorz && pExtBar->m_sizeDockedH.cx >= _size.cx )
- pVLI->m_bOverflowMode = true;
- else
- if( (!bHorz) && pExtBar->m_sizeDockedV.cy >= _size.cy )
- pVLI->m_bOverflowMode = true;
- if( pVLI->m_bOverflowMode )
- break;
- }
- }
- 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 );
- CExtControlBar * pExtBar = pVLI->m_vRow[ 0 ];
- ASSERT( pExtBar != NULL );
- if( pVLI->m_bOverflowMode )
- {
- if( bHorz )
- pExtBar->m_sizeDockedH.cx = _size.cx / nRowSize;
- else
- pExtBar->m_sizeDockedV.cy = _size.cy / nRowSize;
- }
-
- LONG nMinHW = pExtBar->_CalcDesiredMinHW();
- LONG nMinVH = pExtBar->_CalcDesiredMinVH();
- pVLI->m_nRowMinMetric = bHorz
- ? nMinVH
- : nMinHW;
- pVLI->m_nRowMetric = bHorz
- ? pExtBar->m_sizeDockedH.cy
- : pExtBar->m_sizeDockedV.cx;
- _vl.m_nTotalMetric += pVLI->m_nRowMetric;
- INT nRowMinMetric = bHorz
- ? nMinVH
- : nMinHW;
- INT nRowMinExtent = bHorz
- ? nMinHW
- : nMinVH;
- INT nRowExtent = bHorz
- ? pExtBar->m_sizeDockedH.cx
- : pExtBar->m_sizeDockedV.cy;
- for( INT nBar = 1; nBar < nRowSize; nBar++ )
- {
- pExtBar = pVLI->m_vRow[ nBar ];
- ASSERT( pExtBar != NULL );
- if( pVLI->m_bOverflowMode )
- {
- if( bHorz )
- pExtBar->m_sizeDockedH.cx = _size.cx / nRowSize;
- else
- pExtBar->m_sizeDockedV.cy = _size.cy / nRowSize;
- }
- LONG nMinHW = pExtBar->_CalcDesiredMinHW();
- LONG nMinVH = pExtBar->_CalcDesiredMinVH();
- INT nBarMinMetric = bHorz
- ? nMinVH
- : nMinHW;
- nRowMinMetric =
- min( nRowMinMetric, nBarMinMetric );
- nRowMinExtent += bHorz
- ? nMinHW
- : nMinVH;
- nRowExtent += bHorz
- ? pExtBar->m_sizeDockedH.cx
- : pExtBar->m_sizeDockedV.cy;
- }
- _vl.m_nTotalMinMetric += nRowMinMetric;
- _vl.m_nTotalMinExtent = max( nRowMinExtent, _vl.m_nTotalMinExtent );
- pVLI->m_nRowExtent = nRowExtent;
- } // for( INT nRow = 0; nRow < nRowsCount; nRow ++ )
- }
- void CExtDockDynBar::_VisibleLayoutAlign(
- VisibleLayout_t & _vl,
- CSize _size
- )
- {
- ASSERT_VALID( this );
- ASSERT( !_vl.IsEmpty() );
- ASSERT( _size.cx > 0 && _size.cy > 0 );
- if( ! ( m_bHelperSizing || _vl.m_nDelayShowCount > 0L ) )
- return;
- m_bHelperSizing = false;
- CRect rcDockBarReal;
- GetClientRect( &rcDockBarReal );
- _size = rcDockBarReal.Size();
- if( _size.cx <= 0 || _size.cy <= 0 )
- return;
- UINT nOwnID = GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID_DOCKED( nOwnID );
- BOOL bHorz = ( nOwnID == AFX_IDW_DOCKBAR_TOP || nOwnID == AFX_IDW_DOCKBAR_BOTTOM );
- INT nRowsCount = (INT)_vl.m_vRows.GetSize();
- ASSERT( nRowsCount > 0 );
- INT nDesiredMetric = bHorz ? _size.cy : _size.cx;
- INT nIncrement = ( _vl.m_nTotalMetric < nDesiredMetric ) ? 1 : -1;
- INT nDiff = abs(_vl.m_nTotalMetric - nDesiredMetric);
- // align direction 1 (row metrics)
- bool bResetRowMetrics = true;
- while( nDiff != 0 )
- {
- bResetRowMetrics = false;
- ASSERT( nDiff >= 0 );
- INT nRowsMinSized = 0;
- for( INT 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();
- // TO FIX:
- if( nRowSize == 0 )
- continue;
- ASSERT( nRowSize > 0 );
- if( nIncrement < 0 && pVLI->IsRowMinSized() )
- {
- nRowsMinSized ++;
- if( nRowsCount == nRowsMinSized )
- break;
- continue;
- }
- pVLI->m_nRowMetric += nIncrement;
- nDiff--;
- 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 += nIncrement;
- } // for( INT nBar = 0; nBar < nRowSize; nBar++ )
- if( nDiff == 0 )
- break;
- } // for( INT nRow = 0; nRow < nRowsCount; nRow ++ )
- if( nRowsCount == nRowsMinSized )
- break;
- } // while( nDiff != 0 )
- if( bResetRowMetrics )
- {
- for( INT 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 );