ExtToolControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:409k
- // This is part of the Professional User Interface Suite library.
- // Copyright (C) 2001-2009 FOSS Software, Inc.
- // All rights reserved.
- //
- // http://www.prof-uis.com
- // mailto:support@prof-uis.com
- //
- // This source code can be used, modified and redistributed
- // under the terms of the license agreement that is included
- // in the Professional User Interface Suite package.
- //
- // Warranties and Disclaimers:
- // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
- // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
- // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
- // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- #include "stdafx.h"
- #if _MFC_VER < 0x700
- #include <../src/AfxImpl.h>
- #else
- #include <../src/mfc/AfxImpl.h>
- #endif
- #if (!defined __AFXPRIV_H__)
- #include <AfxPriv.h>
- #endif
- #if (!defined __EXT_TOOLCONTROLBAR_H)
- #include <ExtToolControlBar.h>
- #endif
- #if (!defined __EXT_MENUCONTROLBAR_H)
- #include <ExtMenuControlBar.h>
- #endif
- #if (!defined __EXTDOCKBAR_H)
- #include "ExtDockBar.h"
- #endif
- #if( !defined __EXTMINIDOCKFRAMEWND_H)
- #include "ExtMiniDockFrameWnd.h"
- #endif
- #if (!defined __EXT_PAINT_MANAGER_H)
- #include <ExtPaintManager.h>
- #endif
- #if (!defined __EXT_MEMORY_DC_H)
- #include <../Src/ExtMemoryDC.h>
- #endif
- #if (!defined __EXT_POPUP_MENU_WND_H)
- #include <ExtPopupMenuWnd.h>
- #endif
- #if (!defined __ExtCmdManager_H)
- #include <ExtCmdManager.h>
- #endif
- #if (!defined __EXT_LOCALIZATION_H)
- #include <../Src/ExtLocalization.h>
- #endif
- #if (!defined __EXT_MFC_NO_CUSTOMIZE) || (!defined __EXT_MFC_NO_DATE_PICKER_POPUP) || (!defined __EXT_MFC_NO_UNDO_REDO_POPUP) || (!defined __EXT_MFC_NO_GRIDBASEWND)
- #if (!defined __EXT_POPUP_CTRL_MENU_H)
- #include <ExtPopupCtrlMenu.h>
- #endif
- #endif
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- #if (!defined __EXT_RIBBON_BAR_H)
- #include <ExtRibbonBar.h>
- #endif // (!defined __EXT_RIBBON_BAR_H)
- #endif
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXTCUSTOMIZE_H)
- #include <ExtCustomize.h>
- #endif
- #endif
- #ifndef __EXT_MFC_NO_GRIDWND
- #if (!defined __EXT_GRIDWND_H)
- #include <ExtGridWnd.h>
- #endif
- #endif // __EXT_MFC_NO_GRIDWND
- #include <Resources/Resource.h>
- #include <math.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER 9950
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolControlBar::CExtToolControlBarCmdUI
- class CExtToolControlBar::CExtToolControlBarCmdUI : public CCmdUI
- {
- void _SetCheckImpl( int nCheck, bool bUpdateInCmdManager );
- public:
- virtual void Enable( BOOL bOn );
- virtual void SetRadio( BOOL bOn )
- {
- _SetCheckImpl( bOn ? 1 : 0, false );
- // CExtToolControlBar * pToolBar = (CExtToolControlBar*)m_pOther;
- // ASSERT( pToolBar != NULL );
- // ASSERT_KINDOF( CExtToolControlBar, pToolBar );
- // ASSERT( m_nIndex < m_nIndexMax );
- // if( pToolBar->IsRightExpandButton(m_nIndex) )
- // return;
- // CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr(
- // g_CmdManager->ProfileNameFromWnd( pToolBar->GetSafeHwnd() ),
- // pToolBar->GetButtonID(m_nIndex)
- // );
- // if( pCmdItem != NULL )
- // pCmdItem->StateSetRadio( bOn ? true : false );
- }
- virtual void SetCheck( int nCheck )
- {
- _SetCheckImpl( nCheck, true );
- }
- virtual void SetText( LPCTSTR lpszText )
- {
- lpszText;
- // ignore it
- //#if (!defined __EXT_MFC_NO_CUSTOMIZE)
- // CExtToolControlBar* pToolBar = (CExtToolControlBar*)m_pOther;
- // ASSERT(pToolBar != NULL);
- // ASSERT_KINDOF(CExtToolControlBar, pToolBar);
- // ASSERT(m_nIndex < m_nIndexMax);
- // if( pToolBar->IsRightExpandButton(m_nIndex) )
- // return;
- // CExtBarButton * pTBB = pToolBar->GetButton( m_nIndex );
- // ASSERT_VALID( pTBB );
- // CExtCustomizeCmdTreeNode * pNode = pTBB->GetCmdNode( false );
- // if( pNode == NULL )
- // return;
- // ASSERT_VALID( pNode );
- // if( lpszText == NULL )
- // lpszText = _T("");
- // LPCTSTR _strCurText = pNode->GetTextInToolbar( NULL, true );
- // if( _strCurText == NULL )
- // _strCurText = _T("");
- // if( _tcscmp( _strCurText, lpszText ) != 0 )
- // {
- // pNode->SetTextInToolbar( lpszText );
- // if( pToolBar->IsVisible() )
- // {
- // DWORD dwDisplayStyle = pNode->GetFlags()&__ECTN_DISPLAY_MASK;
- // if( dwDisplayStyle == __ECTN_DISPLAY_TEXTONLY_ALWAYS
- // || dwDisplayStyle == __ECTN_DISPLAY_TEXT_AND_IMAGE
- // )
- // {
- // CFrameWnd * pFrame = pToolBar->GetParentFrame();
- // if( pFrame != NULL )
- // pFrame->DelayRecalcLayout();
- // }
- // }
- // }
- //#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- };
- }; // class CExtToolControlBar::CExtToolControlBarCmdUI
- void CExtToolControlBar::CExtToolControlBarCmdUI::_SetCheckImpl(
- int nCheck,
- bool bUpdateInCmdManager
- )
- {
- bUpdateInCmdManager;
- ASSERT( nCheck >= 0 && nCheck <= 2 );
- CExtToolControlBar * pToolBar = (CExtToolControlBar*)m_pOther;
- ASSERT( pToolBar != NULL );
- ASSERT_KINDOF( CExtToolControlBar, pToolBar );
- ASSERT( m_nIndex < m_nIndexMax );
- if( pToolBar->IsRightExpandButton( m_nIndex ) )
- return;
- UINT nByttonStyle = pToolBar->GetButtonStyle( m_nIndex );
- UINT nNewStyle = nByttonStyle & (~(TBBS_CHECKED | TBBS_INDETERMINATE));
- if( nCheck == 1 )
- nNewStyle |= TBBS_CHECKED;
- else if( nCheck == 2 )
- nNewStyle |= TBBS_INDETERMINATE;
- ASSERT( ( nNewStyle & TBBS_SEPARATOR ) == 0 );
- pToolBar->SetButtonStyle(m_nIndex, nNewStyle | TBBS_CHECKBOX);
- // if( bUpdateInCmdManager )
- // {
- // CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr(
- // g_CmdManager->ProfileNameFromWnd( pToolBar->GetSafeHwnd() ),
- // pToolBar->GetButtonID(m_nIndex)
- // );
- // if( pCmdItem != NULL )
- // {
- // pCmdItem->StateSetCheck(
- // (nNewStyle &
- // (TBBS_CHECKED|TBBS_INDETERMINATE)
- // ) ? true : false
- // );
- // }
- // }
- }
- void CExtToolControlBar::CExtToolControlBarCmdUI::Enable( BOOL bOn )
- {
- CCmdUI::m_bEnableChanged = TRUE;
- CExtToolControlBar * pToolBar = (CExtToolControlBar*)m_pOther;
- ASSERT( pToolBar != NULL );
- ASSERT_KINDOF( CExtToolControlBar, pToolBar );
- ASSERT( m_nIndex < m_nIndexMax );
- if( pToolBar->IsRightExpandButton( m_nIndex ) )
- return;
- UINT nByttonStyle = pToolBar->GetButtonStyle( m_nIndex );
- UINT nNewStyle = nByttonStyle & (~(TBBS_DISABLED));
- if( ! bOn )
- nNewStyle |= TBBS_DISABLED;
- ASSERT( ( nNewStyle & TBBS_SEPARATOR ) == 0 );
- pToolBar->SetButtonStyle( m_nIndex, nNewStyle );
- //CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr(
- // g_CmdManager->ProfileNameFromWnd( pToolBar->GetSafeHwnd() ),
- // pToolBar->GetButtonID(m_nIndex)
- // );
- // if( pCmdItem != NULL )
- // pCmdItem->StateEnable( bOn ? true : false );
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtBarButton
- IMPLEMENT_DYNCREATE(CExtBarButton, CObject)
- CExtBarButton::CExtBarButton(
- CExtToolControlBar * pBar, // = NULL
- UINT nCmdID, // = ID_SEPARATOR
- UINT nStyle // = 0
- )
- : CExtAnimationClient( pBar )
- , m_nStyle( nStyle )
- , m_pBar( pBar )
- , m_pParentButton(NULL )
- , m_nButtonCmdID( ID_SEPARATOR )
- , m_nEffectiveCmdID( ID_SEPARATOR )
- , m_pCtrl( NULL )
- , m_bCtrlVisibleVert( false )
- , m_bCtrlAutoDestroyed( false )
- , m_ActiveSize( 0, 0 )
- , m_ActiveRect( 0, 0, 0, 0 )
- , m_bWrapH( false )
- , m_bWrapV( false )
- , m_bWrapF( false )
- , m_bHover( false )
- , m_bVisible(true )
- , m_bVertDocked( false )
- , m_hMenu( NULL )
- , m_bPopupMenu( false )
- , m_bAutoDestroyMenu( false )
- , m_bAppendMdiWindowsMenu( false )
- , m_bSeparatedDropDown( false )
- , m_bAutoChangeID( false )
- , m_bDropDownHT( false )
- , m_bNoRotateVerticalLayout( false )
- , m_bPressedTracking( false )
- , m_bDrawBorder( true )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_pWndKeyTip( NULL )
- , m_pCmdNodeI( NULL )
- , m_pCmdNodeC( NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_nMaxButtonWidth( -1 )
- , m_nIconAlignment( -1 )
- , m_nTextAlignment( -1 )
- , m_rcIconMargins( -1, -1, -1, -1 )
- , m_rcTextMargins( -1, -1, -1, -1 )
- {
- SetCmdID( nCmdID );
- }
- CExtBarButton::~CExtBarButton()
- {
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS != NULL )
- pAcAS->AnimationSite_ClientRemove( this );
- _DestroyMenu();
- m_arrChildren.RemoveAll();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HDWP hPassiveModeDWP = NULL;
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- CtrlSet( NULL, true ); // destroy attached window
- }
- void CExtBarButton::Show(
- bool bShow // = true
- )
- {
- ASSERT_VALID( this );
- m_bVisible = bShow;
- _UpdateCtrl();
- INT nIndex, nCount = ChildButtonGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtBarButton * pChildTBB = ChildButtonGetAt( nIndex );
- ASSERT_VALID( pChildTBB );
- pChildTBB->Show( bShow );
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- }
- bool CExtBarButton::IsVisible() const
- {
- ASSERT_VALID( this );
- return m_bVisible; // && ( (m_nStyle & TBBS_HIDDEN) == 0 );
- }
- bool CExtBarButton::IsChildButton(
- const CExtBarButton * pTestChildTBB,
- bool bTestOneLevelOnly // = false
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTestChildTBB );
- const CExtBarButton * pTBB = pTestChildTBB->ParentButtonGet();
- if( pTBB == NULL )
- return false;
- if( LPVOID(pTBB) == LPVOID(this) )
- return true;
- if( bTestOneLevelOnly )
- return false;
- bool bRetVal = IsChildButton( pTBB );
- return bRetVal;
- }
- CExtBarButton * CExtBarButton::ParentButtonGet()
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( m_pParentButton != NULL )
- {
- ASSERT_VALID( m_pParentButton );
- }
- #endif // _DEBUG
- return m_pParentButton;
- }
- const CExtBarButton * CExtBarButton::ParentButtonGet() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> ParentButtonGet();
- }
- void CExtBarButton::ParentButtonSet(
- CExtBarButton * pParentButton // = NULL
- )
- {
- ASSERT_VALID( this );
- m_pParentButton = pParentButton;
- #ifdef _DEBUG
- if( m_pParentButton != NULL )
- {
- ASSERT_VALID( m_pParentButton );
- }
- #endif // _DEBUG
- }
- INT CExtBarButton::ChildButtonGetCount() const
- {
- ASSERT_VALID( this );
- INT nCount = INT( m_arrChildren.GetSize() );
- return nCount;
- }
- CExtBarButton * CExtBarButton::ChildButtonGetAt( INT nPos )
- {
- ASSERT_VALID( this );
- if( nPos < 0 )
- return NULL;
- INT nCount = ChildButtonGetCount();
- if( nPos >= nCount )
- return NULL;
- CExtBarButton * pTBB = m_arrChildren.GetAt( nPos );
- #ifdef _DEBUG
- if( pTBB != NULL )
- {
- ASSERT_VALID( pTBB );
- CExtBarButton * pParentTBB = pTBB->ParentButtonGet();
- ASSERT( pParentTBB == NULL || pParentTBB == this );
- }
- #endif // _DEBUG
- return pTBB;
- }
- const CExtBarButton * CExtBarButton::ChildButtonGetAt( INT nPos ) const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> ChildButtonGetAt( nPos );
- }
- bool CExtBarButton::ChildButtonSetAt(
- INT nPos,
- CExtBarButton * pTBB
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB->ParentButtonSet( NULL );
- if( nPos < 0 )
- return false;
- INT nCount = ChildButtonGetCount();
- if( nPos >= nCount )
- return false;
- m_arrChildren.SetAt( nPos, pTBB );
- pTBB->ParentButtonSet( this );
- return true;
- }
- void CExtBarButton::ChildButtonInsertAt(
- INT nPos,
- CExtBarButton * pTBB
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB->ParentButtonSet( NULL );
- INT nCount = ChildButtonGetCount();
- if( nPos < 0 || nPos > nCount )
- nPos = nCount;
- m_arrChildren.InsertAt( nPos, pTBB );
- pTBB->ParentButtonSet( this );
- }
- void CExtBarButton::ChildButtonAdd(
- CExtBarButton * pTBB
- )
- {
- ASSERT_VALID( this );
- ChildButtonInsertAt( -1, pTBB );
- }
- bool CExtBarButton::ChildButtonRemove(
- CExtBarButton * pTBB,
- bool bDestroy // = false
- )
- {
- ASSERT_VALID( this );
- INT nPos = ChildButtonGetIndexOf( pTBB );
- if( nPos < 0 )
- return false;
- ChildButtonRemoveAt( nPos, 1, bDestroy );
- return true;
- }
- void CExtBarButton::ChildButtonRemoveAll(
- bool bDestroy // = false
- )
- {
- ASSERT_VALID( this );
- ChildButtonRemoveAt( 0, -1, bDestroy );
- }
- INT CExtBarButton::ChildButtonRemoveAt(
- INT nPos,
- INT nCountToRemove, // = 1 // -1 remove up to end
- bool bDestroy // = false
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- if( nCountToRemove == 0 )
- return 0;
- if( nPos < 0 )
- return 0;
- INT nCount = ChildButtonGetCount();
- if( nPos >= nCount )
- return 0;
- if( nCountToRemove < 0 )
- nCountToRemove = nCount;
- if( ( nPos + nCountToRemove ) > nCount )
- nCountToRemove = nCount - nPos;
- if( nCountToRemove == 0 )
- return 0;
- if( bDestroy )
- {
- INT nIndex;
- for( nIndex = 0; nIndex < nCountToRemove; nIndex ++ )
- {
- CExtBarButton * pTBB = m_arrChildren[ nPos + nIndex ];
- ASSERT_VALID( pTBB );
- pBar->AnimationSite_ClientRemove( pTBB );
- delete pTBB;
- } // for( nIndex = 0; nIndex < nCountToRemove; nIndex ++ )
- } // if( bDestroy )
- m_arrChildren.RemoveAt( nPos, nCountToRemove );
- return nCountToRemove;
- }
- INT CExtBarButton::ChildButtonGetIndexOf(
- const CExtBarButton * pTBB
- ) const
- {
- ASSERT_VALID( this );
- if( pTBB == NULL )
- return -1;
- ASSERT_VALID( pTBB );
- INT nIndex, nCount = ChildButtonGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- const CExtBarButton * pChildTBB = ChildButtonGetAt( nIndex );
- ASSERT_VALID( pChildTBB );
- if( pChildTBB == pTBB )
- return nIndex;
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- return -1;
- }
- CExtToolControlBar * CExtBarButton::GetSafeBar()
- {
- if( this == NULL )
- return NULL;
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT( pBar != NULL );
- return pBar;
- }
- const CExtToolControlBar * CExtBarButton::GetSafeBar() const
- {
- return
- ( const_cast < CExtBarButton * > ( this ) ) -> GetSafeBar();
- }
- CExtToolControlBar * CExtBarButton::GetBar()
- {
- ASSERT_VALID( this );
- return m_pBar;
- }
- const CExtToolControlBar * CExtBarButton::GetBar() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) ) -> GetBar();
- }
- void CExtBarButton::SetBar( CExtToolControlBar * pBar )
- {
- ASSERT_VALID( this );
- m_pBar = pBar;
- INT nChildIndex, nChildCount = ChildButtonGetCount();
- for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- {
- CExtBarButton * pTBB = ChildButtonGetAt( nChildIndex );
- ASSERT_VALID( pTBB );
- pTBB->SetBar( pBar );
- } // for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- }
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool CExtBarButton::IsRibbonPaintingMode() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- if( pBar == NULL )
- return false;
- if( ! pBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) ) )
- return false;
- return true;
- }
- bool CExtBarButton::IsNoRibbonLayout() const
- {
- ASSERT_VALID( this );
- return false;
- }
- CExtRibbonNode * CExtBarButton::Ribbon_GetNode(
- bool bInitial // = false
- )
- {
- ASSERT_VALID( this );
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( bInitial );
- if( pNode == NULL )
- return NULL;
- ASSERT_VALID( pNode );
- CExtRibbonNode * pRibbonNode = DYNAMIC_DOWNCAST( CExtRibbonNode, pNode );
- return pRibbonNode;
- }
- const CExtRibbonNode * CExtBarButton::Ribbon_GetNode(
- bool bInitial // = false
- ) const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> Ribbon_GetNode( bInitial );
- }
- CSize CExtBarButton::RibbonILV_CalcSize(
- CDC & dc,
- INT nILV // = -1 // -1 use current visual level
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- dc;
- if( ! IsVisible() )
- return CSize( 0, 0 );
- if( (GetStyle()&TBBS_HIDDEN) != 0 )
- return CSize( 0, 0 );
- CSize _size =
- GetBar() ->
- PmBridge_GetPM() ->
- Ribbon_CalcButtonSize( dc, nILV, this );
- return _size;
- }
- bool CExtBarButton::RibbonWrapFromILE( INT nILE ) const
- {
- ASSERT_VALID( this );
- ASSERT(
- __EXT_RIBBON_ILE_MIN <= nILE
- && nILE <= __EXT_RIBBON_ILE_MAX
- );
- const CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return false;
- bool bRibbonWrap = pRibbonNode->RibbonWrapFromILE( nILE );
- return bRibbonWrap;
- }
- INT CExtBarButton::RibbonILV_fromILE(
- INT nILE,
- bool * p_bIsWrap // = NULL
- ) const
- {
- ASSERT_VALID( this );
- ASSERT(
- __EXT_RIBBON_ILE_MIN <= nILE
- && nILE <= __EXT_RIBBON_ILE_MAX
- );
- const CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return __EXT_RIBBON_ILV_SIMPLE_MAX;
- INT nILV = pRibbonNode->RibbonILV_fromILE( nILE, p_bIsWrap );
- return nILV;
- }
- INT CExtBarButton::RibbonILV_Get(
- INT nType // = 0 // -1 min, 0 current, 1 - max
- ) const
- {
- ASSERT_VALID( this );
- const CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return __EXT_RIBBON_ILV_SIMPLE_MAX;
- const CExtCustomizeCmdTreeNode * pParentNode = pRibbonNode->GetParentNode();
- if( pParentNode != NULL
- && ( pParentNode->IsKindOf( RUNTIME_CLASS( CExtRibbonNodeRightButtonsCollection ) )
- || pParentNode->IsKindOf( RUNTIME_CLASS( CExtRibbonNodeQuickAccessButtonsCollection ) )
- )
- )
- return __EXT_RIBBON_ILV_SIMPLE_MIN;
- INT nILV = pRibbonNode->RibbonILV_Get( nType );
- return nILV;
- }
- void CExtBarButton::RibbonILV_Set(
- INT nILV,
- INT nType // = 0, // -1 min, 0 current, 1 - max
- )
- {
- ASSERT_VALID( this );
- CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return;
- pRibbonNode->RibbonILV_Set( nILV, nType );
- }
- INT CExtBarButton::RibbonILE_Get() const
- {
- ASSERT_VALID( this );
- const CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return __EXT_RIBBON_ILE_MAX;
- INT nILE = pRibbonNode->RibbonILE_Get();
- return nILE;
- }
- bool CExtBarButton::RibbonILE_Set( INT nILE ) // returns flag indicating whether ILV changed
- {
- ASSERT_VALID( this );
- CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return false;
- bool bRetVal = pRibbonNode->RibbonILE_Set( nILE );
- return bRetVal;
- }
- INT CExtBarButton::RibbonILE_GetCollapsed() const
- {
- ASSERT_VALID( this );
- const CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return __EXT_RIBBON_ILE_MAX;
- INT nILE = pRibbonNode->RibbonILE_GetCollapsed();
- return nILE;
- }
- bool CExtBarButton::RibbonILE_SetCollapsed( INT nILE ) // returns flag indicating whether collapsed state changed
- {
- ASSERT_VALID( this );
- CExtRibbonNode * pRibbonNode = Ribbon_GetNode();
- if( pRibbonNode == NULL )
- return false;
- pRibbonNode->RibbonILE_SetCollapsed( nILE );
- return false;
- }
- CRect CExtBarButton::OnRibbonGetContentPadding() const
- {
- ASSERT_VALID( this );
- // return CRect( 0, 0, 0, 0 );
- CRect rcContentPadding = GetBar()->PmBridge_GetPM()->Ribbon_GetContentPadding( this );
- return rcContentPadding;
- }
- void CExtBarButton::OnRibbonAlignContent( CDC & dc )
- {
- ASSERT_VALID( this );
- INT nChildIndex, nChildCount = ChildButtonGetCount();
- for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- {
- CExtBarButton * pTBB = ChildButtonGetAt( nChildIndex );
- ASSERT_VALID( pTBB );
- if( ! pTBB->IsVisible() )
- continue;
- if( ( pTBB->GetStyle() & TBBS_HIDDEN ) != 0 )
- continue;
- pTBB->OnRibbonAlignContent( dc );
- } // for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- }
- INT CExtBarButton::OnRibbonGetSeparatorExtent( bool bHorz )
- {
- ASSERT_VALID( this );
- bHorz;
- return 2;
- }
- void CExtBarButton::OnRibbonCalcMinMaxILE( INT & nMinILE, INT & nMaxILE )
- {
- ASSERT_VALID( this );
- bool bWrap = false;
- INT nILV = 32761;
- INT nILE = __EXT_RIBBON_ILE_MAX;
- for( ; true; nILE-- )
- {
- bool bLastWrap = false;
- INT nNextILV =
- RibbonILV_fromILE(
- nILE,
- &bLastWrap
- );
- if( nNextILV != nILV
- || ( bWrap && ( ! bLastWrap ) )
- || ( ( ! bWrap ) && bLastWrap )
- )
- {
- nILV = nNextILV;
- bWrap = bLastWrap;
- if( nMinILE > nILE )
- nMinILE = nILE;
- if( nMaxILE < nILE )
- nMaxILE = nILE;
- }
- if( nILE == __EXT_RIBBON_ILE_MIN )
- break;
- } // for( ; true; nILE-- )
- INT nIndex, nCount = ChildButtonGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtBarButton * pChildTBB = ChildButtonGetAt( nIndex );
- ASSERT_VALID( pChildTBB );
- pChildTBB->OnRibbonCalcMinMaxILE( nMinILE, nMaxILE );
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdKeyTip * CExtBarButton::OnKeyTipGetInfo()
- {
- ASSERT_VALID( this );
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- CExtCustomizeCmdKeyTip * pCmdKeyTip = pNode->CmdKeyTipGet();
- return pCmdKeyTip;
- }
- return NULL;
- }
- CExtSafeString CExtBarButton::OnKeyTipGetText(
- INT nIndent
- )
- {
- ASSERT_VALID( this );
- CExtSafeString strKeyTipText( _T("") );
- CExtCustomizeCmdKeyTip * pCmdKeyTip = OnKeyTipGetInfo();
- if( pCmdKeyTip != NULL )
- strKeyTipText = pCmdKeyTip->GetTipText( nIndent );
- return strKeyTipText;
- }
- CWnd * CExtBarButton::OnKeyTipGetParentWnd()
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pToolBar = GetBar();
- ASSERT_VALID( pToolBar );
- ASSERT( pToolBar->GetSafeHwnd() != NULL );
- if( pToolBar->m_pDockSite != NULL )
- return pToolBar->GetParentFrame();
- CWnd * pWnd = pToolBar->GetParent();
- for( ; pWnd != NULL; pWnd = pWnd->GetParent() )
- {
- if( ( pWnd->GetStyle() & WS_CHILD ) == 0 )
- return pWnd;
- }
- return NULL;
- }
- CPoint CExtBarButton::OnKeyTipGetGuideLines()
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pToolBar = GetBar();
- ASSERT_VALID( pToolBar );
- ASSERT( pToolBar->GetSafeHwnd() != NULL );
- CRect rcTBB = *this;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtRibbonPage * pRibbonPage = DYNAMIC_DOWNCAST( CExtRibbonPage, pToolBar );
- if( pRibbonPage != NULL )
- {
- INT nILV = RibbonILV_Get();
- if( nILV < __EXT_RIBBON_ILV_SIMPLE_LARGE )
- {
- INT nTabLineHeight = pRibbonPage->RibbonLayout_GetTabLineHeight();
- INT nFrameCaptionHeight = pRibbonPage->RibbonLayout_GetFrameCaptionHeight();
- INT nHeightAtTheTop = nTabLineHeight + nFrameCaptionHeight;
- INT nBottomLineHeight = pRibbonPage->RibbonLayout_GetBottomLineHeight();
- CRect rcClient;
- pRibbonPage->GetClientRect( &rcClient );
- CExtPaintManager * pPM = pRibbonPage->PmBridge_GetPM();
- ASSERT_VALID( pPM );
- INT nCaptionHeight = pPM->Ribbon_GroupCaptionGetHeight( NULL );
- bool bCaptionAtTop = pRibbonPage->RibbonLayout_GroupCaptionIsTopAligned( NULL );
- if( bCaptionAtTop )
- rcClient.top += nCaptionHeight;
- else
- rcClient.bottom -= nCaptionHeight;
- CRect rcPageBk = rcClient;
- rcPageBk.top += nHeightAtTheTop;
- rcPageBk.bottom -= nBottomLineHeight;
- CPoint ptCenter = rcTBB.CenterPoint();
- if( rcPageBk.PtInRect( ptCenter ) )
- {
- pToolBar->ClientToScreen( &rcTBB );
- INT nHeight3 = rcPageBk.Height() / 3;
- if( rcPageBk.top <= ptCenter.y
- && ptCenter.y < ( rcPageBk.top + nHeight3 )
- )
- {
- CPoint ptGuideLines(
- ( nILV == __EXT_RIBBON_ILV_SIMPLE_NORMAL )
- ? ( rcTBB.left + pPM->UiScalingDo( 18, CExtPaintManager::__EUIST_X ) )
- : ( rcTBB.left + rcTBB.Width() / 2 )
- ,
- rcTBB.top
- );
- return ptGuideLines;
- }
- if( ( rcPageBk.top + nHeight3 ) <= ptCenter.y
- && ptCenter.y < ( rcPageBk.bottom - nHeight3 )
- )
- {
- CPoint ptGuideLines(
- ( nILV == __EXT_RIBBON_ILV_SIMPLE_NORMAL )
- ? ( rcTBB.left + pPM->UiScalingDo( 18, CExtPaintManager::__EUIST_X ) )
- : ( rcTBB.left + rcTBB.Width() / 2 )
- ,
- rcTBB.top + rcTBB.Height() / 2
- );
- return ptGuideLines;
- }
- CPoint ptGuideLines(
- ( nILV == __EXT_RIBBON_ILV_SIMPLE_NORMAL )
- ? ( rcTBB.left + pPM->UiScalingDo( 18, CExtPaintManager::__EUIST_X ) )
- : ( rcTBB.left + rcTBB.Width() / 2 )
- ,
- rcTBB.bottom
- );
- return ptGuideLines;
- } // if( rcPageBk.PtInRect( ptCenter ) )
- } // if( nILV < __EXT_RIBBON_ILV_SIMPLE_LARGE )
- } // if( pRibbonPage != NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- pToolBar->ClientToScreen( &rcTBB );
- CPoint ptGuideLines(
- rcTBB.left + rcTBB.Width() / 2,
- rcTBB.bottom
- );
- return ptGuideLines;
- }
- CExtPopupKeyTipWnd * CExtBarButton::OnKeyTipGetWnd()
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( m_pWndKeyTip != NULL )
- {
- ASSERT_VALID( m_pWndKeyTip );
- }
- #endif // _DEBUG
- return m_pWndKeyTip;
- }
- void CExtBarButton::OnKeyTipTrackingQuery(
- bool bShow,
- CExtCustomizeCmdKeyTip * pKeyTipChain,
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pToolBar = GetBar();
- ASSERT_VALID( pToolBar );
- if( bShow )
- {
- ASSERT_VALID( pKeyTipChain );
- if( ( ! IsVisible() )
- || ( GetStyle() & TBBS_HIDDEN ) != 0
- || pToolBar->GetSafeHwnd() == NULL
- || ( ! pToolBar->IsVisible() )
- )
- {
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- return;
- }
- INT nIndent = pKeyTipChain->KeyCodeGetCount();
- CExtSafeString strKeyTipText = OnKeyTipGetText( nIndent );
- if( strKeyTipText.IsEmpty() )
- {
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- return;
- }
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtBarButton * pCheckTBB = ParentButtonGet();
- for( ; pCheckTBB != NULL; )
- {
- ASSERT_VALID( pCheckTBB );
- CExtBarButton * pParentTBB = pCheckTBB->ParentButtonGet();
- if( pParentTBB == NULL
- && pCheckTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonGroup) )
- && ((CExtRibbonButtonGroup*)pCheckTBB)->TopCollapsedStateGet()
- )
- {
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- return;
- }
- pCheckTBB = pParentTBB;
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pWndKeyTip == NULL )
- {
- try
- {
- m_pWndKeyTip = new CExtPopupKeyTipWnd;
- }
- catch( CException * pException )
- {
- pException->Delete();
- return;
- }
- } // if( m_pWndKeyTip == NULL )
- #ifdef _DEBUG
- else
- {
- ASSERT_VALID( m_pWndKeyTip );
- } // else from if( m_pWndKeyTip == NULL )
- #endif // _DEBUG
- CWnd * pWndKeyTipParent = OnKeyTipGetParentWnd();
- ASSERT_VALID( pWndKeyTipParent );
- ASSERT( pWndKeyTipParent->GetSafeHwnd() != NULL );
- CPoint ptGuideLines = OnKeyTipGetGuideLines();
- if( ! m_pWndKeyTip->Create(
- pWndKeyTipParent,
- ptGuideLines,
- strKeyTipText,
- IsEnabled(),
- hPassiveModeDWP
- )
- )
- {
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- return;
- }
- if( hPassiveModeDWP == NULL )
- m_pWndKeyTip->ShowWindow( SW_SHOWNOACTIVATE );
- } // if( bShow )
- else
- {
- if( m_pWndKeyTip != NULL )
- {
- ASSERT_VALID( m_pWndKeyTip );
- m_pWndKeyTip->Hide();
- delete m_pWndKeyTip;
- m_pWndKeyTip = NULL;
- } // if( m_pWndKeyTip != NULL )
- } // else from if( bShow )
- }
- void CExtBarButton::OnKeyTipTrackingQueryNested(
- bool bShow,
- CExtCustomizeCmdKeyTip * pKeyTipChain,
- bool bApplyToThisItem,
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- if( bApplyToThisItem )
- OnKeyTipTrackingQuery( bShow, pKeyTipChain, hPassiveModeDWP );
- INT nChildIndex, nChildCount = ChildButtonGetCount();
- for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- {
- CExtBarButton * pTBB = ChildButtonGetAt( nChildIndex );
- ASSERT_VALID( pTBB );
- pTBB->OnKeyTipTrackingQueryNested( bShow, pKeyTipChain, true, hPassiveModeDWP );
- } // for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- }
- bool CExtBarButton::OnKeyTipTranslate(
- DWORD dwKeyCode,
- CExtCustomizeCmdKeyTip * pKeyTipChain,
- bool bAutoInvokeAction,
- bool & bActionInvoked,
- bool & bContinueKeyTipMode
- )
- {
- ASSERT_VALID( this );
- bActionInvoked = false;
- CExtToolControlBar * pToolBar = GetBar();
- if( pToolBar->GetSafeHwnd() == NULL )
- return false;
- ASSERT_VALID( pToolBar );
- if( ! IsVisible() )
- return false;
- if( ( GetStyle() & TBBS_HIDDEN ) != 0 )
- return false;
- if( IsDisabled() )
- return false;
- CExtCustomizeCmdKeyTip * pCmdKeyTip = OnKeyTipGetInfo();
- if( pCmdKeyTip == NULL )
- return false;
- CExtPopupKeyTipWnd * pWndKeyTip = OnKeyTipGetWnd();
- if( pWndKeyTip->GetSafeHwnd() == NULL
- || ( pWndKeyTip->GetStyle() & WS_VISIBLE ) == 0
- )
- return false;
- if( ! pCmdKeyTip->CompareWidthChain( *pKeyTipChain ) )
- return false;
- INT nKeyCodeCountOwn = pCmdKeyTip->KeyCodeGetCount();
- INT nKeyCodeCountChain = pKeyTipChain->KeyCodeGetCount();
- ASSERT( nKeyCodeCountOwn > nKeyCodeCountChain );
- DWORD dwKeyCodeOwn = pCmdKeyTip->KeyCodeGetAt( nKeyCodeCountChain );
- if( dwKeyCodeOwn != dwKeyCode )
- return false;
- pKeyTipChain->KeyCodeAdd( dwKeyCode );
- nKeyCodeCountChain++;
- if( nKeyCodeCountOwn > nKeyCodeCountChain )
- return true;
- if( bAutoInvokeAction )
- bActionInvoked = OnKeyTipInvokeAction( bContinueKeyTipMode );
- return true;
- }
- void CExtBarButton::OnKeyTipDisplay(
- CExtCustomizeCmdKeyTip & keyTipChain
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pToolBar = GetBar();
- if( pToolBar->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( pToolBar );
- if( ! IsVisible() )
- return;
- if( ( GetStyle() & TBBS_HIDDEN ) != 0 )
- return;
- // if( IsDisabled() )
- // return;
- CExtCustomizeCmdKeyTip * pCmdKeyTip = OnKeyTipGetInfo();
- if( pCmdKeyTip == NULL )
- return;
- CExtPopupKeyTipWnd * pWndKeyTip = OnKeyTipGetWnd();
- if( pWndKeyTip->GetSafeHwnd() == NULL
- || ( pWndKeyTip->GetStyle() & WS_VISIBLE ) == 0
- )
- return;
- if( pCmdKeyTip->CompareWidthChain( keyTipChain ) )
- return;
- pWndKeyTip->ShowWindow( SW_HIDE );
- }
- bool CExtBarButton::OnKeyTipInvokeAction(
- bool & bContinueKeyTipMode
- )
- {
- ASSERT_VALID( this );
- if( IsAbleToTrackMenu() )
- {
- bContinueKeyTipMode = true;
- CExtToolControlBar::g_bMenuTrackingExpanded = false;
- CRect rcTBB = *this;
- CPoint pt( rcTBB.right - 1, rcTBB.bottom - 1 );
- //CList < HWND, HWND > _listHwndTipsDelayedHide;
- CExtToolControlBar * pToolBar = GetBar();
- ASSERT( pToolBar->GetSafeHwnd() != NULL );
- ASSERT_VALID( pToolBar );
- /*
- int nBtnIdx, nCountOfButtons = pToolBar->GetButtonsCount();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = pToolBar->GetButton( nBtnIdx );
- ASSERT_VALID( pTBB );
- CExtPopupKeyTipWnd * pWndKeyTip = pTBB->OnKeyTipGetWnd();
- if( pWndKeyTip->GetSafeHwnd() == NULL
- // || ( pWndKeyTip->GetStyle() & WS_VISIBLE ) == 0
- )
- continue;
- //_listHwndTipsDelayedHide.AddTail( pWndKeyTip->m_hWnd );
- //pWndKeyTip->ShowWindow( SW_HIDE );
- pTBB->OnKeyTipTrackingQuery( false );
- }
- */
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( IsKindOf( RUNTIME_CLASS(CExtRibbonButtonGroup) )
- && ((CExtRibbonButtonGroup*)this)->TopCollapsedStateGet()
- )
- {
- int nBtnIdx, nCountOfButtons = pToolBar->GetButtonsCount();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = pToolBar->GetButton( nBtnIdx );
- ASSERT_VALID( pTBB );
- CExtPopupKeyTipWnd * pWndKeyTip = pTBB->OnKeyTipGetWnd();
- if( pWndKeyTip->GetSafeHwnd() == NULL )
- continue;
- HDWP hPassiveModeDWP = NULL;
- pTBB->OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- }
- }
- else
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- {
- CExtMenuControlBar * pMenuBar = DYNAMIC_DOWNCAST( CExtMenuControlBar, pToolBar );
- if( pMenuBar != NULL )
- pMenuBar->_CancelFlatTracking( FALSE );
- else
- pToolBar->OnFlatTrackingStop();
- }
- pToolBar->Invalidate();
- //pToolBar->UpdateWindow();
- CExtPaintManager::stat_PassPaintMessages();
- pToolBar->KeyTipsDisplayedSet( true );
- OnTrackPopup( pt, true, true );
- pToolBar->KeyTipsDisplayedSet( false );
- return true;
- }
- bContinueKeyTipMode = false;
- CWnd * pCtrl = CtrlGet();
- if( pCtrl != NULL
- && ( pCtrl->GetStyle() & WS_VISIBLE ) != 0
- )
- {
- ASSERT_VALID( pCtrl );
- CExtToolControlBar * pBar = GetSafeBar();
- ASSERT_VALID( pBar );
- if( CWnd::GetCapture() == pBar )
- pBar->SendMessage( WM_CANCELMODE );
- pCtrl->SetFocus();
- return true;
- }
- OnDeliverCmd();
- return true;
- }
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtBarButton::OnFlatTrackingStart(
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- hPassiveModeDWP;
- CExtToolControlBar * pBar = GetSafeBar();
- if( pBar == NULL )
- return;
- ASSERT_VALID( pBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- OnKeyTipTrackingQuery( true, &(pBar->KeyTipChainGet()), hPassiveModeDWP );
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtBarButton::OnFlatTrackingStop()
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HDWP hPassiveModeDWP = NULL;
- OnKeyTipTrackingQuery( false, NULL, hPassiveModeDWP );
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- bool CExtBarButton::OnQueryFlatTrackingEnabled() const
- {
- ASSERT_VALID( this );
- if( ! IsVisible() )
- return false;
- if( ( GetStyle() & TBBS_HIDDEN ) != 0 )
- return false;
- if( IsSeparator() )
- return false;
- if( ChildButtonGetCount() > 0 )
- return false;
- return true;
- }
- CRect CExtBarButton::OnQueryFlatWalkingCalcRect() const
- {
- ASSERT_VALID( this );
- CRect rcOwn = *this;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( OnQueryFlatTrackingEnabled() )
- {
- const CExtBarButton * pParentTBB = ParentButtonGet();
- if( pParentTBB != NULL
- && pParentTBB->ParentButtonGet() == NULL
- && pParentTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonGroup ) )
- && (! pParentTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonToolGroup ) ) )
- )
- {
- ASSERT_VALID( pParentTBB );
- INT nSiblingIndex, nSavedSiblingIndex = pParentTBB->ChildButtonGetIndexOf( this );
- INT nSiblingCount = pParentTBB->ChildButtonGetCount();
- ASSERT( 0 <= nSavedSiblingIndex && nSavedSiblingIndex < nSiblingCount );
- for( nSiblingIndex = nSavedSiblingIndex; nSiblingIndex < nSiblingCount; nSiblingIndex ++ )
- {
- const CExtBarButton * pTBB = pParentTBB->ChildButtonGetAt( nSiblingIndex );
- ASSERT_VALID( pTBB );
- if( ! pTBB->OnQueryFlatTrackingEnabled() )
- continue;
- if( pTBB->IsWrap( __EVT_FLOAT ) )
- break;
- CRect rcTBB = *pTBB;
- rcOwn.left = min( rcOwn.left, rcTBB.left );
- rcOwn.right = max( rcOwn.right, rcTBB.right );
- } // for( nSiblingIndex = nSavedSiblingIndex; nSiblingIndex < nSiblingCount; nSiblingIndex ++ )
- for( nSiblingIndex = nSavedSiblingIndex; nSiblingIndex > 0; nSiblingIndex -- )
- {
- const CExtBarButton * pTBB = pParentTBB->ChildButtonGetAt( nSiblingIndex - 1 );
- ASSERT_VALID( pTBB );
- if( ! pTBB->OnQueryFlatTrackingEnabled() )
- continue;
- if( pTBB->IsWrap( __EVT_FLOAT ) )
- break;
- CRect rcTBB = *pTBB;
- rcOwn.left = min( rcOwn.left, rcTBB.left );
- rcOwn.right = max( rcOwn.right, rcTBB.right );
- } // for( nSiblingIndex = nSavedSiblingIndex; nSiblingIndex > 0; nSiblingIndex -- )
- } // if( pParentTBB != NULL ...
- } // if( OnQueryFlatTrackingEnabled() )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return rcOwn;
- }
- void CExtBarButton::_DestroyMenu()
- {
- if( m_hMenu == NULL )
- return;
- if( m_bAutoDestroyMenu )
- {
- ASSERT( ::IsMenu(m_hMenu) );
- VERIFY( ::DestroyMenu(m_hMenu) );
- }
- m_hMenu = NULL;
- }
- bool CExtBarButton::IsSeparator() const
- {
- ASSERT_VALID( this );
- bool bSeparator =
- (GetStyle() & TBBS_SEPARATOR) ?
- true : false;
- return bSeparator;
- }
- bool CExtBarButton::IsDisabled() const
- {
- ASSERT_VALID( this );
- bool bDisabled =
- (GetStyle() & TBBS_DISABLED) ?
- true : false;
- return bDisabled;
- }
- bool CExtBarButton::IsShowTipWhenDisabled() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- if( pBar != NULL
- && ( ! pBar->IsShowTipWhenDisabled( this ) )
- )
- return false;
- return true;
- }
- bool CExtBarButton::IsEnabled() const
- {
- ASSERT_VALID( this );
- return !( IsDisabled() );
- }
- bool CExtBarButton::IsIndeterminate() const
- {
- ASSERT_VALID( this );
- bool bIndeterminate =
- (GetStyle() & TBBS_INDETERMINATE) ?
- true : false;
- return bIndeterminate;
- }
- bool CExtBarButton::IsPressed() const
- {
- ASSERT_VALID( this );
- bool bPressed =
- (GetStyle() & (TBBS_PRESSED|TBBS_CHECKED)) ?
- true : false;
- return bPressed;
- }
- bool CExtBarButton::IsHover() const
- {
- ASSERT_VALID( this );
- return m_bHover;
- }
- void CExtBarButton::SetHover(
- bool bHover // = true
- )
- {
- // TRACE2( ">>>>>>>>>>>>SetHover - %p, %sn", this, bHover ? "on" : "--------OFF" );
- ASSERT_VALID( this );
- bool bAnimate = false;
- bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
- if( ! bAnimationLocked )
- {
- if( m_bHover != bHover )
- {
- bAnimate = true;
- AnimationClient_CacheGeneratorLock();
- AnimationClient_StateGet( true ).Empty();
- AnimationClient_StateGet( false ).Empty();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- bHover
- ? __EAPT_BY_HOVERED_STATE_TURNED_ON
- : __EAPT_BY_HOVERED_STATE_TURNED_OFF
- );
- //AnimationClient_CacheGeneratorUnlock();
- }
- } // if( ! bAnimationLocked )
- m_bHover = bHover;
- OnUpdateParentStyle();
- if( bAnimate )
- {
- //AnimationClient_CacheGeneratorLock();
- AnimationClient_CacheNextStateMinInfo(
- true,
- bHover
- ? __EAPT_BY_HOVERED_STATE_TURNED_ON
- : __EAPT_BY_HOVERED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- } // if( bAnimate )
- _UpdateCtrl();
- }
- CWnd * CExtBarButton::CtrlGet()
- {
- ASSERT_VALID( this );
- return m_pCtrl;
- }
- const CWnd * CExtBarButton::CtrlGet() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) ) ->
- CtrlGet();
- }
- void CExtBarButton::CtrlSet(
- CWnd * pCtrl,
- bool bCtrlAutoDestroyed
- )
- {
- ASSERT_VALID( this );
- if( m_pCtrl != NULL )
- {
- CWnd * pOldCtrl = m_pCtrl;
- m_pCtrl = NULL;
- if( pOldCtrl->GetSafeHwnd() != NULL )
- pOldCtrl->DestroyWindow();
- if( ! m_bCtrlAutoDestroyed )
- delete pOldCtrl;
- }
- m_pCtrl = pCtrl;
- m_bCtrlAutoDestroyed = bCtrlAutoDestroyed;
- #ifdef _DEBUG
- if( m_pCtrl != NULL )
- {
- ASSERT_VALID( m_pCtrl );
- }
- #endif // _DEBUG
- }
- CWnd * CExtBarButton::CtrlDetach()
- {
- ASSERT_VALID( this );
- CWnd * pCtrl = m_pCtrl;
- m_pCtrl = NULL;
- return pCtrl;
- }
- UINT CExtBarButton::GetStyle() const
- {
- ASSERT_VALID( this );
- return m_nStyle;
- }
- void CExtBarButton::SetStyle( UINT nStyle )
- {
- ASSERT_VALID( this );
- DWORD nOldStyle = m_nStyle;
- DWORD nNewStyle = nStyle;
- bool bOldPressed = ( (nOldStyle&TBBS_PRESSED) != 0 || IsPressed() ) ? true : false;
- m_nStyle = nNewStyle;
- bool bNewPressed = ( (nNewStyle&TBBS_PRESSED) != 0 || IsPressed() ) ? true : false;
- m_nStyle = nOldStyle;
- // if( (nOldStyle&TBBS_PRESSED) != (nNewStyle&TBBS_PRESSED) /*&& (nNewStyle&TBBS_PRESSED) == 0*/ )
- if( bOldPressed != bNewPressed )
- {
- AnimationClient_CacheGeneratorLock();
- if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- bNewPressed
- ? __EAPT_BY_PRESSED_STATE_TURNED_ON
- : __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- // AnimationClient_CacheGeneratorUnlock();
- }
- m_nStyle = nNewStyle;
-
- if( (m_nStyle & TBBS_PRESSED) == 0 && (! IsHover() ) )
- m_bDropDownHT = false;
- OnUpdateParentStyle();
- _UpdateCmdIdFromStyle();
- _UpdateCtrl();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _UpdateCmdNodeFromStyle();
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- // if( (nOldStyle&TBBS_PRESSED) != (nNewStyle&TBBS_PRESSED) /*&& (nNewStyle&TBBS_PRESSED) == 0*/ )
- if( bOldPressed != bNewPressed )
- {
- // AnimationClient_CacheGeneratorLock();
- AnimationClient_CacheNextStateMinInfo(
- true,
- bNewPressed
- ? __EAPT_BY_PRESSED_STATE_TURNED_ON
- : __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- // CWindowDC dc( NULL );
- // AnimationClient_StateGet( false ).Draw(
- // dc.m_hDC,
- // 100,
- // 0,
- // AnimationClient_StateGet( false ).GetSize().cx,
- // AnimationClient_StateGet( false ).GetSize().cy
- // );
- // AnimationClient_StateGet( true ).Draw(
- // dc.m_hDC,
- // 0,
- // 0,
- // AnimationClient_StateGet( true ).GetSize().cx,
- // AnimationClient_StateGet( true ).GetSize().cy
- // );
- }
- }
- void CExtBarButton::ModifyStyle(
- UINT nAdd,
- UINT nRemove // = 0
- )
- {
- ASSERT_VALID( this );
- DWORD nOldStyle = m_nStyle;
- DWORD nNewStyle = m_nStyle;
- nNewStyle |= nAdd;
- nNewStyle &= ~nRemove;
-
- bool bOldPressed = ( (nOldStyle&TBBS_PRESSED) != 0 || IsPressed() ) ? true : false;
- m_nStyle = nNewStyle;
- bool bNewPressed = ( (nNewStyle&TBBS_PRESSED) != 0 || IsPressed() ) ? true : false;
- m_nStyle = nOldStyle;
- // if( (nOldStyle&TBBS_PRESSED) != (nNewStyle&TBBS_PRESSED) /*&& (nNewStyle&TBBS_PRESSED) == 0*/ )
- if( bOldPressed != bNewPressed )
- {
- AnimationClient_CacheGeneratorLock();
- if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- bNewPressed
- ? __EAPT_BY_PRESSED_STATE_TURNED_ON
- : __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- // AnimationClient_CacheGeneratorUnlock();
- }
-
- m_nStyle = nNewStyle;
- if( (m_nStyle & TBBS_PRESSED) == 0 && (! IsHover() ) )
- m_bDropDownHT = false;
- OnUpdateParentStyle();
- _UpdateCmdIdFromStyle();
- _UpdateCtrl();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _UpdateCmdNodeFromStyle();
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- // if( (nOldStyle&TBBS_PRESSED) != (nNewStyle&TBBS_PRESSED) /*&& (nNewStyle&TBBS_PRESSED) == 0*/ )
- if( bOldPressed != bNewPressed )
- {
- // AnimationClient_CacheGeneratorLock();
- AnimationClient_CacheNextStateMinInfo(
- true,
- bNewPressed
- ? __EAPT_BY_PRESSED_STATE_TURNED_ON
- : __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- // CWindowDC dc( NULL );
- // AnimationClient_StateGet( false ).Draw(
- // dc.m_hDC,
- // 100,
- // 0,
- // AnimationClient_StateGet( false ).GetSize().cx,
- // AnimationClient_StateGet( false ).GetSize().cy
- // );
- // AnimationClient_StateGet( true ).Draw(
- // dc.m_hDC,
- // 0,
- // 0,
- // AnimationClient_StateGet( true ).GetSize().cx,
- // AnimationClient_StateGet( true ).GetSize().cy
- // );
- }
- }
- void CExtBarButton::OnUpdateParentStyle()
- {
- ASSERT_VALID( this );
- /*
- if( AnimationClient_CacheGeneratorIsLocked() )
- return;
- CExtBarButton * pParentTBB = ParentButtonGet();
- if( pParentTBB == NULL )
- return;
- ASSERT_VALID( pParentTBB );
- bool bOwnHover = ( IsEnabled() && ( IsHover() || IsPressed() ) ) ? true : false;
- bool bParentHover = ( pParentTBB->IsHover() ) ? true : false;
- // bool bOwnHover = m_bHover;
- // bool bParentHover = pParentTBB->m_bHover;
- if( bParentHover != bOwnHover )
- {
- bool bResetParentState = true;
- if( ! bOwnHover )
- {
- CExtToolControlBar * pBar = GetBar();
- if( pBar )
- {
- ASSERT_VALID( pBar );
- INT nBtnIdxHover = pBar->_GetHoverButtonIndex();
- if( nBtnIdxHover >= 0 )
- {
- CExtBarButton * pHoverTBB = pBar->GetButton( nBtnIdxHover );
- ASSERT_VALID( pHoverTBB );
- if( pParentTBB->IsChildButton( pHoverTBB ) )
- bResetParentState = false;
- } // if( nBtnIdxHover >= 0 )
- } // if( pBar )
- } // if( ! bOwnHover )
- if( bResetParentState )
- pParentTBB->SetHover( bOwnHover );
- pParentTBB->RedrawButton( false );
- } // if( bParentHover != bOwnHover )
- */
- }
- bool CExtBarButton::OnInvalidateButton()
- {
- ASSERT_VALID( this );
- return false;
- }
- void CExtBarButton::OnPressedTrackingStart()
- {
- ASSERT_VALID( this );
- m_bPressedTracking = true;
- }
- void CExtBarButton::OnPressedTrackingStop()
- {
- ASSERT_VALID( this );
- m_bPressedTracking = false;
- }
- bool CExtBarButton::IsPressedTracking() const
- {
- ASSERT_VALID( this );
- return m_bPressedTracking;
- }
- void CExtBarButton::SetVertDocked(
- bool bVertDocked
- )
- {
- ASSERT_VALID( this );
- m_bVertDocked = bVertDocked;
- }
- bool CExtBarButton::IsWrap(
- CExtBarButton::e_wrap_t _evt
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( __EVT_MIN_VALUE <= _evt && _evt <= __EVT_MAX_VALUE );
- switch( _evt )
- {
- case __EVT_HORZ:
- return m_bWrapH;
- case __EVT_VERT:
- return m_bWrapV;
- default:
- ASSERT( _evt == __EVT_FLOAT );
- return m_bWrapF;
- } // switch( _evt )
- }
- void CExtBarButton::SetWrap(
- CExtBarButton::e_wrap_t _evt,
- bool bWrap // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT( __EVT_MIN_VALUE <= _evt && _evt <= __EVT_MAX_VALUE );
- switch( _evt )
- {
- case __EVT_HORZ:
- m_bWrapH = bWrap;
- break;
- case __EVT_VERT:
- m_bWrapV = bWrap;
- break;
- default:
- ASSERT( _evt == __EVT_FLOAT );
- m_bWrapF = bWrap;
- break;
- } // switch( _evt )
- }
- bool CExtBarButton::IsLargeIcon() const
- {
- ASSERT_VALID( this );
- if( GetBar() == NULL )
- return false;
- if( IsSeparator() )
- return false;
- const CExtToolControlBar * pBar = GetBar();
- return pBar->IsLargeIcons();
- }
- bool CExtBarButton::IsDisplayScreenTip() const
- {
- ASSERT_VALID( this );
- if( GetBar() == NULL )
- return false;
- if( IsSeparator() )
- return false;
- const CExtToolControlBar * pBar = GetBar();
- return pBar->IsDisplayScreenTips();
- }
- bool CExtBarButton::IsDisplayShortcutKeysOnScreenTip() const
- {
- ASSERT_VALID( this );
- if( GetBar() == NULL )
- return false;
- if( IsSeparator() )
- return false;
- const CExtToolControlBar * pBar = GetBar();
- return pBar->IsDisplayShortcutKeysOnScreenTips();
- }
- UINT CExtBarButton::GetCmdID(
- bool bEffective // = true
- ) const
- {
- ASSERT_VALID( this );
- return bEffective ? m_nEffectiveCmdID : m_nButtonCmdID;
- }
- void CExtBarButton::SetCmdID(
- UINT nCmdID,
- bool bEffectiveOnly, // = false
- bool bEffectiveRecalcLayout // = false
- )
- {
- ASSERT_VALID( this );
- bool bRecalcLayout = false;
- if( bEffectiveRecalcLayout
- && m_nEffectiveCmdID != nCmdID
- )
- bRecalcLayout = true;
-
- m_nEffectiveCmdID = nCmdID;
-
- if( ! bEffectiveOnly )
- {
- m_nButtonCmdID = nCmdID;
- if( m_nButtonCmdID == ID_SEPARATOR )
- {
- m_nStyle |= TBBS_SEPARATOR;
- m_nStyle &= ~(TBBS_BUTTON);
- }
- else
- {
- m_nStyle |= TBBS_BUTTON;
- m_nStyle &= ~(TBBS_SEPARATOR);
- }
- } // if( !bEffectiveOnly )
- if( bRecalcLayout )
- {
- CExtToolControlBar * pBar = GetBar();
- if( pBar->GetSafeHwnd() != NULL )
- {
- pBar->Invalidate();
- CFrameWnd * pFrame = pBar->GetParentFrame();
- if( pFrame != NULL )
- pFrame->RecalcLayout();
- else
- pBar->_RecalcLayoutImpl();
- } // if( pBar->GetSafeHwnd() != NULL )
- } // if( bRecalcLayout )
- }
- bool CExtBarButton::CanBePressedInDisabledState()
- {
- return IsAbleToTrackMenu();
- }
- bool CExtBarButton::IsPaintDropDown(
- bool bCustomizeMode // = false
- ) const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetSafeBar();
- if( pBar == NULL )
- return false;
- bool bPaintAsDropDown =
- ( IsAbleToTrackMenu( bCustomizeMode )
- //&&(! pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- && (! pBar->_IsSimplifiedDropDownButtons() )
- ) ? true : false;
- return bPaintAsDropDown;
- }
- bool CExtBarButton::IsAbleToTrackMenu(
- bool bCustomizeMode // = false
- ) const
- {
- ASSERT_VALID( this );
- bCustomizeMode;
- if( ( const_cast < CExtBarButton * > ( this ) ) -> GetMenu() != NULL
- || IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- )
- return true;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- const CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL
- && ( (pNode->GetFlags() & __ECTN_AUTO_POPUP) != 0
- || pNode->GetNodeCount() > 0
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtBarButton::IsContainerOfPopupLikeMenu()
- {
- ASSERT_VALID( this );
- ASSERT(
- ( m_hMenu == NULL )
- || ( m_hMenu != NULL && ::IsMenu(m_hMenu) )
- );
- return m_bPopupMenu;
- }
- CExtSafeString CExtBarButton::GetText() const
- {
- ASSERT_VALID( this );
- CExtSafeString sText( _T("") );
- if( IsSeparator() )
- return sText;
- const CExtToolControlBar * pBar = GetBar();
- HWND hWndBar = pBar->GetSafeHwnd();
- CExtCmdItem * pCmdItem = NULL;
- if( hWndBar != NULL )
- pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndBar ),
- GetCmdID( true )
- );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode =
- ((CExtBarButton*)this)->GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- return CExtSafeString( pNode->GetTextInToolbar( pCmdItem ) );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pCmdItem == NULL )
- return sText;
- if( ! pCmdItem->m_sToolbarText.IsEmpty() )
- sText = pCmdItem->m_sToolbarText;
- int nTabChrPos = sText.Find( _T('t') );
- if( nTabChrPos < 0 )
- return sText;
- return sText.Left( nTabChrPos );
- }
- bool CExtBarButton::GetSeparatedDropDown() const
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- if( ( pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN ) != 0 )
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return m_bSeparatedDropDown;
- }
- void CExtBarButton::SetSeparatedDropDown(
- bool bSeparatedDropDown // = true
- )
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->ModifyFlags(
- bSeparatedDropDown ? __ECTN_TBB_SEPARATED_DROPDOWN : 0,
- bSeparatedDropDown ? 0 : __ECTN_TBB_SEPARATED_DROPDOWN
- );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bSeparatedDropDown == bSeparatedDropDown )
- return;
- m_bSeparatedDropDown = bSeparatedDropDown;
- _UpdateCtrl();
- }
- bool CExtBarButton::GetAutoChangeID() const
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- return (pNode->GetFlags()&__ECTN_TBB_AUTOCHANGE_ID) ? true : false;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return m_bAutoChangeID;
- }
- void CExtBarButton::SetAutoChangeID(
- bool bAutoChangeID // = true
- )
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->ModifyFlags(
- bAutoChangeID ? __ECTN_TBB_AUTOCHANGE_ID : 0,
- bAutoChangeID ? 0 : __ECTN_TBB_AUTOCHANGE_ID
- );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bAutoChangeID == bAutoChangeID )
- return;
- m_bAutoChangeID = bAutoChangeID;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- // reset text
- if( m_bAutoChangeID )
- SetCmdID( GetCmdID(true), true );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- _UpdateCtrl();
- }
- bool CExtBarButton::GetNoRotateVerticalLayout() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pToolBar = GetBar();
- if( pToolBar != NULL )
- {
- ASSERT_VALID( pToolBar );
- if( pToolBar->m_bPaletteMode )
- return true;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- return (pNode->GetFlags()&__ECTN_TBB_NO_ROTATE_VL) ? true : false;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return m_bNoRotateVerticalLayout;
- }
- void CExtBarButton::SetNoRotateVerticalLayout(
- bool bNoRotateVerticalLayout // = true
- )
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->ModifyFlags(
- bNoRotateVerticalLayout ? __ECTN_TBB_NO_ROTATE_VL : 0,
- bNoRotateVerticalLayout ? 0 : __ECTN_TBB_NO_ROTATE_VL
- );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bNoRotateVerticalLayout == bNoRotateVerticalLayout )
- return;
- m_bNoRotateVerticalLayout = bNoRotateVerticalLayout;
- _UpdateCtrl();
- }
- bool CExtBarButton::GetCtrlVisibleVertically() const
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- return (pNode->GetFlags()&__ECTN_TBB_CTRL_VIS_VL) ? true : false;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return m_bCtrlVisibleVert;
- }
- void CExtBarButton::SetCtrlVisibleVertically( bool bVisible )
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->ModifyFlags(
- bVisible ? __ECTN_TBB_CTRL_VIS_VL : 0,
- bVisible ? 0 : __ECTN_TBB_CTRL_VIS_VL
- );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_bCtrlVisibleVert = bVisible;
- _UpdateCtrl();
- }
- BOOL CExtBarButton::PutToPopupMenu(
- CExtPopupMenuWnd * pPopup
- )
- {
- ASSERT_VALID( this );
- ASSERT( pPopup != NULL );
- ASSERT( pPopup->GetSafeHwnd() == NULL );
- CWnd * pCtrl = CtrlGet();
- if( pCtrl != NULL )
- {
- if( pCtrl->SendMessage(
- CExtToolControlBar::g_nMsgPutToPopupMenu,
- reinterpret_cast <WPARAM> ( pPopup ),
- 0
- )
- )
- return TRUE;
- }
- CExtToolControlBar * pBar = GetBar();
- if( IsAbleToTrackMenu() )
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pBar->GetSafeHwnd() ),
- GetCmdID( false )
- );
- ASSERT( pCmdItem != NULL );
- // CExtSafeString sText = pCmdItem->m_sMenuText;
- // if( sText.IsEmpty() )
- // sText = pCmdItem->m_sToolbarText;
- CExtSafeString sText = pCmdItem->m_sToolbarText;
- if( sText.IsEmpty() )
- sText = pCmdItem->m_sMenuText;
- const CExtCmdIcon & _icon = GetIcon();
- VERIFY( pPopup->ItemInsert( (UINT)CExtPopupMenuWnd::TYPE_POPUP, -1, LPCTSTR(sText), _icon ) );
- CExtPopupMenuWnd * pChildPopup = pPopup->ItemGetPopup( pPopup->ItemGetCount() - 1 );
- ASSERT( pChildPopup != NULL );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- VERIFY(
- pChildPopup->UpdateFromCmdTree(
- GetCmdTargetWnd()->GetSafeHwnd(),
- pNode,
- false
- )
- );
- CExtPopupMenuWnd::MENUITEMDATA & _mii = pPopup->ItemGetInfo( pPopup->ItemGetCount() - 1 );
- _mii.SetCmdNode( pNode );
- sText = pNode->GetTextInToolbar( pCmdItem, true );
- if( ! sText.IsEmpty() )
- _mii.SetText( LPCTSTR(sText) );
- } // if( pNode != NULL )
- else
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- HMENU hMenu = GetMenu();
- ASSERT( hMenu != NULL );
- ASSERT( ::IsMenu(hMenu) );
- CMenu _menu;
- _menu.Attach( hMenu );
- pChildPopup->UpdateFromMenu(
- GetCmdTargetWnd()->GetSafeHwnd(),
- &_menu,
- IsContainerOfPopupLikeMenu(),
- false
- );
- _menu.Detach();
- } // else from if( pNode != NULL )
- if( (pPopup->TrackFlagsGet()&TPMX_PALETTE) != 0 )
- pPopup->ItemGetInfo(
- pPopup->ItemGetCount()-1
- ).SetChildCombine();
- } // if( IsAbleToTrackMenu() )
- else
- {
- if( (pPopup->TrackFlagsGet()&TPMX_PALETTE) != 0 && (! IsSeparator() ) )
- {
- int nCheck = 0;
- if( (GetStyle()&TBBS_CHECKED) != 0 )
- nCheck = 1;
- const CExtCmdIcon & _icon = GetIcon();
- CExtSafeString strButtonText = GetText();
- HWND hWndCmdReceiver = pBar->GetOwner()->GetSafeHwnd();
- if( ! pPopup->ItemInsertCommand(
- GetCmdID(true),
- -1,
- strButtonText.IsEmpty() ? NULL : LPCTSTR(strButtonText),
- NULL,
- _icon,
- nCheck,
- hWndCmdReceiver
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pBar->GetSafeHwnd() ),
- GetCmdID( false )
- );
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pPopup->ItemGetInfo( pPopup->ItemGetCount() - 1 );
- mi.Enable( IsEnabled() );
- mi.SetNoCmdUI( true );
- if( pCmdItem != NULL
- && (! pCmdItem->m_sTipTool.IsEmpty() )
- )
- mi.SetCustomTip( LPCTSTR(pCmdItem->m_sTipTool) );
- } // if( (pPopu p->TrackFlagsGet()&TPMX_PALETTE) != 0 && (! IsSeparator() ) )
- else
- {
- if( ! pPopup->ItemInsert( GetCmdID(true) ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- } // else from if( (pPopup->TrackFlagsGet()&TPMX_PALETTE) != 0 && (! IsSeparator() ) )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pPopup->ItemGetInfo(
- pPopup->ItemGetCount() - 1
- ).SetCmdNode( pNode );
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- } // else from if( IsAbleToTrackMenu() )
- return TRUE;
- }
- CRect CExtBarButton::RectDropDown() const
- {
- ASSERT_VALID( this );
- CRect rcBtnDropDownArea = Rect();
- BOOL bHorz = TRUE;
- const CExtToolControlBar * pToolBar = GetBar();
- ASSERT_VALID( pToolBar );
- if( (!GetNoRotateVerticalLayout()) && pToolBar->IsDockedVertically() )
- bHorz = FALSE;
- bool bBarIsRTL = false;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( ! pToolBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) ) )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- {
- bBarIsRTL =
- ( (pToolBar->GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- ? true : false;
- if( (! bBarIsRTL)
- && pToolBar->m_pDockBar == NULL
- )
- bBarIsRTL =
- ( (pToolBar->GetParent()->GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- ? true : false;
- }
- if( bHorz )
- {
- if( bBarIsRTL )
- rcBtnDropDownArea.right =
- rcBtnDropDownArea.left
- + __DROPDOWN_ARROW_GAP*2
- + CExtPaintManager::g_glyph_btn_expand_bottom.Size().cx
- ;
- else
- rcBtnDropDownArea.left =
- rcBtnDropDownArea.right
- - __DROPDOWN_ARROW_GAP*2
- - CExtPaintManager::g_glyph_btn_expand_bottom.Size().cx
- ;
- } // if( bHorz )
- else
- {
- rcBtnDropDownArea.top =
- rcBtnDropDownArea.bottom
- - __DROPDOWN_ARROW_GAP*2
- - CExtPaintManager::g_glyph_btn_expand_right.Size().cy
- ;
- } // else from if( bHorz )
- return rcBtnDropDownArea;
- }
- CRect CExtBarButton::RectWithoutDropDown() const
- {
- ASSERT_VALID( this );
- CRect rc = Rect();
- if( GetSeparatedDropDown() )
- {
- CRect rcDD = RectDropDown();
- rc.right = rcDD.left;
- }
- return rc;
- }
- bool CExtBarButton::_UpdateCtrlIsEnabled()
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- if( pBar->GetSafeHwnd() == NULL )
- return false;
- if( ! pBar->_UpdateCtrlIsEnabled( this ) )
- return false;
- return true;
- }
- void CExtBarButton::_UpdateCtrl()
- {
- ASSERT_VALID( this );
- if( ! _UpdateCtrlIsEnabled() )
- return;
- CExtToolControlBar * pBar = GetBar();
- if( pBar->GetSafeHwnd() == NULL )
- return;
- CWnd * pCtrl = CtrlGet();
- if( pCtrl == NULL )
- return;
- bool bShow =
- ( IsVisible()
- && ( (! m_bVertDocked) || GetCtrlVisibleVertically() )
- && ( m_nStyle & TBBS_HIDDEN ) == 0
- )
- ? true : false;
- if( bShow )
- {
- ASSERT_VALID( pCtrl );
- CRect rcCtrl;
- pCtrl->GetWindowRect( &rcCtrl );
- pBar->ScreenToClient( &rcCtrl );
- CRect rcMove(
- m_ActiveRect.TopLeft(),
- rcCtrl.Size()
- );
- if( m_bVertDocked )
- {
- int nOffset = (m_ActiveRect.Width() - rcCtrl.Width()) / 2;
- rcMove.OffsetRect( nOffset, 0 );
- } // if( m_bVertDocked )
- else
- {
- int nOffset = (m_ActiveRect.Height() - rcCtrl.Height()) / 2;
- rcMove.OffsetRect( 0, nOffset );
- } // else from if( m_bVertDocked )
- if( rcCtrl != rcMove )
- pCtrl->MoveWindow( &rcMove, FALSE );
- } // if( bShow )
- pCtrl->ShowWindow( bShow ? SW_SHOW : SW_HIDE );
- pCtrl->EnableWindow( IsEnabled() );
- if( pCtrl->IsKindOf( RUNTIME_CLASS( CButton ) ) )
- {
- int nCheck = 0;
- if( IsPressed() )
- nCheck = 1;
- else if( IsIndeterminate() )
- nCheck = 2;
- ((CButton *)(pCtrl))->SetCheck( nCheck );
- }
- // if( IsVisible() && m_bHover )
- // pCtrl->SetFocus();
- }
- void CExtBarButton::SetLayoutRect( CDC &dc, const RECT & rectButton )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- dc;
- SetRect( rectButton );
- }
- void CExtBarButton::SetRect( const RECT & rectButton )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- GetBar()->AnimationSite_ClientProgressStop(
- this
- );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- AnimationClient_TargetRectSet( rectButton );
- m_ActiveRect = rectButton;
- CWnd * pCtrl = CtrlGet();
- if( pCtrl != NULL )
- _UpdateCtrl();
- }
- CRect CExtBarButton::Rect() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- CRect rcBtn = m_ActiveRect;
- if( GetBar() != NULL
- && pBar->PmBridge_GetPM()->GetCb2DbTransparentMode( (CObject *)(this) )
- && pBar->PmBridge_GetPM()->IsMenuMustCombineExcludeArea( this )
- && pBar->m_pDockSite != NULL
- && (! pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- )
- {
- const CSize _sizeRoundedAreaMerics =
- pBar->PmBridge_GetPM()->FixedBar_GetRoundedAreaMerics();
- CRect rcClient;
- pBar->GetClientRect( &rcClient );
- CRect rcBtn2(rcBtn);
- if( pBar->IsDockedVertically() )
- {
- rcBtn2.OffsetRect(
- rcBtn.left - rcClient.left,
- rcClient.bottom - rcBtn.bottom
- );
- rcBtn2.top = rcBtn.top - _sizeRoundedAreaMerics.cy*2-1;
- rcBtn2.right = rcClient.right;
- } // if( pBar->IsDockedVertically() )
- else if( pBar->IsDockedHorizontally() )
- {
- rcBtn2.OffsetRect(
- rcClient.right - rcBtn.right,
- rcBtn.top - rcClient.top
- );
- rcBtn2.left = rcBtn.left - _sizeRoundedAreaMerics.cx*2-1;
- rcBtn2.bottom = rcClient.bottom;
- } // else if( pBar->IsDockedHorizontally() )
- }
- return rcBtn;
- }
- CSize CExtBarButton::CalculateLayout(
- CDC & dc,
- CSize sizePreCalc,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT_VALID( (&dc) );
- if( GetNoRotateVerticalLayout() )
- bHorz = TRUE;
- CWnd * pCtrl = CtrlGet();
- if( ( pCtrl != NULL )
- && ( (! m_bVertDocked ) || GetCtrlVisibleVertically() )
- )
- {
- ASSERT_VALID( pCtrl );
- CRect rcCtrl;
- pCtrl->GetWindowRect( &rcCtrl );
- m_ActiveSize.cx = rcCtrl.Width();
- m_ActiveSize.cy = rcCtrl.Height();
- if( m_ActiveSize.cy < sizePreCalc.cy )
- m_ActiveSize.cy = sizePreCalc.cy;
- return m_ActiveSize;
- }
- m_ActiveSize = sizePreCalc;
- CExtToolControlBar * pBar = GetBar();
- if( IsSeparator() )
- {
- if( bHorz )
- m_ActiveSize.cx = __EXT_TB_BUTTON_SEPARATOR_WIDTH;
- else
- m_ActiveSize.cy = __EXT_TB_BUTTON_SEPARATOR_HEIGHT;
- }
- else
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( GetCmdNode() == NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pBar->GetSafeHwnd() ),
- GetCmdID( true )
- );
- if( pCmdItem == NULL )
- return m_ActiveSize; // shutdown mode
- }
- // TODO
- bool bBold = false;
- CSize szButton( 0, 0 );
- INT nMaxButtonWidth = OnQueryMaxButtonWidth( bHorz ? TRUE : FALSE );
- CRect rcBorderSizes = OnQueryBorderSizes( bHorz ? TRUE : FALSE );
- INT nIconAlignment = OnQueryAlignmentIcon( bHorz ? TRUE : FALSE );
- CRect rcIconMargins = OnQueryMarginsIcon( bHorz ? TRUE : FALSE );
- CRect rcTextMargins = OnQueryMarginsText( bHorz ? TRUE : FALSE );
- CExtCmdIcon * pIcon = GetIconPtr();
- CSize szIcon( 0, 0 );
- if( pIcon != NULL && (! pIcon->IsEmpty() ) )
- {
- szIcon = pIcon->GetSize();
- if( IsLargeIcon() )
- {
- szIcon.cx *= 2;
- szIcon.cy *= 2;
- }
- szIcon.cx += bHorz
- ? ( rcIconMargins.left + rcIconMargins.right )
- : ( rcIconMargins.top + rcIconMargins.bottom );
- szIcon.cy += bHorz
- ? ( rcIconMargins.top + rcIconMargins.bottom )
- : ( rcIconMargins.left + rcIconMargins.right );
- }
- CExtSafeString sTitle = GetText();
- if( ! sTitle.IsEmpty() )
- {
- CFont * pFont = pBar->OnGetToolbarFont( ! bHorz, true );
- if( pFont->GetSafeHandle() == NULL )
- {
- if( bHorz )
- {
- pFont = bBold
- ? &pBar->PmBridge_GetPM()->m_FontBold
- : &pBar->PmBridge_GetPM()->m_FontNormal;
- }
- else
- {
- pFont = bBold
- ? &pBar->PmBridge_GetPM()->m_FontBoldVert
- : &pBar->PmBridge_GetPM()->m_FontNormalVert;
- }
- }
- ASSERT( pFont != NULL );
- CFont * pOldFont = dc.SelectObject( pFont );
- CRect rcText( 0, 0, 0, 0 );
- UINT nDtMeasureFlags =
- DT_LEFT | DT_TOP | DT_CALCRECT;
- if( nMaxButtonWidth >= 0 )
- {
- rcText.right = nMaxButtonWidth;
- nDtMeasureFlags |= DT_WORDBREAK;
- }
- else
- nDtMeasureFlags |= DT_SINGLELINE;
- dc.DrawText(
- sTitle,
- -1,
- rcText,
- nDtMeasureFlags
- );
-
- if( bHorz )
- {
- rcText.InflateRect( rcTextMargins );
- if( ( nIconAlignment & CExtPaintManager::__ALIGN_HORIZ_MASK ) == CExtPaintManager::__ALIGN_HORIZ_CENTER )
- {
- if( ( nIconAlignment & CExtPaintManager::__ALIGN_VERT_MASK ) == CExtPaintManager::__ALIGN_VERT_CENTER )
- {
- szButton.cx = 0;
- szButton.cy = 0;
- }
- else
- {
- szButton.cx = max( rcText.Width(), szIcon.cx );
- szButton.cy = rcText.Height() + szIcon.cy;
- }
- }
- else
- {
- szButton.cx = rcText.Width() + szIcon.cx;
- szButton.cy = max( rcText.Height(), szIcon.cy );
- }
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- szButton.cx += 10;
- }
- else
- {
- rcText.InflateRect(
- rcTextMargins.top,
- rcTextMargins.right,
- rcTextMargins.bottom,
- rcTextMargins.left
- );
- if( ( nIconAlignment & CExtPaintManager::__ALIGN_HORIZ_MASK ) == CExtPaintManager::__ALIGN_HORIZ_CENTER )
- {
- if( ( nIconAlignment & CExtPaintManager::__ALIGN_VERT_MASK ) == CExtPaintManager::__ALIGN_VERT_CENTER )
- {
- szButton.cx = 0;
- szButton.cy = 0;
- }
- else
- {
- szButton.cx = rcText.Height() + szIcon.cx;
- szButton.cy = max( rcText.Width(), szIcon.cy );
- }
- }
- else
- {
- szButton.cx = max( rcText.Height(), szIcon.cx );
- szButton.cy = rcText.Width() + szIcon.cy;
- }
-
- if( pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- szButton.cy += 10;
- }
-
- dc.SelectObject( pOldFont );
-
- } // if( ! sTitle.IsEmpty() )
- else
- szButton = szIcon;
- szButton.cx += bHorz
- ? ( rcBorderSizes.left + rcBorderSizes.right )
- : ( rcBorderSizes.top + rcBorderSizes.bottom );
- szButton.cy += bHorz
- ? ( rcBorderSizes.top + rcBorderSizes.bottom )
- : ( rcBorderSizes.left + rcBorderSizes.right );
- if( m_ActiveSize.cx < szButton.cx )
- m_ActiveSize.cx = szButton.cx;
- if( m_ActiveSize.cy < szButton.cy )
- m_ActiveSize.cy = szButton.cy;
- pBar->PmBridge_GetPM()->Toolbar_AdjustButtonSize( this, m_ActiveSize );
- } // else from if( IsSeparator() )
- if( IsAbleToTrackMenu()
- && ( ! pBar->_IsSimplifiedDropDownButtons() )
- )
- {
- if( bHorz )
- m_ActiveSize.cx +=
- __DROPDOWN_ARROW_GAP * 2
- + CExtPaintManager::g_glyph_btn_expand_bottom.Size().cx;
- else
- m_ActiveSize.cy +=
- __DROPDOWN_ARROW_GAP * 2
- + CExtPaintManager::g_glyph_btn_expand_right.Size().cy;
- }
- CSize _size = pBar->PmBridge_GetPM()->Toolbar_GetMinButtonSize( this );
- if( bHorz )
- {
- m_ActiveSize.cx += _size.cx;
- if( m_ActiveSize.cy < _size.cy )
- m_ActiveSize.cy = _size.cy;
- }
- else
- {
- if( m_ActiveSize.cx < _size.cx )
- m_ActiveSize.cx = _size.cx;
- m_ActiveSize.cy += _size.cy;
- }
- return m_ActiveSize;
- }
- CExtCmdIcon * CExtBarButton::GetIconPtr()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- CExtToolControlBar * pBar = GetBar();
- if( pBar->GetSafeHwnd() == NULL )
- return NULL;
- __EXT_MFC_SAFE_LPCTSTR strProfile = g_CmdManager->ProfileNameFromWnd( pBar->GetSafeHwnd() );
- if( strProfile == NULL )
- return NULL;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pOwnNode = GetCmdNode();
- if( pOwnNode != NULL )
- {
- ASSERT_VALID( pOwnNode );
- if( !CExtCmdManager::IsCommand( GetCmdID( true ) ) )
- return NULL;
- CExtCmdIcon * pIcon =
- pOwnNode->GetIconPtrInToolbar(
- g_CmdManager->CmdGetPtr(
- strProfile,
- GetCmdID( true )
- )
- );
- if( pIcon == NULL )
- return NULL;
- if( (pOwnNode->GetFlags()&__ECTN_TBB_AUTOCHANGE_ID) == 0 )
- return pIcon;
- } // if( pOwnNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- UINT nCmdID = GetCmdID( true );
- if( ! CExtCmdManager::IsCommand( nCmdID ) )
- return NULL;
- return
- g_CmdManager->CmdGetIconPtr(
- strProfile,
- nCmdID
- );
- }
- const CExtCmdIcon * CExtBarButton::GetIconPtr() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> GetIconPtr();
- }
- CExtCmdIcon & CExtBarButton::GetIcon()
- {
- ASSERT_VALID( this );
- CExtCmdIcon * pIcon = GetIconPtr();
- if( pIcon != NULL )
- return (*pIcon);
- static CExtCmdIcon g_EmptyIcon;
- return g_EmptyIcon;
- }
- const CExtCmdIcon & CExtBarButton::GetIcon() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> GetIcon();
- }
- const CExtAnimationParameters *
- CExtBarButton::AnimationClient_OnQueryAnimationParameters(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT_VALID( this );
- const CExtAnimationParameters * pAnimationParameters =
- g_PaintManager->Animation_GetParameters(
- eAPT,
- (CObject*)this,
- this
- );
- return pAnimationParameters;
- }
- bool CExtBarButton::AnimationClient_CacheNextState(
- CDC & dc,
- const RECT & rcAcAnimationTarget,
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( AnimationClient_CacheGeneratorIsLocked() );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- if( AnimationClient_NonClientModeGet() )
- pBar->DoPaintNC( &dc );
- else
- pBar->DoEraseBk( &dc );
- PaintCompound( dc, true, false, false );
- return
- CExtAnimationClient::AnimationClient_CacheNextState(
- dc,
- rcAcAnimationTarget,
- bAnimate,
- eAPT
- );
- }
- bool CExtBarButton::AnimationClient_StatePaint(
- CDC & dc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( GetBar() );
- if( AnimationClient_SiteGet() == NULL )
- AnimationClient_SiteSet( GetBar() );
- bool bRetVal = CExtAnimationClient::AnimationClient_StatePaint( dc );
- PaintChildren( dc, true );
- return bRetVal;
- }
- void CExtBarButton::AnimationClient_StateDoStep()
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- if( pBar->m_pDockBar == NULL )
- {
- CExtRibbonBar * pRibbonBar = DYNAMIC_DOWNCAST( CExtRibbonBar, pBar );
- if( pRibbonBar != NULL
- && pRibbonBar->m_pExtNcFrameImpl != NULL
- && pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- )
- {
- CWnd * pWndParent = pBar->GetParent();
- if( pWndParent != NULL )
- {
- CRect _rectTest = *this;
- pBar->ClientToScreen( &_rectTest );
- pWndParent->ScreenToClient( &_rectTest );
- if( _rectTest.bottom <= 0
- || ( _rectTest.top <= 0
- && IsKindOf( RUNTIME_CLASS(CExtRibbonButtonFile) )
- )
- )
- {
- pBar->_InvalidateButton( pBar->_GetIndexOf( this ) );
- return;
- }
- } // if( pWndParent != NULL )
- } // if( m_pDockBar == NULL ...
- } // if( pBar->m_pDockBar == NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtAnimationClient::AnimationClient_StateDoStep();
- }
- bool CExtBarButton::IsHorzBarOrientation() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- if( pBar == NULL )
- return true;
- ASSERT_VALID( pBar );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( pBar->IsKindOf( RUNTIME_CLASS(CExtRibbonPage) ) )
- return true;
- #endif
- DWORD dwBarStyle =
- ( const_cast < CExtToolControlBar * > ( pBar ) )
- -> GetBarStyle();
- if( ( dwBarStyle & CBRS_ORIENT_HORZ ) != 0 )
- return true;
- if( pBar->m_bPaletteMode )
- return true;
- if( GetNoRotateVerticalLayout() )
- return true;
- return false;
- }
- bool CExtBarButton::IsPaintAble( CDC & dc ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! IsVisible() )
- return false;
- if( ( GetStyle() & TBBS_HIDDEN ) != 0 )
- return false;
- CRect rcTBB = *this;
- if( ! dc.RectVisible( &rcTBB ) )
- return false;
- return true;
- }
- void CExtBarButton::PaintParentChain(
- CDC & dc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtBarButton * pTBB = ParentButtonGet();
- if( pTBB == NULL )
- return;
- CTypedPtrList < CPtrList, CExtBarButton * > _list;
- for( ; pTBB != NULL; pTBB = pTBB->ParentButtonGet() )
- {
- ASSERT_VALID( pTBB );
- _list.AddHead( pTBB );
- }
- POSITION pos = _list.GetHeadPosition();
- for( ; pos != NULL; )
- {
- pTBB = _list.GetNext( pos );
- ASSERT_VALID( pTBB );
- pTBB->PaintCompound( dc, false, false, false );
- }
- }
- void CExtBarButton::PaintChildren(
- CDC & dc,
- bool bPaintOneNearestChildrenLevelOnly
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- INT nChildIndex, nChildCount = ChildButtonGetCount();
- for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- {
- CExtBarButton * pTBB = ChildButtonGetAt( nChildIndex );
- ASSERT_VALID( pTBB );
- if( ! pTBB->IsVisible() )
- continue;
- if( ( pTBB->GetStyle() & TBBS_HIDDEN ) != 0 )
- continue;
- pTBB->PaintCompound( dc, false, ! bPaintOneNearestChildrenLevelOnly, false );
- } // for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- }
- void CExtBarButton::Paint( // old version version (left for compatibility)
- CDC & dc,
- bool bHorz // unused, same as IsHorzBarOrientation()
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- bHorz;
- Paint( dc );
- }
- void CExtBarButton::Paint( // new simplified version (for simple toolbars)
- CDC & dc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- PaintCompound( dc, false, false, false );
- }
- void CExtBarButton::PaintCompound( // new fully featured version (for compound toolbars and rendering animation parts)
- CDC & dc,
- bool bPaintParentChain,
- bool bPaintChildren,
- bool bPaintOneNearestChildrenLevelOnly
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- if( ! IsPaintAble( dc ) )
- return;
- if( AnimationClient_StatePaint( dc ) )
- return;
- if( bPaintParentChain )
- PaintParentChain( dc );
- CWnd * pCtrl = CtrlGet();
- if( ( pCtrl != NULL )
- && ( ( ! m_bVertDocked )
- || GetCtrlVisibleVertically()
- )
- )
- return;
- // ASSERT( !IsSeparator() );
- CRect rcArea( m_ActiveRect );
- if( rcArea.right <= rcArea.left
- || rcArea.bottom <= rcArea.top
- )
- return;
- if( (! IsVisible() )
- || (GetStyle() & TBBS_HIDDEN) != 0
- || (! dc.RectVisible(&m_ActiveRect) )
- )
- return;
- bool bDockSiteCustomizeMode =
- pBar->_IsDockSiteCustomizeMode();
- bool bPushed =
- ( IsPressed() && (!bDockSiteCustomizeMode) )
- ? true : false;
- bool bEnabled =
- ( IsDisabled() && (!bDockSiteCustomizeMode) )
- ? false : true;
- bool bHover =
- ( IsHover() && (!bDockSiteCustomizeMode) )
- ? true : false;
- if( (! bDockSiteCustomizeMode )
- && (! GetBar()->IsForceHoverWhenMenuTracking() )
- )
- {
- if( CExtToolControlBar::g_bMenuTracking
- || CExtPopupMenuWnd::IsMenuTracking()
- )
- bHover = false;
- else if( !bHover )
- bHover = IsPressedTracking();
- //if( bPushed && bHover && IsPressedTracking() )
- //bHover = false;
- } // if( ! bDockSiteCustomizeMode ...
- bool bIndeterminate =
- ( IsIndeterminate() && (!bDockSiteCustomizeMode) )
- ? true : false;
- CExtSafeString sText = GetText();
- CExtCmdIcon * pIcon = GetIconPtr();
- CExtCmdIcon * pIconLarge = NULL;
- if( pIcon != NULL
- && (! pIcon->IsEmpty() )
- && IsLargeIcon()
- )
- {
- CSize _sizeIcon = pIcon->GetSize();
- _sizeIcon.cx *= 2;
- _sizeIcon.cy *= 2;
- pIconLarge = new CExtCmdIcon;
- if( pIconLarge->CreateScaledCopy(
- *pIcon,
- _sizeIcon
- )
- )
- pIcon = pIconLarge;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- }
- bool bPaintAsDropDown = IsPaintDropDown();
- bool bHorz = IsHorzBarOrientation();
- HFONT hFont =
- (HFONT) pBar
- -> OnGetToolbarFont( ! bHorz, false )
- -> GetSafeHandle();
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
- this,
- bHorz,
- rcArea,
- sText,
- pIcon,
- true,
- bHover,
- bPushed,
- bIndeterminate,
- bEnabled,
- m_bDrawBorder,
- false,
- false,
- 0,
- hFont,
- bPaintAsDropDown,
- 0,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbd.m_rcBorderSizes = OnQueryBorderSizes( bHorz );
- _ppbd.m_nIconAlignment = OnQueryAlignmentIcon( bHorz );
- _ppbd.m_nTextAlignment = OnQueryAlignmentText( bHorz );
- _ppbd.m_rcIconMargins = OnQueryMarginsIcon( bHorz );
- _ppbd.m_rcTextMargins = OnQueryMarginsText( bHorz );
- if( OnQueryMaxButtonWidth( bHorz ) >= 0 )
- _ppbd.m_bWordBreak = true;
- if( GetSeparatedDropDown() )
- {
- _ppbd.m_bSeparatedDropDown = true;
- _ppbd.m_bHoverDropDown = m_bDropDownHT;
- if( ( m_bDropDownHT /*|| CExtToolControlBar::g_bMenuTracking*/ )
- && bPushed
- && ( ! bDockSiteCustomizeMode )
- )
- {
- //_ppbd.m_bPushed = false;
- _ppbd.m_bPushedDropDown = true;
- }
- }
- _ppbd.m_clrCustomAccentEffectForIcon =
- OnQueryCustomAccentEffectForIcon( dc );
- bool bChecked =
- ( (GetStyle()&TBBS_CHECKED) != 0 )
- ? true
- : false;
- _ppbd.m_bChecked = bChecked;
- if( CExtToolControlBar::g_bMenuTracking
- && pBar->_GetIndexOf(this) == pBar->m_nBtnIdxMenuTracking
- )
- {
- CExtPopupMenuWnd * pPopup = CExtPopupMenuWnd::GetTrackingMenu();
- if( pPopup->GetSafeHwnd() != NULL
- && pPopup->m_eCombineAlign != CExtPopupMenuWnd::__CMBA_NONE
- && ( pPopup->GetStyle() & WS_VISIBLE ) != 0
- )
- {
- _ppbd.m_bHover = _ppbd.m_bPushed
- = _ppbd.m_bHoverDropDown = _ppbd.m_bPushedDropDown
- = _ppbd.m_bChecked
- = _ppbd.m_bDrawBorder
- = false;
- _ppbd.m_bTransparentBackground = true;
- }
- }
- pBar->PmBridge_GetPM()->PaintPushButton( dc, _ppbd );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- && pSite->CustomizedNodeGet() != NULL
- && pSite->CustomizedNodeGet() == GetCmdNode( false )
- )
- {
- pBar->PmBridge_GetPM()->PaintDragSourceRect(
- dc,
- rcArea
- );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pIconLarge != NULL )
- delete pIconLarge;
- if( bPaintChildren )
- PaintChildren( dc, bPaintOneNearestChildrenLevelOnly );
- }
- CRect CExtBarButton::OnQueryBorderSizes(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- return CRect( 1, 1, 1, 1 );
- }
- INT CExtBarButton::OnQueryAlignmentText(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- return
- m_nTextAlignment >= 0
- ? m_nTextAlignment
- : CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_CENTER;
- }
- INT CExtBarButton::OnQueryAlignmentIcon(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- CExtSafeString sText = GetText();
- return
- m_nIconAlignment >= 0
- ? m_nIconAlignment
- : sText.IsEmpty()
- ? CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_CENTER
- : CExtPaintManager::__ALIGN_HORIZ_LEFT | CExtPaintManager::__ALIGN_VERT_CENTER;
- }
- CRect CExtBarButton::OnQueryMarginsText(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- if( m_rcTextMargins.left >= 0
- && m_rcTextMargins.top >= 0
- && m_rcTextMargins.right >= 0
- && m_rcTextMargins.bottom >= 0
- )
- return m_rcTextMargins;
- return CRect( 2, 2, 2, 2 );
- }
- CRect CExtBarButton::OnQueryMarginsIcon(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- if( m_rcIconMargins.left >= 0
- && m_rcIconMargins.top >= 0
- && m_rcIconMargins.right >= 0
- && m_rcIconMargins.bottom >= 0
- )
- return m_rcIconMargins;
- return CRect( 2, 2, 2, 2 );
- }
- INT CExtBarButton::OnQueryMaxButtonWidth(
- bool bHorz // = true
- ) const
- {
- ASSERT_VALID( this );
- bHorz;
- return m_nMaxButtonWidth;
- }
- void CExtBarButton::SetMaxButtonWidth(
- INT nWidth
- )
- {
- ASSERT_VALID( this );
- m_nMaxButtonWidth = nWidth;
- }
- INT CExtBarButton::GetMaxButtonWidth() const
- {
- ASSERT_VALID( this );
- return m_nMaxButtonWidth;
- }
- void CExtBarButton::SetTextAlignment(
- INT nAlignment
- )
- {
- ASSERT_VALID( this );
- m_nTextAlignment = nAlignment;
- }
- INT CExtBarButton::GetTextAlignment() const
- {
- ASSERT_VALID( this );
- return m_nTextAlignment;
- }
- void CExtBarButton::SetIconAlignment(
- INT nAlignment
- )
- {
- ASSERT_VALID( this );
- m_nIconAlignment = nAlignment;
- }
- INT CExtBarButton::GetIconAlignment() const
- {
- ASSERT_VALID( this );
- return OnQueryAlignmentIcon();
- }
- void CExtBarButton::SetTextMargins(
- INT nLeft,
- INT nTop,
- INT nRight,
- INT nBottom
- )
- {
- ASSERT_VALID( this );
- m_rcTextMargins.SetRect(
- nLeft,
- nTop,
- nRight,
- nBottom
- );
- }
- void CExtBarButton::SetTextMargins(
- const RECT & rcMargins
- )
- {
- ASSERT_VALID( this );
- SetTextMargins(
- rcMargins.left,
- rcMargins.top,
- rcMargins.right,
- rcMargins.bottom
- );
- }
- void CExtBarButton::SetTextMargins(
- LPCRECT lprcMargins
- )
- {
- ASSERT_VALID( this );
- if( lprcMargins == NULL )
- {
- ASSERT( FALSE );
- return;
- }
- SetTextMargins(
- lprcMargins->left,
- lprcMargins->top,
- lprcMargins->right,
- lprcMargins->bottom
- );
- }
- void CExtBarButton::SetIconMargins(
- INT nLeft,
- INT nTop,
- INT nRight,
- INT nBottom
- )
- {
- ASSERT_VALID( this );
- m_rcIconMargins.SetRect(
- nLeft,
- nTop,
- nRight,
- nBottom
- );
- ASSERT_VALID( this );
- }
- void CExtBarButton::SetIconMargins(
- const RECT & rcMargins
- )
- {
- ASSERT_VALID( this );
- SetIconMargins(
- rcMargins.left,
- rcMargins.top,
- rcMargins.right,
- rcMargins.bottom
- );
- }
- void CExtBarButton::SetIconMargins(
- LPCRECT lprcMargins
- )
- {
- ASSERT_VALID( this );
- if( lprcMargins == NULL )
- {
- ASSERT( FALSE );
- return;
- }
- SetIconMargins(
- lprcMargins->left,
- lprcMargins->top,
- lprcMargins->right,
- lprcMargins->bottom
- );
- }
- void CExtBarButton::GetTextMargins(
- INT & nLeft,
- INT & nTop,
- INT & nRight,
- INT & nBottom
- ) const
- {
- ASSERT_VALID( this );
- CRect rcTextMargins = GetTextMargins();
- nLeft = rcTextMargins.left;
- nTop = rcTextMargins.top;
- nRight = rcTextMargins.right;
- nBottom = rcTextMargins.bottom;
- }
- CRect CExtBarButton::GetTextMargins() const
- {
- ASSERT_VALID( this );
- return m_rcTextMargins;
- }
- void CExtBarButton::GetIconMargins(
- INT & nLeft,
- INT & nTop,
- INT & nRight,
- INT & nBottom
- ) const
- {
- ASSERT_VALID( this );
- CRect rcIconMargins = GetTextMargins();
- nLeft = rcIconMargins.left;
- nTop = rcIconMargins.top;
- nRight = rcIconMargins.right;
- nBottom = rcIconMargins.bottom;
- }
- CRect CExtBarButton::GetIconMargins() const
- {
- ASSERT_VALID( this );
- return m_rcIconMargins;
- }
- bool CExtBarButton::GetDrawBorder() const
- {
- ASSERT_VALID( this );
- return m_bDrawBorder;
- }
- void CExtBarButton::SetDrawBorder(
- bool bEnable // = true
- )
- {
- ASSERT_VALID( this );
- m_bDrawBorder = bEnable;
- }
- COLORREF CExtBarButton::OnQueryCustomAccentEffectForIcon(
- CDC & dc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtToolControlBar * pBar = GetBar();
- return pBar->OnQueryCustomAccentEffectForIcon( dc, this );
- }
- void CExtBarButton::OnUpdateCmdUI(
- CWnd * pTarget,
- BOOL bDisableIfNoHndler,
- int nIndex
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- if( pTarget == NULL )
- pTarget = pBar->GetOwner();
- ASSERT_VALID( pTarget );
- if( IsSeparator() // ignore separators
- || ( IsAbleToTrackMenu() // ignore menu drop buttons
- //&&(pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)))
- && ( pBar->_IsSimplifiedDropDownButtons() )
- )
- )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = pBar->GetCustomizeSite();
- if( pSite != NULL )
- {
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode != NULL
- //&& (pNode->GetFlags() & __ECTN_AUTO_POPUP) != 0
- && (pNode->GetFlags() & __ECTN_DYNAMIC_POPUP) != 0
- )
- return;
- if( pSite->IsUserBarCommand( GetCmdID( false ) ) )
- return;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- // send the update notification
- CExtToolControlBar::CExtToolControlBarCmdUI state;
- state.m_pOther = GetBar();
- state.m_nIndex = nIndex;
- state.m_nIndexMax = pBar->GetButtonsCount();
- state.m_nID = GetCmdID( true );
- state.DoUpdate( pTarget, bDisableIfNoHndler );
- }
- bool CExtBarButton::CanStartCommandDrag()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- if( IsSeparator() )
- return false;
- CWnd * pCtrl = CtrlGet();
- if( pCtrl->GetSafeHwnd() != NULL )
- return false;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( GetCmdNode() == NULL )
- return false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return true;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtBarButton::_UpdateCmdNodeFromStyle()
- {
- ASSERT_VALID( this );
- if( GetBar() == NULL )
- return;
- ASSERT_VALID( GetBar() );
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode == NULL )
- return;
- ASSERT_VALID( pNode );
- if( GetStyle() & TBBS_HIDDEN )
- pNode->ModifyFlags( __ECTN_TBB_HIDDEN, 0 );
- else
- pNode->ModifyFlags( 0, __ECTN_TBB_HIDDEN );
- }
- bool CExtBarButton::IsCustomizeActiveItem()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- CExtToolControlBar * pBar = GetBar();
- CExtCustomizeSite * pSite =
- pBar->GetCustomizeSite();
- if( pSite == NULL )
- return false;
- return pSite->IsActiveItem( this );
- }
- void CExtBarButton::SetCustomizeActiveItem()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- if( IsSeparator() )
- return;
- CExtToolControlBar * pBar = GetBar();
- CExtCustomizeSite * pSite =
- pBar->GetCustomizeSite();
- if( pSite == NULL )
- return;
- pSite->ActiveItemSet( this, pBar->GetSafeHwnd() );
- pBar->_GetIndexOf( this );
- RedrawButton();
- }
- int CExtBarButton::CalculateDropOverEffect(
- CPoint point,
- CExtCustomizeSite::CCmdDragInfo & _dragInfo,
- bool bAllowTrackNodePopup // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT( !_dragInfo.IsEmpty() );
- _dragInfo;
- if( IsSeparator() )
- return 0;
- if( !CanStartCommandDrag() )
- return 0;
- if( GetCmdNode() == NULL )
- return false;
- //CPoint ptMid = Rect().CenterPoint();
- CPoint ptMidL = Rect().TopLeft();
- ptMidL.x += Rect().Size().cx / 4;
- ptMidL.y += Rect().Size().cy / 4;
- CPoint ptMidR( ptMidL );
- ptMidR.x += Rect().Size().cx / 2;
- ptMidR.y += Rect().Size().cy / 2;
- int nRetVal = 0;
- CExtToolControlBar * pBar = GetBar();
- if( (pBar->m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- {
- if( point.x <= ptMidL.x )
- nRetVal = -1;
- else if( point.x >= ptMidR.x )
- nRetVal = 1;
- else
- nRetVal = -2;
- } // if( (pBar->m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- else
- {
- if( point.y <= ptMidL.y )
- nRetVal = -1;
- else if( point.y >= ptMidR.y )
- nRetVal = 1;
- else
- nRetVal = -2;
- } // else from if( (pBar->m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- if( bAllowTrackNodePopup )
- {
- CExtCustomizeSite * pSite = pBar->GetCustomizeSite();
- ASSERT( pSite != NULL );
- if( IsAbleToTrackMenu( true ) )
- {
- CExtCustomizeCmdTreeNode * pOwnNode = GetCmdNode();
- ASSERT_VALID( pOwnNode );
- CRect rcBtn = Rect();
- pBar->ClientToScreen( &rcBtn );
- pBar->ClientToScreen( &point );
- DWORD dwTrackFlags = OnGetTrackPopupFlags();
- pSite->DropTargetPopupTrack(
- pOwnNode,
- rcBtn,
- point,
- dwTrackFlags
- );
- } // if( IsAbleToTrackMenu() )
- else
- pSite->DropTargetPopupCancel();
- } // if( bAllowTrackNodePopup )
- else
- {
- CExtCustomizeSite * pSite = pBar->GetCustomizeSite();
- if( pSite != NULL )
- pSite->DropTargetPopupCancel();
- } // else from if( bAllowTrackNodePopup )
- return nRetVal;
- }
- CExtCustomizeCmdTreeNode * CExtBarButton::GetCmdNode(
- bool bInitial // = false
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // if( IsSeparator() )
- // {
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // return NULL;
- // }
- CExtCustomizeCmdTreeNode * pNode =
- bInitial ? m_pCmdNodeI : m_pCmdNodeC;
- #ifdef _DEBUG
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- }
- #endif // _DEBUG
- return pNode;
- }
- const CExtCustomizeCmdTreeNode * CExtBarButton::GetCmdNode(
- bool bInitial // = false
- ) const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtBarButton * > ( this ) )
- -> GetCmdNode( bInitial );
- }
- void CExtBarButton::OnCustomizeUpdateProps(
- CExtCustomizeCmdTreeNode * pNode // = NULL // update from basic node
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- if( pNode == NULL )
- pNode = m_pCmdNodeI;
- ASSERT_VALID( pNode );
- #ifdef _DEBUG
- if( m_pCmdNodeI != NULL )
- {
- ASSERT_VALID( m_pCmdNodeI );
- }
- #endif // _DEBUG
- // ASSERT( !IsSeparator() );
- SetCmdID( pNode->GetCmdID(false), false ); // reset all IDs
- SetCmdID( pNode->GetCmdID(true), true ); // reset effective ID
- DWORD dwNodeFlags = pNode->GetFlags();
- if( dwNodeFlags&__ECTN_TBB_APPEND_MDI_MENU )
- SetAppendMdiWindowsMenu( true );
- if( dwNodeFlags&__ECTN_TBB_SEPARATED_DROPDOWN )
- SetSeparatedDropDown( true );
- if( dwNodeFlags&__ECTN_TBB_AUTOCHANGE_ID )
- SetAutoChangeID( true );
- if( dwNodeFlags&__ECTN_TBB_NO_ROTATE_VL )
- SetNoRotateVerticalLayout( true );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( GetAutoChangeID() && m_pCmdNodeC != NULL )
- {
- ASSERT_VALID( m_pCmdNodeC );
- CExtToolControlBar * pBar = GetBar();
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(
- pBar->GetSafeHwnd()
- ),
- GetCmdID( true )
- );
- LPCTSTR strText =
- ( pCmdItem != NULL )
- ? ( pCmdItem->m_sToolbarText.IsEmpty()
- ? ( pCmdItem->m_sMenuText.IsEmpty()
- ? _T("")
- : pCmdItem->m_sMenuText
- )
- : pCmdItem->m_sToolbarText
- )
- : _T("")
- ;
- m_pCmdNodeC->SetTextInToolbar( strText );
- m_pCmdNodeC->SetTextInMenu( strText );
- } // if( GetAutoChangeID() && m_pCmdNodeC != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtBarButton::SetBasicCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT_VALID( pNode );
- // ASSERT( !IsSeparator() );
- m_pCmdNodeI = pNode;
- // ASSERT( m_pCmdNodeI->GetCmdID(false) == GetCmdID(false) );
- }
- void CExtBarButton::SetCustomizedCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT_VALID( pNode );
- #ifdef _DEBUG
- if( m_pCmdNodeI != NULL )
- {
- ASSERT_VALID( m_pCmdNodeI );
- }
- #endif // _DEBUG
- // ASSERT( !IsSeparator() );
- m_pCmdNodeC = pNode;
- ASSERT( m_pCmdNodeC->GetCmdID(false) == GetCmdID(false) );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( GetAutoChangeID() )
- {
- CExtToolControlBar * pBar = GetBar();
- HWND hWnd = pBar->GetSafeHwnd();
- if( hWnd != NULL )
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr( g_CmdManager->ProfileNameFromWnd( hWnd ), GetCmdID( true ) );
- LPCTSTR strText =
- ( pCmdItem != NULL )
- ? ( pCmdItem->m_sToolbarText.IsEmpty()
- ? ( pCmdItem->m_sMenuText.IsEmpty()
- ? _T("")
- : pCmdItem->m_sMenuText
- )
- : pCmdItem->m_sToolbarText
- )
- : _T("")
- ;
- m_pCmdNodeC->SetTextInToolbar( strText );
- m_pCmdNodeC->SetTextInMenu( strText );
- } // if( hWnd != NULL )
- } // if( GetAutoChangeID() )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- CExtCustomizeCmdTreeNode * CExtBarButton::OnCustomizeNodeInit(
- CExtCustomizeSite * pSite,
- CExtCustomizeCmdTreeNode * pParentNode // toolbar node
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT( pSite != NULL );
- ASSERT_VALID( pParentNode );
- if( IsSeparator() )
- {
- ASSERT( m_pCmdNodeI == NULL );
- ASSERT( m_pCmdNodeC == NULL );
- return NULL;
- }
- m_pCmdNodeI = m_pCmdNodeC = NULL;
- m_pCmdNodeI =
- pSite->OnCmdNodeCreate(
- GetCmdID( false ),
- GetCmdID( true )
- );
- pParentNode->InsertNode( pSite, m_pCmdNodeI );
- CExtToolControlBar * pBar = GetBar();
- INT nOwnIdx = pBar->_GetIndexOf( this );
- ASSERT( 0 <= nOwnIdx && nOwnIdx < pBar->GetButtonsCount() );
- if( nOwnIdx > 0 )
- {
- CExtBarButton * pPrevTBB =
- pBar->GetButton( nOwnIdx - 1 );
- if( pPrevTBB->IsSeparator() )
- m_pCmdNodeI->ModifyFlags( __ECTN_GROUP_START );
- } // __ECTN_GROUP_START
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pBar->m_hWnd ),
- GetCmdID()
- );
- ASSERT( pCmdItem != NULL );
- m_pCmdNodeI->SetTextInToolbar( pCmdItem->m_sToolbarText );
- m_pCmdNodeI->SetTextInMenu( pCmdItem->m_sMenuText );
- DWORD dwAddFlags = 0;
- if( IsAppendMdiWindowsMenu() )
- dwAddFlags |= __ECTN_TBB_APPEND_MDI_MENU;
- if( GetSeparatedDropDown() || pCmdItem->StateIsSeparatedDD() )
- dwAddFlags |= __ECTN_TBB_SEPARATED_DROPDOWN;
- if( GetAutoChangeID() || pCmdItem->StateIsAutochangeID() )
- dwAddFlags |= __ECTN_TBB_AUTOCHANGE_ID;
- if( GetNoRotateVerticalLayout() || pCmdItem->StateIsNoRotateVL() )
- dwAddFlags |= __ECTN_TBB_NO_ROTATE_VL;
- if( GetCtrlVisibleVertically() || pCmdItem->StateIsCtrlVisibleVertically() )
- dwAddFlags |= __ECTN_TBB_CTRL_VIS_VL;
- if( pCmdItem->StateIsCannotHide() )
- dwAddFlags |= __ECTN_TBB_CANNOT_HIDE;
- if( dwAddFlags != 0 )
- m_pCmdNodeI->ModifyFlags( dwAddFlags );
- m_pCmdNodeI->SetLParam( pCmdItem->m_nLParamUserData );
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- m_pCmdNodeI->TextFieldWidthSet( pCmdItem->m_nTextFieldWidth );
- m_pCmdNodeI->DropDownWidthSet( pCmdItem->m_nDropDownWidth );
- m_pCmdNodeI->DropDownHeightMaxSet( pCmdItem->m_nDropDownHeightMax );
- if( pCmdItem->StateIsCombo() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_COMBO|__ECTN_TBB_TEXT_FIELD, __ECTN_TBB_DATE );
- else if( pCmdItem->StateIsDate() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_DATE|__ECTN_TBB_TEXT_FIELD, __ECTN_TBB_COMBO );
- else if( pCmdItem->StateIsTextField() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_TEXT_FIELD, __ECTN_TBB_COMBO|__ECTN_TBB_DATE );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_TEXT_FIELD|__ECTN_TBB_COMBO|__ECTN_TBB_DATE|__ECTN_TBB_RESIZABLE );
- if( pCmdItem->StateIsTextFieldNotEditable() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_TF_NE, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_TF_NE );
- if( ( (m_pCmdNodeI->GetFlags() & (__ECTN_TBB_COMBO|__ECTN_TBB_DATE|__ECTN_TBB_TEXT_FIELD)) != 0 )
- && pCmdItem->StateIsResizable()
- )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_RESIZABLE, 0 );
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( pCmdItem->StateIsCheckBox() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_CHECK_BOX, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_CHECK_BOX );
- if( pCmdItem->StateIsRadioBox() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_RADIO_BOX, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_RADIO_BOX );
- if( pCmdItem->StateIsUndoRedo() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_UNDO_REDO, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_UNDO_REDO );
- if( pCmdItem->StateIsColor() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_COLOR, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_COLOR );
-
- if( pCmdItem->StateIsColorBtnDefault() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_MCB_DEFAULT, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_MCB_DEFAULT );
-
- if( pCmdItem->StateIsColorBtnCustom() )
- m_pCmdNodeI->ModifyFlags( __ECTN_TBB_MCB_CUSTOM, 0 );
- else
- m_pCmdNodeI->ModifyFlags( 0, __ECTN_TBB_MCB_CUSTOM );
-
- if( GetMenu() != NULL )
- {
- CMenu * pMenu = CMenu::FromHandle( GetMenu() );
- ASSERT( pMenu != NULL );
- VERIFY(
- m_pCmdNodeI->LoadMenuTree(
- GetBar(),
- pBar->GetCustomizeSite(),
- pMenu,
- IsContainerOfPopupLikeMenu()
- )
- );
- SetMenu( NULL, true, true ); // no longer needed
- } // if( GetMenu() != NULL )
- return m_pCmdNodeI;
- }
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- int CExtBarButton::GetInitialResizingStateH( // -1 - left side resizing, 1 - right side resizing, 0 - no resizing at specified point (in bar's client coord)
- CPoint point,
- int * p_nWidthMin, // = NULL
- int * p_nWidthMax // = NULL
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- point;
- p_nWidthMin;
- p_nWidthMax;
- return 0;
- }
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtBarButton::RedrawButton(
- bool bUpdateNow // = false
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- CExtToolControlBar * pBar = GetBar();
- if( IsVisible()
- && (GetStyle() & TBBS_HIDDEN) == 0
- )
- pBar->_InvalidateButton( pBar->_GetIndexOf(this) );
- if( bUpdateNow )
- pBar->UpdateWindow();
- }
- void CExtBarButton::SetMenu(
- HMENU hMenu,
- bool bPopupMenu,
- bool bAutoDestroyMenu
- )
- {
- ASSERT_VALID( this );
- _DestroyMenu();
- m_hMenu = hMenu;
- if( m_hMenu != NULL )
- {
- ASSERT( ::IsMenu(hMenu) );
- CExtToolControlBar * pBar = GetBar();
- VERIFY(
- g_CmdManager->UpdateFromMenu(
- g_CmdManager->ProfileNameFromWnd( pBar->GetSafeHwnd() ),
- hMenu
- )
- );
- m_bPopupMenu = bPopupMenu ? true : false;
- ModifyStyle(0,TBBS_DISABLED);
- m_bAutoDestroyMenu = bAutoDestroyMenu;
- }
- }
- UINT CExtBarButton::OnGetTrackPopupFlags()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- DWORD dwTrackFlags = 0;
- CExtToolControlBar * pBar = GetBar();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pBar->KeyTipsDisplayedGet() )
- dwTrackFlags |= TPMX_RIBBON_KEYTIPS;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pBar->m_bPresubclassDialogMode )
- {
- if( pBar->IsDockedAtRight() )
- dwTrackFlags |= TPMX_RIGHTALIGN;
- else if( pBar->IsDockedAtLeft() )
- dwTrackFlags |= TPMX_LEFTALIGN;
- else if( pBar->IsDockedAtBottom() )
- dwTrackFlags |= TPMX_BOTTOMALIGN;
- else
- dwTrackFlags |= TPMX_TOPALIGN;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- CExtRibbonNode * pRibbonNode =
- DYNAMIC_DOWNCAST( CExtRibbonNode, pNode );
- if( pRibbonNode != NULL )
- dwTrackFlags |= pRibbonNode->m_nTpmxAdditionalFlags;
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return dwTrackFlags;
- } // if( pBar->m_bPresubclassDialogMode )
- switch( pBar->GetSafeDockBarDlgCtrlID() )
- {
- case AFX_IDW_DOCKBAR_TOP:
- dwTrackFlags |= TPMX_TOPALIGN;
- break;
- case AFX_IDW_DOCKBAR_BOTTOM:
- dwTrackFlags |= TPMX_BOTTOMALIGN;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- dwTrackFlags |= TPMX_LEFTALIGN;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- dwTrackFlags |= TPMX_RIGHTALIGN;
- break;
- default: // floating
- dwTrackFlags |= TPMX_TOPALIGN;
- break;
- } // switch( pBar->GetSafeDockBarDlgCtrlID() )
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- CExtRibbonNode * pRibbonNode =
- DYNAMIC_DOWNCAST( CExtRibbonNode, pNode );
- if( pRibbonNode != NULL )
- dwTrackFlags |= pRibbonNode->m_nTpmxAdditionalFlags;
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return dwTrackFlags;
- }
- bool CExtBarButton::OnSetCursor( CPoint point )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- point;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- CExtToolControlBar * pBar = GetBar();
- CExtCustomizeSite * pSite = pBar->GetCustomizeSite();
- if( pSite == NULL )
- return false;
- if( pSite->ActiveItemGet() != ((LPVOID)this) )
- return false;
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode( false );
- if( pNode == NULL )
- return false;
- ASSERT_VALID( pNode );
- if( (pNode->GetFlags() & __ECTN_TBB_RESIZABLE) == 0 )
- return false;
- int nInitialResizingStateH =
- GetInitialResizingStateH( point );
- if( nInitialResizingStateH != 0 )
- {
- CExtLocalResourceHelper _LRH;
- CWinApp * pApp = ::AfxGetApp();
- ASSERT_VALID( pApp );
- HCURSOR hCursor = pApp->LoadCursor( MAKEINTRESOURCE( IDC_EXT_RESIZE_H1 ) );
- if( hCursor == NULL )
- {
- ASSERT( FALSE );
- hCursor = ::LoadCursor( NULL, IDC_SIZEWE );
- }
- ASSERT( hCursor != NULL );
- ::SetCursor( hCursor );
- return true;
- } // if( nInitialResizingStateH != 0 )
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- CWnd * CExtBarButton::GetCmdTargetWnd()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- CExtToolControlBar * pBar = GetBar();
- CWnd * pWnd = pBar->GetOwner();
- ASSERT_VALID( pWnd );
- return pWnd;
- }
- bool CExtBarButton::OnQueryHoverBasedMenuTracking() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- bool bEnabled = pBar->OnQueryHoverBasedMenuTracking( this );
- return bEnabled;
- }
- CExtPopupMenuWnd * CExtBarButton::OnCreatePopupMenuWnd()
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- pBar->GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- ASSERT_VALID( pPopup );
- return pPopup;
- }
- UINT CExtBarButton::OnTrackPopup(
- CPoint point,
- bool bSelectAny,
- bool bForceNoAnimation
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- bool bDockSiteCustomizeMode = pBar->_IsDockSiteCustomizeMode();
- if( bDockSiteCustomizeMode )
- return UINT(-1L);
- if( IsDisabled() && (! CanBePressedInDisabledState() ) )
- return UINT(-1L);
- CWnd * pWnd = CtrlGet();
- if( pWnd != NULL )
- {
- LRESULT lResult = pWnd->SendMessage( CExtToolControlBar::g_nMsgContinueTrackMenu, WPARAM( this ), bSelectAny ? 1L : 0L );
- lResult;
- return UINT(-1L);
- } // if( pWnd != NULL )
- if( ! IsAbleToTrackMenu() )
- return UINT(-1L);
- bool bPrevTBMT = CExtToolControlBar::g_bMenuTracking;
- if( CExtToolControlBar::g_bMenuTracking && pBar->_GetIndexOf(this) == pBar->m_nBtnIdxMenuTracking )
- return UINT(-1L);
- if( GetSeparatedDropDown() )
- m_bDropDownHT = true;
- CExtToolControlBar::_CloseTrackingMenus();
- if( pBar->IsFloating() )
- {
- pBar->ActivateTopParent();
- CFrameWnd * pFrame = pBar->GetDockingFrame();
- ASSERT_VALID( pFrame );
- pFrame->BringWindowToTop();
- }
- CWnd * pWndCmdTarget = GetCmdTargetWnd();
- ASSERT_VALID( pWndCmdTarget );
- CExtPopupMenuWnd * pPopup = OnCreatePopupMenuWnd();
- ASSERT_VALID( pPopup );
- DWORD dwTrackFlags = OnGetTrackPopupFlags() | TPMX_OWNERDRAW_FIXED;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)