ExtControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:775k
- // 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.
- // extcontrolbar.cpp : implementation file
- //
- #include "stdafx.h"
- //
- // Many thanks to Paul DiLascia & Cristi Posea, their works
- // were a powerful incentive to learn more about pretty
- // complicated MFC docking windows mechanism
- //
- #if (!defined __EXT_CONTROLBAR_H)
- #include <ExtControlBar.h>
- #endif
- #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 (!defined __EXTMINIDOCKFRAMEWND_H)
- #include "ExtMiniDockFrameWnd.h"
- #endif
- #if (!defined __ExtCmdManager_H)
- #include <ExtCmdManager.h>
- #endif
- #if (!defined __EXT_MEMORY_DC_H)
- #include <../Src/ExtMemoryDC.h>
- #endif
- #if (!defined __EXT_NC_FRAME_H)
- #include <ExtNcFrame.h>
- #endif
- #if (!defined __EXT_LOCALIZATION_H)
- #include <../Src/ExtLocalization.h>
- #endif
- #if (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- #if (! defined __EXT_TAB_PAGE_CONTAINER_WND_H)
- #include <ExtTabPageContainerWnd.h>
- #endif // (!defined __EXT_TAB_PAGE_CONTAINER_WND_H)
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- #if (!defined __EXT_NC_FRAME_H)
- #include <ExtNcFrame.h>
- #endif
- #endif // (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
- #include <Resources/Resource.h>
- #if (!defined __AFXPRIV_H__)
- #include <AfxPriv.h>
- #endif
- #if _MFC_VER < 0x700
- #include <../src/AfxImpl.h>
- #else
- #ifndef __AFXSTATE_H__
- #include <../src/mfc/afxstat_.h>
- #endif
- #include <../src/mfc/AfxImpl.h>
- #endif
- #ifndef __AFXOLE_H__
- #include <AfxOle.h>
- #endif
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXTCUSTOMIZE_H)
- #include <ExtCustomize.h>
- #endif
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CExtAnimationParameters
- CExtAnimationParameters::CExtAnimationParameters(
- INT nAcStepCount, // = __EXT_MFC_DEF_ANIMATION_STEP_COUNT
- UINT nAcTimerElapse // = __EXT_MFC_DEF_ANIMATION_TIMER_ELAPSE,
- )
- : m_nAcStepCount( nAcStepCount )
- , m_nAcTimerElapse( nAcTimerElapse )
- {
- }
- CExtAnimationParameters::~CExtAnimationParameters()
- {
- }
- INT CExtAnimationParameters::AnimationClient_StepCountGet() const
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepCount && m_nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- return m_nAcStepCount;
- }
- void CExtAnimationParameters::AnimationClient_StepCountSet( INT nAcStepCount )
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepCount && m_nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- ASSERT( 0 <= nAcStepCount && nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- m_nAcStepCount = nAcStepCount;
- }
- UINT CExtAnimationParameters::AnimationClient_TimerElapseGet() const
- {
- ASSERT( this != NULL );
- return m_nAcTimerElapse;
- }
- void CExtAnimationParameters::AnimationClient_TimerElapseSet( UINT nAcTimerElapse )
- {
- ASSERT( this != NULL );
- m_nAcTimerElapse = nAcTimerElapse;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtAnimationClient
- CExtAnimationClient::CExtAnimationClient(
- CExtAnimationSite * pAcAS, // = NULL
- bool bAcEnabled, // = true
- bool bAcNonClientMode, // = false
- INT nAcStepNumber, // = 0
- INT nAcStepCount, // = __EXT_MFC_DEF_ANIMATION_STEP_COUNT
- UINT nAcTimerElapse, // = __EXT_MFC_DEF_ANIMATION_TIMER_ELAPSE,
- const RECT * pAcRcAnimationTarget // = NULL
- )
- : m_pAcAS( pAcAS )
- , m_bAcEnabled( bAcEnabled )
- , m_bAcNonClientMode( bAcNonClientMode )
- , m_nAcStepNumber( nAcStepNumber )
- , m_nAcStepCount( nAcStepCount )
- , m_nAcTimerElapse( nAcTimerElapse )
- , m_rcAcTarget( 0, 0, 0, 0 )
- , m_nAcCacheGeneratorLock( 0 )
- , m_eAPT_Last( 0 )
- {
- ASSERT( 0 <= m_nAcStepNumber );
- ASSERT( 0 <= m_nAcStepCount && m_nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- if( m_pAcAS != NULL && m_pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- m_pAcAS->AnimationSite_ClientAdd( this );
- if( pAcRcAnimationTarget != NULL )
- m_rcAcTarget = (*pAcRcAnimationTarget);
- }
- CExtAnimationClient::~CExtAnimationClient()
- {
- if( m_pAcAS != NULL )
- m_pAcAS->AnimationSite_ClientRemove( this );
- }
- void CExtAnimationClient::AnimationClient_CacheGeneratorLock()
- {
- ASSERT( this != NULL );
- ASSERT( m_nAcCacheGeneratorLock >= 0 );
- m_nAcCacheGeneratorLock ++;
- }
- void CExtAnimationClient::AnimationClient_CacheGeneratorUnlock()
- {
- ASSERT( this != NULL );
- ASSERT( m_nAcCacheGeneratorLock >= 0 );
- m_nAcCacheGeneratorLock --;
- }
- bool CExtAnimationClient::AnimationClient_CacheGeneratorIsLocked() const
- {
- ASSERT( this != NULL );
- ASSERT( m_nAcCacheGeneratorLock >= 0 );
- if( ! AnimationClient_EnabledGet() )
- return true;
- if( m_nAcCacheGeneratorLock == 0 )
- return false;
- else
- return true;
- }
- CExtAnimationSite * CExtAnimationClient::AnimationClient_SiteGet()
- {
- ASSERT( this != NULL );
- return m_pAcAS;
- }
- const CExtAnimationSite * CExtAnimationClient::AnimationClient_SiteGet() const
- {
- ASSERT( this != NULL );
- return
- ( const_cast < CExtAnimationClient * > ( this ) )
- -> AnimationClient_SiteGet();
- }
- void CExtAnimationClient::AnimationClient_SiteSet(
- CExtAnimationSite * pAcAS // = NULL
- )
- {
- ASSERT( this != NULL );
- if( m_pAcAS == pAcAS )
- return;
- if( m_pAcAS != NULL )
- m_pAcAS->AnimationSite_ClientRemove( this );
- m_pAcAS = pAcAS;
- if( m_pAcAS != NULL && m_pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- m_pAcAS->AnimationSite_ClientAdd( this );
- }
- CExtBitmap & CExtAnimationClient::AnimationClient_StateGet( bool bAcNext )
- {
- ASSERT( this != NULL );
- if( bAcNext )
- return m_bmpAcStateNext;
- else
- return m_bmpAcStatePrev;
- }
- const CExtBitmap & CExtAnimationClient::AnimationClient_StateGet( bool bAcNext ) const
- {
- ASSERT( this != NULL );
- return
- ( const_cast < CExtAnimationClient * > ( this ) )
- -> AnimationClient_StateGet( bAcNext );
- }
- bool CExtAnimationClient::AnimationClient_IsEmpty() const
- {
- ASSERT( this != NULL );
- if( AnimationClient_StateGet( false ).IsEmpty()
- && AnimationClient_StateGet( true ).IsEmpty()
- )
- return true;
- else
- return false;
- }
- void CExtAnimationClient::AnimationClient_Empty()
- {
- ASSERT( this != NULL );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- AnimationClient_StepNumberSet( 0 );
- // AnimationClient_NonClientModeSet();
- //CRect rcEmpty( 0, 0, 0, 0 );
- // AnimationClient_TargetRectSet( rcEmpty );
- }
- INT CExtAnimationClient::AnimationClient_StepNumberGet() const
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepNumber );
- return m_nAcStepNumber;
- }
- void CExtAnimationClient::AnimationClient_StepNumberSet( INT nAcStepNumber )
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepNumber );
- ASSERT( 0 <= nAcStepNumber );
- m_nAcStepNumber = nAcStepNumber;
- }
- INT CExtAnimationClient::AnimationClient_StepCountGet() const
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepCount && m_nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- return m_nAcStepCount;
- }
- void CExtAnimationClient::AnimationClient_StepCountSet( INT nAcStepCount )
- {
- ASSERT( this != NULL );
- ASSERT( 0 <= m_nAcStepCount && m_nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- ASSERT( 0 <= nAcStepCount && nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- m_nAcStepCount = nAcStepCount;
- }
- UINT CExtAnimationClient::AnimationClient_TimerElapseGet() const
- {
- ASSERT( this != NULL );
- return m_nAcTimerElapse;
- }
- void CExtAnimationClient::AnimationClient_TimerElapseSet( UINT nAcTimerElapse )
- {
- ASSERT( this != NULL );
- m_nAcTimerElapse = nAcTimerElapse;
- }
- bool CExtAnimationClient::AnimationClient_NonClientModeGet() const
- {
- ASSERT( this != NULL );
- return m_bAcNonClientMode;
- }
- void CExtAnimationClient::AnimationClient_NonClientModeSet(
- bool bAcNonClientMode // = false
- )
- {
- ASSERT( this != NULL );
- m_bAcNonClientMode = bAcNonClientMode;
- }
- bool CExtAnimationClient::AnimationClient_EnabledGet() const
- {
- ASSERT( this != NULL );
- return m_bAcEnabled;
- }
- void CExtAnimationClient::AnimationClient_EnabledSet(
- bool bAcEnabled // = true
- )
- {
- ASSERT( this != NULL );
- m_bAcEnabled = bAcEnabled;
- }
- bool CExtAnimationClient::AnimationClient_OnQueryEnabledState(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT( this != NULL );
- const CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- if( pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- return false;
- if( ! AnimationClient_EnabledGet() )
- return false;
- if( AnimationClient_IsEmpty() )
- return false;
- if( AnimationClient_TargetRectGet().IsRectEmpty() )
- return false;
- INT nAcStepCount = AnimationClient_OnStepCountGet( eAPT );
- ASSERT( 0 <= nAcStepCount && nAcStepCount <= __EXT_MFC_DEF_ANIMATION_STEP_COUNT_MAX );
- if( nAcStepCount == 0 )
- return false;
- INT nAcStepNumber = AnimationClient_StepNumberGet();
- ASSERT( 0 <= nAcStepNumber );
- if( nAcStepNumber >= nAcStepCount )
- return false;
- return true;
- }
- CRect CExtAnimationClient::AnimationClient_TargetRectGet() const
- {
- ASSERT( this != NULL );
- return m_rcAcTarget;
- }
- void CExtAnimationClient::AnimationClient_TargetRectSet(
- const RECT & rcAcAnimationTarget
- )
- {
- ASSERT( this != NULL );
- m_rcAcTarget = rcAcAnimationTarget;
- }
- bool CExtAnimationClient::AnimationClient_CacheNextState(
- CDC & dc,
- const RECT & rcAcAnimationTarget,
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- if( pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- return false;
- if( ! AnimationClient_EnabledGet() )
- return false;
- if( AnimationClient_OnStepCountGet( eAPT ) == 0 )
- return false;
- m_bmpAcStatePrev = m_bmpAcStateNext;
- m_bmpAcStateNext.FromSurface( dc, rcAcAnimationTarget );
- m_bmpAcStateNext.Make32();
- AnimationClient_NextStateAdjust( m_bmpAcStateNext );
- m_rcAcTarget = rcAcAnimationTarget;
- // if( AnimationClient_IsEmpty() )
- // return false;
- AnimationClient_StepNumberSet( 0 );
- if( bAnimate )
- pAcAS->AnimationSite_OnClientStateChanged( this, eAPT );
- else
- pAcAS->AnimationSite_ClientProgressStop( this );
- return true;
- }
- bool CExtAnimationClient::AnimationClient_CacheNextState(
- HWND hWnd,
- const RECT & rcAcAnimationTarget,
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || ( ! ::IsWindow( hWnd ) ) )
- return false;
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- if( pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- return false;
- if( ! AnimationClient_EnabledGet() )
- return false;
- if( AnimationClient_OnStepCountGet( eAPT ) == 0 )
- return false;
- bool bAcNonClientMode = AnimationClient_NonClientModeGet();
- HDC hDC =
- (! bAcNonClientMode )
- ? ( ::GetDC( hWnd ) )
- : ( ::GetWindowDC( hWnd ) )
- ;
- if( hDC == NULL )
- return false;
- if( bAcNonClientMode )
- {
- RECT rcClient, rcWnd;
- if( ::GetClientRect( hWnd, &rcClient )
- && ::GetWindowRect( hWnd, &rcWnd )
- && ::ClientToScreen( hWnd, LPPOINT(&rcClient) )
- && ::ClientToScreen( hWnd, LPPOINT(&rcClient)+1 )
- && ::OffsetRect( &rcClient, -rcWnd.left, -rcWnd.top )
- )
- {
- ::ExcludeClipRect(
- hDC,
- rcClient.left,
- rcClient.top,
- rcClient.right,
- rcClient.bottom
- );
- } // if( ::GetClientRect( hWnd, &rcClient ) ...
- else
- {
- ::ReleaseDC( hWnd, hDC );
- return false;
- } // else from if( ::GetClientRect( hWnd, &rcClient ) ...
- } // if( bAcNonClientMode )
- bool bRetVal = false;
- CDC * pDC = CDC::FromHandle( hDC );
- if( pDC != NULL )
- {
- CRect _rcAcAnimationTarget = rcAcAnimationTarget;
- CExtMemoryDC dc( pDC, &_rcAcAnimationTarget );
- AnimationClient_NextStatePrepare(
- dc,
- rcAcAnimationTarget,
- bAnimate,
- eAPT
- );
- bRetVal =
- AnimationClient_CacheNextState(
- dc, //*pDC,
- rcAcAnimationTarget,
- bAnimate,
- eAPT
- );
- dc.__Flush( FALSE );
- }
- ::ReleaseDC( hWnd, hDC );
- return bRetVal;
- }
- bool CExtAnimationClient::AnimationClient_CacheNextStateMinInfo(
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- HWND hWnd = pAcAS->AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- CRect rcAcAnimationTarget = AnimationClient_TargetRectGet();
- return
- AnimationClient_CacheNextState(
- hWnd,
- rcAcAnimationTarget,
- bAnimate,
- eAPT
- );
- }
- void CExtAnimationClient::AnimationClient_NextStatePrepare(
- CDC & dc,
- const RECT & rcAcAnimationTarget,
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- ASSERT( dc.GetSafeHdc() != NULL );
- dc;
- rcAcAnimationTarget;
- bAnimate;
- eAPT;
- }
- void CExtAnimationClient::AnimationClient_NextStateAdjust(
- CExtBitmap & _bmp
- )
- {
- ASSERT( this != NULL );
- _bmp;
- }
- void CExtAnimationClient::AnimationClient_StateDoStep()
- {
- ASSERT( this != NULL );
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return;
- HWND hWnd = pAcAS->AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return;
- ASSERT( ::IsWindow( hWnd ) );
- CRect _rcAcAnimationTarget = AnimationClient_TargetRectGet();
- ::InvalidateRect( hWnd, &_rcAcAnimationTarget, TRUE );
- //static int g_nDebugCounter = 0;
- // TRACE1( "Animation step %drn", g_nDebugCounter++ );
- }
- bool CExtAnimationClient::AnimationClient_StatePaint(
- CDC & dc
- )
- {
- ASSERT( this != NULL );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( AnimationClient_CacheGeneratorIsLocked() )
- return false;
- if( ! AnimationClient_OnQueryEnabledState( m_eAPT_Last ) )
- return false;
- CRect rcAcAnimationTarget = AnimationClient_TargetRectGet();
- if( dc.RectVisible( &rcAcAnimationTarget ) )
- {
- INT nAcStepNumber = AnimationClient_StepNumberGet();
- INT nAcStepCount = AnimationClient_OnStepCountGet( m_eAPT_Last );
- ASSERT( nAcStepNumber <= nAcStepCount && nAcStepCount > 0 );
- CExtBitmap & bmpPrev = AnimationClient_StateGet( false );
- CExtBitmap & bmpNext = AnimationClient_StateGet( true );
- if( bmpPrev.IsEmpty() )
- return false;
- if( bmpNext.IsEmpty() )
- return false;
- double lfNextSCA = double(nAcStepNumber + 1) / double(nAcStepCount);
- // lfNextSCA = double( sin( lfNextSCA * 0.8 ) );
- // lfNextSCA = double( sin( lfNextSCA * 0.8 ) );
- if( lfNextSCA > 1.0 )
- lfNextSCA = 1.0;
- INT nNextSCA = INT( lfNextSCA * 255.0 );
- if( nNextSCA > 255 )
- nNextSCA = 255;
- ASSERT( 0 <= nNextSCA && nNextSCA <= 255 );
- int nPrevSCA = 255; // 255 - nNextSCA;
- int nOldStretchBltMode = ::GetStretchBltMode( dc.m_hDC );
- ::SetStretchBltMode( dc.m_hDC, g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR );
- DWORD dwPrevOldRTF = 0, dwNextOldRTF = 0;
- bool bChangeRTF = false;
- if( g_PaintManager.m_bIsWinVistaOrLater
- && g_PaintManager.m_DWM.IsCompositionEnabled()
- )
- bChangeRTF = true;
- if( bChangeRTF )
- {
- dwPrevOldRTF = bmpPrev.RunTimeFlagsGet();
- dwNextOldRTF = bmpNext.RunTimeFlagsGet();
- bmpPrev.RunTimeFlagsSet( dwPrevOldRTF | __EXT_BMP_FLAG_NO_RTL_DETECTION );
- bmpNext.RunTimeFlagsSet( dwNextOldRTF | __EXT_BMP_FLAG_NO_RTL_DETECTION );
- }
- if( nPrevSCA > 0 )
- bmpPrev.AlphaBlend(
- dc.m_hDC,
- rcAcAnimationTarget,
- BYTE(nPrevSCA)
- );
- if( nNextSCA > 0 )
- bmpNext.AlphaBlend(
- dc.m_hDC,
- rcAcAnimationTarget,
- BYTE(nNextSCA)
- );
- if( bChangeRTF )
- {
- bmpPrev.RunTimeFlagsSet( dwPrevOldRTF );
- bmpNext.RunTimeFlagsSet( dwNextOldRTF );
- }
- ::SetStretchBltMode( dc.m_hDC, nOldStretchBltMode );
- } // if( dc.RectVisible( &rcAcAnimationTarget ) )
- return true;
- }
- bool CExtAnimationClient::AnimationClient_StatePaint(
- HWND hWnd
- )
- {
- ASSERT( this != NULL );
- if( hWnd == NULL || ( ! ::IsWindow( hWnd ) ) )
- return false;
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- if( pAcAS->AnimationSite_ClientGetIndexOf( this ) < 0 )
- return false;
- if( ! AnimationClient_EnabledGet() )
- return false;
- if( AnimationClient_OnStepCountGet( m_eAPT_Last ) == 0 )
- return false;
- bool bAcNonClientMode = AnimationClient_NonClientModeGet();
- HDC hDC =
- bAcNonClientMode
- ? ( ::GetWindowDC( hWnd ) )
- : ( ::GetDC( hWnd ) )
- ;
- if( hDC == NULL )
- return false;
- if( bAcNonClientMode )
- {
- RECT rcClient, rcWnd;
- if( ::GetClientRect( hWnd, &rcClient )
- && ::GetWindowRect( hWnd, &rcWnd )
- && ::ClientToScreen( hWnd, LPPOINT(&rcClient) )
- && ::ClientToScreen( hWnd, LPPOINT(&rcClient)+1 )
- && ::OffsetRect( &rcClient, -rcWnd.left, -rcWnd.top )
- )
- {
- ::ExcludeClipRect(
- hDC,
- rcClient.left,
- rcClient.top,
- rcClient.right,
- rcClient.bottom
- );
- } // if( ::GetClientRect( hWnd, &rcClient ) ...
- else
- {
- ::ReleaseDC( hWnd, hDC );
- return false;
- } // else from if( ::GetClientRect( hWnd, &rcClient ) ...
- } // if( bAcNonClientMode )
- bool bRetVal = false;
- CDC * pDC = CDC::FromHandle( hDC );
- if( pDC != NULL )
- {
- CRect _rcAcAnimationTarget = AnimationClient_TargetRectGet();
- CExtMemoryDC dc( pDC, &_rcAcAnimationTarget );
- dc.FillSolidRect( &_rcAcAnimationTarget, 0 );
- bRetVal = AnimationClient_StatePaint( dc );
- }
- ::ReleaseDC( hWnd, hDC );
- return bRetVal;
- }
- bool CExtAnimationClient::AnimationClient_StatePaint()
- {
- ASSERT( this != NULL );
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS == NULL )
- return false;
- HWND hWnd = pAcAS->AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- return AnimationClient_StatePaint( hWnd );
- }
- void CExtAnimationClient::AnimationClient_OnProgressStart(
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- eAPT;
- AnimationClient_StepNumberSet( 0 );
- }
- void CExtAnimationClient::AnimationClient_OnProgressStop(
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- AnimationClient_StepNumberSet( AnimationClient_OnStepCountGet( eAPT ) );
- // AnimationClient_StateGet( true ).Empty();
- // AnimationClient_StateGet( false ).Empty();
- }
- INT CExtAnimationClient::AnimationClient_OnStepCountGet(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT( this != NULL );
- const CExtAnimationParameters * pAnimationParameters =
- AnimationClient_OnQueryAnimationParameters( eAPT );
- if( pAnimationParameters != NULL )
- {
- INT nAcStepCount =
- pAnimationParameters ->
- AnimationClient_StepCountGet();
- return nAcStepCount;
- } // if( pAnimationParameters != NULL )
- INT nAcStepCount =
- AnimationClient_StepCountGet();
- return nAcStepCount;
- }
- UINT CExtAnimationClient::AnimationClient_OnTimerElapseGet(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT( this != NULL );
- const CExtAnimationParameters * pAnimationParameters =
- AnimationClient_OnQueryAnimationParameters( eAPT );
- if( pAnimationParameters != NULL )
- {
- UINT nAcTimerElapse =
- pAnimationParameters ->
- AnimationClient_TimerElapseGet();
- return nAcTimerElapse;
- } // if( pAnimationParameters != NULL )
- UINT nAcTimerElapse =
- AnimationClient_TimerElapseGet();
- return nAcTimerElapse;
- }
- const CExtAnimationParameters *
- CExtAnimationClient::AnimationClient_OnQueryAnimationParameters(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT( this != NULL );
- const CExtAnimationParameters * pAnimationParameters =
- g_PaintManager->Animation_GetParameters(
- eAPT,
- NULL,
- this
- );
- return pAnimationParameters;
- }
- INT CExtAnimationClient::AnimationClient_LastAnimationTypeGet() const
- {
- ASSERT( this != NULL );
- return m_eAPT_Last;
- }
- void CExtAnimationClient::AnimationClient_LastAnimationTypeSet(
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- m_eAPT_Last = eAPT;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtAnimationSite
- IMPLEMENT_CExtPmBridge_MEMBERS_GENERIC( CExtAnimationSite );
- CExtAnimationSite::CExtAnimationSite(
- bool bAsEnabled // = true
- )
- : m_bAsEnabled( bAsEnabled )
- {
- // AnimationSite_Init( false );
- // m_AcHS.AnimationSiteSet( this, false );
- PmBridge_Install();
- }
- CExtAnimationSite::~CExtAnimationSite()
- {
- PmBridge_Uninstall();
- AnimationSite_Done();
- AnimationSite_ClientRemove();
- }
- HWND CExtAnimationSite::PmBridge_GetSafeHwnd() const
- {
- ASSERT( this != NULL );
- return AnimationSite_GetSafeHWND();
- }
- void CExtAnimationSite::PmBridge_OnPaintManagerChanged(
- CExtPaintManager * pGlobalPM
- )
- {
- ASSERT( this != NULL );
- INT nIndex, nCount = AnimationSite_ClientGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtAnimationClient * pAC = AnimationSite_ClientGetAt( nIndex );
- ASSERT( pAC != NULL );
- AnimationSite_ClientProgressStop( pAC );
- pAC->AnimationClient_StateGet( false ).Empty();
- pAC->AnimationClient_StateGet( true ).Empty();
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- CExtPmBridge::PmBridge_OnPaintManagerChanged(
- pGlobalPM
- );
- }
- bool CExtAnimationSite::AnimationSite_EnabledGet() const
- {
- ASSERT( this != NULL );
- return m_bAsEnabled;
- }
- void CExtAnimationSite::AnimationSite_EnabledSet(
- bool bAsEnabled // = true
- )
- {
- ASSERT( this != NULL );
- m_bAsEnabled = bAsEnabled;
- }
- bool CExtAnimationSite::AnimationSite_OnQueryEnabledState() const
- {
- ASSERT( this != NULL );
- if( ! AnimationSite_EnabledGet() )
- return false;
- HWND hWnd = AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- return true;
- }
- INT CExtAnimationSite::AnimationSite_ClientGetCount(
- bool bAsIncludeClientArea, // = true
- bool bAsIncludeNonClientArea // = true
- ) const
- {
- ASSERT( this != NULL );
- INT nCount = INT( m_arrAsAnimationClients.GetSize() );
- if( nCount == 0 )
- return 0;
- if( bAsIncludeClientArea )
- {
- if( bAsIncludeNonClientArea )
- return nCount;
- nCount = 0;
- INT nIndex;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- const CExtAnimationClient * pAC = m_arrAsAnimationClients.GetAt( nIndex );
- ASSERT( pAC != NULL );
- if( pAC->AnimationClient_NonClientModeGet() )
- continue;
- nCount ++;
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- return nCount;
- } // if( bAsIncludeClientArea )
- else
- {
- if( bAsIncludeNonClientArea )
- {
- nCount = 0;
- INT nIndex;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- const CExtAnimationClient * pAC = m_arrAsAnimationClients.GetAt( nIndex );
- ASSERT( pAC != NULL );
- if( ! pAC->AnimationClient_NonClientModeGet() )
- continue;
- nCount ++;
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- return nCount;
- } // if( bAsIncludeNonClientArea )
- return 0;
- } // else from if( bAsIncludeClientArea )
- }
- CExtAnimationClient * CExtAnimationSite::AnimationSite_ClientGetAt( INT nAcIndex )
- {
- ASSERT( this != NULL );
- if( nAcIndex < 0 )
- return NULL;
- INT nCount = INT( m_arrAsAnimationClients.GetSize() );
- if( nAcIndex >= nCount )
- return NULL;
- CExtAnimationClient * pAC = m_arrAsAnimationClients.GetAt( nAcIndex );
- ASSERT( pAC != NULL );
- return pAC;
- }
- const CExtAnimationClient * CExtAnimationSite::AnimationSite_ClientGetAt( INT nAcIndex ) const
- {
- ASSERT( this != NULL );
- return
- ( const_cast < CExtAnimationSite * > ( this ) )
- -> AnimationSite_ClientGetAt( nAcIndex );
- }
- bool CExtAnimationSite::AnimationSite_ClientInsertAt( INT nAcIndex, CExtAnimationClient * pAC )
- {
- ASSERT( this != NULL );
- if( pAC == NULL )
- return false;
- if( nAcIndex < 0 )
- return false;
- INT nCount = INT( m_arrAsAnimationClients.GetSize() );
- if( nAcIndex > nCount )
- return false;
- if( AnimationSite_ClientGetIndexOf( pAC ) >= 0 )
- return false;
- m_arrAsAnimationClients.InsertAt( nAcIndex, pAC );
- return true;
- }
- bool CExtAnimationSite::AnimationSite_ClientAdd( CExtAnimationClient * pAC )
- {
- ASSERT( this != NULL );
- return AnimationSite_ClientInsertAt( AnimationSite_ClientGetCount(), pAC );
- }
- INT CExtAnimationSite::AnimationSite_ClientGetIndexOf( const CExtAnimationClient * pAC ) const
- {
- ASSERT( this != NULL );
- if( pAC == NULL )
- return -1;
- INT nIndex, nCount = AnimationSite_ClientGetCount();
- if( nCount == 0 )
- return -1;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- const CExtAnimationClient * pOwnAC = AnimationSite_ClientGetAt( nIndex );
- ASSERT( pOwnAC != NULL );
- if( pOwnAC == pAC )
- return nIndex;
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- return -1;
- }
- INT CExtAnimationSite::AnimationSite_ClientRemove(
- INT nAcIndex, // = 0
- INT nAcCount, // = -1
- bool bDelete // = true
- )
- {
- ASSERT( this != NULL );
- if( nAcIndex < 0 || nAcCount == 0 )
- return 0;
- INT nCount = INT( m_arrAsAnimationClients.GetSize() );
- if( nAcIndex >= nCount )
- return 0;
- if( nAcCount < 0 )
- nAcCount = nCount;
- INT nIndex = nAcIndex, nCountRemoved = 0;
- for( ; nIndex < nCount && nCountRemoved < nAcCount; )
- {
- CExtAnimationClient * pAC = m_arrAsAnimationClients.GetAt( nIndex );
- ASSERT( pAC != NULL );
- m_arrAsAnimationClients.RemoveAt( nIndex, 1 );
- nCount --;
- nCountRemoved ++;
- AnimationSite_ClientProgressStop( pAC );
- if( bDelete )
- delete pAC;
- } // for( ; nIndex < nCount && nCountRemoved < nAcCount; )
- return nCountRemoved;
- }
- bool CExtAnimationSite::AnimationSite_ClientRemove(
- CExtAnimationClient * pAC,
- bool bDelete // = true
- )
- {
- ASSERT( this != NULL );
- INT nAcIndex = AnimationSite_ClientGetIndexOf( pAC );
- if( nAcIndex < 0 )
- return false;
- if( AnimationSite_ClientRemove( nAcIndex, 1, bDelete ) != 1 )
- return false;
- return true;
- }
- WORD CExtAnimationSite::AnimationSite_TimerGetBaseID()
- {
- ASSERT( this != NULL );
- return __EXT_MFC_DEF_ANIMATION_TIMER_BASE_TIMER_ID;
- }
- WORD CExtAnimationSite::AnimationSite_TimerGetMaxID()
- {
- ASSERT( this != NULL );
- return __EXT_MFC_DEF_ANIMATION_TIMER_MAX_TIMER_ID;
- }
- bool CExtAnimationSite::AnimationSite_ClientProgressStart(
- CExtAnimationClient * pAC,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- if( pAC == NULL )
- return false;
- AnimationSite_ClientProgressStop( pAC );
- pAC->AnimationClient_LastAnimationTypeSet( eAPT );
- HWND hWnd = AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- WORD wElapse = (WORD)pAC->AnimationClient_OnTimerElapseGet( pAC->AnimationClient_LastAnimationTypeGet() );
- WORD wTimerID = __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID;
- if( ! m_mapAsAnimationTimers.Lookup( wElapse, wTimerID ) )
- {
- wTimerID = AnimationSite_TimerGetBaseID();
- WORD wLastTimerID = AnimationSite_TimerGetMaxID();
- ASSERT( wTimerID <= wLastTimerID );
- for( ; wTimerID <= wLastTimerID; wTimerID ++ )
- {
- bool bFreeTimerID = true;
- POSITION pos = m_mapAsAnimationTimers.GetStartPosition();
- for( ; pos != NULL; )
- {
- WORD wCheckTimerID, wCheckElapse;
- m_mapAsAnimationTimers.GetNextAssoc( pos, wCheckElapse, wCheckTimerID );
- if( wTimerID == wCheckTimerID )
- {
- bFreeTimerID = false;
- break;
- }
- } // for( ; pos != NULL; )
- if( bFreeTimerID )
- break;
- else
- continue;
- } // for( ; wTimerID <= wLastTimerID; wTimerID ++ )
- ASSERT( wTimerID != __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID );
- if( wTimerID > wLastTimerID )
- return false;
- m_mapAsAnimationTimers.SetAt( wElapse, wTimerID );
- ::SetTimer( hWnd, UINT(wTimerID), UINT(wElapse), NULL );
- } // if( ! m_mapAsAnimationTimers.Lookup( wElapse, wTimerID ) )
- m_mapAsAnimationClients.SetAt( pAC, wTimerID );
- pAC->AnimationClient_OnProgressStart( pAC->AnimationClient_LastAnimationTypeGet() );
- return true;
- }
- void CExtAnimationSite::AnimationSite_ClientProgressStop(
- CExtAnimationClient * pAC
- )
- {
- ASSERT( this != NULL );
- if( pAC == NULL )
- return;
- WORD wTimerID = __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID;
- if( ! m_mapAsAnimationClients.Lookup( pAC, wTimerID ) )
- return;
- ASSERT( wTimerID != __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID );
- m_mapAsAnimationClients.RemoveKey( pAC );
- // pAC->AnimationClient_Empty();
- CRect _rcAcAnimationTarget = pAC->AnimationClient_TargetRectGet();
- bool bKillTimer = true;
- POSITION pos = m_mapAsAnimationClients.GetStartPosition();
- for( ; pos != NULL; )
- {
- CExtAnimationClient * pOtherAC = NULL;
- WORD wOtherTimerID = __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID;
- m_mapAsAnimationClients.GetNextAssoc( pos, pOtherAC, wOtherTimerID );
- ASSERT( pOtherAC != NULL );
- ASSERT( wOtherTimerID != __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID );
- if( wOtherTimerID == wTimerID )
- bKillTimer = false;
- } // for( ; pos != NULL; )
- HWND hWnd = AnimationSite_GetSafeHWND();
- ASSERT( hWnd == NULL || ::IsWindow( hWnd ) );
- if( bKillTimer )
- {
- WORD wElapse = (WORD)pAC->AnimationClient_OnTimerElapseGet( pAC->AnimationClient_LastAnimationTypeGet() );
- m_mapAsAnimationTimers.RemoveKey( wElapse );
- if( hWnd != NULL )
- {
- ASSERT( ::IsWindow( hWnd ) );
- ::KillTimer( hWnd, UINT(wTimerID) );
- }
- } // if( bKillTimer )
- if( hWnd != NULL )
- {
- ASSERT( ::IsWindow( hWnd ) );
- ::InvalidateRect( hWnd, &_rcAcAnimationTarget, TRUE );
- }
- pAC->AnimationClient_OnProgressStop( pAC->AnimationClient_LastAnimationTypeGet() );
- if( bKillTimer )
- AnimationSite_OnProgressShutdownTimer( UINT(wTimerID) );
- }
- CExtAnimationSite::AnimationHookSink::AnimationHookSink(
- CExtAnimationSite * pAS // = NULL
- )
- : m_pAS( pAS )
- , m_bHookEnabled( false )
- {
- AnimationInit( false );
- }
- CExtAnimationSite::AnimationHookSink::~AnimationHookSink()
- {
- AnimationDone();
- }
- CExtAnimationSite * CExtAnimationSite::AnimationHookSink::AnimationSiteGet()
- {
- ASSERT( this != NULL );
- return m_pAS;
- }
- const CExtAnimationSite * CExtAnimationSite::AnimationHookSink::AnimationSiteGet() const
- {
- ASSERT( this != NULL );
- return
- ( const_cast < AnimationHookSink * > ( this ) )
- -> AnimationSiteGet();
- }
- void CExtAnimationSite::AnimationHookSink::AnimationSiteSet( CExtAnimationSite * pAS, bool bHookEnabled )
- {
- ASSERT( this != NULL );
- if( m_pAS == pAS )
- return;
- AnimationDone();
- m_pAS = pAS;
- AnimationInit( bHookEnabled );
- }
- bool CExtAnimationSite::AnimationHookSink::AnimationInit( bool bHookEnabled )
- {
- ASSERT( this != NULL );
- CExtAnimationSite * pAS = AnimationSiteGet();
- if( pAS == NULL )
- return false;
- HWND hWnd = pAS->AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- m_bHookEnabled = bHookEnabled;
- if( bHookEnabled )
- SetupHookWndSink( hWnd );
- pAS->AnimationSite_OnAnimationHookInit();
- return true;
- }
- void CExtAnimationSite::AnimationHookSink::AnimationDone()
- {
- ASSERT( this != NULL );
- // if( bHookEnabled )
- // RemoveAllWndHooks();
- CExtAnimationSite * pAS = AnimationSiteGet();
- if( pAS != NULL )
- {
- // if( m_bHookEnabled )
- // {
- // HWND hWnd = pAS->AnimationSite_GetSafeHWND();
- // if( hWnd != NULL )
- // {
- // ASSERT( ::IsWindow( hWnd ) );
- // if( IsHookedWindow( hWnd ) )
- // SetupHookWndSink( hWnd, true );
- // }
- // } // if( m_bHookEnabled )
- pAS->AnimationSite_OnAnimationHookDone();
- }
- }
- bool CExtAnimationSite::AnimationHookSink::OnHookWndMsg(
- LRESULT & lResult,
- HWND hWndHooked,
- UINT nMessage,
- WPARAM & wParam,
- LPARAM & lParam
- )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT( this != NULL );
- CExtAnimationSite * pAS = AnimationSiteGet();
- if( pAS != NULL
- && hWndHooked == pAS->AnimationSite_GetSafeHWND()
- )
- {
- if( nMessage == WM_DESTROY
- || nMessage == WM_NCDESTROY
- )
- AnimationDone();
- else if(
- pAS->AnimationSite_OnHookWndMsg(
- lResult,
- hWndHooked,
- nMessage,
- wParam,
- lParam
- )
- )
- return true;
- }
- return
- CExtHookSink::OnHookWndMsg(
- lResult,
- hWndHooked,
- nMessage,
- wParam,
- lParam
- );
- }
- void CExtAnimationSite::AnimationSite_OnAnimationHookInit()
- {
- ASSERT( this != NULL );
- }
- void CExtAnimationSite::AnimationSite_OnAnimationHookDone()
- {
- ASSERT( this != NULL );
- }
- bool CExtAnimationSite::AnimationSite_OnHookWndMsg(
- LRESULT & lResult,
- HWND hWndHooked,
- UINT nMessage,
- WPARAM & wParam,
- LPARAM & lParam
- )
- {
- ASSERT( this != NULL );
- lParam;
- if( nMessage == WM_TIMER
- && hWndHooked == AnimationSite_GetSafeHWND()
- )
- {
- if( CExtAnimationSite::AnimationSite_OnHookTimer( UINT(wParam) ) )
- {
- lResult = 0;
- return true;
- }
- } // if( nMessage == WM_TIMER ...
- return false;
- }
- bool CExtAnimationSite::AnimationSite_OnHookTimer(
- UINT nTimerID
- )
- {
- ASSERT( this != NULL );
- HWND hWnd = AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- bool bTimerHandled = false;
- POSITION pos = m_mapAsAnimationTimers.GetStartPosition();
- for( ; pos != NULL; )
- {
- WORD wTimerID, wElapse;
- m_mapAsAnimationTimers.GetNextAssoc( pos, wElapse, wTimerID );
- if( wTimerID == WORD(nTimerID) )
- {
- bTimerHandled = true;
- break;
- }
- } // for( ; pos != NULL; )
- if( ! bTimerHandled )
- return false;
- INT nIndex, nCount = AnimationSite_ClientGetCount();
- INT nCountAnimatedCurrent = 0, nCountAnimatedMax = 10;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtAnimationClient * pAC =
- AnimationSite_ClientGetAt(
- nCount - nIndex - 1
- );
- ASSERT( pAC != NULL );
- WORD wTimerID = __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID;
- if( ! m_mapAsAnimationClients.Lookup( pAC, wTimerID ) )
- continue;
- ASSERT( wTimerID != __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID );
- if( ! pAC->AnimationClient_OnQueryEnabledState( pAC->AnimationClient_LastAnimationTypeGet() ) )
- {
- AnimationSite_ClientProgressStop( pAC );
- continue;
- }
- //CRect _rcAcAnimationTarget = pAC->AnimationClient_TargetRectGet();
- if( wTimerID == WORD(nTimerID) )
- {
- INT nAcStepNumber = pAC->AnimationClient_StepNumberGet();
- nAcStepNumber ++;
- pAC->AnimationClient_StepNumberSet( nAcStepNumber );
- if( (! pAC->AnimationClient_OnQueryEnabledState( pAC->AnimationClient_LastAnimationTypeGet() ) )
- || nCountAnimatedCurrent > nCountAnimatedMax
- )
- AnimationSite_ClientProgressStop( pAC );
- else
- {
- pAC->AnimationClient_StateDoStep();
- nCountAnimatedCurrent ++;
- }
- } // if( wTimerID == WORD(nTimerID) )
- //::InvalidateRect( hWnd, &_rcAcAnimationTarget, TRUE );
- // pAC->AnimationClient_StateDoStep();
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- // if( nCountAnimatedCurrent == 0 )
- // ::InvalidateRect( hWnd, NULL, TRUE );
- // ::UpdateWindow( hWnd );
- return true;
- }
- bool CExtAnimationSite::AnimationSite_Init( bool bHookEnabled )
- {
- ASSERT( this != NULL );
- m_AcHS.AnimationSiteSet( NULL, false );
- HWND hWnd = AnimationSite_GetSafeHWND();
- if( hWnd == NULL )
- return false;
- ASSERT( ::IsWindow( hWnd ) );
- m_AcHS.AnimationSiteSet( this, bHookEnabled );
- if( ! m_AcHS.IsHookedWindow( hWnd ) )
- return false;
- return true;
- }
- void CExtAnimationSite::AnimationSite_Done()
- {
- ASSERT( this != NULL );
- m_AcHS.AnimationSiteSet( NULL, false );
- }
- void CExtAnimationSite::AnimationSite_OnClientStateChanged(
- CExtAnimationClient * pAC,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT( this != NULL );
- ASSERT( pAC != NULL );
- AnimationSite_ClientProgressStart( pAC, eAPT );
- }
- void CExtAnimationSite::AnimationSite_PassAnimationEvents()
- {
- ASSERT( this != NULL );
- if( ! AnimationSite_EnabledGet() )
- return;
- HWND hWnd = AnimationSite_GetSafeHWND();
- // Pass timers first for animation issues
- bool bTimersFound = false;
- MSG msg;
- for( ; ::PeekMessage( &msg, hWnd, WM_TIMER, WM_TIMER, PM_NOREMOVE ); )
- {
- if( ! ::GetMessage( &msg, hWnd, WM_TIMER, WM_TIMER ) )
- break;
- ::DispatchMessage( &msg );
- bTimersFound = true;
- }
- for( ; ::PeekMessage( &msg, hWnd, __EXT_MFC_WM_MOUSEFIRST, __EXT_MFC_WM_MOUSELAST, PM_NOREMOVE ); )
- {
- if( ! ::GetMessage( &msg, hWnd, __EXT_MFC_WM_MOUSEFIRST, __EXT_MFC_WM_MOUSELAST ) )
- break;
- ::DispatchMessage( &msg );
- bTimersFound = true;
- }
- if( bTimersFound )
- {
- CExtPaintManager::stat_PassPaintMessages();
- // if( hWnd != NULL )
- // UpdateWindow( hWnd );
- }
- }
- void CExtAnimationSite::AnimationSite_OnProgressShutdownTimer( UINT nTimerID )
- {
- ASSERT( this != NULL );
- ASSERT( nTimerID != __EXT_MFC_DEF_ANIMATION_TIMER_INVALID_ID );
- nTimerID;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtAnimationSingleton
- CExtAnimationSingleton::CExtAnimationSingleton(
- bool bAsEnabled, // = true
- INT nAcStepNumber, // = 0
- INT nAcStepCount, // = __EXT_MFC_DEF_ANIMATION_STEP_COUNT
- UINT nAcTimerElapse, // = __EXT_MFC_DEF_ANIMATION_TIMER_ELAPSE
- const RECT * pAcRcAnimationTarget // = NULL
- )
- : CExtAnimationSite(
- bAsEnabled
- )
- , CExtAnimationClient(
- NULL,
- bAsEnabled,
- false,
- nAcStepNumber,
- nAcStepCount,
- nAcTimerElapse,
- pAcRcAnimationTarget
- )
- {
- AnimationClient_SiteSet( this );
- AnimationSite_ClientAdd( this );
- }
- CExtAnimationSingleton::~CExtAnimationSingleton()
- {
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS != NULL )
- pAcAS->AnimationSite_ClientRemove( this );
- }
- /////////////////////////////////////////////////////////////////////////////
- #define __TIMER_ID_DRAGGING_START 4100
- #define __TIMER_ID_DRELAYED_REPAINT_FAKE 4101
- //#define __TIMER_ID_DELAYED_UPDATE 4102
- #define __DOCKSITE_DCX_FLAGS
- ( DCX_WINDOW
- |DCX_CACHE
- |DCX_LOCKWINDOWUPDATE
- |DCX_CLIPSIBLINGS
- )
- #define __BAR_NC_GAP_X 1 //afxData.cxBorder2
- #define __BAR_NC_GAP_Y 1 //afxData.cyBorder2
- #define __DOCKING_SIDE_GAP 10
- static HCURSOR g_hCursorArrow = ::LoadCursor( NULL, IDC_ARROW );
- static HCURSOR g_hCursorDrag = ::LoadCursor( NULL, IDC_SIZEALL );
- static HCURSOR g_hCursorResizeV = ::LoadCursor( NULL, IDC_SIZENS );
- static HCURSOR g_hCursorResizeH = ::LoadCursor( NULL, IDC_SIZEWE );
- /////////////////////////////////////////////////////////////////////////////
- // CExtControlBar::FriendlyDockBarHack
- class CExtControlBar::FriendlyDockBarHack
- : CDockBar
- {
- public:
- friend class CExtControlBar;
- friend class CExtControlBar::InternalDraggingState_t;
- INT GetCalcExtentMax( BOOL bHorz )
- {
- ASSERT( this != NULL );
- ASSERT_VALID( this );
- ASSERT( m_pDockSite != NULL );
- ASSERT_VALID( m_pDockSite );
- ASSERT_KINDOF( CDockBar, this );
- INT nCalcExtentMax = bHorz
- ? m_rectLayout.Width()
- : m_rectLayout.Height();
- ASSERT( nCalcExtentMax >= 0 );
- if( nCalcExtentMax == 0
- || m_rectLayout.IsRectEmpty()
- )
- {
- CRect rcDock;
- GetClientRect( &rcDock );
- nCalcExtentMax = bHorz
- ? rcDock.Width() // + 2
- : rcDock.Height() // - 2
- ;
- if( nCalcExtentMax <= 0 )
- return 3; // dummy choice
- } // if( nCalcExtentMax == 0 )
- return nCalcExtentMax;
- }
- void _InsertBar( INT nPos, CControlBar * pBar )
- {
- ASSERT_VALID( this );
- ASSERT( nPos >= 0 && nPos < m_arrBars.GetSize() );
- m_arrBars.InsertAt( nPos, pBar );
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBar != NULL )
- {
- ASSERT_BAR_LOCATION_IN_ROW( this, pBar );
- }
- #endif // _DEBUG
- }
-
- void _InsertRowSplitter( INT nPos )
- {
- ASSERT_VALID( this );
- _InsertBar( nPos, NULL );
- ASSERT_VALID( this );
- }
- }; // class CExtControlBar::FriendlyDockBarHack
- /////////////////////////////////////////////////////////////////////////////
- // CExtControlBar::POPUP_MENU_EVENT_DATA
- CExtControlBar::POPUP_MENU_EVENT_DATA::POPUP_MENU_EVENT_DATA(
- SHORT nHelperNotificationType,
- CExtPopupMenuWnd * pPopupMenuWnd,
- CWnd * pWndEventSrc,
- const POINT & ptScreen,
- UINT nMsgID, // = WM_NULL
- CObject * pObjectSrc // = NULL
- )
- : m_nHelperNotificationType( nHelperNotificationType )
- , m_pPopupMenuWnd( pPopupMenuWnd )
- , m_pWndEventSrc( pWndEventSrc )
- , m_ptScreen( ptScreen )
- , m_nMsgID( nMsgID )
- , m_pObjectSrc( pObjectSrc )
- , m_pWndInitialTarget( NULL )
- , m_bPostNotification( false )
- {
- ASSERT_VALID( m_pPopupMenuWnd );
- ASSERT_VALID( m_pWndEventSrc );
- ASSERT( m_pWndEventSrc->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(m_pWndEventSrc->GetSafeHwnd()) );
- if( m_ptScreen.x < 0 || m_ptScreen.y < 0 )
- {
- if( ! ::GetCursorPos( &m_ptScreen ) )
- m_ptScreen.x = m_ptScreen.y = 0;
- }
- }
- CExtControlBar::POPUP_MENU_EVENT_DATA::~POPUP_MENU_EVENT_DATA()
- {
- }
- bool CExtControlBar::POPUP_MENU_EVENT_DATA::IsControlBarMenuListNotification() const
- {
- switch( m_nHelperNotificationType )
- {
- case __PMED_DOCKBAR_CTX:
- case __PMED_CONTROLBAR_CTX:
- case __PMED_CONTROLBAR_NC_CTX:
- case __PMED_STATUSBAR_CTX:
- case __PMED_AUTOHIDESLIDER_CTX:
- case __PMED_MINIFRAME_NC_CTX:
- case __PMED_MDICLIAREA_CTX:
- case __PMED_CONTROLBAR_NCBTNMENU_BARS:
- case __PMED_CTXEXPBTN_BARS:
- return true;
- } // switch( m_nHelperNotificationType )
- return false;
- }
- CExtControlBar::POPUP_MENU_EVENT_DATA::operator WPARAM() const
- {
- return ( (WPARAM) this );
- }
- CExtControlBar::POPUP_MENU_EVENT_DATA *
- CExtControlBar::POPUP_MENU_EVENT_DATA::FromWParam( WPARAM wParam )
- {
- return ( (POPUP_MENU_EVENT_DATA *) wParam );
- }
- CExtControlBar::POPUP_MENU_EVENT_DATA *
- CExtControlBar::POPUP_MENU_EVENT_DATA::FromMSG( MSG * pMSG )
- {
- ASSERT( pMSG != NULL );
- ASSERT( pMSG->message == CExtControlBar::g_nMsgConstructPopupMenu );
- return FromWParam( pMSG->wParam );
- }
- bool CExtControlBar::POPUP_MENU_EVENT_DATA::NotifyTarget(
- bool bPostNotification
- )
- {
- ASSERT_VALID( m_pPopupMenuWnd );
- ASSERT_VALID( m_pWndEventSrc );
- ASSERT( m_pWndEventSrc->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(m_pWndEventSrc->GetSafeHwnd()) );
- m_bPostNotification = bPostNotification;
- CControlBar * pBar = DYNAMIC_DOWNCAST( CControlBar, m_pWndEventSrc );
- if( pBar != NULL )
- m_pWndInitialTarget = pBar->m_pDockSite;
- if( m_pWndInitialTarget == NULL )
- {
- m_pWndInitialTarget = m_pWndEventSrc->GetParentFrame();
- if( m_pWndInitialTarget == NULL )
- {
- m_pWndInitialTarget = m_pWndEventSrc->GetParent();
- ASSERT_VALID( m_pWndInitialTarget );
- }
- else if( m_pWndInitialTarget->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)) )
- {
- m_pWndInitialTarget = m_pWndInitialTarget->GetParentFrame();
- ASSERT_VALID( m_pWndInitialTarget );
- ASSERT( ! m_pWndInitialTarget->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)) );
- }
- }
- ASSERT_VALID( m_pWndInitialTarget );
- ASSERT( m_pWndInitialTarget->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(m_pWndInitialTarget->GetSafeHwnd()) );
- LRESULT lResult =
- m_pWndInitialTarget->SendMessage(
- CExtControlBar::g_nMsgConstructPopupMenu,
- *this
- );
- return (lResult != 0) ? true : false;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtControlBar
- IMPLEMENT_DYNCREATE( CExtControlBar, CControlBar );
- void CExtControlBar::PmBridge_OnPaintManagerChanged(
- CExtPaintManager * pGlobalPM
- )
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() != NULL )
- {
- CUSTOM_NC_AREA_QUERY_DATA _cnaqd( this );
- _cnaqd.Notify();
- } // if( GetSafeHwnd() != NULL )
- CExtAnimationSite::PmBridge_OnPaintManagerChanged(
- pGlobalPM
- );
- }
- //CCriticalSection CExtControlBar::g_csCB;
- ExtControlBarVector_t CExtControlBar::g_AllBars;
- CExtControlBar::InternalDockBarInfo_t CExtControlBar::g_DockBarInfo;
- bool CExtControlBar::g_bEnableOnIdleCalls = false;
- bool CExtControlBar::g_bUseAdvancedToolTips = true;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtControlBar::g_bUseMouseClickOnlyInAutoHideTabs = false; // (+ v.2.82)
- bool CExtControlBar::g_bUseMouseClickOnOffStyleAutoHideTabs = false; // (+ v.2.83)
- bool CExtControlBar::g_bAllowAutohideTabsOleDropTarget = true; // (+ v.2.23)
- bool CExtControlBar::g_bAllowDynamicTabsOleDropTarget = true; // (+ v.2.23)
- bool CExtControlBar::g_bAllowKeyboardTabSwitch = true; // (+ v.2.24)
- bool CExtControlBar::g_bAllowKeyboardAutohideSwitch = true; // (+ v.2.24)
- bool CExtControlBar::g_bCloseOnlyOneBarInTabGroup = false; // (+ v.2.40)
- bool CExtControlBar::g_bTabsAtTop = false; // (+ v.2.43)
- DWORD CExtControlBar::g_dwTabContainerTabsStyle = __ETWS_EQUAL_WIDTHS; // | __ETWS_MULTI_ROW_COLUMN | __ETWS_FULL_WIDTH
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtControlBar::eResizablePanelDockingType_t CExtControlBar::g_eResizablePanelDockingType
- = CExtControlBar::__RESIZABLE_DOCKING_TYPE_BY_THEME;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtControlBar::eAutoHideTabsType_t CExtControlBar::g_eAutoHideTabsType
- = CExtControlBar::__AUTOHIDE_TABS_TYPE_BY_THEME;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- const UINT CExtControlBar::g_nMsgQueryFocusChangingEnabled =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgQueryFocusChangingEnabled")
- );
- const UINT CExtControlBar::g_nMsgQueryRepositionCalcEffect =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgQueryRepositionCalcEffect")
- );
- const UINT CExtControlBar::g_nMsgQueryIcon =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgQueryIcon")
- );
- const UINT CExtControlBar::g_nMsgPutToPopupMenu =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgPutToPopupMenu")
- );
- const UINT CExtControlBar::g_nMsgConstructPopupMenu =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgConstructPopupMenu")
- );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- int CExtControlBar::g_nTabDrarDropSelectionDelay = 500;
- const UINT CExtControlBar::g_nMsgCreateTabbedBar =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgCreateTabbedBar")
- );
- bool CExtControlBar::g_bDisableAutoHideAnimationExpanding = false;
- bool CExtControlBar::g_bDisableAutoHideAnimationCollapsing = false;
- INT CExtControlBar::g_nAutoHideAnimationStepCount = 5;
- INT CExtControlBar::g_nAutoHideAnimationStepTime = 10;
- const int CExtControlBar::g_nTabShapeMaxHeight = 18;
- const int CExtControlBar::g_nTabShapeBottomLeftAreaWidth = 8;
- const int CExtControlBar::g_nTabShapeBottomMiddleAreaWidth = 36;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- const UINT CExtControlBar::g_nMsgDrawTrackedArea =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgDrawTrackedArea")
- );
- CExtControlBar * CExtControlBar::g_pBarToggleFloatingState = NULL;
- CExtControlBar * CExtControlBar::_GetBarToggleFloatingState()
- {
- return g_pBarToggleFloatingState;
- }
- CExtControlBar::QueryFocusChangingEnabled_t::QueryFocusChangingEnabled_t(
- CWnd * pWndQueryOwner,
- HWND hWndNewFocusOwner
- )
- : m_bFocusChangingEnabled( true )
- , m_pWndQueryOwner( pWndQueryOwner )
- , m_hWndNewFocusOwner( hWndNewFocusOwner )
- {
- ASSERT_VALID( m_pWndQueryOwner );
- ASSERT( m_pWndQueryOwner->GetSafeHwnd() != NULL );
- ASSERT( m_hWndNewFocusOwner != NULL && ::IsWindow( m_hWndNewFocusOwner ) );
- }
- bool CExtControlBar::stat_QueryFocusChangingEnabled(
- HWND hWndNotifyTarget,
- CWnd * pWndQueryOwner,
- HWND hWndNewFocusOwner
- )
- {
- ASSERT( hWndNotifyTarget != NULL && ::IsWindow( hWndNotifyTarget ) );
- ASSERT_VALID( pWndQueryOwner );
- ASSERT( pWndQueryOwner->GetSafeHwnd() != NULL );
- ASSERT( hWndNewFocusOwner != NULL && ::IsWindow( hWndNewFocusOwner ) );
- CExtControlBar * pBar = DYNAMIC_DOWNCAST( CExtControlBar, pWndQueryOwner );
- if( pBar != NULL
- && pBar->IsFixedMode()
- )
- return false;
- QueryFocusChangingEnabled_t _QFCE( pWndQueryOwner, hWndNewFocusOwner );
- ::SendMessage( hWndNotifyTarget, g_nMsgQueryFocusChangingEnabled, _QFCE, 0 );
- return _QFCE.m_bFocusChangingEnabled;
- }
- bool CExtControlBar::stat_QueryFocusChangingEnabled(
- CExtControlBar * pWndQueryOwner,
- HWND hWndNewFocusOwner
- )
- {
- ASSERT_VALID( pWndQueryOwner );
- ASSERT( pWndQueryOwner->GetSafeHwnd() != NULL );
- ASSERT( hWndNewFocusOwner != NULL && ::IsWindow( hWndNewFocusOwner ) );
- HWND hWndNotifyTarget = pWndQueryOwner->m_pDockSite->GetSafeHwnd();
- if( hWndNotifyTarget == NULL )
- hWndNotifyTarget = ::GetParent( pWndQueryOwner->m_hWnd );
- return
- stat_QueryFocusChangingEnabled(
- hWndNotifyTarget,
- pWndQueryOwner,
- hWndNewFocusOwner
- );
- }
- bool CExtControlBar::stat_DragDetect_ImplStep(
- HWND hWnd,
- POINT pt,
- UINT nUpMessage // = WM_LBUTTONUP
- )
- {
- if( hWnd == NULL || (! ::IsWindow( hWnd ) ) )
- return false;
- CSize sizeDrag( ::GetSystemMetrics( SM_CXDRAG ), ::GetSystemMetrics( SM_CYDRAG ) );
- CRect rc( pt.x - sizeDrag.cx, pt.y - sizeDrag.cy, pt.x + sizeDrag.cx, pt.y + sizeDrag.cy );
- ::SetCapture( hWnd );
- for( MSG _msg; ::IsWindow( hWnd ) ; )
- {
- for( ;
- ::IsWindow( hWnd )
- && ( ::PeekMessage( &_msg, hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE )
- || ::PeekMessage( &_msg, 0, WM_CANCELMODE, WM_CANCELMODE, PM_NOREMOVE )
- || ::PeekMessage( &_msg, 0, WM_ACTIVATEAPP, WM_ACTIVATEAPP, PM_NOREMOVE )
- )
- ;
- )
- {
- if( _msg.message == nUpMessage
- || _msg.message == WM_CANCELMODE
- || _msg.message == WM_ACTIVATEAPP
- )
- {
- ::ReleaseCapture();
- return false;
- }
- ::PeekMessage( &_msg, hWnd, _msg.message, _msg.message, PM_REMOVE );
- if( _msg.message == WM_MOUSEMOVE )
- {
- CPoint ptMessage( LOWORD( _msg.lParam ), HIWORD( _msg.lParam ) );
- if( ! rc.PtInRect( ptMessage ) )
- {
- ReleaseCapture();
- return true;
- }
- }
- }
- ::WaitMessage();
- }
- return false;
- }
- bool CExtControlBar::stat_DoDragDetect(
- HWND hWnd,
- const POINT & ptWndClient,
- UINT nUpMessage // = WM_LBUTTONUP
- )
- {
- if( hWnd == NULL || (! ::IsWindow( hWnd ) ) )
- return false;
- CPoint ptScreen = ptWndClient;
- ::ClientToScreen( hWnd, &ptScreen );
- for( ; stat_DragDetect_ImplStep( hWnd, ptScreen, nUpMessage ) ; )
- {
- POINT ptCursorPos = { -32767, -32767 };
- if( ! ::GetCursorPos( &ptCursorPos ) )
- return false;
- if( ptScreen == ptCursorPos )
- continue; //only drag time elapsed but mouse is not moved
- return true;
- }
- return false;
- }
- static CExtSafeString productsection2regkeypath(
- __EXT_MFC_SAFE_LPCTSTR sProfileName,
- __EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USERSoftware
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProduct // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%
- )
- {
- return CExtCmdManager::GetSubSystemRegKeyPath(
- __PROF_UIS_REG_CONTROL_BAR,
- sProfileName,
- sSectionNameCompany,
- sSectionNameProduct
- );
- }
- CExtControlBar::InternalDockBarInfo_t::InternalDockBarInfo_t()
- {
- m_mapDockBarInfo.SetAt(
- AFX_IDW_DOCKBAR_TOP,
- CBRS_TOP
- );
- m_mapDockBarInfo.SetAt(
- AFX_IDW_DOCKBAR_BOTTOM,
- CBRS_BOTTOM
- );
- m_mapDockBarInfo.SetAt(
- AFX_IDW_DOCKBAR_LEFT,
- CBRS_LEFT
- );
- m_mapDockBarInfo.SetAt(
- AFX_IDW_DOCKBAR_RIGHT,
- CBRS_RIGHT
- );
- }
- DWORD CExtControlBar::InternalDockBarInfo_t::operator [] ( UINT nDockBarID )
- {
- DWORD dwStyle = 0;
- VERIFY( m_mapDockBarInfo.Lookup(nDockBarID,dwStyle) );
- return dwStyle;
- }
- bool CExtControlBar::InternalDockBarInfo_t::ReplaceFrameDockBar(
- UINT nDockBarID,
- DWORD dwDockStyle,
- CFrameWnd * pFrame
- )
- {
- ASSERT_VALID(pFrame);
- ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
- DWORD dwDockBarStyle = (*this)[nDockBarID];
- if( (dwDockBarStyle&dwDockStyle&CBRS_ALIGN_ANY) == 0 )
- return false;
-
- CDockBar * pDockBar = (CDockBar*)
- pFrame->GetControlBar(nDockBarID);
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CDockBar, pDockBar );
- if( pDockBar->IsKindOf(
- RUNTIME_CLASS(CExtDockOuterBar)
- )
- )
- return true;
- BOOL bExplicitDelete = !pDockBar->m_bAutoDelete;
- pDockBar->m_pDockSite->RemoveControlBar( pDockBar );
- pDockBar->m_pDockSite = NULL;
- pDockBar->DestroyWindow();
- if( bExplicitDelete )
- delete pDockBar;
- CExtDockBar * pDockBarEx = new CExtDockOuterBar();
- DWORD dwStyle =
- WS_CHILD|WS_VISIBLE
- |WS_CLIPSIBLINGS|WS_CLIPCHILDREN
- |dwDockBarStyle
- ;
- if( ! pDockBarEx->Create(
- pFrame,
- dwStyle,
- nDockBarID
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- return true;
- }
- CExtControlBar::CExtControlBar()
- : m_bGripperStaticallyAtTop( true )
- //, m_bAllowContractExpand( false ) // (- v.2.24)
- , m_bDoNotEraseClientBackground( false )
- , m_bPresubclassDialogMode( false )
- , m_bReflectParentSizing( true )
- , m_bInCustomModeUpdateCmdUI( false )
- , m_bFixedMode( false )
- , m_bNoForcedRecalcMetrics( false )
- , m_bAppearInDockSiteControlBarPopupMenu( true )
- , m_nGripHeightAtTop( ::GetSystemMetrics(SM_CYSMCAPTION)+1 )
- , m_nGripWidthAtLeft( ::GetSystemMetrics(SM_CYSMCAPTION)+1 )
- , m_nSeparatorHeight( min( 4, ::GetSystemMetrics(SM_CYSIZEFRAME) ) )
- , m_nSeparatorWidth( min( 4, ::GetSystemMetrics(SM_CXSIZEFRAME) ) )
- , m_nTrackerOffset( 0 )
- , m_nMetricOffset( 0 )
- , m_sizeDockedH( 200, 150 )
- , m_sizeDockedV( 150, 200 )
- , m_sizeFloated( 200, 200 )
- , m_bRowResizing( false )
- , m_bRowRecalcing( false )
- , m_bDragging( false )
- , m_bReposSingleChildMode( true )
- , m_ptHelperDragOffsetFloated( 0, 0 )
- , m_ptHelperDragOffsetDockedH( 0, 0 )
- , m_ptHelperDragOffsetDockedV( 0, 0 )
- , m_ptFloatHelper( 0, 0 )
- , m_bWindowActive( false )
- , m_bTopRecalcing( false )
- , m_bNcAreaBtnTracking( false )
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- , m_bAutoHideDeactivateOnEsc( false )
- , m_bAutoHideMode( false )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- , m_ptDraggingLast( -1, -1 )
- , m_bUpdatingChain( false )
- , m_nDelayedRowUpdateMetric( 0 )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_bVisibleInCustomizeListBox( false )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_nTearOffCmdID( 0 )
- , m_bSuspendTips( false )
- , m_bDelelayRepaintNcButtons( false )
- , m_bHelperSuppressDestruction( false )
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- , m_nAutoHideWidth( -1 )
- , m_nAutoHideHeight( -1 )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- , m_bDisplaying( false )
- , m_bVisCheckFlag( false )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_pNotifiedCustomizeSite( NULL )
- #endif
- , m_bUseInvisibleCmdUI( false )
- , m_eCBPC( CExtControlBar::__ECBPC_EMPTY )
- , m_nFlashCaptionCounter( 0 )
- , m_nFlashCaptionStepMilliseconds( 0 )
- , m_nFlashCaptionTimerID( 99 )
- , m_clrFlashCaptionText( COLORREF(-1L) )
- , m_clrFlashCaptionBackground( COLORREF(-1L) )
- , m_bFlashCaptionHighlightedState( false )
- , m_bDelayShowInvoked( false )
- , m_bDelayShowFlag( false )
- {
- VERIFY( RegisterControlBarClass() );
- m_nMinHW = ::GetSystemMetrics( SM_CYSMCAPTION ) + 1 + m_nSeparatorWidth;
- m_nMinVH = ::GetSystemMetrics( SM_CYSMCAPTION ) + 1 + m_nSeparatorHeight;
- m_rcGrip.SetRectEmpty();
- m_rcRowResize.SetRectEmpty();
- m_rcRowRecalc.SetRectEmpty();
- m_rcRowRecalcUp.SetRectEmpty();
- //CSingleLock _slCsCB( &g_csCB );
- // _slCsCB.Lock();
- g_AllBars.Add( this );
- // _slCsCB.Unlock();
- }
- CExtControlBar::~CExtControlBar()
- {
- AnimationSite_ClientRemove( 0, -1, false );
- //CSingleLock _slCsCB( &g_csCB );
- // _slCsCB.Lock();
- INT nCountOfExtBars = (INT)g_AllBars.GetSize();
- for( INT nExtBar = 0; nExtBar < nCountOfExtBars; nExtBar++ )
- {
- CExtControlBar * pBar = g_AllBars[ nExtBar ];
- ASSERT( pBar != NULL );
- if( pBar == this )
- {
- g_AllBars.RemoveAt( nExtBar );
- break;
- }
- } // for( INT nExtBar = 0; nExtBar < nCountOfExtBars; nExtBar++ )
- // _slCsCB.Unlock();
- NcButtons_RemoveAll();
- }
- BEGIN_MESSAGE_MAP(CExtControlBar, CControlBar)
- //{{AFX_MSG_MAP(CExtControlBar)
- ON_WM_NCCALCSIZE()
- ON_WM_NCPAINT()
- ON_WM_CANCELMODE()
- ON_WM_CAPTURECHANGED()
- ON_WM_MOUSEMOVE()
- ON_WM_NCLBUTTONDOWN()
- ON_WM_NCLBUTTONUP()
- ON_WM_RBUTTONDOWN()
- ON_WM_MBUTTONDOWN()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_RBUTTONUP()
- ON_WM_SIZE()
- ON_WM_NCLBUTTONDBLCLK()
- ON_WM_NCRBUTTONUP()
- ON_WM_NCLBUTTONDOWN()
- ON_WM_NCMBUTTONDOWN()
- ON_WM_NCRBUTTONDOWN()
- ON_WM_SHOWWINDOW()
- ON_WM_SETFOCUS()
- ON_WM_CONTEXTMENU()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- ON_MESSAGE( WM_SETTEXT, OnSetText )
- ON_MESSAGE( WM_SIZEPARENT, OnSizeParent )
- ON_MESSAGE( WM_HELPHITTEST, OnHelpHitTest )
- ON_WM_SYSCOLORCHANGE()
- __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_MESSAGE( WM_DISPLAYCHANGE, OnDisplayChange )
- ON_MESSAGE( __ExtMfc_WM_THEMECHANGED, OnThemeChanged )
- __EXT_MFC_ON_WM_NCHITTEST()
- ON_MESSAGE_VOID( WM_INITIALUPDATE, OnInitialUpdate )
- ON_MESSAGE( WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI )
- END_MESSAGE_MAP()
- BOOL CExtControlBar::Create(
- __EXT_MFC_SAFE_LPCTSTR lpszWindowName,
- CWnd * pParentWnd,
- UINT nID, // = AFX_IDW_DIALOGBAR
- DWORD dwStyle // =
- //WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS
- //|CBRS_TOP|CBRS_GRIPPER|CBRS_TOOLTIPS
- //|CBRS_FLYBY|CBRS_SIZE_DYNAMIC
- //|CBRS_HIDE_INPLACE
- )
- {
- ASSERT_VALID( pParentWnd );
-
- if( !RegisterControlBarClass() )
- {
- ASSERT( FALSE );
- return FALSE;
- }
-
- ASSERT(
- !((dwStyle & CBRS_SIZE_FIXED)
- &&
- (dwStyle & CBRS_SIZE_DYNAMIC))
- );
- m_dwStyle = dwStyle & CBRS_ALL;
- CExtSafeString sWindowName( (LPCTSTR(lpszWindowName) != NULL) ? LPCTSTR(lpszWindowName) : _T("") );
- if( lpszWindowName == NULL && nID != 0 && nID != UINT(-1) )
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pParentWnd->GetSafeHwnd() ),
- nID
- );
- if( pCmdItem != NULL )
- {
- sWindowName = pCmdItem->m_sMenuText;
- sWindowName.Replace( _T("&"), _T("") );
- }
- else
- {
- if( ! g_ResourceManager->LoadString( sWindowName, nID ) )
- sWindowName = _T("");
- }
- }
- if( ! sWindowName.IsEmpty() )
- {
- int nNlPos = sWindowName.Find( _T('n') );
- if( nNlPos >= 0 )
- sWindowName = sWindowName.Left( nNlPos );
- }
-
- dwStyle &= ~CBRS_ALL;
- dwStyle |= WS_CLIPCHILDREN;
- CExtSafeString sWndClassName(
- ::AfxRegisterWndClass(
- CS_DBLCLKS,
- g_hCursorArrow,
- PmBridge_GetPM()->GetBrush( COLOR_BTNFACE ),
- 0
- )
- );
- if( ! CWnd::Create(
- sWndClassName,
- sWindowName.IsEmpty() ? _T("") : sWindowName,
- dwStyle,
- CRect( 0, 0, 0, 0 ),
- pParentWnd,
- nID
- )
- )
- {
- ASSERT( FALSE );
- return 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 CExtControlBar::_SetupFloatingFrameWndImpl(
- CFrameWnd * pFrame
- )
- {
- ASSERT( pFrame != NULL );
- return
- ((CExtControlBar::InternalFriendlyFrameWnd *)pFrame)->
- SetupSmilyFrameWnd();
- }
- bool CExtControlBar::_FrameEnableDockingImpl(
- CFrameWnd * pFrame,
- DWORD dwDockStyle, // = CBRS_ALIGN_ANY
- bool bReplaceFloatingWnd // = true
- )
- {
- // NOTE: this rule is specific for current implementation
- ASSERT( dwDockStyle == CBRS_ALIGN_ANY );
- ASSERT_VALID(pFrame);
- ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);
- pFrame->EnableDocking( dwDockStyle );
-
- if( !g_DockBarInfo.ReplaceFrameDockBar(
- AFX_IDW_DOCKBAR_TOP,
- dwDockStyle,
- pFrame
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( !g_DockBarInfo.ReplaceFrameDockBar(
- AFX_IDW_DOCKBAR_BOTTOM,
- dwDockStyle,
- pFrame
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( !g_DockBarInfo.ReplaceFrameDockBar(
- AFX_IDW_DOCKBAR_LEFT,
- dwDockStyle,
- pFrame
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( !g_DockBarInfo.ReplaceFrameDockBar(
- AFX_IDW_DOCKBAR_RIGHT,
- dwDockStyle,
- pFrame
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( bReplaceFloatingWnd )
- {
- if( !_SetupFloatingFrameWndImpl( pFrame ) )
- {
- ASSERT( FALSE );
- return false;
- }
- }
- return true;
- }
- const CRect & CExtControlBar::_RectGripGet() const
- {
- ASSERT_VALID( this );
- return m_rcGrip;
- }
- void CExtControlBar::_RectGripSet( const RECT & rcGrip )
- {
- ASSERT_VALID( this );
- m_rcGrip = rcGrip;
- }
- const CRect & CExtControlBar::_RectRowResizeGet() const
- {
- ASSERT_VALID( this );
- return m_rcRowResize;
- }
- void CExtControlBar::_RectRowResizeSet( const RECT & rcRowResize )
- {
- ASSERT_VALID( this );
- m_rcRowResize = rcRowResize;
- }
- const CRect & CExtControlBar::_RectRowRecalcGet() const
- {
- ASSERT_VALID( this );
- return m_rcRowRecalc;
- }
- void CExtControlBar::_RectRowRecalcSet( const RECT & rcRowRecalc )
- {
- ASSERT_VALID( this );
- m_rcRowRecalc = rcRowRecalc;
- }
- const CRect & CExtControlBar::_RectRowRecalcUpGet() const
- {
- ASSERT_VALID( this );
- return m_rcRowRecalcUp;
- }
- void CExtControlBar::_RectRowRecalcUpSet( const RECT & rcRowRecalcUp )
- {
- ASSERT_VALID( this );
- m_rcRowRecalcUp = rcRowRecalcUp;
- }
- INT CExtControlBar::_GripperWidthAtLeftGet() const
- {
- ASSERT_VALID( this );
- ASSERT( m_nGripWidthAtLeft >= 0 );
- return m_nGripWidthAtLeft;
- }
- void CExtControlBar::_GripperWidthAtLeftSet( INT nGripWidthAtLeft )
- {
- ASSERT_VALID( this );
- ASSERT( nGripWidthAtLeft >= 0 );
- m_nGripWidthAtLeft = nGripWidthAtLeft;
- }
- INT CExtControlBar::_GripperHeightAtTopGet() const
- {
- ASSERT_VALID( this );
- ASSERT( m_nGripHeightAtTop >= 0 );
- return m_nGripHeightAtTop;
- }
- void CExtControlBar::_GripperHeightAtTopSet( INT nGripHeightAtTop )
- {
- ASSERT_VALID( this );
- ASSERT( nGripHeightAtTop >= 0 );
- m_nGripHeightAtTop = nGripHeightAtTop;
- }
- INT CExtControlBar::_SeparatorWidthGet() const
- {
- ASSERT_VALID( this );
- ASSERT( m_nSeparatorWidth >= 0 );
- return m_nSeparatorWidth;
- }
- void CExtControlBar::_SeparatorWidthSet( INT nSeparatorWidth )
- {
- ASSERT_VALID( this );
- ASSERT( nSeparatorWidth >= 0 );
- m_nSeparatorWidth = nSeparatorWidth;
- }
- INT CExtControlBar::_SeparatorHeightGet() const
- {
- ASSERT_VALID( this );
- return m_nSeparatorHeight;
- }
- void CExtControlBar::_SeparatorHeightSet( INT nSeparatorHeight )
- {
- ASSERT_VALID( this );
- ASSERT( nSeparatorHeight >= 0 );
- m_nSeparatorHeight = nSeparatorHeight;
- }
- bool CExtControlBar::_IsCustomNcArea() const
- {
- ASSERT_VALID( this );
- return g_bUseCustomNcArea;
- }
- bool CExtControlBar::g_bUseCustomNcArea = false;
- const UINT CExtControlBar::g_nMsgCustomNcAreaQuery =
- ::RegisterWindowMessage(
- _T("CExtControlBar::g_nMsgCustomNcAreaQuery")
- );
- CExtControlBar::CUSTOM_NC_AREA_QUERY_DATA::CUSTOM_NC_AREA_QUERY_DATA(
- CExtControlBar * pBar,
- HDC hDcDraw // = NULL
- )
- : m_pBar( pBar )
- , m_hDcDraw( hDcDraw )
- , m_bQueryHandled( false )
- {
- ASSERT_VALID( m_pBar );
- }
- bool CExtControlBar::CUSTOM_NC_AREA_QUERY_DATA::Notify()
- {
- ASSERT_VALID( m_pBar );
- m_bQueryHandled = false;
- if( m_pBar->_IsCustomNcArea() )
- {
- CWnd * pWndNotifyTarget = m_pBar->m_pDockSite;
- if( pWndNotifyTarget->GetSafeHwnd() == NULL )
- {
- pWndNotifyTarget = m_pBar->GetOwner();
- if( pWndNotifyTarget->GetSafeHwnd() == NULL )
- {
- pWndNotifyTarget = m_pBar->GetParent();
- }
- }
- if( pWndNotifyTarget->GetSafeHwnd() != NULL )
- pWndNotifyTarget->SendMessage(
- CExtControlBar::g_nMsgCustomNcAreaQuery,
- *this
- );
- } // if( m_pBar->_IsCustomNcArea() )
- if( ! m_bQueryHandled )
- {
- INT nSeparatorWidth =
- m_pBar->PmBridge_GetPM()->Bar_SeparatorWidthGet( m_pBar );
- INT nSeparatorHeight =
- m_pBar->PmBridge_GetPM()->Bar_SeparatorHeightGet( m_pBar );
- if( nSeparatorWidth < 0 )
- nSeparatorWidth = min( 4, ::GetSystemMetrics(SM_CXSIZEFRAME) );
- if( nSeparatorHeight < 0 )
- nSeparatorHeight = min( 4, ::GetSystemMetrics(SM_CYSIZEFRAME) );
- m_pBar->_SeparatorWidthSet( nSeparatorWidth );
- m_pBar->_SeparatorHeightSet( nSeparatorHeight );
- if( (m_pBar->GetBarStyle()&CBRS_GRIPPER) != 0
- && (! m_pBar->IsFixedMode() )
- )
- {
- INT nGripWidthAtLeft =
- m_pBar->PmBridge_GetPM()->Bar_GripperWidthAtLeftGet( m_pBar );
- INT nGripHeightAtTop =
- m_pBar->PmBridge_GetPM()->Bar_GripperHeightAtTopGet( m_pBar );
- if( nGripWidthAtLeft < 0 )
- nGripWidthAtLeft = ::GetSystemMetrics(SM_CYSMCAPTION)+1;
- if( nGripHeightAtTop < 0 )
- nGripHeightAtTop = ::GetSystemMetrics(SM_CYSMCAPTION)+1;
- m_pBar->_GripperWidthAtLeftSet( nGripWidthAtLeft );
- m_pBar->_GripperHeightAtTopSet( nGripHeightAtTop );
- }
- } // if( ! m_bQueryHandled )
- return m_bQueryHandled;
- }
- CExtControlBar::CUSTOM_NC_AREA_QUERY_DATA::operator WPARAM() const
- {
- return WPARAM( this );
- }
- CExtControlBar::CUSTOM_NC_AREA_QUERY_DATA *
- CExtControlBar::CUSTOM_NC_AREA_QUERY_DATA::FromWPARAM( WPARAM wParam )
- {
- CUSTOM_NC_AREA_QUERY_DATA * pCNAQD =
- reinterpret_cast < CUSTOM_NC_AREA_QUERY_DATA * > ( wParam );
- ASSERT( pCNAQD != NULL );
- return pCNAQD;
- }
- bool CExtControlBar::FrameEnableDocking(
- CFrameWnd * pFrame,
- DWORD dwDockStyle, // = CBRS_ALIGN_ANY
- bool bReplaceFloatingWnd // = true
- )
- {
- return
- _FrameEnableDockingImpl(
- pFrame,
- dwDockStyle,
- bReplaceFloatingWnd
- );
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtControlBar::FrameInjectAutoHideAreas(
- CFrameWnd * pFrame
- )
- {
- return _FrameInjectAutoHideAreasImpl( pFrame );
- }
- bool CExtControlBar::_FrameInjectAutoHideAreasImpl(
- CFrameWnd * pFrame
- )
- {
- ASSERT_VALID( pFrame );
- ASSERT( pFrame->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(pFrame->GetSafeHwnd()) );
- CExtDynAutoHideSlider * pWndSlider = new CExtDynAutoHideSlider;
- if( ! pWndSlider->Create( pFrame ) )
- {
- ASSERT( FALSE );
- return false;
- }
- CExtDynAutoHideArea * pWndAutoHideArea =
- new CExtDynAutoHideArea();
- if( ! pWndAutoHideArea->Create(
- pFrame,
- pWndSlider,
- AFX_IDW_DOCKBAR_TOP
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- pWndAutoHideArea =
- new CExtDynAutoHideArea();
- if( ! pWndAutoHideArea->Create(
- pFrame,
- pWndSlider,
- AFX_IDW_DOCKBAR_BOTTOM
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
-
- pWndAutoHideArea =
- new CExtDynAutoHideArea();
- if( ! pWndAutoHideArea->Create(
- pFrame,
- pWndSlider,
- AFX_IDW_DOCKBAR_LEFT
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
-
- pWndAutoHideArea =
- new CExtDynAutoHideArea();
- if( ! pWndAutoHideArea->Create(
- pFrame,
- pWndSlider,
- AFX_IDW_DOCKBAR_RIGHT
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- pFrame->DelayRecalcLayout();
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtControlBar::IsFixedMode() const
- {
- return m_bFixedMode;
- }
- bool CExtControlBar::IsFixedDockStyle() const
- {
- return IsFixedMode();
- }
- bool CExtControlBar::ProfileBarStateLoad(
- CFrameWnd * pFrame,
- __EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USERSoftware
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%%sSectionNameProfile%
- LPWINDOWPLACEMENT pFrameWp, // = NULL // need serialize frame's WP
- bool bSerializeFixedBarsState, // = true,
- bool bSerializeResizableBarsState, // = true
- HKEY hKeyRoot, // HKEY_CURRENT_USER
- bool bEnableThrowExceptions // = false
- )
- {
- ASSERT( sSectionNameCompany != NULL );
- ASSERT( sSectionNameProduct != NULL );
- ASSERT( sSectionNameProfile != NULL );
- ASSERT_VALID( pFrame );
- __EXT_MFC_SAFE_LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd(
- pFrame->GetSafeHwnd()
- );
- if( pFrame == NULL
- || strProfileName == NULL
- || strProfileName[0] == _T(' ')
- )
- {
- //ASSERT( FALSE );
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateLoad() failed to load bar staten" );
- if( bEnableThrowExceptions )
- ::AfxThrowUserException();
- return false;
- }
- ASSERT_VALID( pFrame );
- CExtSafeString sRegKeyPath=
- productsection2regkeypath(
- sSectionNameProfile,
- sSectionNameCompany,
- sSectionNameProduct
- );
- try
- {
- // prepare memory file and archive,
- // get information from registry
- CMemFile _file;
- if( ! CExtCmdManager::FileObjFromRegistry(
- _file,
- sRegKeyPath,
- hKeyRoot,
- bEnableThrowExceptions
- )
- )
- {
- ASSERT( ! bEnableThrowExceptions );
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateLoad() failed to load bar staten" );
- // Windows XP fix - begin
- WINDOWPLACEMENT _wpf;
- ::memset( &_wpf, 0, sizeof(WINDOWPLACEMENT) );
- _wpf.length = sizeof(WINDOWPLACEMENT);
- CWnd * pWndPlacement = stat_GetWndForPlacement( pFrame );
- ASSERT_VALID( pWndPlacement );
- //if( pWndPlacement->GetWindowPlacement(&_wpf) )
- if( CExtControlBar::stat_GetWindowPlacement( pWndPlacement->m_hWnd, _wpf ) )
- {
- _wpf.ptMinPosition.x = _wpf.ptMinPosition.y = 0;
- _wpf.ptMaxPosition.x = _wpf.ptMaxPosition.y = 0;
- _wpf.showCmd =
- (pWndPlacement->GetStyle() & WS_VISIBLE)
- ? SW_SHOWNA
- : SW_HIDE;
- //pWndPlacement->SetWindowPlacement(&_wpf);
- CExtControlBar::stat_SetWindowPlacement( pWndPlacement->m_hWnd, _wpf );
- }
- // Windows XP fix - end
- return false;
- }
- CArchive ar(
- &_file,
- CArchive::load
- );
- // do serialization
- if( ! ProfileBarStateSerialize(
- ar,
- pFrame,
- pFrameWp,
- bSerializeFixedBarsState,
- bSerializeResizableBarsState,
- bEnableThrowExceptions
- )
- )
- {
- //ASSERT( FALSE );
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateLoad() failed to load bar staten" );
- return false;
- }
- return true;
- } // try
- catch( CException * pXept )
- {
- if( bEnableThrowExceptions )
- throw;
- pXept->Delete();
- //ASSERT( FALSE );
- } // catch( CException * pXept )
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- //ASSERT( FALSE );
- } // catch( ... )
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateLoad() failed to load bar staten" );
- return false;
- }
- bool CExtControlBar::ProfileBarStateSave(
- CFrameWnd * pFrame,
- __EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USERSoftware
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%%sSectionNameProfile%%sSectionNameProfile%
- LPWINDOWPLACEMENT pFrameWp, // = NULL // need serialize frame's WP
- bool bSerializeFixedBarsState, // = true,
- bool bSerializeResizableBarsState, // = true
- HKEY hKeyRoot, // HKEY_CURRENT_USER
- bool bEnableThrowExceptions // = false
- )
- {
- ASSERT( sSectionNameCompany != NULL );
- ASSERT( sSectionNameProduct != NULL );
- ASSERT( sSectionNameProfile != NULL );
- ASSERT_VALID( pFrame );
- __EXT_MFC_SAFE_LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd(
- pFrame->GetSafeHwnd()
- );
- if( pFrame == NULL
- || strProfileName == NULL
- || strProfileName[0] == _T(' ')
- )
- {
- //ASSERT( FALSE );
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateSave() failed to save bar staten" );
- if( bEnableThrowExceptions )
- ::AfxThrowUserException();
- return false;
- }
- ASSERT_VALID( pFrame );
- CExtSafeString sRegKeyPath =
- productsection2regkeypath(
- sSectionNameProfile,
- sSectionNameCompany,
- sSectionNameProduct
- );
- try
- {
- // prepare memory file and archive
- CMemFile _file;
- CArchive ar(
- &_file,
- CArchive::store
- );
- // do serialization
- ProfileBarStateSerialize(
- ar,
- pFrame,
- pFrameWp,
- bSerializeFixedBarsState,
- bSerializeResizableBarsState,
- bEnableThrowExceptions
- );
- // OK, serialization passed
- ar.Flush();
- ar.Close();
- // put information to registry
- if( ! CExtCmdManager::FileObjToRegistry(
- _file,
- sRegKeyPath,
- hKeyRoot,
- bEnableThrowExceptions
- )
- )
- {
- ASSERT( ! bEnableThrowExceptions );
- //ASSERT( FALSE );
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateSave() failed to save bar staten" );
- return false;
- }
- return true;
- } // try
- catch( CException * pXept )
- {
- if( bEnableThrowExceptions )
- throw;
- pXept->Delete();
- //ASSERT( FALSE );
- } // catch( CException * pXept )
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- //ASSERT( FALSE );
- } // catch( ... )
- TRACE0( "Prof-UIS: CExtControlBar::ProfileBarStateSave() failed to save bar staten" );
- return false;
- }
- bool CExtControlBar::InternalFriendlyFrameWnd::SetupSmilyFrameWnd(void)
- {
- m_pFloatingFrameClass =
- RUNTIME_CLASS(CExtMiniDockFrameWnd);
- return true;
- }
- //
- //static CString __DEBUG_get_step_string( int nCharStep )
- //{
- //CString s = _T("");
- // for( int i = 0; i < nCharStep; i++ )
- // s += " ";
- // return s;
- //}
- //static CString __DEBUG_get_bar_info_string(
- // LPCTSTR strPrefix,
- // CControlBarInfo * pInfo,
- // int nCharStep = 1
- // )
- //{
- // ASSERT( pInfo != NULL );
- // ASSERT_VALID( pInfo->m_pBar );
- //CString s, sWndText;
- // pInfo->m_pBar->GetWindowText( sWndText );
- // s.Format(
- // _T("%s%sID = %d ="%s" (%s)n"),
- // strPrefix,
- // LPCTSTR( __DEBUG_get_step_string( nCharStep ) ),
- // int(pInfo->m_nBarID),
- // LPCTSTR(sWndText),
- // pInfo->m_pBar->GetRuntimeClass()->m_lpszClassName
- // );
- //int nChildrenCount = int( pInfo->m_arrBarID.GetSize() );
- // if( nChildrenCount > 0 )
- // {
- // CString sTmp;
- // sTmp.Format(
- // _T("%s%s%d children:n"),
- // strPrefix,
- // LPCTSTR( __DEBUG_get_step_string( nCharStep + 1 ) ),
- // nChildrenCount
- // );
- // s += sTmp;
- // for( int i = 0; i < nChildrenCount; i++ )
- // {
- // sTmp.Format(
- // _T("%s%sID = %dn"),
- // strPrefix,
- // LPCTSTR( __DEBUG_get_step_string( nCharStep + 2 ) ),
- // int( pInfo->m_arrBarID[i] )
- // );
- // s += sTmp;
- // }
- // }
- // return s;
- //}
- //static void __DEBUG_trace_bar_info(
- // LPCTSTR strPrefix,
- // CControlBarInfo * pInfo,
- // int nCharStep = 1
- // )
- //{
- // afxDump << __DEBUG_get_bar_info_string( strPrefix, pInfo, nCharStep );
- //}
- //
- void CExtControlBar::InternalFriendlyFrameWnd::SetOuterDockState(
- const CDockState & state,
- const CExtControlBar::OuterPropsArr_t & arrOuterProps,
- bool bSerializeFixedBarsState,
- bool bSerializeResizableBarsState
- )
- {
- // first pass through barinfo's sets the m_pBar member correctly
- // creating floating frames if necessary
- //CMapPtrToWord _mapCFV;
- int i = 0;
- for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- {
- CControlBarInfo * pInfo = (CControlBarInfo *)
- state.m_arrBarInfo[i];
- ASSERT( pInfo != NULL );
- CControlBar * pExistingBar = GetControlBar( pInfo->m_nBarID );
- if( pExistingBar != NULL )
- {
- //
- //CControlBar * pOld = pInfo->m_pBar;
- //pInfo->m_pBar = pExistingBar;
- //__DEBUG_trace_bar_info( _T("-LOAD-"), pInfo, 4 );
- //pInfo->m_pBar = pOld;
- //
- if( (! pExistingBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- || ( ((CExtControlBar*)pExistingBar)->IsFixedMode() )
- || ( ((CExtControlBar*)pExistingBar)->IsFixedDockStyle() )
- )
- {
- if( ! bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! bSerializeResizableBarsState )
- continue;
- }
- }
- if( pInfo->m_bFloating )
- {
- // need to create floating frame to match
- CMiniDockFrameWnd * pDockFrame =
- CreateFloatingFrame(
- pInfo->m_bHorz ?
- CBRS_ALIGN_TOP : CBRS_ALIGN_LEFT
- );
- ASSERT( pDockFrame != NULL) ;
- CRect rcWnd( pInfo->m_pointPos, CSize(10, 10) );
- pDockFrame->CalcWindowRect( &rcWnd );
- pDockFrame->SetWindowPos(
- NULL,
- rcWnd.left, rcWnd.top, 0, 0,
- SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE
- );
- CDockBar * pDockBar = (CDockBar *)
- pDockFrame->GetDlgItem( AFX_IDW_DOCKBAR_FLOAT );
- ASSERT( pDockBar != NULL );
- ASSERT_KINDOF( CDockBar, pDockBar );
- pInfo->m_pBar = pDockBar;
- // if( pInfo->m_bVisible )
- // _mapCFV.SetAt( pDockFrame, 0 );
- } // if( pInfo->m_bFloating )
- else // regular dock bar or toolbar
- {
- pInfo->m_pBar =
- pExistingBar; // GetControlBar( pInfo->m_nBarID );
- if( pInfo->m_pBar == NULL )
- continue;
- } // else from if( pInfo->m_bFloating )
- pInfo->m_pBar->m_nMRUWidth = pInfo->m_nMRUWidth;
- } // for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- // update new outer props
- for( i = 0; i < arrOuterProps.GetSize(); i++ )
- {
- OuterItemData_t _oid = arrOuterProps[i];
- CControlBar * pBarTmp = GetControlBar( _oid.m_nBarID );
- if( pBarTmp == NULL )
- continue;
- CExtControlBar * pExtBar = DYNAMIC_DOWNCAST( CExtControlBar, pBarTmp );
- if( pExtBar == NULL )
- continue;
- if( ( pExtBar->IsFixedMode() )
- || ( pExtBar->IsFixedDockStyle() )
- )
- {
- if( ! bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! bSerializeResizableBarsState )
- continue;
- }
- pExtBar->m_ptFloatHelper = _oid.m_ptFloatHelper;
- pExtBar->m_sizeDockedH = _oid.m_sizeDockedH;
- pExtBar->m_sizeDockedV = _oid.m_sizeDockedV;
- pExtBar->m_sizeFloated = _oid.m_sizeFloated;
- pExtBar->_AffixmentSetOuter( &_oid.m_AffixmentData );
- } // for( i = 0; i < arrOuterProps.GetSize(); i++ )
- // the second pass will actually dock all of the control bars and
- // set everything correctly
- for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- {
- CControlBarInfo * pInfo = (CControlBarInfo *)
- state.m_arrBarInfo[i];
- ASSERT( pInfo != NULL );
- if( pInfo->m_pBar == NULL )
- continue;
- if( (! pInfo->m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- || ( ((CExtControlBar*)pInfo->m_pBar)->IsFixedMode() )
- || ( ((CExtControlBar*)pInfo->m_pBar)->IsFixedDockStyle() )
- )
- {
- if( ! bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! bSerializeResizableBarsState )
- continue;
- }
- if( pInfo->m_pBar->m_pDockContext != NULL
- && pInfo->m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- )
- ((CExtControlBar*)(pInfo->m_pBar))->m_ptFloatHelper
- = pInfo->m_ptMRUFloatPos;
- pInfo->m_pBar->SetBarInfo( pInfo, this );
- } // for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- // the third pass will move independent floating bars
- // into valid positions
- for( i = 0; i < arrOuterProps.GetSize(); i++ )
- {
- OuterItemData_t _oid = arrOuterProps[i];
- CControlBar * pBarTmp = GetControlBar( _oid.m_nBarID );
- if( pBarTmp == NULL )
- continue;
- CExtControlBar * pExtBar = DYNAMIC_DOWNCAST( CExtControlBar, pBarTmp );
- if( pExtBar == NULL )
- continue;
- if( ( pExtBar->IsFixedMode() )
- || ( pExtBar->IsFixedDockStyle() )
- )
- {
- if( ! bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! bSerializeResizableBarsState )
- continue;
- }
- if( ! _oid.m_bFloating )
- continue;
- CSize _sizeFloating = _oid.m_sizeFloated;
- CRect rcFrameInitial( _oid.m_ptFloatHelper, _sizeFloating /*_oid.m_sizeFloated*/ );
- CExtMiniDockFrameWnd * pMiniFrame =
- DYNAMIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- pExtBar->GetParentFrame()
- );
- // if( pMiniFrame != NULL )
- // {
- // CRect rcClientFrame, rcWndFrame;
- // pMiniFrame->GetClientRect( &rcClientFrame );
- // pMiniFrame->GetWindowRect( &rcWndFrame );
- // _sizeFloating += rcWndFrame.Size() - rcClientFrame.Size();
- // rcFrameInitial.right += rcWndFrame.Width() - rcClientFrame.Width();
- // rcFrameInitial.bottom += rcWndFrame.Height() - rcClientFrame.Height();
- // }
- CRect rcFrameNew =
- CExtPaintManager::stat_AlignWndRectToMonitor(
- rcFrameInitial
- );
- // CExtMiniDockFrameWnd * pMiniFrame =
- // DYNAMIC_DOWNCAST(
- // CExtMiniDockFrameWnd,
- // pExtBar->GetParentFrame()
- // );
- if( pMiniFrame != NULL )
- {
- ASSERT_VALID( pMiniFrame );
- CRect rcFrameReal;
- pMiniFrame->GetWindowRect( rcFrameReal );
-
- //if( rcFrameReal == rcFrameNew )
- if( rcFrameReal.TopLeft() == rcFrameNew.TopLeft() )
- {
- pExtBar->DelayShow( _oid.m_bVisible ? TRUE : FALSE );
- pMiniFrame->RecalcLayout();
- continue;
- }
- pExtBar->OnNcAreaButtonsReinitialize();
- if( ! pExtBar->IsFixedMode() )
- pMiniFrame->ModifyStyle( FWS_SNAPTOBARS, 0 );
- //((InternalFriendlyFrameWnd *)pMiniFrame)->m_bInRecalcLayout = TRUE;
- pMiniFrame->MoveWindow( &rcFrameNew, FALSE );
- //((InternalFriendlyFrameWnd *)pMiniFrame)->m_bInRecalcLayout = FALSE;
- pMiniFrame->DelayRecalcLayout();
- //WORD tmp;
- //if( _mapCFV.Lookup( pMiniFrame, tmp )
- // && ( pMiniFrame->GetStyle()&WS_VISIBLE ) == 0
- // && ( ! pExtBar->IsFixedMode() )
- // )
- if( _oid.m_bVisible )
- {
- pExtBar->DelayShow( TRUE );
- CSize _size = rcFrameNew.Size();
- pExtBar->SetInitDesiredSizeFloating( _size );
- pExtBar->m_pDockContext->m_sizeLast = _size;
- pMiniFrame->ShowWindow( SW_SHOWNOACTIVATE );
- // ((InternalFriendlyFrameWnd *)pMiniFrame)->m_bInRecalcLayout = TRUE;
- pMiniFrame->MoveWindow( &rcFrameNew, FALSE );
- // ((InternalFriendlyFrameWnd *)pMiniFrame)->m_bInRecalcLayout = FALSE;
- pMiniFrame->RecalcLayout();
- CRect rcClientFrame, rcWndFrame;
- pMiniFrame->GetClientRect( &rcClientFrame );
- pMiniFrame->GetWindowRect( &rcWndFrame );
- CRect rcClientBar, rcWndBar;
- pExtBar->GetClientRect( &rcClientBar );
- pExtBar->GetWindowRect( &rcWndBar );
- CSize _sizeBar =
- _sizeFloating // _oid.m_sizeFloated
- - rcClientFrame.Size()
- + rcWndFrame.Size()
- - rcClientBar.Size()
- + rcWndBar.Size()
- ;
- pExtBar->OnRepositionSingleChild(
- _sizeBar.cx,
- _sizeBar.cy,
- true
- );
- }
- } // if( pMiniFrame != NULL )
- else
- pExtBar->FloatControlBar( rcFrameNew.TopLeft() );
- } // for( i = 0; i < arrOuterProps.GetSize(); i++ )
- // last pass shows all the floating windows that were previously shown
- for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- {
- CControlBarInfo * pInfo = (CControlBarInfo *)
- state.m_arrBarInfo[i];
- ASSERT( pInfo != NULL );
- if( pInfo->m_pBar == NULL )
- continue;
- if( (! pInfo->m_pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- || ( ((CExtControlBar*)pInfo->m_pBar)->IsFixedMode() )
- || ( ((CExtControlBar*)pInfo->m_pBar)->IsFixedDockStyle() )
- )
- {
- if( ! bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! bSerializeResizableBarsState )
- continue;
- }
- if( ! pInfo->m_bFloating )
- continue;
- CFrameWnd * pFrameWnd =
- pInfo->m_pBar->GetParentFrame();
- CDockBar * pDockBar = (CDockBar *) pInfo->m_pBar;
- ASSERT_KINDOF( CDockBar, pDockBar );
- if( pDockBar->GetDockedVisibleCount() > 0 )
- {
- pFrameWnd->RecalcLayout();
- pFrameWnd->ShowWindow( SW_SHOWNA );
- for( INT nBar = 1; nBar < pDockBar->m_arrBars.GetSize(); nBar ++ )
- {
- ASSERT( pDockBar->m_arrBars[0] == NULL );
- CControlBar * pBar = (CControlBar *)
- pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- continue;
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- CExtControlBar * pExtBar =
- DYNAMIC_DOWNCAST(
- CExtControlBar,
- pBar
- );
- if( pExtBar == NULL
- || pExtBar->IsFixedMode()
- )
- continue;
- pExtBar->_RecalcNcArea();
- }
- } // if( pDockBar->GetDockedVisibleCount() > 0 )
- } // for( i = 0; i < state.m_arrBarInfo.GetSize(); i++ )
- }
- void CExtControlBar::InternalFriendlyFrameWnd::GetOuterDockState(
- CDockState & state,
- CExtControlBar::OuterPropsArr_t & arrOuterProps
- ) const
- {
- for( POSITION pos = m_listControlBars.GetHeadPosition();
- pos != NULL;
- )
- { // get state info for each bar
- CControlBar * pBar = (CControlBar *)
- m_listControlBars.GetNext( pos );
- ASSERT( pBar != NULL );
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar))
- || pBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar))
- )
- continue;
- if( pBar->m_pDockBar != NULL
- && pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar))
- )
- continue;
- if( pBar->IsDockBar() )
- {
- UINT nID = pBar->GetDlgCtrlID();
- ASSERT_DOCKBAR_DLGCTRLID( nID );
- if( nID == AFX_IDW_DOCKBAR_FLOAT )
- {
- CWnd * pWnd = pBar->GetWindow(GW_CHILD);
- if( pWnd->GetSafeHwnd() == NULL )
- continue;
- CControlBar * pBarChild =
- STATIC_DOWNCAST(
- CControlBar,
- pWnd
- );
- if( pBarChild->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- continue;
- }
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDockBar))
- && ((CExtDockBar *)pBar)->_GetCircleNo() != 0
- )
- continue;
- } // if( pBar->IsDockBar() )
- #ifdef _DEBUG
- else
- {
- ASSERT( !pBar->IsKindOf(RUNTIME_CLASS(CDockBar)) );
- } // else from if( pBar->IsDockBar() )
- #endif // _DEBUG
- CSize sizeReset( -1, -1 );
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- {
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- continue;
- if( (! ((CExtControlBar*)pBar)->IsFixedMode() )
- && (! pBar->IsFloating() )
- )
- {
- if( pBar->m_pDockBar == NULL )
- continue;
- CExtDockBar * pDockBar =
- STATIC_DOWNCAST(
- CExtDockBar,
- pBar->m_pDockBar
- );
- ASSERT( !pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar)) );
- if( pDockBar->_GetCircleNo() > 0 )
- continue;
- }
- OuterItemData_t _oid;
- _oid.m_nBarID = pBar->GetDlgCtrlID();
- _oid.m_ptFloatHelper = ((CExtControlBar*)pBar)->m_ptFloatHelper;
- _oid.m_sizeDockedH = ((CExtControlBar*)pBar)->m_sizeDockedH;
- _oid.m_sizeDockedV = ((CExtControlBar*)pBar)->m_sizeDockedV;
- _oid.m_sizeFloated = ((CExtControlBar*)pBar)->m_sizeFloated;
- ASSERT( _oid.m_AffixmentData.IsEmpty() );
- InternalAffixmentData * pAffixmentData =
- ((CExtControlBar*)pBar)->_AffixmentGetOuter();
- if( pAffixmentData != NULL )
- _oid.m_AffixmentData = *pAffixmentData;
- _oid.m_bVisible = pBar->IsVisible() ? true : false;
-
- ASSERT( !_oid.m_bFloating );
- if( pBar->IsFloating() )
- {
- CRect rcBarWnd;
- CRect rcFraweWnd;
- pBar->GetWindowRect( &rcBarWnd );
- CExtMiniDockFrameWnd * pMiniFrame =
- STATIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- pBar->GetParentFrame()
- );
- pMiniFrame->GetWindowRect( &rcFraweWnd );
- CSize sizeBarWnd = rcBarWnd.Size();
- CSize sizeFraweWnd = rcFraweWnd.Size();
- CSize sizeDiff = sizeFraweWnd - sizeBarWnd;
- _oid.m_ptFloatHelper = rcFraweWnd.TopLeft();
- if( ((CExtControlBar*)pBar)->IsFixedMode() )
- {
- _oid.m_sizeFloated += sizeDiff;
- sizeReset = _oid.m_sizeFloated;
- } // if( ((CExtControlBar*)pBar)->IsFixedMode() )
- _oid.m_bFloating = true;
- } // if( pBar->IsFloating() )
- arrOuterProps.Add( _oid );
- } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- CControlBarInfo* pInfo = new CControlBarInfo;
- pBar->GetBarInfo( pInfo );
- if( pInfo->m_pBar == NULL )
- continue;
- //
- //__DEBUG_trace_bar_info( _T("-SAVE-"), pInfo, 4 );
- //
- if( sizeReset.cx > 0 && sizeReset.cy > 0 )
- pInfo->m_nMRUWidth = sizeReset.cx;
- state.m_arrBarInfo.Add(pInfo);
- } // get state info for each bar
- }
- void CExtControlBar::InternalFriendlyFrameWnd::SetDockState(
- const CExtControlBar::InternalDockStateSite & state,
- bool bPresetWP
- )
- {
- state.StateSet( bPresetWP );
- }
- void CExtControlBar::InternalFriendlyFrameWnd::GetDockState(
- CExtControlBar::InternalDockStateSite & state
- ) const
- {
- state.StateGet();
- }
- CExtControlBar::InternalDockStateSite::InternalDockStateSite(
- CFrameWnd * pDockSite,
- bool bSerializeFixedBarsState, // = true,
- bool bSerializeResizableBarsState // = true
- )
- : m_pDockSite( pDockSite )
- , m_pOuterState( NULL )
- , m_bSerializeFixedBarsState( bSerializeFixedBarsState )
- , m_bSerializeResizableBarsState( bSerializeResizableBarsState )
- {
- ASSERT_VALID( m_pDockSite );
- ASSERT_KINDOF( CFrameWnd, m_pDockSite );
- ASSERT( !m_pDockSite->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
- ::memset( &m_wp, 0, sizeof(WINDOWPLACEMENT) );
- m_pOuterState = new CDockState;
- }
- CExtControlBar::InternalDockStateSite::~InternalDockStateSite()
- {
- Clear();
- if( m_pOuterState != NULL )
- delete m_pOuterState;
- }
- void CExtControlBar::InternalDockStateSite::Clear()
- {
- ASSERT_VALID( this );
- ASSERT( m_pOuterState != NULL );
- ::memset( &m_wp, 0, sizeof(WINDOWPLACEMENT) );
- m_wp.length = sizeof(WINDOWPLACEMENT);
- m_pOuterState->Clear();
- INT nCount = (INT)m_arrBarStates.GetSize();
- for( INT i = 0; i < nCount; i++ )
- {
- InternalDockStateBar * pState =
- m_arrBarStates[i];
- ASSERT_VALID( pState );
- pState->Clear();
- delete pState;
- }
- m_arrBarStates.RemoveAll();
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- m_arrAutoHideOrder.RemoveAll();
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- m_arrOuterProps.RemoveAll();
- }
- void CExtControlBar::InternalDockStateSite::Serialize( CArchive & ar )
- {
- ASSERT_VALID( this );
- //bool bSerializeFixedBarsState = m_bSerializeFixedBarsState;
- bool bSerializeResizableBarsState = m_bSerializeResizableBarsState;
- INT i, nCount;
- DWORD dwApiVer0 = g_CmdManager.GetVersionDWORD( false );
- DWORD dwApiVer1 = g_CmdManager.GetVersionDWORD( true );
- DWORD dwReserved = 0;
- if( ar.IsStoring() )
- {
- // serialize version info
- CExtSafeString sTmpBuffer;
- CExtSafeString sFriendlyVer;
- sFriendlyVer.Format(
- _T("Prof-UIS (v. %s) control bar state"),
- g_CmdManager.GetVersionString( sTmpBuffer )
- );
- ar << sFriendlyVer;
- ar << dwApiVer0;
- ar << dwApiVer1;
- ar << dwReserved;
- ar << dwReserved;
- ar << dwReserved;
- ar << dwReserved;
- // serialize frame position
- CExtSafeString sFrameWp;
- sFrameWp.Format(
- _T("%d,%d,%d,%d,%d,%d"),
- m_wp.rcNormalPosition.left,
- m_wp.rcNormalPosition.top,
- m_wp.rcNormalPosition.right,
- m_wp.rcNormalPosition.bottom,
- m_wp.showCmd,
- m_wp.flags
- );
- ar << sFrameWp;
- //if( bSerializeFixedBarsState )
- { // BLOCK BEGIN (+2.52): replacement of CDockState::Serialize() method
- //
- // this block fixes bug in MFC 8.0 which causes 32<-->64 bit
- // version incompatibility of the CControlBarInfo::Serialize() method
- // invoked from the CDockState::Serialize() method
- //
- // the CDockState::Serialize() methods body also expanded into
- // this code block
- //
- // the InternalFriendlyDockState class defined locally is needed
- // for accessing the CDockState::m_dwVersion protected property
- //
- ////// m_pOuterState->Serialize( ar );
- class InternalFriendlyDockState : public CDockState
- {
- public:
- friend class CExtControlBar::InternalDockStateSite;
- };
- InternalFriendlyDockState * pDockState =
- (InternalFriendlyDockState *)m_pOuterState;
- ar << pDockState->m_dwVersion;
- if( pDockState->m_dwVersion > 1 )
- ar << pDockState->GetScreenSize();
- WORD wBarInfoIndex, wBarInfoCount = WORD(pDockState->m_arrBarInfo.GetSize());
- ar << wBarInfoCount;
- for( wBarInfoIndex = 0; wBarInfoIndex < wBarInfoCount; wBarInfoIndex++ )
- {
- ////// ((CControlBarInfo*)m_arrBarInfo[i])->Serialize(ar, this);
- CControlBarInfo * pCBI =
- (CControlBarInfo*)pDockState->m_arrBarInfo[wBarInfoIndex];
- ar << (DWORD)pCBI->m_nBarID;
- ar << (DWORD)pCBI->m_bVisible;
- ar << (DWORD)pCBI->m_bFloating;
- ar << (DWORD)pCBI->m_bHorz;
- ar << pCBI->m_pointPos;
- if( pDockState->GetVersion() > 1 )
- {
- ar << (DWORD)pCBI->m_nMRUWidth;
- ar << (DWORD)pCBI->m_bDocking;
- if( pCBI->m_bDocking )
- {
- ar << (DWORD)pCBI->m_uMRUDockID;
- ar << pCBI->m_rectMRUDockPos;
- ar << pCBI->m_dwMRUFloatStyle;
- ar << pCBI->m_ptMRUFloatPos;
- } // if( pCBI->m_bDocking )
- } // if( pDockState->GetVersion() > 1 )
- WORD wIdIndex, wIdCount = WORD(pCBI->m_arrBarID.GetSize());
- ar << wIdCount;
- for( wIdIndex = 0; wIdIndex < wIdCount; wIdIndex++ )
- {
- DWORD dw = DWORD(__EXT_MFC_DWORD_PTR(pCBI->m_arrBarID[wIdIndex]));
- ar << dw;
- } // for( wIdIndex = 0; wIdIndex < wIdCount; wIdIndex++ )
- } // for( wBarInfoIndex = 0; wBarInfoIndex < wBarInfoCount; wBarInfoIndex++ )
- //
- // the final block is added to serialize the Prof-UIS specific
- // properties of the fixed sized control bars located in the
- // outer dock bar windows (CExtDockOuterBar)
- //
- nCount = (INT)m_arrOuterProps.GetSize();
- ar << DWORD(nCount);
- for( i = 0; i < nCount; i++ )
- m_arrOuterProps.ElementAt(i).Serialize( ar );
- } // BLOCK END (+2.52): replacement of CDockState::Serialize() method
- if( bSerializeResizableBarsState )
- {
- nCount = (INT)m_arrBarStates.GetSize();
- ar << DWORD(nCount);
- for( i = 0; i < nCount; i++ )
- {
- InternalDockStateBar * pState =
- m_arrBarStates[i];
- ASSERT_VALID( pState );
- pState->Serialize( ar );
- } // for( i = 0; i < nCount; i++ )
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- nCount = (INT)m_arrAutoHideOrder.GetSize();
- ar << DWORD(nCount);
- for( i = 0; i < nCount; i++ )
- {
- UINT nBarID = m_arrAutoHideOrder[ i ];
- ar << DWORD(nBarID);
- } // for( i = 0; i < nCount; i++ )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- } // if( bSerializeResizableBarsState )
-
- } // if( ar.IsStoring() )
- else
- {
- Clear();
- // serialize version info
- DWORD dwApiVer0a = 0, dwApiVer1a = 0, dwTmp;
- CExtSafeString sFriendlyVer;
- ar >> sFriendlyVer;
- ar >> dwApiVer0a;
- ar >> dwApiVer1a;
- ar >> dwReserved;
- ar >> dwReserved;
- ar >> dwReserved;
- ar >> dwReserved;
- // if( dwApiVer1 != dwApiVer1a )
- if( dwApiVer1 < dwApiVer1a )
- {
- ASSERT( FALSE );
- #if _MFC_VER >= 0x0800
- ::AfxThrowArchiveException( CArchiveException::genericException, NULL );
- #else
- ::AfxThrowArchiveException( CArchiveException::generic, NULL );
- #endif
- }
- CExtSafeString sFrameWp;
- ar >> sFrameWp;
- ASSERT( !sFrameWp.IsEmpty() );
- ::memset( &m_wp, 0, sizeof(WINDOWPLACEMENT) );
- m_wp.length = sizeof(WINDOWPLACEMENT);
- CWnd * pWndPlacement = stat_GetWndForPlacement( m_pDockSite );
- ASSERT_VALID( pWndPlacement );
- // VERIFY( pWndPlacement->GetWindowPlacement(&m_wp) );
- VERIFY( CExtControlBar::stat_GetWindowPlacement( pWndPlacement->m_hWnd, m_wp ) );
- m_wp.ptMinPosition.x = m_wp.ptMinPosition.y = 0;
- m_wp.ptMaxPosition.x = m_wp.ptMaxPosition.y = 0;
- if( __EXT_MFC_STSCANF(
- sFrameWp,
- _T("%d,%d,%d,%d,%d,%d"),
- &m_wp.rcNormalPosition.left,
- &m_wp.rcNormalPosition.top,
- &m_wp.rcNormalPosition.right,
- &m_wp.rcNormalPosition.bottom,
- &m_wp.showCmd,
- &m_wp.flags
- ) != 6
- )
- {
- ASSERT( FALSE );
- ::memset( &m_wp, 0, sizeof(WINDOWPLACEMENT) );
- m_wp.length = sizeof(WINDOWPLACEMENT);
- m_wp.showCmd = SW_HIDE;
- //return false;
- #if _MFC_VER >= 0x0800
- ::AfxThrowArchiveException( CArchiveException::genericException, NULL );
- #else
- ::AfxThrowArchiveException( CArchiveException::generic, NULL );
- #endif
- }
- //if( bSerializeFixedBarsState )
- { // BLOCK BEGIN (+2.52): replacement of CDockState::Serialize() method
- //
- // this block fixes bug in MFC 8.0 which causes 32<-->64 bit
- // version incompatibility of the CControlBarInfo::Serialize() method
- // invoked from the CDockState::Serialize() method
- //
- // the CDockState::Serialize() methods body also expanded into
- // this code block
- //
- // the InternalFriendlyDockState class defined locally is needed
- // for accessing the CDockState::m_dwVersion protected property
- //
- ////// m_pOuterState->Serialize( ar );
- class InternalFriendlyDockState : public CDockState
- {
- public:
- friend class CExtControlBar::InternalDockStateSite;
- };
- InternalFriendlyDockState * pDockState =
- (InternalFriendlyDockState *)m_pOuterState;
- pDockState->Clear();
- ar >> pDockState->m_dwVersion;
- ASSERT( pDockState->m_dwVersion == 1 || pDockState->m_dwVersion == 2 );
- if( pDockState->m_dwVersion > 1 )
- {
- CSize size;
- ar >> size;
- pDockState->SetScreenSize(size);
- } // if( pDockState->m_dwVersion > 1 )
- WORD nOldSize;
- ar >> nOldSize;
- pDockState->m_arrBarInfo.SetSize( nOldSize );
- WORD wBarInfoIndex, wBarInfoCount = WORD(pDockState->m_arrBarInfo.GetSize());
- for( wBarInfoIndex = 0; wBarInfoIndex < wBarInfoCount; wBarInfoIndex++ )
- {
- ////// m_arrBarInfo[i] = new CControlBarInfo;
- ////// ((CControlBarInfo*)m_arrBarInfo[i])->Serialize(ar, this);
- CControlBarInfo * pCBI = new CControlBarInfo;
- pDockState->m_arrBarInfo.SetAt( wBarInfoIndex, pCBI );
- DWORD dw;
- ar >> dw;
- pCBI->m_nBarID = (int)dw;
- ar >> dw;
- pCBI->m_bVisible = (BOOL)dw;
- ar >> dw;
- pCBI->m_bFloating = (BOOL)dw;
- ar >> dw;
- pCBI->m_bHorz = (BOOL)dw;
- ar >> pCBI->m_pointPos;
- if( pDockState->GetVersion() > 1 )
- {
- pDockState->ScalePoint( pCBI->m_pointPos );
- ar >> dw;
- pCBI->m_nMRUWidth = (int)dw;
- ar >> dw;
- pCBI->m_bDocking = (BOOL)dw;
- if( pCBI->m_bDocking )
- {
- ar >> dw;
- pCBI->m_uMRUDockID = (DWORD)dw;
- ar >> pCBI->m_rectMRUDockPos;
- pDockState->ScaleRectPos( pCBI->m_rectMRUDockPos );
- ar >> pCBI->m_dwMRUFloatStyle;
- ar >> pCBI->m_ptMRUFloatPos;
- pDockState->ScalePoint( pCBI->m_ptMRUFloatPos );
- } // if( pCBI->m_bDocking )
- } // if( pDockState->GetVersion() > 1 )
- WORD wIdIndex, wIdCount;
- ar >> wIdCount;
- pCBI->m_arrBarID.SetSize( wIdCount );
- for( wIdIndex = 0; wIdIndex < wIdCount; wIdIndex++ )
- {
- DWORD dw;
- ar >> dw;
- #if (_MFC_VER >= 0x900)
- pCBI->m_arrBarID.SetAt( wIdIndex, (UINT)dw );
- #else
- pCBI->m_arrBarID.SetAt( wIdIndex, (LPVOID)(__EXT_MFC_DWORD_PTR)dw );
- #endif
- } // for( wIdIndex = 0; wIdIndex < wIdCount; wIdIndex++ )
- } // for( wBarInfoIndex = 0; wBarInfoIndex < wBarInfoCount; wBarInfoIndex++ )
- pDockState->m_dwVersion = 2;
- //
- // the final block is added to serialize the Prof-UIS specific
- // properties of the fixed sized control bars located in the
- // outer dock bar windows (CExtDockOuterBar)
- //
- ar >> dwTmp;
- nCount = INT(dwTmp);
- for( i = 0; i < nCount; i++ )
- {
- OuterItemData_t _oid;
- _oid.Serialize( ar );
- m_arrOuterProps.Add( _oid );
- } // for( i = 0; i < nCount; i++ )
- } // BLOCK END (+2.52): replacement of CDockState::Serialize() method
- if( bSerializeResizableBarsState )
- {
- ar >> dwTmp;
- nCount = INT(dwTmp);
- for( i = 0; i < nCount; i++ )
- {
- InternalDockStateBar * pState =
- new InternalDockStateBar;
- pState->Serialize( ar );
- ASSERT_VALID( pState );
- m_arrBarStates.Add( pState );
- } // for( i = 0; i < nCount; i++ )
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ar >> dwTmp;
- nCount = INT(dwTmp);
- for( i = 0; i < nCount; i++ )
- {
- UINT nBarID;
- ar >> dwTmp;
- nBarID = UINT(dwTmp);
- m_arrAutoHideOrder.Add( nBarID );
- } // for( i = 0; i < nCount; i++ )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- } // if( bSerializeResizableBarsState )
- } // else from if( ar.IsStoring() )
- }
- void CExtControlBar::InternalDockStateSite::StateGet()
- {
- ASSERT_VALID( this );
- ASSERT( m_pOuterState != NULL );
- ASSERT_VALID( m_pDockSite );
- Clear();
- CExtDockBar::_OptimizeCircles( m_pDockSite );
- CWnd * pWndPlacement = stat_GetWndForPlacement( m_pDockSite );
- ASSERT_VALID( pWndPlacement );
- ::memset( &m_wp, 0, sizeof(WINDOWPLACEMENT) );
- m_wp.length = sizeof(WINDOWPLACEMENT);
- // VERIFY( pWndPlacement->GetWindowPlacement( &m_wp ) );
- VERIFY( CExtControlBar::stat_GetWindowPlacement( pWndPlacement->m_hWnd, m_wp ) );
- POSITION pos = m_pDockSite->m_listControlBars.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CControlBar * pBar = (CControlBar *)
- m_pDockSite->m_listControlBars.GetNext( pos );
- ASSERT_VALID( pBar );
-
- if( pBar->IsFloating() )
- {
- if( pBar->IsDockBar() )
- continue;
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- {
- CExtMiniDockFrameWnd * pFrame =
- STATIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- pBar->GetParentFrame()
- );
- ASSERT_VALID( pBar->m_pDockBar );
- ASSERT_KINDOF( CDockBar, pBar->m_pDockBar );
- ASSERT( !pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) );
- ASSERT( pBar->m_pDockBar->GetDlgCtrlID() == AFX_IDW_DOCKBAR_FLOAT );
- ASSERT( pBar->m_pDockBar->GetParent() == pFrame );
- AppendFloatingLayout(
- STATIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- pFrame
- )
- );
- } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- continue;
- } // if( pBar->IsFloating() )
-
- if( !pBar->IsDockBar() )
- continue;
- ASSERT_KINDOF( CDockBar, pBar );
- if( !pBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- continue;
- CFrameWnd * pFrame = pBar->GetParentFrame();
- ASSERT_VALID( pFrame );
- if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
- {
- ASSERT_KINDOF( CExtMiniDockFrameWnd, pFrame );
- continue;
- }
- ASSERT(
- !pBar->GetParentFrame()->IsKindOf(
- RUNTIME_CLASS( CMiniFrameWnd )
- )
- );
-
- CExtDockBar * pDockBar =
- STATIC_DOWNCAST(
- CExtDockBar,
- pBar
- );
- UINT nCircleNo = pDockBar->_GetCircleNo();
- if( nCircleNo == 0 )
- continue;
- AppendDockBarAtSideLayout( pDockBar );
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynAutoHideArea * arrAutoHiders[4] =
- {
- NULL, NULL, NULL, NULL
- };
- static const UINT arrSideMap[4] =
- {
- AFX_IDW_DOCKBAR_TOP,
- AFX_IDW_DOCKBAR_BOTTOM,
- AFX_IDW_DOCKBAR_LEFT,
- AFX_IDW_DOCKBAR_RIGHT,
- };
- for( INT nSide = 0; nSide < 4; nSide++ )
- {
- UINT nDockBarID = arrSideMap[ nSide ];
- CExtDockBar * pDockBar = (CExtDockBar *)
- m_pDockSite->GetControlBar( nDockBarID );
- if( pDockBar == NULL )
- continue;
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CExtDockBar, pDockBar );
- ASSERT( pDockBar->_GetCircleNo() == 0 );
- arrAutoHiders[ nSide ] = pDockBar->_GetAutoHideArea();
- if( arrAutoHiders[ nSide ] == NULL )
- {
- ASSERT( nSide == 0 );
- break;
- }
- ASSERT_VALID( arrAutoHiders[ nSide ] );
- ASSERT(
- UINT( arrAutoHiders[ nSide ]->GetDlgCtrlID() )
- == arrSideMap[nSide]
- );
- } // for( INT nSide = 0; nSide < 4; nSide++ )
- if( arrAutoHiders[0] != NULL )
- {
- for( INT nSide = 0; nSide < 4; nSide++ )
- {
- ASSERT_VALID( arrAutoHiders[nSide] );
- INT nCount = arrAutoHiders[nSide]->ItemGetCount();
- for( INT nItem = 0; nItem < nCount; nItem++ )
- {
- CExtTabWnd::TAB_ITEM_INFO * pTII =
- arrAutoHiders[nSide]->ItemGet( nItem );
- ASSERT_VALID( pTII );
- if( (pTII->GetItemStyle() & __ETWI_IN_GROUP_ACTIVE) == 0 )
- continue;
- CExtControlBar * pBar =
- reinterpret_cast < CExtControlBar * >
- ( pTII->LParamGet() );
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtControlBar, pBar );
- ASSERT( !pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) );
- ASSERT( !pBar->IsFixedMode() );
- ASSERT( m_pDockSite->m_listControlBars.Find(pBar) != NULL );
- ASSERT( pBar->AutoHideModeGet() );
- UINT nBarID = (UINT) pBar->GetDlgCtrlID();
- m_arrAutoHideOrder.Add( nBarID );
- } // for( INT nItem = 0; nItem < nCount; nItem++ )
- } // for( nSide = 0; nSide < 4; nSide++ )
- } // if( arrAutoHiders[0] != NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ((InternalFriendlyFrameWnd *)m_pDockSite)->GetOuterDockState(
- *m_pOuterState,
- m_arrOuterProps
- );
- }
- CExtControlBar::InternalAffixmentData::InternalAffixmentData()
- : m_nAffixmentWeight( 0 )
- , m_rcAffixment( 0, 0, 0, 0 )
- , m_sizeCompressed( 0, 0 )
- , m_dwAffixmentFlags( __EAFF_FIXED_MODE_INITIAL_RECALC )
- {
- }
- CExtControlBar::InternalAffixmentData::InternalAffixmentData(
- const CExtControlBar::InternalAffixmentData & other
- )
- {
- _AssignFromOther( other );
- }
- CExtControlBar::InternalAffixmentData::~InternalAffixmentData()
- {
- }
- void CExtControlBar::InternalAffixmentData::_AssignFromOther(
- const CExtControlBar::InternalAffixmentData & other
- )
- {
- m_nAffixmentWeight = other.m_nAffixmentWeight;
- m_rcAffixment = other.m_rcAffixment;
- m_sizeCompressed = other.m_sizeCompressed;
- m_dwAffixmentFlags = other.m_dwAffixmentFlags;
- }
- bool CExtControlBar::InternalAffixmentData::IsEmpty() const
- {
- return (m_nAffixmentWeight==0) ? true : false;
- }
- void CExtControlBar::InternalAffixmentData::Empty()
- {
- m_nAffixmentWeight = 0;
- m_rcAffixment.SetRectEmpty();
- ASSERT(
- m_rcAffixment.left == 0
- && m_rcAffixment.right == 0
- && m_rcAffixment.top == 0
- && m_rcAffixment.bottom == 0
- );
- m_sizeCompressed.cx = m_sizeCompressed.cy = 0;
- m_dwAffixmentFlags = __EAFF_FIXED_MODE_INITIAL_RECALC;
- }
- int CExtControlBar::InternalAffixmentData::CompareAffixment(
- const CExtControlBar::InternalAffixmentData & other
- ) const
- {
- if( !IsEmpty() )
- {
- if( other.IsEmpty() )
- return 1;
- if( m_nAffixmentWeight > other.m_nAffixmentWeight )
- return 1;
- if( m_nAffixmentWeight < other.m_nAffixmentWeight )
- return -1;
- } // if( !IsEmpty() )
- else
- {
- if( !other.IsEmpty() )
- return -1;
- } // else from if( !IsEmpty() )
- return 0;
- }
- void CExtControlBar::InternalAffixmentData::Serialize( CArchive & ar )
- {
- DWORD dwHelperFlags = 0;
- if( ar.IsStoring() )
- {
- if( IsEmpty() )
- dwHelperFlags |= 0x01;
- ar << dwHelperFlags;
- if( dwHelperFlags & 0x01 )
- return;
- ar << DWORD(m_nAffixmentWeight);
- ar << m_rcAffixment;
- ar << m_sizeCompressed;
- ar << m_dwAffixmentFlags;
- } // if( ar.IsStoring() )
- else
- {
- Empty();
- ar >> dwHelperFlags;
- if( dwHelperFlags & 0x01 )
- return;
- DWORD dwTmp;
- ar >> dwTmp;
- m_nAffixmentWeight = UINT(dwTmp);
- ar >> m_rcAffixment;
- ar >> m_sizeCompressed;
- ar >> m_dwAffixmentFlags;
- } // else from if( ar.IsStoring() )
- }
- CExtControlBar::InternalDockStateBar *
- CExtControlBar::InternalDockStateSite::AppendFloatingLayout(
- CExtMiniDockFrameWnd * pMiniFrame
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pMiniFrame );
- ASSERT_KINDOF( CExtMiniDockFrameWnd, pMiniFrame );
- CDockBar * pFloatDocker =
- STATIC_DOWNCAST(
- CDockBar,
- pMiniFrame->GetWindow( GW_CHILD )
- );
- ASSERT_VALID( pFloatDocker );
- ASSERT( pFloatDocker->IsDockBar() );
- ASSERT_KINDOF( CDockBar, pFloatDocker );
- ASSERT( !pFloatDocker->IsKindOf(RUNTIME_CLASS(CExtDockBar)) );
- ASSERT( pFloatDocker->GetDlgCtrlID() == AFX_IDW_DOCKBAR_FLOAT );
- CExtDynControlBar * pDynDocker =
- STATIC_DOWNCAST(
- CExtDynControlBar,
- pFloatDocker->GetWindow( GW_CHILD )
- );
- ASSERT_VALID( pDynDocker );
- InternalDockStateBar * _idsb =
- new InternalDockStateBar;
- _idsb->StateGet( pDynDocker, NULL );
- ASSERT( _idsb->m_dwDockStateFlags & InternalDockStateBar::__STATE_FLOATING );
- m_arrBarStates.Add( _idsb );
- return _idsb;
- }
- CExtControlBar::InternalDockStateBar *
- CExtControlBar::InternalDockStateSite::AppendDockBarAtSideLayout(
- CExtDockBar * pDockBar
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDockBar );
- ASSERT_KINDOF( CExtDockBar, pDockBar );
- ASSERT( !pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar)) );
- ASSERT( pDockBar->_GetCircleNo() > 0 );
- ASSERT( pDockBar->m_arrBars[0] == NULL );
- bool bNewRow = false;
- INT nCount = (INT)pDockBar->m_arrBars.GetSize();
- InternalDockStateBar * pLastState = NULL;
- for( INT nBar = 1; nBar < nCount; nBar ++ )
- {
- CExtControlBar * pBar = (CExtControlBar *)
- pDockBar->m_arrBars[nBar];
- if( pBar == NULL )
- {
- bNewRow = true;
- continue;
- }
- if( __PLACEHODLER_BAR_PTR(pBar) )
- continue;
- ASSERT_KINDOF( CExtControlBar, pBar );
- ASSERT( !pBar->IsFixedMode() );
- InternalDockStateBar * _idsb =
- new InternalDockStateBar;
- _idsb->StateGet( pBar, NULL );
- if( bNewRow )
- _idsb->m_dwDockStateFlags |= InternalDockStateBar::__STATE_NEW_ROW;
- m_arrBarStates.Add( _idsb );
- bNewRow = false;
- pLastState = _idsb;
- }
- return pLastState;
- }
- void CExtControlBar::InternalDockStateSite::StateSet( bool bPresetWP ) const
- {
- ASSERT_VALID( this );
- ASSERT( m_pOuterState != NULL );
- ASSERT_VALID( m_pDockSite );
- if( bPresetWP )
- {
- CRect rcDockSiteWnd;
- if( m_wp.showCmd == SW_SHOWMAXIMIZED
- || m_wp.showCmd == SW_SHOWMINIMIZED
- || m_wp.showCmd == SW_SHOWMINNOACTIVE
- || m_wp.showCmd == SW_HIDE
- || m_wp.showCmd == SW_FORCEMINIMIZE
- )
- {
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, m_wp.rcNormalPosition );
- rcDockSiteWnd = _mp.m_rcWorkArea;
- }
- else
- {
- rcDockSiteWnd = m_wp.rcNormalPosition;
- }
- CWnd * pWndPlacement = CExtControlBar::stat_GetWndForPlacement( m_pDockSite );
- ASSERT_VALID( pWndPlacement );
- if( pWndPlacement != m_pDockSite )
- {
- m_pDockSite->SetWindowPos(
- NULL,
- 0, 0,
- rcDockSiteWnd.Width(), rcDockSiteWnd.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE
- |SWP_NOREDRAW ////|SWP_NOSENDCHANGING
- |SWP_NOMOVE
- );
- pWndPlacement->SetWindowPos(
- NULL,
- rcDockSiteWnd.left, rcDockSiteWnd.top,
- rcDockSiteWnd.Width(), rcDockSiteWnd.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE
- //|SWP_NOREDRAW
- ////|SWP_NOSENDCHANGING
- );
- }
- else
- pWndPlacement->SetWindowPos(
- NULL,
- rcDockSiteWnd.left, rcDockSiteWnd.top,
- rcDockSiteWnd.Width(), rcDockSiteWnd.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE
- |SWP_NOREDRAW ////|SWP_NOSENDCHANGING
- );
- } // if( bPresetWP )
- POSITION pos;
- INT i, nCount;
- ExtControlBarVector_t vRedockBars;
- for( pos = m_pDockSite->m_listControlBars.GetHeadPosition();
- pos != NULL;
- )
- {
- CControlBar * pBar = (CControlBar *)
- m_pDockSite->m_listControlBars.GetNext( pos );
- ASSERT_VALID( pBar );
- if( (! pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- || ( ((CExtControlBar*)pBar)->IsFixedMode() )
- || ( ((CExtControlBar*)pBar)->IsFixedDockStyle() )
- )
- {
- if( ! m_bSerializeFixedBarsState )
- continue;
- }
- else
- {
- if( ! m_bSerializeResizableBarsState )
- continue;
- }
-
- if( pBar->GetParentFrame()->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
- {
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar))
- && (! pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar)) )
- )
- vRedockBars.Add( (CExtControlBar *)pBar );
- continue;
- }
- if( pBar->IsDockBar() )
- continue;
- if( pBar->m_pDockSite == NULL
- || pBar->m_pDockContext == NULL
- )
- continue;
- if( pBar->m_pDockBar == NULL )
- {
- m_pDockSite->DockControlBar( pBar );
- m_pDockSite->ShowControlBar( pBar, FALSE, TRUE );
- continue;
- }
- if( (! pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) )
- || pBar->IsKindOf(RUNTIME_CLASS(CExtDynControlBar))
- || ((CExtControlBar *)pBar)->IsFixedMode()
- )
- continue;
- ASSERT_KINDOF( CExtDockBar, pBar->m_pDockBar );
- if( ((CExtDockBar*)pBar->m_pDockBar)->_GetCircleNo() == 0
- && (! pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynBar)) )
- )
- continue;
-
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( m_bSerializeResizableBarsState
- && ((CExtControlBar *)pBar)->AutoHideModeGet()
- )
- ((CExtControlBar *)pBar)->AutoHideModeSet(
- false, false, false, true );
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- m_pDockSite->ShowControlBar( pBar, FALSE, TRUE );
- }
- nCount = (INT)vRedockBars.GetSize();
- for( i = 0; i < nCount; i++ )
- {
- CExtControlBar * pBar = vRedockBars[i];
- DWORD dwBarStyle = pBar->GetBarStyle();
- UINT nBarDockerID = AFX_IDW_DOCKBAR_TOP;
- if( dwBarStyle & CBRS_ALIGN_BOTTOM )
- nBarDockerID = AFX_IDW_DOCKBAR_BOTTOM;
- else if( dwBarStyle & CBRS_ALIGN_LEFT )
- nBarDockerID = AFX_IDW_DOCKBAR_LEFT;
- else if( dwBarStyle & CBRS_ALIGN_RIGHT )
- nBarDockerID = AFX_IDW_DOCKBAR_RIGHT;
- if( pBar->IsFixedMode() )
- {
- bool bFloating = pBar->IsFloating();
- if( bFloating )
- m_pDockSite->ShowControlBar( pBar, FALSE, FALSE );
- m_pDockSite->DockControlBar(
- pBar,
- nBarDockerID
- );
- m_pDockSite->ShowControlBar( pBar, FALSE, TRUE );
- } // if( pBar->IsFixedMode() )
- else
- {
- ((CExtControlBar *)pBar)->DockControlBar(
- nBarDockerID,
- 1,
- m_pDockSite,
- false
- );
- m_pDockSite->ShowControlBar( pBar, FALSE, TRUE );
- } // else from if( pBar->IsFixedMode() )
- } // for( i = 0; i < nCount; i++ )
- CExtDockBar::_OptimizeCircles( m_pDockSite );
- m_pDockSite->RecalcLayout();
- if( m_bSerializeResizableBarsState )
- {
- ASSERT( ! ((InternalFriendlyFrameWnd*)m_pDockSite)->m_bInRecalcLayout );
- ((InternalFriendlyFrameWnd*)m_pDockSite)->m_bInRecalcLayout = TRUE;
- nCount = (INT)m_arrBarStates.GetSize();
- for( i = 0; i < nCount; i++ )