ExtToolControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:409k
- Invalidate();
- UpdateWindow();
- }
- void CExtToolControlBar::_SetCursor(
- const CPoint & point
- )
- {
- ASSERT_VALID( this );
- int nBtnIdx = _HitTestImpl(point);
- if( nBtnIdx >= 0 )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->OnSetCursor(point) )
- return;
- } // if( nBtnIdx >= 0 )
- CExtControlBar::_SetCursor( point );
- }
- bool CExtToolControlBar::g_bMenuTracking = false;
- bool CExtToolControlBar::g_bMenuTrackingExpanded = false;
- bool CExtToolControlBar::g_bToolbarLargeIcons = false;
- bool CExtToolControlBar::g_bToolbarScreenTips = true;
- bool CExtToolControlBar::g_bToolbarShortcutKeysOnScreenTips = false;
- bool CExtToolControlBar::g_bEnableDblClickToggleDocking = false;
- CExtToolControlBar::CExtToolControlBar()
- {
- m_bGripperStaticallyAtTop = false;
- m_bForceBalloonGradientInDialogs = false;
- m_bForceNoBalloonWhenRedockable = false;
- m_pRightBtn = NULL;
- m_bRightButtonDisplayBarsList = true;
- m_bPaletteMode = false;
- m_bHelperTempFullRowMode = false;
- m_bInsideCalcLayout = false;
- m_bFixedMode = true;
- m_bReposSingleChildMode = false;
- m_nBtnIdxCapture = -1;
- m_nBtnIdxHover = -1;
- m_nBtnIdxMenuTracking = -1;
- m_nUpdateCtrlLockCount = 0;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_bCustomizationAllowed = true;
- m_pCustomizeSite = NULL;
- m_bAutoShowOnCustomizationStart = false;
- m_bAutoHideOnCustomizationEnd = false;
- m_bVisibleInCustomizeListBox = true;
- m_pDragSourceTBB = NULL;
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- m_bHelperSeparatorAction = false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_cxLeftBorder = 1;
- m_cxRightBorder = 1;
- m_cyTopBorder = 0;
- m_cyBottomBorder = 0;
- m_nGripWidthAtLeft = 8;
- m_nGripHeightAtTop = 10;
- m_bHelperFlatTrackingCalcEnabledLeftRight = false;
- m_bHelperFlatTrackingCalcEnabledUpDown = false;
- m_bHelperFlatTrackingCalcEnabledTab = false;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_bKeyTipsDisplayed = false;
- m_bHelperKeyTipsSupported = false;
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_bLastDropDownHT = false;
- m_ptLastClientHover.x = m_ptLastClientHover.y = -32767;
- m_bEnableDblClickToggleDocking = g_bEnableDblClickToggleDocking;
- }
- bool CExtToolControlBar::_AdjustBGInfo()
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() != NULL )
- {
- CRect rcBorders( 0, 0, 0, 0 );
- if( PmBridge_GetPM()->Toolbar_GetBGInfo(
- rcBorders,
- m_nGripWidthAtLeft,
- m_nGripHeightAtTop,
- this
- )
- )
- {
- DWORD dwBarStyle = GetBarStyle();
- if( (dwBarStyle&CBRS_GRIPPER) == 0 )
- {
- m_nGripWidthAtLeft = 0;
- m_nGripHeightAtTop = 0;
- } // if( (GetBarStyle()&CBRS_GRIPPER) != 0 )
- m_cxLeftBorder = rcBorders.left;
- m_cxRightBorder = rcBorders.right;
- m_cyTopBorder = rcBorders.top;
- m_cyBottomBorder = rcBorders.bottom;
- CRect rcGrip( 0, 0, 0, 0 );
- if( (dwBarStyle&CBRS_FLOATING) == 0 )
- {
- GetWindowRect( &rcGrip );
- rcGrip.OffsetRect( -rcGrip.TopLeft() );
- rcGrip.DeflateRect(
- rcBorders.left,
- rcBorders.top,
- rcBorders.right,
- rcBorders.bottom
- );
- if( (dwBarStyle&CBRS_ORIENT_HORZ) != 0 )
- {
- rcGrip.right = rcGrip.left;
- rcGrip.left -= m_nGripWidthAtLeft;
- }
- else
- {
- rcGrip.bottom = rcGrip.top;
- rcGrip.top -= m_nGripHeightAtTop;
- }
- } // if( (dwBarStyle&CBRS_FLOATING) == 0 )
- _RectGripSet( rcGrip );
- return true;
- }
- } // if( GetSafeHwnd() != NULL )
- m_cxLeftBorder = 1;
- m_cxRightBorder = 1;
- m_cyTopBorder = 0;
- m_cyBottomBorder = 0;
- m_nGripWidthAtLeft = 8;
- m_nGripHeightAtTop = 10;
- return false;
- }
- CExtToolControlBar::~CExtToolControlBar()
- {
- _RemoveAllButtonsImpl();
- //CSingleLock _slCsCB( &g_csCB );
- // _slCsCB.Lock();
- __EXT_MFC_INT_PTR nCountOfBars = g_AllBars.GetSize();
- for( __EXT_MFC_INT_PTR i = 0; i<nCountOfBars; i++ )
- {
- CExtControlBar * pBar = g_AllBars[i];
- ASSERT( pBar != NULL );
- if( pBar == this )
- {
- g_AllBars.RemoveAt( i );
- break;
- }
- }
- // _slCsCB.Unlock();
- }
- BOOL CExtToolControlBar::LoadToolBar(
- __EXT_MFC_SAFE_LPCTSTR lpszResourceName,
- COLORREF clrTransparent // = RGB(192,192,192)
- )
- {
- LPUINT pCmdArray = NULL;
- INT nCmdCount = 0;
- if( !g_CmdManager->UpdateFromToolBar(
- g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() ),
- lpszResourceName,
- &pCmdArray,
- &nCmdCount,
- false,
- true,
- clrTransparent
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- ASSERT( pCmdArray != NULL && nCmdCount > 0 );
- BOOL bRetVal = SetButtons( pCmdArray, nCmdCount );
- ASSERT( bRetVal );
- delete [] pCmdArray;
- return bRetVal;
- }
- bool CExtToolControlBar::_IsShowContentWhenDragging() const
- {
- //BOOL bDragShowContent = FALSE;
- // ::SystemParametersInfo(
- // SPI_GETDRAGFULLWINDOWS,
- // 0,
- // &bDragShowContent,
- // 0
- // );
- // return bDragShowContent ? true : false;
- // if( IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) )
- // return true;
- // return false;
- // if( CExtPopupMenuWnd::IsKeyPressed(VK_CONTROL) )
- // return false;
- return true;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtToolControlBar::KeyTipsDisplayedGet() const
- {
- ASSERT_VALID( this );
- return m_bKeyTipsDisplayed;
- }
- void CExtToolControlBar::KeyTipsDisplayedSet(
- bool bKeyTipsDisplayed // = true
- )
- {
- ASSERT_VALID( this );
- if( ! m_bHelperKeyTipsSupported )
- m_bKeyTipsDisplayed = false;
- else
- m_bKeyTipsDisplayed = bKeyTipsDisplayed;
- }
- CExtCustomizeCmdKeyTip & CExtToolControlBar::KeyTipChainGet()
- {
- ASSERT_VALID( this );
- return m_keyTipChain;
- }
- const CExtCustomizeCmdKeyTip & CExtToolControlBar::KeyTipChainGet() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtToolControlBar * > ( this ) )
- -> KeyTipChainGet();
- }
- void CExtToolControlBar::KeyTipChainSet(
- const CExtCustomizeCmdKeyTip & keyTipChain
- )
- {
- ASSERT_VALID( this );
- m_keyTipChain = keyTipChain;
- }
- void CExtToolControlBar::KeyTipChainEmpty()
- {
- ASSERT_VALID( this );
- KeyTipChainGet().KeyCodeRemoveAll();
- }
- INT CExtToolControlBar::KeyTipTranslate(
- DWORD dwKeyCode,
- CExtCustomizeCmdKeyTip * pKeyTipChain,
- bool bAutoInvokeAction,
- bool & bActionInvoked,
- bool & bContinueKeyTipMode
- )
- {
- ASSERT_VALID( this );
- bActionInvoked = false;
- int nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->OnKeyTipTranslate(
- dwKeyCode,
- pKeyTipChain,
- bAutoInvokeAction,
- bActionInvoked,
- bContinueKeyTipMode
- )
- )
- return nBtnIdx;
- }
- return -1;
- }
- void CExtToolControlBar::KeyTipDisplay(
- CExtCustomizeCmdKeyTip & keyTipChain
- )
- {
- int nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->OnKeyTipDisplay( keyTipChain );
- }
- }
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtToolControlBar::OnFlatTrackingStart(
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- hPassiveModeDWP;
- MSG _msg;
- if( ::PeekMessage( &_msg, NULL, WM_ACTIVATEAPP, WM_ACTIVATEAPP, PM_NOREMOVE )
- && _msg.wParam == 0
- )
- return;
- if( ! CExtPopupMenuWnd::TestHoverEnabledFromActiveHWND( m_hWnd ) )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- KeyTipsDisplayedSet( true );
- KeyTipChainEmpty();
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool bHaveDWP = false;
- if( hPassiveModeDWP == NULL
- // && g_PaintManager.m_bIsWinVistaOrLater
- // && g_PaintManager.m_DWM.IsCompositionEnabled()
- )
- {
- bHaveDWP = true;
- hPassiveModeDWP = ::BeginDeferWindowPos( 64 );
- }
- int nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->OnFlatTrackingStart( hPassiveModeDWP );
- }
- if( bHaveDWP && hPassiveModeDWP != NULL )
- {
- ::EndDeferWindowPos( hPassiveModeDWP );
- hPassiveModeDWP = NULL;
- CExtPaintManager::stat_PassPaintMessages();
- CExtPopupMenuTipWnd::UpdateDelayedLayeredBehaviorAll();
- }
- CExtPopupMenuTipWnd::UpdateDelayedLayeredBehaviorAll();
- }
- void CExtToolControlBar::OnFlatTrackingStop()
- {
- ASSERT_VALID( this );
- int nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->OnFlatTrackingStop();
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- KeyTipsDisplayedSet( false );
- KeyTipChainEmpty();
- #endif // from (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- BOOL CExtToolControlBar::RemoveButton(
- int nPos,
- BOOL bDoRecalcLayout // = TRUE
- )
- {
- if( nPos < 0 )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nPos >= nCountOfButtons )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- CExtBarButton * pTBB =
- _GetButtonPtr( nPos );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- m_buttons.RemoveAt( nPos );
- INT nChildIndex, nChildCount = pTBB->ChildButtonGetCount();
- for( nChildIndex = 0; nChildIndex < nChildCount; nChildIndex ++ )
- RemoveButton( _GetIndexOf( pTBB->ChildButtonGetAt( nChildIndex ) ), FALSE );
- AnimationSite_ClientRemove( pTBB );
- delete pTBB;
- m_nBtnIdxCapture = -1; // nothing captured
- m_nBtnIdxHover = -1;
- m_nBtnIdxMenuTracking = -1;
- if( bDoRecalcLayout )
- _RecalcLayoutImpl();
- return TRUE;
- }
- bool CExtToolControlBar::IsShowTipWhenDisabled( const CExtBarButton * pTBB ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB;
- return true;
- }
- BOOL CExtToolControlBar::InsertSpecButton(
- int nPos, // -1 - append
- CExtBarButton * pButton,
- BOOL bDoRecalcLayout // = TRUE
- )
- {
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nPos < 0 )
- nPos = nCountOfButtons;
- if( nPos > nCountOfButtons )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- if( nCountOfButtons > 0
- && nPos == nCountOfButtons
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nCountOfButtons - 1 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- nPos--;
- }
- ASSERT_VALID( pButton );
- ASSERT( pButton->GetSafeBar() != NULL );
- ASSERT( pButton->GetSafeBar() == this );
- if( _GetIndexOf(pButton) >= 0 )
- {
- ASSERT( FALSE ); // already inserted
- return FALSE;
- }
- m_buttons.InsertAt( nPos, pButton );
- ASSERT( _GetIndexOf(pButton) >= 0 );
- if( bDoRecalcLayout )
- _RecalcLayoutImpl();
- return TRUE;
- }
- BOOL CExtToolControlBar::InsertButton(
- int nPos, // = -1, // append
- UINT nCmdID, // = ID_SEPARATOR
- BOOL bDoRecalcLayout // = TRUE
- )
- {
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nPos < 0 )
- nPos = nCountOfButtons;
- if( nPos > nCountOfButtons )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- if( nCountOfButtons > 0
- && nPos == nCountOfButtons
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nCountOfButtons - 1 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- nPos--;
- }
- try
- {
- CExtBarButton * pTBB = OnCreateBarCommandBtn( nCmdID );
- ASSERT_VALID( pTBB );
- m_buttons.InsertAt( nPos, pTBB );
- if( bDoRecalcLayout )
- _RecalcLayoutImpl();
- } // try
- // catch( std::exception * pXept )
- // {
- // delete pXept;
- // ASSERT( FALSE );
- // return FALSE;
- // } // catch( std::exception * pXept )
- catch( CException * pXept )
- {
- pXept->Delete();
- ASSERT( FALSE );
- return FALSE;
- } // catch( CException * pXept )
- catch( ... )
- {
- ASSERT( FALSE );
- return FALSE;
- } // catch( ... )
- return TRUE;
- }
- CExtBarButton * CExtToolControlBar::OnCreateBarCommandBtn(
- UINT nCmdID,
- UINT nStyle // = 0
- )
- {
- ASSERT_VALID( this );
- CExtBarButton * pTBB = new CExtBarButton( this, nCmdID, nStyle );
- ASSERT_VALID( pTBB );
- return pTBB;
- }
- CExtBarContentExpandButton * CExtToolControlBar::OnCreateBarRightBtn()
- {
- ASSERT_VALID( this );
- if( m_bPaletteMode )
- return NULL;
- CExtBarContentExpandButton * pRightBtn =
- new CExtBarContentExpandButton( this );
- ASSERT_VALID( pRightBtn );
- return pRightBtn;
- }
- COLORREF CExtToolControlBar::OnQueryCustomAccentEffectForIcon(
- CDC & dc,
- CExtBarButton * pTBB
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- dc;
- pTBB;
- return COLORREF(-1L);
- }
- BOOL CExtToolControlBar::SetButtons(
- const UINT * lpIDArray, // = NULL
- int nIDCount // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT(
- lpIDArray == NULL
- || nIDCount == 0
- || AfxIsValidAddress(
- lpIDArray,
- sizeof(UINT) * nIDCount,
- FALSE
- )
- );
- _RemoveAllButtonsImpl();
- if( lpIDArray == NULL
- || nIDCount == 0
- )
- return TRUE;
- try
- {
- bool bRevertRTL = OnQueryRevertRTL();
- for( int i = 0; i < nIDCount; i++ )
- {
- CExtBarButton * pTBB = OnCreateBarCommandBtn( *lpIDArray++, 0 );
- ASSERT_VALID( pTBB );
- if( bRevertRTL )
- m_buttons.InsertAt( 0, pTBB );
- else
- m_buttons.Add( pTBB );
- } // for( int i = 0; i < nIDCount; i++ )
- ASSERT( m_pRightBtn == NULL );
- m_pRightBtn = OnCreateBarRightBtn();
- if( m_pRightBtn != NULL )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT_KINDOF( CExtBarContentExpandButton, m_pRightBtn );
- m_buttons.Add( m_pRightBtn );
- } // if( m_pRightBtn != NULL )
- } // try
- catch( CException * pXept )
- {
- pXept->Delete();
- ASSERT( FALSE );
- return FALSE;
- } // catch( CException * pXept )
- catch( ... )
- {
- ASSERT( FALSE );
- return FALSE;
- } // catch( ... )
- return TRUE;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- BOOL CExtToolControlBar::SetButtons(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- SetButtons();
- if( pNode == NULL )
- return TRUE;
- ASSERT_VALID( pNode );
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite == NULL )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- bool bRevertRTL = OnQueryRevertRTL();
- int nCount = pNode->GetNodeCount();
- for( int i = 0; i < nCount; i++ )
- {
- CExtCustomizeCmdTreeNode * pNodeBtn =
- pNode->ElementAt( i );
- ASSERT_VALID( pNodeBtn );
- if( pNodeBtn->GetFlags() & __ECTN_GROUP_START )
- {
- if( i == 0 )
- {
- ASSERT( FALSE );
- continue;
- }
- // separator
- VERIFY(
- InsertButton(
- bRevertRTL ? 0 : -1,
- ID_SEPARATOR,
- FALSE
- )
- );
- }
- ASSERT( CExtCmdManager::IsCommand(pNodeBtn->GetCmdID(false)) || pNodeBtn->GetCmdID(false) == UINT(-1) );
- ASSERT( CExtCmdManager::IsCommand(pNodeBtn->GetCmdID(true)) || pNodeBtn->GetCmdID(true) == UINT(-1) );
- CExtBarButton * pTBB =
- pSite->OnCreateToolbarButton(
- this,
- NULL,
- pNodeBtn
- );
- if( pTBB == NULL )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- ASSERT_VALID( pTBB );
- if( bRevertRTL )
- m_buttons.InsertAt( 0, pTBB );
- else
- m_buttons.Add( pTBB );
- } // for( int i = 0; i < nCount; i++ )
- ASSERT( m_pRightBtn == NULL );
- m_pRightBtn = OnCreateBarRightBtn();
- if( m_pRightBtn != NULL )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT_KINDOF( CExtBarContentExpandButton, m_pRightBtn );
- m_buttons.Add( m_pRightBtn );
- } // if( m_pRightBtn != NULL )
- return TRUE;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtToolControlBar::IsLargeIcons() const
- {
- ASSERT_VALID( this );
- return g_bToolbarLargeIcons;
- }
- bool CExtToolControlBar::IsDisplayScreenTips() const
- {
- ASSERT_VALID( this );
- return g_bToolbarScreenTips;
- }
- bool CExtToolControlBar::IsDisplayShortcutKeysOnScreenTips() const
- {
- ASSERT_VALID( this );
- return g_bToolbarShortcutKeysOnScreenTips;
- }
- LRESULT CExtToolControlBar::DoHelpHitTest( CPoint ptHelpHitTest )
- {
- ASSERT_VALID( this );
- LRESULT nHelpHit =
- ((CExtToolControlBar*)this)->
- HitTest(ptHelpHitTest);
- if( nHelpHit >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( (int)nHelpHit );
- ASSERT_VALID( pTBB );
- if( pTBB != NULL )
- {
- nHelpHit = pTBB->OnHelpHitTest( ptHelpHitTest );
- if( nHelpHit == -1 || nHelpHit == -2 )
- return -2;
- return nHelpHit;
- }
- } // if( nHelpHit >= 0 )
- return CExtControlBar::DoHelpHitTest( ptHelpHitTest );
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolControlBar attribute access
- int CExtToolControlBar::CommandToIndex(UINT nIDFind) const
- {
- ASSERT_VALID(this);
- int nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->GetCmdID(false) == nIDFind )
- return nBtnIdx;
- }
- return -1;
- }
- UINT CExtToolControlBar::GetButtonID(int nIndex) const
- {
- // ASSERT_VALID(this);
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- return ID_SEPARATOR;
- ASSERT_VALID( pTBB );
- return pTBB->GetCmdID(false);
- }
- void CExtToolControlBar::GetButtonRect(int nIndex, LPRECT lpRect) const
- {
- // ASSERT_VALID(this);
- ASSERT(AfxIsValidAddress(lpRect, sizeof(RECT)));
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- {
- ::memset( lpRect, 0, sizeof(RECT) );
- return;
- }
- ASSERT_VALID( pTBB );
- *lpRect = *pTBB;
- }
- UINT CExtToolControlBar::GetButtonStyle(int nIndex) const
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- return 0;
- ASSERT_VALID( pTBB );
- return pTBB->GetStyle();
- }
- void CExtToolControlBar::SetButtonStyle(int nIndex, UINT nStyle)
- {
- CExtBarButton * pTBB = _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- return;
- ASSERT_VALID( pTBB );
- UINT nOldStyle = pTBB->GetStyle();
- if( nOldStyle != nStyle )
- {
- pTBB->SetStyle( nStyle );
- _InvalidateButton( nIndex );
- // UpdateWindow();
- }
- }
- CWnd * CExtToolControlBar::GetButtonCtrl(
- int nIndex
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return NULL;
- ASSERT_VALID( pTBB );
- CWnd * pCtrl = pTBB->CtrlGet();
- return pCtrl;
- }
- void CExtToolControlBar::SetButtonCtrlVisibleVertically(
- int nIndex,
- bool bVisible // = true
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return;
- pTBB->SetCtrlVisibleVertically( bVisible );
- }
- bool CExtToolControlBar::GetButtonCtrlVisibleVertically(
- int nIndex
- ) const
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return false;
- return pTBB->GetCtrlVisibleVertically();
- }
- bool CExtToolControlBar::SetButtonCtrl(
- int nIndex,
- CWnd * pCtrl, // = NULL
- bool bCtrlAutoDestroyed // = TRUE
- )
- {
- CExtBarButton * pTBB = _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return FALSE;
- ASSERT_VALID( pTBB );
- if( pCtrl != NULL )
- {
- ASSERT_VALID( pCtrl );
- DWORD dwCtrlStyle = pCtrl->GetStyle();
- ASSERT( (dwCtrlStyle&WS_CHILD) != 0 );
- if( (dwCtrlStyle&WS_CHILD) == 0 )
- return FALSE;
- ASSERT( IsChild( pCtrl ) );
- if( !IsChild( pCtrl ) )
- return FALSE;
- UINT nDlgCtrlID = (UINT)pCtrl->GetDlgCtrlID();
- ASSERT( nDlgCtrlID == pTBB->GetCmdID(false) );
- if( nDlgCtrlID != pTBB->GetCmdID(false) )
- return FALSE;
- }
- pTBB->CtrlSet( pCtrl, bCtrlAutoDestroyed );
- _RecalcLayoutImpl();
- return TRUE;
- }
- int CExtToolControlBar::GetButtonByAccessKey(__EXT_MFC_SAFE_TCHAR vkTCHAR)
- {
- int nCountOfButtons = _GetButtonsCountImpl();
- ASSERT( nCountOfButtons >= 0 );
- if( nCountOfButtons == 0 )
- return -1;
- for( int nBtnIdx=0; nBtnIdx<nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr(nBtnIdx);
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator()
- || (! pTBB->IsVisible() )
- || ( pTBB->GetStyle() & TBBS_HIDDEN )
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- )
- continue;
- // ASSERT( CExtCmdManager::IsCommand(pTBB->GetCmdID(false)) );
- // ASSERT( CExtCmdManager::IsCommand(pTBB->GetCmdID(true)) );
- if( ! CExtCmdManager::IsCommand(pTBB->GetCmdID(false)) )
- continue;
- if( ! CExtCmdManager::IsCommand(pTBB->GetCmdID(true)) )
- continue;
- CExtSafeString strButtonText( pTBB->GetText() );
- if( strButtonText.IsEmpty() )
- continue;
- int nTextLen = strButtonText.GetLength();
- ASSERT( nTextLen > 0 );
- int nAmdIndex = strButtonText.Find(_T('&'));
- if( nAmdIndex < 0 )
- continue;
- if( nAmdIndex == nTextLen - 1 ) // !?!?!
- continue;
- TCHAR vk = strButtonText[nAmdIndex+1];
- TCHAR szChar[2] = { vk, _T(' ') };
- ::CharUpper( szChar );
- vk = szChar[0];
- if( vkTCHAR == ((TCHAR)vk) )
- {
- if( ( !pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- )
- {
- if( m_pRightBtn != NULL )
- return _GetIndexOf( m_pRightBtn );
- continue;
- }
- return nBtnIdx;
- } // if( vkTCHAR == ((TCHAR)vk) )
- } // for( int nBtnIdx=0; nBtnIdx<nCountOfButtons; nBtnIdx++ )
- return -1;
- }
- HMENU CExtToolControlBar::GetButtonMenu(
- int nIndex
- )
- {
- CExtBarButton * pTBB = _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return NULL;
- ASSERT_VALID( pTBB );
- return ((HMENU)(*pTBB));
- }
- bool CExtToolControlBar::MarkButtonAsMdiWindowsMenu(
- int nIndex,
- bool bAppendMdiWindowsMenu // = TRUE
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return false;
- ASSERT_VALID( pTBB );
- pTBB->SetAppendMdiWindowsMenu(
- bAppendMdiWindowsMenu
- );
- return true;
- }
- bool CExtToolControlBar::SetButtonMenu(
- int nIndex,
- HMENU hMenu, // = NULL
- bool bPopupMenu, // = TRUE
- bool bAutoDestroyMenu, // = TRUE
- bool bDoRecalcLayout // = TRUE
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return false;
- ASSERT_VALID( pTBB );
- pTBB->SetMenu(
- hMenu,
- bPopupMenu,
- bAutoDestroyMenu
- );
- if( bDoRecalcLayout )
- _RecalcLayoutImpl();
- return true;
- }
- int CExtToolControlBar::GetVisibleButton(
- int nBtnIdx,
- BOOL bNext,
- BOOL bPassDisabled // = TRUE
- )
- {
- int nCountOfButtons = _GetButtonsCountImpl();
- ASSERT( nCountOfButtons >= 0 );
- if( nCountOfButtons == 0 )
- return -1;
- if( nCountOfButtons == 1 )
- return 0;
- if( bNext )
- {
- int iNewButton = nBtnIdx + 1;
- if( iNewButton >= nCountOfButtons )
- iNewButton = 0;
- while( iNewButton != nBtnIdx )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(iNewButton);
- ASSERT_VALID( pTBB );
- if( pTBB->OnQueryFlatTrackingEnabled()
- && ( (!bPassDisabled)
- || (bPassDisabled && (!pTBB->IsDisabled()))
- )
- )
- {
- return iNewButton;
- }
- iNewButton++;
- if( iNewButton >= nCountOfButtons )
- iNewButton = 0;
- }
- return iNewButton;
- } // if( bNext )
- else
- {
- int iNewButton =
- nBtnIdx - 1;
- if( iNewButton < 0 )
- iNewButton = nCountOfButtons - 1;
- while( iNewButton != nBtnIdx )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(iNewButton);
- ASSERT_VALID( pTBB );
- if( pTBB->OnQueryFlatTrackingEnabled()
- && ( (!bPassDisabled)
- || (bPassDisabled && (!pTBB->IsDisabled()))
- )
- )
- return iNewButton;
- iNewButton--;
- if( iNewButton < 0 )
- iNewButton = nCountOfButtons - 1;
- }
- return iNewButton;
- } // else from if( bNext )
- }
- INT CExtToolControlBar::OnCalcFlatTrackingIndex(
- /*__EXT_MFC_SAFE_TCHAR*/ INT vkTCHAR,
- INT nStartSearchIndex
- )
- {
- ASSERT_VALID( this );
- if( (! m_bHelperFlatTrackingCalcEnabledLeftRight )
- && (! m_bHelperFlatTrackingCalcEnabledUpDown )
- )
- return -1;
- if( vkTCHAR != VK_LEFT
- && vkTCHAR != VK_RIGHT
- && vkTCHAR != VK_UP
- && vkTCHAR != VK_DOWN
- && vkTCHAR != VK_TAB
- )
- return -1;
- bool bShift = false;
- CTypedPtrArray < CPtrArray, CExtBarButton * > arrTabOrder;
- if( vkTCHAR == VK_TAB )
- {
- bShift = CExtPopupMenuWnd::IsKeyPressed( VK_SHIFT ) ? true : false;
- if( ! OnCalcFlatTrackingTabOrder( arrTabOrder ) )
- {
- if( bShift )
- vkTCHAR = VK_LEFT;
- else
- vkTCHAR = VK_RIGHT;
- } // if( ! OnCalcFlatTrackingTabOrder( arrTabOrder ) )
- } // if( _vkTCHAR == VK_TAB )
- INT nButtonIndex, nCountOfButtons = GetButtonsCount();
- if( nCountOfButtons == 0 )
- return -1;
- CExtBarButton * pStartTBB = NULL;
- if( 0 <= nStartSearchIndex && nStartSearchIndex < nCountOfButtons )
- {
- pStartTBB = GetButton( nStartSearchIndex );
- ASSERT_VALID( pStartTBB );
- if( ! pStartTBB->OnQueryFlatTrackingEnabled() )
- {
- pStartTBB = NULL;
- nStartSearchIndex = -1;
- }
- } // if( 0 <= nStartSearchIndex && nStartSearchIndex < nCountOfButtons )
- if( nStartSearchIndex < 0 || pStartTBB == NULL )
- {
- CPoint ptMinLT( 32767, 32767 );
- for( nButtonIndex = 0; nButtonIndex < nCountOfButtons; nButtonIndex++ )
- {
- CExtBarButton * pTBB = GetButton( nButtonIndex );
- ASSERT_VALID( pTBB );
- if( ! pTBB->OnQueryFlatTrackingEnabled() )
- continue;
- CRect rcTBB = *pTBB;
- if( rcTBB.left < ptMinLT.x
- || ( rcTBB.left == ptMinLT.x && rcTBB.top < ptMinLT.y )
- )
- {
- nStartSearchIndex = nButtonIndex;
- ptMinLT.x = min( ptMinLT.x, rcTBB.left );
- ptMinLT.y = min( ptMinLT.y, rcTBB.top );
- }
- } // for( nButtonIndex = 0; nButtonIndex < nCountOfButtons; nButtonIndex++ )
- return nStartSearchIndex;
- } // if( nStartSearchIndex < 0 || pStartTBB == NULL )
- if( vkTCHAR == VK_TAB )
- {
- INT nIndex, nFound = -1, nCount = INT( arrTabOrder.GetSize() );
- if( nCount == 0 )
- return nStartSearchIndex;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtBarButton * pTBB = arrTabOrder[ nIndex ];
- ASSERT_VALID( pTBB );
- if( pTBB == pStartTBB )
- {
- nFound = nIndex;
- break;
- }
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- if( nFound < 0 )
- return nStartSearchIndex;
- if( bShift )
- {
- if( nFound == 0 )
- nFound = nCount - 1;
- else
- nFound --;
- } // if( bShift )
- else
- {
- if( nFound == ( nCount - 1 ) )
- nFound = 0;
- else
- nFound ++;
- } // else from if( bShift )
- CExtBarButton * pTBB = arrTabOrder[ nFound ];
- ASSERT_VALID( pTBB );
- nStartSearchIndex = _GetIndexOf( pTBB );
- return nStartSearchIndex;
- } // if( vkTCHAR == VK_TAB )
- CRect rcNextTBB( 0, 0, 0, 0 );
- switch( TCHAR(vkTCHAR) )
- {
- case VK_LEFT:
- if( ! m_bHelperFlatTrackingCalcEnabledLeftRight )
- return nStartSearchIndex;
- rcNextTBB.SetRect( -32767, -32767, -32767, 32767 );
- break;
- case VK_RIGHT:
- if( ! m_bHelperFlatTrackingCalcEnabledLeftRight )
- return nStartSearchIndex;
- rcNextTBB.SetRect( 32767, -32767, 32767, 32767 );
- break;
- case VK_UP:
- if( ! m_bHelperFlatTrackingCalcEnabledUpDown )
- return nStartSearchIndex;
- rcNextTBB.SetRect( -32767, -32767, -32767, -32767 );
- break;
- case VK_DOWN:
- if( ! m_bHelperFlatTrackingCalcEnabledUpDown )
- return nStartSearchIndex;
- rcNextTBB.SetRect( -32767, 32767, -32767, 32767 );
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- return nStartSearchIndex;
- #endif // _DEBUG
- } // switch( TCHAR(vkTCHAR) )
- CRuntimeClass * pStartRTC = pStartTBB->GetRuntimeClass();
- CExtBarButton * pNextsParentTBB = pStartTBB->ParentButtonGet();
- //CRect rcStartTBB = *pStartTBB;
- CRect rcStartTBB = pStartTBB->OnQueryFlatWalkingCalcRect();
- CPoint ptStartCP = rcStartTBB.CenterPoint(), ptNextCP( 32767, 32767 );
- INT nNextDist = 32767, nPassIndex;
- INT nSavedStartSearchIndex = nStartSearchIndex;
- for( nPassIndex = 0; nPassIndex < 3; nPassIndex ++ )
- {
- for( nButtonIndex = 0; nButtonIndex < nCountOfButtons; nButtonIndex++ )
- {
- CExtBarButton * pTBB = GetButton( nButtonIndex );
- ASSERT_VALID( pTBB );
- if( (! pTBB->OnQueryFlatTrackingEnabled() )
- || pTBB == pStartTBB
- || nButtonIndex == nStartSearchIndex
- )
- continue;
- CExtBarButton * pParentTBB = pTBB->ParentButtonGet();
- //CRect rcTBB = *pTBB;
- CRect rcTBB = pTBB->OnQueryFlatWalkingCalcRect();
- CPoint ptCP = rcTBB.CenterPoint();
- INT nX2 = ptCP.x - ptStartCP.x;
- INT nY2 = ptCP.y - ptStartCP.y;
- INT nCurrDist = nX2*nX2 + nY2*nY2;
- bool bHorzIntersection = false, bVertIntersection = false, bRtcIntersection = false;
- // if( ( rcTBB.top >= rcStartTBB.top && rcTBB.bottom >= rcStartTBB.bottom )
- // || ( rcTBB.top <= rcStartTBB.top && rcTBB.bottom <= rcStartTBB.bottom )
- // )
- // bHorzIntersection = true;
- // if( ( rcTBB.left >= rcStartTBB.left && rcTBB.right >= rcStartTBB.right )
- // || ( rcTBB.left <= rcStartTBB.left && rcTBB.right <= rcStartTBB.right )
- // )
- // bVertIntersection = true;
- // if( rcTBB.top == rcStartTBB.top && rcTBB.bottom == rcStartTBB.bottom )
- // bHorzIntersection = true;
- // if( rcTBB.left == rcStartTBB.left && rcTBB.right == rcStartTBB.right )
- // bVertIntersection = true;
- if( OnCalcFlatTrackingIndexCheckIntersectionEnabled( pTBB, vkTCHAR ) )
- {
- if( ( rcTBB.top < ptStartCP.y && ptStartCP.y < rcTBB.bottom )
- && ( rcStartTBB.top < ptCP.y && ptCP.y < rcStartTBB.bottom )
- )
- bHorzIntersection = true;
- }
- if( OnCalcFlatTrackingIndexCheckIntersectionEnabled( pTBB, vkTCHAR ) )
- {
- if( ( rcTBB.left < ptStartCP.y && ptStartCP.y < rcTBB.right )
- && ( rcStartTBB.left < ptCP.y && ptCP.y < rcStartTBB.right )
- )
- bVertIntersection = true;
- }
- CRuntimeClass * pCurrRTC = pTBB->GetRuntimeClass();
- if( pStartRTC->IsDerivedFrom( pCurrRTC )
- && pCurrRTC->IsDerivedFrom( pStartRTC )
- )
- bRtcIntersection = true;
- if( nPassIndex == 0 )
- {
- if( ! bRtcIntersection )
- continue;
- }
- switch( TCHAR(vkTCHAR) )
- {
- case VK_LEFT:
- if( nPassIndex <= 1 )
- {
- if( ! bHorzIntersection )
- continue;
- }
- if( rcTBB.right > rcStartTBB.left )
- continue;
- if( rcTBB.right < rcNextTBB.right )
- {
- if( pNextsParentTBB != pParentTBB )
- continue;
- if( nCurrDist >= nNextDist )
- continue;
- }
- if( rcTBB.right == rcNextTBB.right )
- {
- INT nDistCurr = INT( abs( ( ptStartCP.y - ptCP.y ) ) );
- INT nDistPrev = INT( abs( ( ptStartCP.y - rcNextTBB.CenterPoint().y ) ) );
- if( nDistCurr > nDistPrev )
- continue;
- }
- if( nCurrDist >= nNextDist )
- continue;
- pNextsParentTBB = pParentTBB;
- ptNextCP = ptCP;
- nNextDist = nCurrDist;
- rcNextTBB = rcTBB;
- nStartSearchIndex = nButtonIndex;
- break;
- case VK_RIGHT:
- if( nPassIndex <= 1 )
- {
- if( ! bHorzIntersection )
- continue;
- }
- if( rcTBB.left < rcStartTBB.right )
- continue;
- if( rcTBB.left > rcNextTBB.left )
- {
- if( pNextsParentTBB != pParentTBB )
- continue;
- if( nCurrDist >= nNextDist )
- continue;
- }
- else if( rcTBB.left == rcNextTBB.left )
- {
- INT nDistCurr = INT( abs( ( ptStartCP.y - ptCP.y ) ) );
- INT nDistPrev = INT( abs( ( ptStartCP.y - rcNextTBB.CenterPoint().y ) ) );
- if( nDistCurr > nDistPrev )
- continue;
- }
- if( nCurrDist >= nNextDist )
- continue;
- pNextsParentTBB = pParentTBB;
- ptNextCP = ptCP;
- nNextDist = nCurrDist;
- rcNextTBB = rcTBB;
- nStartSearchIndex = nButtonIndex;
- break;
- case VK_UP:
- if( nPassIndex <= 1 )
- {
- if( ! bVertIntersection )
- continue;
- }
- if( rcTBB.bottom > rcStartTBB.top )
- continue;
- if( rcTBB.bottom < rcNextTBB.bottom )
- {
- if( pNextsParentTBB != pParentTBB )
- continue;
- if( nCurrDist >= nNextDist )
- continue;
- }
- if( rcTBB.bottom == rcNextTBB.bottom )
- {
- INT nDistCurr = INT( abs( ( ptStartCP.y - ptCP.y ) ) );
- INT nDistPrev = INT( abs( ( ptStartCP.y - rcNextTBB.CenterPoint().y ) ) );
- if( nDistCurr > nDistPrev )
- continue;
- }
- if( nCurrDist >= nNextDist )
- continue;
- pNextsParentTBB = pParentTBB;
- ptNextCP = ptCP;
- nNextDist = nCurrDist;
- rcNextTBB = rcTBB;
- nStartSearchIndex = nButtonIndex;
- break;
- case VK_DOWN:
- if( nPassIndex <= 1 )
- {
- if( ! bVertIntersection )
- continue;
- }
- if( rcTBB.top < rcStartTBB.bottom )
- continue;
- if( rcTBB.top > rcNextTBB.top )
- {
- if( pNextsParentTBB != pParentTBB )
- continue;
- if( nCurrDist >= nNextDist )
- continue;
- }
- else if( rcTBB.top == rcNextTBB.top )
- {
- INT nDistCurr = INT( abs( ( ptStartCP.y - ptCP.y ) ) );
- INT nDistPrev = INT( abs( ( ptStartCP.y - rcNextTBB.CenterPoint().y ) ) );
- if( nDistCurr > nDistPrev )
- continue;
- }
- if( nCurrDist >= nNextDist )
- continue;
- pNextsParentTBB = pParentTBB;
- ptNextCP = ptCP;
- nNextDist = nCurrDist;
- rcNextTBB = rcTBB;
- nStartSearchIndex = nButtonIndex;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- return nStartSearchIndex;
- #endif // _DEBUG
- } // switch( TCHAR(vkTCHAR) )
- } // for( nButtonIndex = 0; nButtonIndex < nCountOfButtons; nButtonIndex++ )
- if( nSavedStartSearchIndex != nStartSearchIndex )
- {
- if( nStartSearchIndex >= 0 )
- {
- if( ! OnCalcFlatTrackingIndexCheckPass(
- vkTCHAR,
- nPassIndex,
- pStartTBB,
- GetButton( nStartSearchIndex )
- )
- )
- {
- nStartSearchIndex = -1;
- continue;
- }
- } // if( nStartSearchIndex >= 0 )
- // break;
- } // if( nSavedStartSearchIndex != nStartSearchIndex )
- } // for( nPassIndex = 0; nPassIndex < 3; nPassIndex ++ )
- // if( nStartSearchIndex < 0 )
- // return nSavedStartSearchIndex;
- return nStartSearchIndex;
- }
- bool CExtToolControlBar::OnCalcFlatTrackingIndexCheckPass(
- /*__EXT_MFC_SAFE_TCHAR*/ INT vkTCHAR,
- INT nPassIndex,
- const CExtBarButton * pPrevTBB,
- const CExtBarButton * pNextTBB
- ) const
- {
- ASSERT_VALID( this );
- vkTCHAR;
- nPassIndex;
- pPrevTBB;
- pNextTBB;
- return true;
- }
- bool CExtToolControlBar::OnCalcFlatTrackingTabOrder(
- CTypedPtrArray < CPtrArray, CExtBarButton * > & arrTabOrder
- )
- {
- ASSERT_VALID( this );
- arrTabOrder.RemoveAll();
- INT nIndex, nCount = GetButtonsCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtBarButton * pTBB = GetButton( nIndex );
- ASSERT_VALID( pTBB );
- if( ! pTBB->OnQueryFlatTrackingEnabled() )
- continue;
- arrTabOrder.Add( pTBB );
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- return true;
- }
- bool CExtToolControlBar::OnCalcFlatTrackingIndexCheckIntersectionEnabled(
- CExtBarButton * pTBB,
- /*__EXT_MFC_SAFE_TCHAR*/ INT vkTCHAR
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB;
- vkTCHAR;
- return false;
- }
- BOOL CExtToolControlBar::TrackButtonMenu(
- int nIndex,
- BOOL bSelectAny, // = FALSE
- BOOL bDelayedTracking, // = FALSE
- BOOL bNoAnimation // = FALSE
- )
- {
- bool bDockSiteCustomizeMode =
- _IsDockSiteCustomizeMode();
- if( bDockSiteCustomizeMode )
- return FALSE;
- if( g_bMenuTracking
- && m_nBtnIdxMenuTracking == nIndex
- )
- return TRUE;
- if( !SafeDisplayBar() )
- return FALSE;
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- ASSERT( pTBB != NULL );
- if( pTBB == NULL )
- return FALSE;
- ASSERT_VALID( pTBB );
- if( pTBB->GetStyle() & (TBBS_HIDDEN|TBBS_DISABLED) )
- return FALSE;
- if( ! pTBB->IsAbleToTrackMenu() )
- return FALSE;
- CPoint point( -32767, -32767 );
- if( (! IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- || (! ((CExtMenuControlBar*)this)->m_bUseFastKeyboardMenuTracking )
- )
- {
- if( ! ::GetCursorPos(&point) )
- return FALSE;
- ScreenToClient( &point );
- }
- if( bDelayedTracking )
- PostMessage(
- g_nMsgTrackButtonMenu,
- (WPARAM)nIndex,
- (LPARAM)bNoAnimation
- );
- else
- pTBB->OnTrackPopup(
- point,
- bSelectAny ? true : false,
- bNoAnimation ? true : false
- );
- return TRUE;
- }
- CSize CExtToolControlBar::CalcDynamicLayout(int nLength, DWORD dwMode)
- {
- if( (nLength == -1)
- && !(dwMode & (LM_MRUWIDTH|LM_COMMIT))
- && (dwMode & (LM_HORZDOCK|LM_VERTDOCK))
- )
- return
- CalcFixedLayout(
- dwMode & LM_STRETCH,
- dwMode & LM_HORZDOCK
- );
- ASSERT(
- (dwMode&(LM_HORZ|LM_HORZDOCK))
- ||
- (!(dwMode&LM_HORZDOCK))
- );
- return _CalcLayout( dwMode, nLength );
- }
- CSize CExtToolControlBar::CalcFixedLayout(
- BOOL bStretch,
- BOOL bHorz
- )
- {
- DWORD dwMode = bStretch ? LM_STRETCH : 0;
- dwMode |= bHorz ? LM_HORZ : 0;
- ASSERT(
- (dwMode&(LM_HORZ|LM_HORZDOCK))
- ||
- (!(dwMode&LM_HORZDOCK))
- );
- return _CalcLayout( dwMode );
- }
- CSize CExtToolControlBar::_CalcLayout(
- DWORD dwMode,
- int nLength
- )
- {
- ASSERT_VALID(this);
- if( ! m_bInsideCalcLayout )
- m_bHelperTempFullRowMode = false;
- // if( m_pDockSite->GetSafeHwnd() != NULL
- // && (! IsFloating() )
- // && OnQueryMultiRowLayout()
- // )
- // {
- // WINDOWPLACEMENT _wp;
- // ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- // _wp.length = sizeof(WINDOWPLACEMENT);
- // if( m_pDockSite->GetWindowPlacement( &_wp )
- // && _wp.showCmd == SW_SHOWMINIMIZED
- // )
- // {
- // CRect rcWnd;
- // GetWindowRect( &rcWnd );
- // return rcWnd.Size();
- // }
- // }
-
- CSize sizeDefButton = _GetDefButtonSize();
- CSize sizeCalcLayout = sizeDefButton;
- if( _GetButtonsCountImpl() > 0 )
- {
- if( m_pRightBtn != NULL )
- m_pRightBtn->ClearContent( false );
- BOOL bDynamic = m_dwStyle & CBRS_SIZE_DYNAMIC;
- INT nLengthToSizeTB =
- (dwMode & LM_HORZ) ? 32767 : 0;
- BOOL bVertSizeTB = FALSE;
- if( bDynamic )
- {
- if( dwMode & LM_MRUWIDTH )
- nLengthToSizeTB = m_nMRUWidth;
- else if( dwMode & LM_HORZDOCK )
- nLengthToSizeTB = 32767;
- else if( dwMode & LM_VERTDOCK )
- nLengthToSizeTB = 0;
- else if( nLength != -1 )
- {
- CRect rcInside( 0, 0, 0, 0 );
- _CalcInsideRect(
- rcInside,
- (dwMode & LM_HORZ)
- );
- bVertSizeTB = (dwMode & LM_LENGTHY);
- nLengthToSizeTB =
- nLength +
- ( bVertSizeTB ?
- rcInside.Height() : rcInside.Width()
- );
- }
- else if( (m_dwStyle & CBRS_FLOATING) != 0 )
- nLengthToSizeTB = m_nMRUWidth;
- } // if( bDynamic )
- bool bMultiRowLayout =
- OnQueryMultiRowLayout();
- if( bMultiRowLayout
- && ((dwMode & LM_HORZ) == 0)
- && (!m_bPaletteMode)
- )
- {
- CRect rcDockBarClient;
- if( m_pDockBar != NULL )
- {
- ASSERT_VALID( m_pDockBar );
- ASSERT_VALID( m_pDockSite );
- //m_pDockSite->GetClientRect( &rcDockBarClient );
- rcDockBarClient = ((CExtDockBar*)m_pDockBar)->m_rectLayout;
- }
- else
- GetParent()->GetClientRect( &rcDockBarClient );
- nLength = nLengthToSizeTB = rcDockBarClient.Height();
- bVertSizeTB = TRUE;
- }
- _SizeToolBar( nLengthToSizeTB, bVertSizeTB );
- sizeCalcLayout =
- _CalcSize(
- ( (dwMode & LM_HORZ) == 0 ) ? TRUE : FALSE
- );
- if( bDynamic
- && bMultiRowLayout
- && (!m_bPaletteMode)
- )
- {
- CSize sizeDiff(
- __EXT_TB_BUTTON_OUTER_MARGIN*2,
- __EXT_TB_BUTTON_OUTER_MARGIN*2
- );
- if( m_pRightBtn != NULL
- && m_pRightBtn->IsVisible()
- )
- {
- CSize sizeRb = m_pRightBtn->Size();
- sizeDiff +=
- CSize(
- ((dwMode&LM_HORZ) == 0) ? 0 : sizeRb.cx,
- ((dwMode&LM_HORZ) == 0) ? sizeRb.cy : 0
- );
- }
- CRect rcDockBarClient;
- if( m_pDockBar != NULL )
- {
- ASSERT_VALID( m_pDockBar );
- ASSERT_VALID( m_pDockSite );
- //m_pDockSite->GetClientRect( &rcDockBarClient );
- rcDockBarClient = ((CExtDockBar*)m_pDockBar)->m_rectLayout;
- }
- else
- GetParent()->GetClientRect( &rcDockBarClient );
- CSize _sizeDockBarClient = rcDockBarClient.Size();
- INT nNewLengthToSizeTB = nLengthToSizeTB;
- if( (dwMode & LM_HORZ) == 0 )
- {
- if( (sizeCalcLayout.cy+sizeDiff.cy) > _sizeDockBarClient.cy )
- nNewLengthToSizeTB = _sizeDockBarClient.cy-sizeDiff.cy;
- } // if( (dwMode & LM_HORZ) == 0 )
- else
- {
- if( (sizeCalcLayout.cx+sizeDiff.cx) > _sizeDockBarClient.cx )
- nNewLengthToSizeTB = _sizeDockBarClient.cx-sizeDiff.cx;
- } // else from if( (dwMode & LM_HORZ) == 0 )
- if( nNewLengthToSizeTB < 1 )
- nNewLengthToSizeTB = 1;
- if( nNewLengthToSizeTB != nLengthToSizeTB )
- {
- if( ! m_bInsideCalcLayout )
- {
- m_bHelperTempFullRowMode = true;
- m_bInsideCalcLayout = true;
- sizeCalcLayout = _CalcLayout( dwMode, nNewLengthToSizeTB );
- if( nLengthToSizeTB != 32767 )
- _RecalcPositionsImpl();
- m_bInsideCalcLayout = false;
- return sizeCalcLayout;
- }
- }
- if( nLengthToSizeTB != 32767 )
- _RecalcPositionsImpl();
- }
- if( m_pRightBtn != NULL
- && m_pRightBtn->GetButtons().GetSize() == 0
- )
- {
- m_pRightBtn->ClearContent();
- sizeCalcLayout = _CalcSize( (dwMode & LM_HORZ) == 0 );
- }
- if( dwMode & LM_COMMIT )
- if( (m_dwStyle & (CBRS_FLOATING|CBRS_SIZE_DYNAMIC)) != 0 )
- if( dwMode & LM_HORZ )
- m_nMRUWidth = sizeCalcLayout.cx;
- CRect rcInside( 0, 0, 0, 0 );
- _CalcInsideRect(
- rcInside,
- (dwMode & LM_HORZ)
- );
- sizeCalcLayout.cy -= rcInside.Height();
- sizeCalcLayout.cx -= rcInside.Width();
- CSize sizeCalcFixedLayout =
- CControlBar::CalcFixedLayout(
- dwMode & LM_STRETCH,
- (dwMode & LM_HORZ)
- );
- sizeCalcLayout.cx =
- max( sizeCalcLayout.cx, sizeCalcFixedLayout.cx );
- sizeCalcLayout.cy =
- max( sizeCalcLayout.cy, sizeCalcFixedLayout.cy );
- if( IsFloating() && IsBarWithGripper() )
- {
- CRect rcGrip = _RectGripGet();
- int nCyGripper = min( rcGrip.Width(), rcGrip.Height() );
- sizeCalcLayout.cy += nCyGripper;
- }
- } // if( _GetButtonsCountImpl() > 0 )
- if( IsDockedHorizontally() )
- {
- m_sizeDockedH = sizeCalcLayout;
- m_nMinHW = sizeCalcLayout.cy;
- }
- else if( IsDockedVertically() )
- {
- m_sizeDockedV = sizeCalcLayout;
- m_nMinVH = sizeCalcLayout.cx;
- }
- else if( IsFloating() )
- {
- if( sizeCalcLayout.cx < sizeDefButton.cx * 2 ) // (+ 2.23 )
- sizeCalcLayout.cx = sizeDefButton.cx * 2;
- m_sizeFloated = sizeCalcLayout;
- }
- if( m_pDockSite == NULL )
- { // specific for dialog mode
- if( IsDockedHorizontally() )
- sizeCalcLayout.cy += 4;
- else
- sizeCalcLayout.cx += 4;
- } // specific for dialog mode
- return sizeCalcLayout;
- }
- CSize CExtToolControlBar::_CalcSize( BOOL bVerticallyDocked )
- {
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nCountOfButtons == 0 )
- return _GetDefButtonSize();
- CFont * pFont =
- OnGetToolbarFont(
- ( bVerticallyDocked && (!m_bPaletteMode) )
- ? true : false,
- true
- );
- if( pFont->GetSafeHandle() == NULL )
- pFont = ( bVerticallyDocked && (!m_bPaletteMode) )
- ? (&( PmBridge_GetPM()->m_FontNormalVert ))
- : (&( PmBridge_GetPM()->m_FontNormal ))
- ;
- CClientDC dc( this );
- CFont * pOldFont = dc.SelectObject( pFont );
- ASSERT( pOldFont != NULL );
- bool bMultiRowLayout = OnQueryMultiRowLayout();
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- CSize sizeDefButton = _GetDefButtonSize();
- CSize sizeCalc(0,0); // ( sizeDefButton );
- CPoint ptCurrent( 0, 0 );
- int nRowExtent = 0;
- if( bMultiRowLayout && bVerticallyDocked && (!m_bPaletteMode) )
- nRowExtent = sizeDefButton.cx;
- else
- nRowExtent = sizeDefButton.cy;
- INT nRowDistance = PmBridge_GetPM()->FixedBar_GetRowDistance( this ); // (+ v.2.22)
- INT nWrapCount = 0;
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
-
- if( pTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- CSize sizeTBB(
- pTBB->CalculateLayout(
- dc,
- sizeDefButton,
- (!bVerticallyDocked) || m_bPaletteMode
- )
- );
- if( nBtnIdx == (nCountOfButtons-1)
- && m_pRightBtn != NULL
- && (IsFloating() || bMultiRowLayout)
- )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT( m_pRightBtn == pTBB );
- if( bMultiRowLayout )
- {
- if( bVerticallyDocked )
- sizeCalc.cy += sizeTBB.cy;
- else
- sizeCalc.cx += sizeTBB.cx;
- if( nWrapCount > 0 && (! m_bPaletteMode) )
- m_bHelperTempFullRowMode = true;
- }
- break;
- }
- if( bMultiRowLayout && bVerticallyDocked && (!m_bPaletteMode) )
- {
- if( ( ptCurrent.y == 0 || pTBB->IsWrap(_evt) )
- && pTBB->IsSeparator()
- )
- sizeTBB = CSize( 0, 0 );
- nRowExtent = max( nRowExtent, sizeTBB.cx );
- sizeCalc.cx =
- max(
- ptCurrent.x + sizeTBB.cx,
- sizeCalc.cx
- );
- sizeCalc.cy =
- max(
- ptCurrent.y + sizeTBB.cy,
- sizeCalc.cy
- );
- ptCurrent.y += sizeTBB.cy;
- if( pTBB->IsWrap(_evt) )
- {
- ptCurrent.y = 0;
- ptCurrent.x += nRowExtent + nRowDistance;
- nRowExtent = sizeDefButton.cx;
- nWrapCount++;
- }
- } // if( bMultiRowLayout && bVerticallyDocked && (!m_bPaletteMode) )
- else
- {
- if( ( (!bVerticallyDocked) || m_bPaletteMode )
- && ( ptCurrent.x == 0 || pTBB->IsWrap(_evt) )
- && pTBB->IsSeparator()
- )
- sizeTBB = CSize( 0, 0 );
- nRowExtent = max( nRowExtent, sizeTBB.cy );
- sizeCalc.cx =
- max(
- ptCurrent.x + sizeTBB.cx,
- sizeCalc.cx
- );
- sizeCalc.cy =
- max(
- ptCurrent.y + sizeTBB.cy,
- sizeCalc.cy
- );
- if( bVerticallyDocked
- && (!m_bPaletteMode)
- )
- {
- ptCurrent.x = 0;
- ptCurrent.y += sizeTBB.cy;
- } // if( bVerticallyDocked && (!m_bPaletteMode) ...
- else
- {
- ptCurrent.x += sizeTBB.cx;
- if( pTBB->IsWrap(_evt) )
- {
- ptCurrent.x = 0;
- ptCurrent.y += nRowExtent + nRowDistance;
- nRowExtent = sizeDefButton.cy;
- nWrapCount++;
- }
- } // else from if( bVerticallyDocked && (!m_bPaletteMode) ...
- } // else from if( bMultiRowLayout && bVerticallyDocked && (!m_bPaletteMode) )
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- dc.SelectObject( pOldFont );
- if( sizeCalc.cx < sizeDefButton.cx )
- sizeCalc.cx = sizeDefButton.cx;
- if( sizeCalc.cy < sizeDefButton.cy )
- sizeCalc.cy = sizeDefButton.cy;
- bool bFloating = IsFloating();
- if( ! bVerticallyDocked )
- {
- // sizeCalc.cx += m_cxLeftBorder + m_cxRightBorder;
- sizeCalc.cx += nRowDistance/2; // (+ v.2.22)
- // if( (! bFloating )
- // && (GetBarStyle()&CBRS_GRIPPER) != 0
- // )
- // {
- // INT nGripWidth = _GripperWidthAtLeftGet();
- // if( nGripWidth >= 0 )
- // sizeCalc.cx += nGripWidth;
- // }
- }
- else
- {
- // sizeCalc.cx += 1;
- // sizeCalc.cy += m_cyTopBorder + m_cyBottomBorder;
- sizeCalc.cy += nRowDistance; // (+ v.2.22)
- // if( (! bFloating )
- // && (GetBarStyle()&CBRS_GRIPPER) != 0
- // )
- // {
- // INT nGripHeight = _GripperHeightAtTopGet();
- // if( nGripHeight >= 0 )
- // sizeCalc.cy += nGripHeight;
- // }
- }
- if( bFloating ) // (+ v.2.22)
- {
- sizeCalc.cx += 1;
- sizeCalc.cy += 1;
- }
- // if( m_bPaletteMode && m_bPresubclassDialogMode )
- // {
- // CRect rcTest( 0, 0, 1, 1 );
- // CSize _sizeInitial = rcTest.Size();
- // CalcWindowRect( &rcTest );
- // CSize _sizeUpdated = rcTest.Size();
- // ASSERT(
- // _sizeUpdated.cx >= _sizeInitial.cx
- // && _sizeUpdated.cy >= _sizeInitial.cy
- // );
- // sizeCalc += _sizeUpdated - _sizeInitial;
- // sizeCalc.cx += m_cxLeftBorder + m_cxRightBorder;
- // sizeCalc.cy += m_cyTopBorder + m_cyBottomBorder;
- // }
- return sizeCalc;
- }
- void CExtToolControlBar::_SizeToolBar(int nLength, BOOL bVert)
- {
- if( m_bPaletteMode )
- return;
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nCountOfButtons == 0 )
- return;
- bool bMultiRowLayout = OnQueryMultiRowLayout();
- if( !( IsFloating()
- || bMultiRowLayout
- )
- )
- {
- _WrapToolBarH(
- bVert ? 32767 : nLength,
- bVert ? nLength : 32767
- );
- return;
- }
- CSize sizeDefButton = _GetDefButtonSize();
- if( bMultiRowLayout )
- {
- if( bVert )
- {
- int nLengthCurr = nLength - sizeDefButton.cy;
- if( nLengthCurr < sizeDefButton.cy )
- nLengthCurr = sizeDefButton.cy;
- for( ; true; )
- {
- _WrapToolBarV( nLengthCurr );
- CSize _size = _CalcSize( TRUE );
- if( _size.cy <= nLength )
- break;
- nLengthCurr -= sizeDefButton.cy / 2;
- if( nLengthCurr <= 0 )
- break;
- }
- } // if( bVert )
- else
- _WrapToolBarH( nLength );
- return;
- } // if( bMultiRowLayout )
- INT nMinExtent = sizeDefButton.cx / 2;
- ASSERT( nMinExtent > 0 );
- if( bVert )
- {
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, this );
- INT nCalcExtentMax = _mp.m_rcWorkArea.Width() + nMinExtent;
- // NOTES:
- // 1) bug was found by Eugene Pl.
- // 2) there is no reason to make toolbar wider
- // then nCalcExtentMax value
- // 3) loop is locked when toolbar button icons are higher
- // then 16px and user drags top/bottom border of a
- // floating toolbar with 1-row layout (and attempting
- // to decrease toolbar height)
- CSize _size( 32767, 32767 );
- for( INT nCalcExtent = nMinExtent;
- nLength < _size.cy;
- nCalcExtent += nMinExtent
- )
- {
- _WrapToolBarH( nCalcExtent );
- _size = _CalcSize( FALSE );
- if( nCalcExtent > nCalcExtentMax )
- return;
- }
- _WrapToolBarH( _size.cx );
- return;
- }
- INT nCountOfRowsDesired = _WrapToolBarH( nLength );
- INT nCountOfRowsCurrent = _WrapToolBarH( nMinExtent );
- if( nCountOfRowsCurrent == nCountOfRowsDesired
- || nMinExtent >= nLength
- )
- {
- _WrapToolBarH( _CalcSize(FALSE).cx );
- return;
- }
- while( nMinExtent < nLength )
- {
- INT nCurrentExtent = (nMinExtent + nLength) / 2;
- nCountOfRowsCurrent = _WrapToolBarH( nCurrentExtent );
- if( nCountOfRowsCurrent == nCountOfRowsDesired )
- {
- nLength = nCurrentExtent;
- continue;
- }
- if( nMinExtent == nCurrentExtent )
- {
- _WrapToolBarH( nLength );
- break;
- }
- nMinExtent = nCurrentExtent;
- }
- _WrapToolBarH( _CalcSize(FALSE).cx );
- }
- void CExtToolControlBar::_DraggingUpdateState(
- const CPoint & point,
- bool bForceFloatMode
- )
- {
- CExtControlBar::_DraggingUpdateState( point, bForceFloatMode );
- // if( IsFloating() )
- // return;
- // if( _IsDockSiteCustomizeMode()
- // && (! IsSingleOnRow() )
- // )
- // MakeSingleOnRow();
- }
- int CExtToolControlBar::_WrapToolBarV(
- int nHeight
- )
- {
- ASSERT( !m_bPaletteMode );
- // ASSERT( !IsFloating() );
- CFont * pFont = OnGetToolbarFont( true, true );
- if( pFont->GetSafeHandle() == NULL )
- (&( PmBridge_GetPM()->m_FontNormalVert ));
- CClientDC dc( this );
- CFont * pOldFont = dc.SelectObject( pFont );
- ASSERT( pOldFont != NULL );
- CSize sizeDefButton = _GetDefButtonSize();
- CRect rcClient;
- GetClientRect( &rcClient );
- CPoint ptCurrent( rcClient.right, rcClient.top );
- if( m_pRightBtn != NULL )
- nHeight -=
- m_pRightBtn->CalculateLayout(
- dc, sizeDefButton, FALSE ).cy;
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- int nCountOfColumns = 1;
- int nCountOfButtons = _GetButtonsCountImpl();
- CExtBarButton * pPrevButton = NULL;
- INT nRowDistance = PmBridge_GetPM()->FixedBar_GetRowDistance( this );
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->SetWrap( _evt, false );
- if( nBtnIdx == (nCountOfButtons-1)
- && m_pRightBtn != NULL
- )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT( m_pRightBtn == pTBB );
- break;
- }
-
- if( pTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- CSize sizeTBB =
- pTBB->CalculateLayout(
- dc,
- sizeDefButton,
- FALSE
- );
- if( ptCurrent.y == 0 && pTBB->IsSeparator() )
- sizeTBB = CSize(0, 0);
- if( pPrevButton != NULL
- && ( (ptCurrent.y + sizeTBB.cy) > nHeight )
- && (! pTBB->IsSeparator() )
- )
- {
- ASSERT_VALID( pPrevButton );
- pPrevButton->SetWrap( _evt );
- ptCurrent.x -=
- sizeTBB.cx
- + nRowDistance;
- ptCurrent.y = 0;
- nCountOfColumns++;
- }
- ptCurrent.y += sizeTBB.cy;
- pPrevButton = pTBB;
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- dc.SelectObject( pOldFont );
- return nCountOfColumns;
- }
- int CExtToolControlBar::_WrapToolBarH(int nWidth, int nHeight /*= 32767*/)
- {
- bool bVerticallyDocked =
- ((m_dwStyle & CBRS_ORIENT_HORZ) == 0)
- ? true : false;
- bool bFloatLikeMode =
- ( IsFloating()
- || nHeight == 32767 // (+ v.2.22)
- || OnQueryMultiRowLayout()
- ) ? true : false;
- CFont * pFont =
- OnGetToolbarFont(
- ( bVerticallyDocked && (!m_bPaletteMode) )
- ? true : false,
- true
- );
- if( pFont->GetSafeHandle() == NULL )
- pFont = ( bVerticallyDocked && (!m_bPaletteMode) )
- ? (&( PmBridge_GetPM()->m_FontNormalVert ))
- : (&( PmBridge_GetPM()->m_FontNormal ))
- ;
- CClientDC dc( this );
- CFont * pOldFont = dc.SelectObject( pFont );
- ASSERT( pOldFont != NULL );
- CSize sizeDefButton = _GetDefButtonSize();
- CRect rcClient;
- GetClientRect( &rcClient );
- CPoint ptCurrent( 0, rcClient.top );
- if( (!bFloatLikeMode)
- && (!bVerticallyDocked)
- && m_pRightBtn != NULL
- && (!m_bPaletteMode)
- )
- nWidth -=
- m_pRightBtn->CalculateLayout(
- dc, sizeDefButton, TRUE ).cx;
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- int nCountOfRows = 1;
- int nCountOfButtons = _GetButtonsCountImpl();
- CExtBarButton * pPrevButton = NULL;
- INT nRowDistance = PmBridge_GetPM()->FixedBar_GetRowDistance( this );
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( ! m_bPaletteMode )
- {
- pTBB->SetWrap( _evt, false );
- }
- if( nBtnIdx == (nCountOfButtons-1)
- && m_pRightBtn != NULL
- )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT( m_pRightBtn == pTBB );
- break;
- }
- if( pTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- CSize sizeTBB =
- pTBB->CalculateLayout(
- dc,
- sizeDefButton,
- (!bVerticallyDocked)
- || m_bPaletteMode
- );
- if( ptCurrent.x == 0 && pTBB->IsSeparator() )
- sizeTBB = CSize(0, 0);
- if( ( m_bPaletteMode
- && pPrevButton != NULL
- && pPrevButton->IsWrap( _evt )
- )
- || ( (! m_bPaletteMode)
- && bFloatLikeMode
- && pPrevButton != NULL
- && (bFloatLikeMode || ptCurrent.y + sizeTBB.cy < nHeight)
- && ptCurrent.x + sizeTBB.cx > nWidth
- && (! pTBB->IsSeparator())
- )
- )
- {
- ASSERT_VALID( pPrevButton );
- if( ! m_bPaletteMode )
- pPrevButton->SetWrap( _evt );
- ptCurrent.x = 0;
- ptCurrent.y +=
- sizeTBB.cy
- + nRowDistance;
- nCountOfRows++;
- }
- ptCurrent.x += sizeTBB.cx;
- pPrevButton = pTBB;
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- dc.SelectObject( pOldFont );
- return nCountOfRows;
- }
- CSize CExtToolControlBar::_CalcDesiredMinOuterSize( BOOL bHorz ) const
- {
- ASSERT_VALID( this );
- if( m_bPaletteMode )
- return
- ( const_cast < CExtToolControlBar * > ( this ) )
- -> CalcFixedLayout( FALSE, bHorz );
- CSize sizeDefButton = _GetDefButtonSize();
- CSize _size( 0, 0 );
- if( m_pRightBtn != NULL )
- {
- CFont * pFont =
- ( const_cast < CExtToolControlBar * > ( this ) )
- -> OnGetToolbarFont(
- ( (!bHorz) && (!m_bPaletteMode) )
- ? true : false,
- true
- );
- if( pFont->GetSafeHandle() == NULL )
- pFont = ( (!bHorz) && (!m_bPaletteMode) )
- ? (&( PmBridge_GetPM()->m_FontNormalVert ))
- : (&( PmBridge_GetPM()->m_FontNormal ))
- ;
- CClientDC dc( ( const_cast < CExtToolControlBar * > ( this ) ) );
- CFont * pOldFont = dc.SelectObject( pFont );
- CSize sizeTBBRight =
- m_pRightBtn->CalculateLayout(
- dc,
- sizeDefButton,
- bHorz //|| m_bPaletteMode
- );
- _size += sizeTBBRight;
- dc.SelectObject( pOldFont );
- }
- // if( IsFloating() )
- // return _size;
- int nCountOfButtons = GetButtonsCount();
- if( nCountOfButtons > 0 )
- {
- CSize _sizeAdjust( 0, 0 );
- CClientDC dc( ( const_cast < CExtToolControlBar * > ( this ) ) );
- CFont * pFont =
- ( const_cast < CExtToolControlBar * > ( this ) )
- -> OnGetToolbarFont(
- ( (!bHorz) && (!m_bPaletteMode) )
- ? true : false,
- true
- );
- if( pFont->GetSafeHandle() == NULL )
- pFont = ( (!bHorz) && (!m_bPaletteMode) )
- ? (&( PmBridge_GetPM()->m_FontNormalVert ))
- : (&( PmBridge_GetPM()->m_FontNormal ))
- ;
- CFont * pOldFont = dc.SelectObject( pFont );
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
-
- if( pTBB->IsSeparator() )
- continue;
- if( pTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- if( nBtnIdx == (nCountOfButtons-1)
- && m_pRightBtn != NULL
- )
- {
- ASSERT_VALID( m_pRightBtn );
- ASSERT( m_pRightBtn == pTBB );
- break;
- }
- CSize sizeTBB(
- pTBB->CalculateLayout(
- dc,
- sizeDefButton,
- bHorz
- )
- );
- if( bHorz )
- {
- if( _sizeAdjust.cx > 0 )
- _sizeAdjust.cx = min( _sizeAdjust.cx, sizeTBB.cx );
- else
- _sizeAdjust = sizeTBB;
- }
- else
- {
- if( _sizeAdjust.cy > 0 )
- _sizeAdjust.cy = min( _sizeAdjust.cy, sizeTBB.cy );
- else
- _sizeAdjust = sizeTBB;
- }
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- if( bHorz )
- {
- if( _sizeAdjust.cx > 0 )
- _size.cx += _sizeAdjust.cx;
- }
- else
- {
- if( _sizeAdjust.cy > 0 )
- _size.cy += _sizeAdjust.cy;
- }
- dc.SelectObject( pOldFont );
- } // if( nCountOfButtons > 0 )
- CRect rcClient, rcWindow;
- GetClientRect( &rcClient );
- GetWindowRect( &rcWindow );
- if( bHorz )
- _size.cx += rcWindow.Width() - rcClient.Width();
- else
- _size.cy += rcWindow.Height() - rcClient.Height();
- return _size;
- }
- bool CExtToolControlBar::_GetFullRowMode() const
- {
- if( m_bHelperTempFullRowMode )
- return true;
- return CExtControlBar::_GetFullRowMode();
- }
- bool CExtToolControlBar::OnQueryMultiRowLayout() const
- {
- ASSERT_VALID( this );
- if( m_bPresubclassDialogMode
- || m_pDockSite == NULL
- || m_bPaletteMode
- )
- return false;
- if( IsFloating() )
- return false;
- if( ! _IsDockSiteCustomizeMode() )
- return false;
- return true;
- }
- CExtControlBar::InternalAffixmentData *
- CExtToolControlBar::_AffixmentGetOuter()
- {
- ASSERT_VALID( this );
- return &m_AffixmentData;
- }
- void CExtToolControlBar::_AffixmentSetOuter(
- CExtControlBar::InternalAffixmentData * pAffixmentData
- )
- {
- ASSERT_VALID( this );
- ASSERT( pAffixmentData != NULL );
- m_AffixmentData = *pAffixmentData;
- }
- bool CExtToolControlBar::_AffixmentIsAlignedHW() const
- {
- ASSERT_VALID( this );
- if( m_bPaletteMode )
- return false;
- return true;
- }
- LRESULT CExtToolControlBar::_ContinueHelpHitTestMode(
- CExtToolControlBar * pBar
- )
- {
- ASSERT_VALID( pBar );
- ASSERT( pBar->GetSafeHwnd() != NULL && ::IsWindow(pBar->GetSafeHwnd()) );
- CFrameWnd * pDockSiteOrOther = pBar->m_pDockSite;
- if( pDockSiteOrOther == NULL
- || (! pDockSiteOrOther->m_bHelpMode )
- )
- {
- pDockSiteOrOther = pBar->GetParentFrame();
- if( pDockSiteOrOther != NULL
- && pDockSiteOrOther->IsKindOf( RUNTIME_CLASS(CExtMiniDockFrameWnd) )
- )
- pDockSiteOrOther = pDockSiteOrOther->GetParentFrame();
- if( pDockSiteOrOther == NULL
- || (! pDockSiteOrOther->m_bHelpMode )
- )
- return -3L;
- }
- static bool g_bContinuedMode = false;
- if( g_bContinuedMode )
- return -3L;
- HWND hWndDockSite = pDockSiteOrOther->m_hWnd;
- HWND hWndBar = pBar->m_hWnd;
- MSG msg;
- g_bContinuedMode = true;
- LRESULT lResult = -3L;
- for( ; true; )
- {
- if( !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- if(!( ::IsWindow( hWndDockSite )
- && ::IsWindow( hWndBar )
- && pDockSiteOrOther->m_bHelpMode
- ))
- break;
- ::WaitMessage();
- continue;
- } // if( !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
-
- if( msg.hwnd != NULL )
- {
- if( msg.message == WM_LBUTTONDOWN )
- {
- CWnd * pWndPerm = CWnd::FromHandlePermanent(msg.hwnd);
- if( pWndPerm != NULL )
- {
- CExtControlBar * pTestBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pWndPerm );
- if( pTestBar != NULL )
- {
- lResult = pTestBar->DoHelpHitTest( CPoint(msg.lParam) );
- if( lResult > 0 )
- {
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- break;
- }
- lResult = -3L;
- } // if( pTestBar != NULL )
- } // if( pWndPerm != NULL )
- } // if( msg.message == WM_LBUTTONDOWN )
- else if( msg.message == WM_MOUSEMOVE )
- {
- CWnd * pWndPerm = CWnd::FromHandlePermanent(msg.hwnd);
- if( pWndPerm != NULL )
- {
- CExtControlBar * pTestBar =
- DYNAMIC_DOWNCAST( CExtControlBar, pWndPerm );
- if( pTestBar != NULL )
- {
- CPoint pt( (DWORD)msg.lParam );
- if( pTestBar->_OnMouseMoveMsg((UINT)msg.wParam,pt) )
- {
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- continue;
- } // if( pTestBar->_OnMouseMoveMsg((UINT)msg.wParam,pt) )
- } // if( pTestBar != NULL )
- } // if( pWndPerm != NULL )
- } // else if( msg.message == WM_MOUSEMOVE )
- else if( msg.message == WM_COMMAND )
- {
- if( ((HIWORD(msg.wParam))==0) || ((HIWORD(msg.wParam))==1) )
- {
- lResult = (LRESULT)( LOWORD(msg.wParam) );
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- break;
- } // if( ((HIWORD(msg.wParam))==0) || ((HIWORD(msg.wParam))==1) )
- } // else if( msg.message == WM_COMMAND )
- else if( msg.message == WM_SYSCOMMAND )
- {
- switch( msg.wParam )
- {
- case SC_SIZE:
- case SC_MOVE:
- case SC_MINIMIZE:
- case SC_MAXIMIZE:
- case SC_NEXTWINDOW:
- case SC_PREVWINDOW:
- case SC_CLOSE:
- case SC_RESTORE:
- case SC_TASKLIST:
- lResult =
- HID_BASE_COMMAND +
- ID_COMMAND_FROM_SC( msg.wParam );
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- break;
- default:
- lResult = (LRESULT)( msg.wParam );
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- break;
- }
- break;
- } // else if( msg.message == WM_SYSCOMMAND )
- } // if( msg.hwnd != NULL )
- if( !AfxGetThread()->PumpMessage() )
- break;
- } // for( LRESULT lResult = -3L; true; )
- g_bContinuedMode = false;
- return lResult;
- }
- void CExtToolControlBar::GetButtonInfo(int nIndex, UINT& nID, UINT& nStyle) const
- {
- ASSERT_VALID(this);
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- {
- ASSERT( FALSE );
- nID = 0;
- nStyle = 0;
- return;
- }
- ASSERT_VALID( pTBB );
- nID = pTBB->GetCmdID(false);
- nStyle = pTBB->GetStyle();
- }
- void CExtToolControlBar::SetButtonInfo(int nIndex, UINT nID, UINT nStyle)
- {
- ASSERT_VALID(this);
- CExtBarButton * pTBB =
- _GetButtonPtr(nIndex);
- if( pTBB == NULL )
- {
- ASSERT( FALSE );
- return;
- }
- ASSERT_VALID( pTBB );
- pTBB->SetCmdID( nID );
- pTBB->SetStyle( nStyle );
- _InvalidateButton( nIndex );
- //UpdateWindow();
- }
- CFont * CExtToolControlBar::OnGetToolbarFont(
- bool bVert,
- bool bMeasureFont
- )
- {
- ASSERT_VALID(this);
- if( ! bMeasureFont )
- return NULL;
- HFONT hFont = PmBridge_GetPM()->Toolbar_GetFont( ! bVert, this );
- if( hFont != NULL )
- return CFont::FromHandle( hFont );
- ASSERT( PmBridge_GetPM()->m_FontNormal.GetSafeHandle() != NULL );
- ASSERT( PmBridge_GetPM()->m_FontNormalVert.GetSafeHandle() != NULL );
- return ( bVert )
- ? ( & PmBridge_GetPM()->m_FontNormalVert )
- : ( & PmBridge_GetPM()->m_FontNormal )
- ;
- }
- bool CExtToolControlBar::_DoFtLayoutQuery(
- FtLayoutQuery * pFtLayoutQuery,
- CDC * pToolBarOutputDC
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( pFtLayoutQuery != NULL || pToolBarOutputDC != NULL );
- bool bPaintRowBkMode = PmBridge_GetPM()->FixedBar_IsPaintRowBkMode( this );
- if( ! bPaintRowBkMode )
- return false;
- #ifdef _DEBUG
- if( pFtLayoutQuery != NULL )
- {
- ASSERT( pFtLayoutQuery->m_pToolBar == this );
- ASSERT_VALID( pFtLayoutQuery->m_pMiniFrame );
- ASSERT( pFtLayoutQuery->m_arrRowBtnIndices.GetSize() == 0 );
- ASSERT( pFtLayoutQuery->m_arrRowRects.GetSize() == 0 );
- } // if( pFtLayoutQuery != NULL )
- if( pToolBarOutputDC != NULL )
- {
- ASSERT_VALID( pToolBarOutputDC );
- ASSERT( pToolBarOutputDC->GetSafeHdc() != NULL );
- } // if( pToolBarOutputDC != NULL )
- #endif // _DEBUG
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- int nCountOfButtons = _GetButtonsCountImpl();
- CRect rcClient;
- GetClientRect( &rcClient );
- CRect rcRowBk( rcClient );
- rcRowBk.bottom = rcRowBk.top;
- int nBtnIdx = 0;
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
-
- if( (! pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- if( !pTBB->IsSeparator() )
- {
- CRect rcTBB = *pTBB;
- rcRowBk.top = min( rcRowBk.top, rcTBB.top );
- rcRowBk.bottom = max( rcRowBk.bottom, rcTBB.bottom );
- }
- if( pTBB->IsWrap(_evt) && ( m_dwStyle & CBRS_ORIENT_HORZ ) )
- {
- if( ! rcRowBk.IsRectEmpty() )
- {
- if( pFtLayoutQuery != NULL )
- {
- pFtLayoutQuery->m_arrRowBtnIndices.Add( nBtnIdx );
- pFtLayoutQuery->m_arrRowRects.Add( rcRowBk );
- } // pFtLayoutQuery
- if( pToolBarOutputDC != NULL )
- {
- PmBridge_GetPM()->PaintFloatToolbarRowBk(
- *pToolBarOutputDC,
- this,
- nBtnIdx,
- rcRowBk
- );
- } // if( pToolBarOutputDC != NULL )
- } // if( ! rcRowBk.IsRectEmpty() )
- rcRowBk.top = rcRowBk.bottom + 1;
- }
- } // for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- if( ! rcRowBk.IsRectEmpty() )
- {
- if( pFtLayoutQuery != NULL )
- {
- pFtLayoutQuery->m_arrRowBtnIndices.Add( nBtnIdx );
- pFtLayoutQuery->m_arrRowRects.Add( rcRowBk );
- } // pFtLayoutQuery
- if( pToolBarOutputDC != NULL )
- {
- PmBridge_GetPM()->PaintFloatToolbarRowBk(
- *pToolBarOutputDC,
- this,
- nBtnIdx,
- rcRowBk
- );
- } // if( pToolBarOutputDC != NULL )
- } // if( ! rcRowBk.IsRectEmpty() )
- return true;
- }
- void CExtToolControlBar::DoPaint( CDC * pDC )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID(this);
- ASSERT_VALID(pDC);
- CExtPaintManager::stat_ExcludeChildAreas(
- *pDC,
- *this
- );
- CRect rcClient;
- GetClientRect( &rcClient );
- CExtMemoryDC dc( pDC, &rcClient );
- //CExtMemoryDC dc( pDC );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( dc.GetSafeHdc() != NULL )
- pDC = &dc;
- DoEraseBk( pDC );
- pDC->SetTextColor(
- PmBridge_GetPM()->GetColor( CExtPaintManager::CLR_TEXT_OUT, this )
- );
- pDC->SetBkMode( TRANSPARENT );
- CFont * pFont =
- OnGetToolbarFont(
- ( ( ( m_dwStyle & CBRS_ORIENT_HORZ ) == 0 ) && (!m_bPaletteMode) )
- ? true : false,
- false
- );
- if( pFont->GetSafeHandle() == NULL )
- pFont = ( ( ( m_dwStyle & CBRS_ORIENT_HORZ ) == 0 ) && (!m_bPaletteMode) )
- ? (&( PmBridge_GetPM()->m_FontNormalVert ))
- : (&( PmBridge_GetPM()->m_FontNormal ))
- ;
- CFont * pOldFont =
- pDC->SelectObject( pFont );
- //ASSERT( pOldFont != NULL );
- int nCountOfButtons = _GetButtonsCountImpl();
- bool bMultiRowLayout = OnQueryMultiRowLayout();
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- INT nRowDistance = PmBridge_GetPM()->FixedBar_GetRowDistance( this );
- // pre-fill row backgrounds
- _DoFtLayoutQuery( NULL, pDC );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtBarButton * pCustomizeActiveTBB = NULL;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
-
- if( (! pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- CRect rcTBB = *pTBB;
- if( !pDC->RectVisible( &rcTBB ) )
- continue;
- if( !pTBB->IsSeparator() )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( GetCustomizeSite() != NULL
- && pTBB->IsCustomizeActiveItem()
- )
- {
- ASSERT( pCustomizeActiveTBB == NULL );
- pCustomizeActiveTBB = pTBB;
- } // if( GetCustomizeSite() != NULL ...
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- pTBB->Paint( *pDC );
- continue;
- } // if( !pTBB->IsSeparator() )
- bool bSeparatorHorz =
- ( ( m_dwStyle & CBRS_ORIENT_HORZ ) != 0
- || m_bPaletteMode
- )
- ? true : false;
- bool bSeparatorRotate = false;
- CRect rectSeparator( rcTBB );
- if( (!bSeparatorHorz) && (!bMultiRowLayout) )
- {
- bSeparatorHorz = true;
- rcTBB.OffsetRect( 0, -rcTBB.Height() );
- }
- if( pTBB->IsWrap(_evt) )
- {
- if( bSeparatorHorz )
- {
- rectSeparator.left = rcClient.left;
- rectSeparator.right = rcClient.right;
- rectSeparator.top = rcTBB.bottom;
- rectSeparator.bottom =
- rectSeparator.top
- + nRowDistance;
- bSeparatorRotate = true;
- } // if( bSeparatorHorz )
- else
- {
- rectSeparator.top = rcClient.top;
- rectSeparator.bottom = rcClient.bottom;
- rectSeparator.left =
- rcTBB.left
- - nRowDistance;
- rectSeparator.right =
- rectSeparator.left
- + nRowDistance;
- bSeparatorRotate = true;
- } // else from if( bSeparatorHorz )
- } // if( pTBB->IsWrap(_evt) )
- if( nRowDistance == 0 && bSeparatorRotate )
- continue;
- if( bSeparatorRotate )
- bSeparatorHorz = !bSeparatorHorz;
- rectSeparator.DeflateRect(
- bSeparatorHorz ? 0 : 2,
- bSeparatorHorz ? 2 : 0
- );
- if( bMultiRowLayout
- && m_pRightBtn != NULL
- && m_pRightBtn->IsVisible()
- && bSeparatorRotate
- )
- {
- CRect rcRightBtn = *m_pRightBtn;
- if( bSeparatorHorz )
- {
- if( ( m_dwStyle & CBRS_ORIENT_HORZ ) == 0 )
- {
- if( rectSeparator.bottom > (rcRightBtn.top-__EXT_TB_BUTTON_OUTER_MARGIN) )
- rectSeparator.bottom = (rcRightBtn.top-__EXT_TB_BUTTON_OUTER_MARGIN);
- }
- } // if( bSeparatorHorz )
- else
- {
- if( ( m_dwStyle & CBRS_ORIENT_HORZ ) != 0 )
- {
- if( rectSeparator.right > (rcRightBtn.left-__EXT_TB_BUTTON_OUTER_MARGIN) )
- rectSeparator.right = (rcRightBtn.left-__EXT_TB_BUTTON_OUTER_MARGIN);
- }
- } // else from if( bSeparatorHorz )
- }
- PmBridge_GetPM()->PaintSeparator(
- *pDC,
- rectSeparator,
- bSeparatorHorz,
- true,
- this
- );
- // DEBUG SEPARATOR AREA PAINTING:
- // pDC->FillSolidRect( &rectSeparator, RGB(0,255,0) );
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_pDragTargetTBB != NULL && (abs(m_nDragTargetShift)) == 1 )
- {
- ASSERT_VALID( m_pDragTargetTBB );
- CRect rcItem = *m_pDragTargetTBB;
- PmBridge_GetPM()->PaintDropDivider(
- *pDC,
- rcItem,
- (m_nDragTargetShift < 0) ? true : false,
- ( ( m_dwStyle & CBRS_ORIENT_HORZ ) != 0 ) ? true : false
- );
- } // if( m_pDragTargetTBB != NULL && (abs(m_nDragTargetShift)) == 1 )
- if( m_pDragSourceTBB != NULL
- || pCustomizeActiveTBB != NULL
- )
- {
- CRect rcItem =
- (pCustomizeActiveTBB != NULL)
- ? (*pCustomizeActiveTBB)
- : (*m_pDragSourceTBB)
- ;
- PmBridge_GetPM()->PaintDragSourceRect(
- *pDC,
- rcItem
- );
- } // if( m_pDragSourceTBB != NULL ...
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite != NULL )
- {
- CExtCustomizeCmdTreeNode * pPopupDropTargetNode =
- pSite->GetPopupDropTargetNode();
- if( pPopupDropTargetNode != NULL )
- {
- ASSERT_VALID( pPopupDropTargetNode );
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( (! pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- )
- continue;
- if( pTBB->IsSeparator() )
- continue;
- CRect rcTBB = *pTBB;
- if( !pDC->RectVisible( &rcTBB ) )
- continue;
- CExtCustomizeCmdTreeNode * pNode =
- pTBB->GetCmdNode();
- if( ((LPVOID)pNode) != ((LPVOID)pPopupDropTargetNode) )
- continue;
- PmBridge_GetPM()->PaintDragSourceRect(
- *pDC,
- rcTBB
- );
- break;
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- } // if( pPopupDropTargetNode != NULL )
- } // if( pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- pDC->SelectObject( pOldFont );
- PmBridge_GetPM()->OnPaintSessionComplete( this );
- }
- void CExtToolControlBar::_InvalidateButton( int nIndex )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nIndex );
- if( pTBB == NULL )
- return;
- ASSERT_VALID( pTBB );
- CRect rect = pTBB->Rect();
- if( rect.IsRectEmpty() )
- return;
- if( pTBB->OnInvalidateButton() )
- return;
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- && PmBridge_GetPM()->GetCb2DbTransparentMode(this)
- )
- {
- const CSize _sizeRoundedAreaMerics = PmBridge_GetPM()->FixedBar_GetRoundedAreaMerics();
- rect.InflateRect( _sizeRoundedAreaMerics.cx + 1, _sizeRoundedAreaMerics.cy + 1 );
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pTBB == m_pDragSourceTBB
- || pTBB == m_pDragTargetTBB
- )
- {
- CSize _sizeDDM = PmBridge_GetPM()->GetDropDividerMerics();
- rect.InflateRect( _sizeDDM );
- rect.InflateRect( 1, 1 );
- } // if( pTBB == m_pDragSourceTBB )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- rect.InflateRect( 1, 1 );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pDockBar == NULL
- && IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl != NULL
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- )
- {
- CWnd * pWndParent = GetParent();
- if( pWndParent != NULL )
- {
- CRect _rectTest = rect;
- ClientToScreen( &_rectTest );
- pWndParent->ScreenToClient( &_rectTest );
- if( _rectTest.bottom <= 0
- || ( _rectTest.top <= 0
- && pTBB->IsKindOf( RUNTIME_CLASS(CExtRibbonButtonFile) )
- )
- )
- pWndParent->SendMessage( WM_NCPAINT );
- } // if( pWndParent != NULL )
- } // if( m_pDockBar == NULL ...
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- InvalidateRect( &rect );
- }
- bool CExtToolControlBar::OnDeliverCmd( CExtBarButton * pTBB )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB;
- return false;
- }
- void CExtToolControlBar::AnimationSite_OnProgressShutdownTimer( UINT nTimerID )
- {
- ASSERT_VALID( this);
- HWND hWndOwn = GetSafeHwnd();
- CExtControlBar::AnimationSite_OnProgressShutdownTimer( nTimerID );
- if( hWndOwn != NULL && ::IsWindow( hWndOwn ) )
- _UpdateHoverButton( CPoint(-1,-1), false );
- }
- __EXT_MFC_INT_PTR CExtToolControlBar::OnToolHitTest(
- CPoint point,
- TOOLINFO * pTI
- ) const
- {
- ASSERT_VALID( this );
- if( (! IsDisplayScreenTips() )
- || CExtToolControlBar::g_bMenuTracking
- || CExtPopupMenuWnd::IsMenuTracking()
- || OnAdvancedPopupMenuTipWndGet() != NULL
- || m_bSuspendTips
- )
- return -1;
- __EXT_MFC_INT_PTR nToolTipHit = (__EXT_MFC_INT_PTR)
- ((CExtToolControlBar*)this)->
- HitTest(point);
- if( nToolTipHit >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( (int)nToolTipHit );
- ASSERT_VALID( pTBB );
- if( pTBB != NULL )
- {
- nToolTipHit = pTBB->OnToolHitTest( point, pTI );
- if( nToolTipHit != -1 )
- return nToolTipHit;
- }
- } // if( nToolTipHit >= 0 )
- nToolTipHit =
- CExtControlBar::OnToolHitTest(
- point,
- pTI
- );
- return nToolTipHit;
- }
- bool CExtToolControlBar::OnQueryHoverBasedMenuTracking(
- const CExtBarButton * pTBB
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- pTBB;
- return true;
- }
- int CExtToolControlBar::_HitTestImpl(
- CPoint point,
- UINT nButtonStyleInclude, // = 0, // button must have style
- UINT nButtonStyleExclude, // = 0 // button must have not style
- bool bAllowFindNearest // = false // if did not hit - find nearest
- ) const
- {
- ASSERT_VALID( this );
- if( m_hWnd == NULL || (! ::IsWindow(m_hWnd) ) )
- return -1; // nowhere
- if( (!bAllowFindNearest) && ::GetCapture() == m_hWnd )
- {
- CPoint ptScreen( point );
- ClientToScreen( &ptScreen );
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint != m_hWnd )
- {
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pDockBar == NULL
- && IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl != NULL
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- && hWndFromPoint == ::GetParent( m_hWnd )
- )
- {
- }
- else
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return -1; // nowhere
- }
- }
- int nCountOfButtons = _GetButtonsCountImpl();
- int nNearestIdx = -1;
- int nNearestDistance = 32767;
- bool bNearestRowMatch = false;
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(nBtnIdx);
- ASSERT_VALID( pTBB );
-
- if( (! pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- )
- continue;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nCountOfButtons-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- continue;
- }
-
- if( (pTBB->GetStyle() & nButtonStyleInclude)
- != nButtonStyleInclude
- )
- continue;
- if( (pTBB->GetStyle() & nButtonStyleExclude)
- != 0
- )
- continue;
- CRect rect = *pTBB;
- if( rect.PtInRect(point) )
- return nBtnIdx;
- if( !bAllowFindNearest )
- continue;
- CPoint ptCenter = rect.CenterPoint();
- double lfDX = double( point.x - ptCenter.x );
- double lfDY = double( point.y - ptCenter.y );
- int nDistance = (int)
- ::sqrt( lfDX*lfDX + lfDY*lfDY );
- bool bRowMatch = false;
- if( (m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- {
- bRowMatch =
- (rect.top <= point.y && point.y <= rect.bottom)
- ? true : false;
- } // if( (m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- else
- {
- bRowMatch =
- (rect.left <= point.x && point.x <= rect.right)
- ? true : false;
- } // if( (m_dwStyle & CBRS_ORIENT_HORZ) != 0 )
- if( (!bNearestRowMatch) && bRowMatch )
- {
- nNearestIdx = nBtnIdx;
- nNearestDistance = nDistance;
- bNearestRowMatch = true;
- } // if( (!bNearestRowMatch) && bRowMatch )
- else if(
- bNearestRowMatch == bRowMatch
- && nNearestDistance > nDistance
- )
- {
- nNearestIdx = nBtnIdx;
- nNearestDistance = nDistance;
- }
- } // for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- if( bAllowFindNearest && nNearestIdx >= 0 )
- return nNearestIdx;
- return -1; // nowhere
- }
- int CExtToolControlBar::HitTest(
- CPoint point // in window relative coords
- ) const
- {
- return
- _HitTestImpl(
- point,
- 0,
- TBBS_SEPARATOR
- );
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolControlBar message handlers
- BEGIN_MESSAGE_MAP(CExtToolControlBar, CExtControlBar)
- //{{AFX_MSG_MAP(CExtToolControlBar)
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_RBUTTONUP()
- ON_WM_CANCELMODE()
- ON_WM_NCCALCSIZE()
- ON_WM_SIZE()
- ON_WM_TIMER()
- ON_WM_CAPTURECHANGED()
- //}}AFX_MSG_MAP
- __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_REGISTERED_MESSAGE( CExtToolControlBar::g_nMsgTrackButtonMenu, OnTrackButtonMenu )
- ON_REGISTERED_MESSAGE( CExtPopupMenuWnd::g_nMsgNotifyMenuClosed, OnMenuClosed )
- ON_WM_ACTIVATEAPP()
- END_MESSAGE_MAP()
- LRESULT CExtToolControlBar::OnMenuClosed( WPARAM wParam, LPARAM lParam )
- {
- wParam;
- lParam;
- _UpdateHoverButton( CPoint(-1,-1), false );
- return 0;
- }
- LRESULT CExtToolControlBar::OnTrackButtonMenu(WPARAM wParam,LPARAM lParam)
- {
- if( !( ::IsWindowEnabled(
- m_bPresubclassDialogMode
- ? GetOwner()->GetSafeHwnd()
- : _GetDockingFrameImpl()->GetSafeHwnd()
- )
- )
- )
- return 0;
- int nCountOfButtons = GetButtonsCount();
- ASSERT( nCountOfButtons >= 0 );
- if( nCountOfButtons == 0 )
- return 0;
- int nIndex = int(wParam);
- if( nIndex < 0 || nIndex>=nCountOfButtons )
- {
- _CloseTrackingMenus();
- return 0;
- }
- CExtBarButton * pTBB = _GetButtonPtr(nIndex);
- ASSERT_VALID( pTBB );
- BOOL bDroppedMode =
- CExtPopupMenuWnd::IsMenuTracking();
- if( ! pTBB->IsAbleToTrackMenu() )
- bDroppedMode = FALSE;
- if( bDroppedMode )
- {
- CExtToolControlBar::TrackButtonMenu(
- nIndex,
- true,
- false,
- (lParam != 0) ? true : false
- );
- return 0;
- }
- _CloseTrackingMenus();
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd() )
- CExtMouseCaptureSink::ReleaseCapture();
- return 0;
- }
- void CExtToolControlBar::OnLButtonDown(UINT nFlags, CPoint point)
- {
- if( m_bRowResizing || m_bRowRecalcing || m_bDragging )
- {
- CExtControlBar::OnLButtonDown(nFlags, point);
- return;
- }
-
- _ActivateOnClick();
- m_nBtnIdxCapture = HitTest( point );
- if( m_nBtnIdxCapture < 0 ) // nothing hit
- {
- CPoint ptScreen = point;
- ClientToScreen( &ptScreen );
- bool bOwnMessage = true;
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint != m_hWnd )
- {
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pDockBar == NULL
- && IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl != NULL
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- && hWndFromPoint == ::GetParent( m_hWnd )
- )
- {
- }
- else
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- bOwnMessage = false; // nowhere
- }
- if( bOwnMessage )
- CExtControlBar::OnLButtonDown(nFlags, point);
- else
- SendMessage( WM_CANCELMODE );
- return;
- }
- CExtBarButton * pTBB =
- _GetButtonPtr(m_nBtnIdxCapture);
- ASSERT_VALID( pTBB );
- ASSERT( !(pTBB->IsSeparator()) );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bCustomizationAllowed )
- {
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite != NULL )
- {
- CExtCustomizeCmdTreeNode * pNodeC =
- pTBB->GetCmdNode( false );
- if( pNodeC != NULL )
- {
- ASSERT_VALID( pNodeC );
- bool bCustomizeMode = pSite->IsCustomizeMode();
- bool bAlt =
- ( (::GetAsyncKeyState(VK_MENU)&0x8000) != 0 )
- ? true : false;
- if( bAlt || bCustomizeMode )
- {
- int nBtnDragSrc = m_nBtnIdxCapture;
- m_nBtnIdxCapture = -1;
- if( !pTBB->CanStartCommandDrag() )
- return;
- if( bCustomizeMode )
- {
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- int nWidthMin = 0, nWidthMax = 0;
- int nInitialResizingStateH =
- pTBB->GetInitialResizingStateH(
- point,
- &nWidthMin,
- &nWidthMax
- );
- if( pTBB->IsCustomizeActiveItem()
- && nInitialResizingStateH != 0
- )
- { // if can resize button horizontally
- bool bCtrl =
- ( (::GetAsyncKeyState(VK_CONTROL)&0x8000) != 0 )
- ? true : false;
- bool bShift =
- ( (::GetAsyncKeyState(VK_SHIFT)&0x8000) != 0 )
- ? true : false;
- if( !( bAlt || bCtrl || bShift ) )
- {
- CRect rcItem = pTBB->Rect();
- if( !pSite->OnCmdNodeResizeH(
- nInitialResizingStateH,
- m_hWnd,
- pTBB,
- pNodeC,
- nWidthMin,
- nWidthMax,
- rcItem
- )
- )
- return; // resizing is canceled
- CFrameWnd * pFrame = GetParentFrame();
- if( pFrame != NULL )
- {
- pFrame->RecalcLayout();
- pSite->ActiveItemSet( pTBB, GetSafeHwnd() );
- }
- return;
- } // if( !( bAlt || bCtrl || bShift ) )
- } // if can resize button horizontally
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- pTBB->SetCustomizeActiveItem();
- } // if( bCustomizeMode )
- // CExtCmdItem * pCmdItem =
- // g_CmdManager->CmdGetPtr(
- // g_CmdManager->ProfileNameFromWnd( m_hWnd ),
- // pTBB->GetCmdID()
- // );
- // if( pCmdItem == NULL )
- // {
- // ASSERT( FALSE );
- // return;
- // }
- CExtCustomizeCmdTreeNode * pNodeI =
- pTBB->GetCmdNode( true );
- SendMessage( WM_CANCELMODE );
- CRect rcItem( 0, 0, 1, 1 );
- CExtCustomizeCmdTreeNode * pPopupDropTargetNode =
- pSite->GetPopupDropTargetNode();
- if( bCustomizeMode
- && pTBB->IsAbleToTrackMenu( true )
- && pPopupDropTargetNode != pNodeC
- )
- {
- // pSite->DropTargetPopupCancel();
- // pSite->DropTargetPopupCancel();
- pSite->DropTargetPopupCancelEx( -2 );
- CRect rcBtn = *pTBB;
- ClientToScreen( &rcBtn );
- CPoint ptTrack( point );
- ClientToScreen( &ptTrack );
- DWORD dwTrackFlags = pTBB->OnGetTrackPopupFlags();
- pSite->DropTargetPopupTrack(
- pNodeC,
- rcBtn,
- ptTrack,
- dwTrackFlags
- );
- } // if( bCustomizeMode && pTBB->IsAbleToTrackMenu() ...
- else
- pSite->DropTargetPopupCancel();
- m_pDragSourceTBB = pTBB;
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- m_bHelperSeparatorAction = false;
- _InvalidateButton( nBtnDragSrc );
- //UpdateWindow();
- if( CExtControlBar::stat_DoDragDetect( m_hWnd, point ) )
- pSite->DoDragCmdNode( this, pNodeI, pNodeC, rcItem );
- m_pDragSourceTBB = NULL;
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- m_bHelperSeparatorAction = false;
- return;
- } // if( bAlt || bCustomizeMode )
- } // if( pNodeC != NULL )
- } // if( pSite != NULL )
- } // if( m_bCustomizationAllowed )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- // update the button before checking for disabled status
- _UpdateButton(m_nBtnIdxCapture);
- if( m_nBtnIdxMenuTracking == m_nBtnIdxCapture
- || ( pTBB->IsDisabled()
- && ( ! pTBB->CanBePressedInDisabledState() )
- )
- )
- {
- m_nBtnIdxCapture = -1;
- return; // don't press it
- } // if( m_nBtnIdxMenuTracking == m_nBtnIdxCapture ...
- pTBB->ModifyStyle( TBBS_PRESSED );
- pTBB->OnPressedTrackingStart();
- _InvalidateButton( m_nBtnIdxCapture );
- // UpdateWindow(); // immediate feedback
- HWND hWndCtrlTBB = pTBB->CtrlGet()->GetSafeHwnd();
- HWND hWndOwn = m_hWnd;
- pTBB->OnClick( point, true );
- if( ! ::IsWindow(hWndOwn) )
- return;
- if( _GetIndexOf( pTBB ) < 0 )
- pTBB = NULL;
- #ifdef _DEBUG
- else
- {
- ASSERT_VALID( pTBB );
- }
- #endif // _DEBUG
- if( ! g_bMenuTracking )
- {
- if( hWndCtrlTBB == NULL
- || ( ::IsWindow(hWndCtrlTBB)
- && ( (::__EXT_MFC_GetWindowLong(hWndCtrlTBB,GWL_STYLE)) & WS_VISIBLE ) == 0
- )
- )
- CExtMouseCaptureSink::SetCapture( GetSafeHwnd() );
- else
- m_nBtnIdxCapture = -1;
- } // if( ! g_bMenuTracking )
- else
- m_nBtnIdxCapture = -1;
- }
- bool CExtToolControlBar::_IsSimplifiedDropDownButtons() const
- {
- ASSERT_VALID( this );
- return false;
- }
- bool CExtToolControlBar::_OnMouseMoveMsg(UINT nFlags, CPoint point)
- {
- __PROF_UIS_MANAGE_STATE;
- if( CExtPopupMenuWnd::IsMenuTracking()
- && (! CExtToolControlBar::g_bMenuTracking )
- )
- return true;
- if( IsFloating()
- && CExtMiniDockFrameWnd::g_bAutoMakeTopmostOnMouseEvent
- )
- {
- CFrameWnd * pParentFrame = GetParentFrame();
- if( pParentFrame != NULL )
- pParentFrame->BringWindowToTop();
- }
- if( m_bRowResizing || m_bRowRecalcing || m_bDragging )
- return CExtControlBar::_OnMouseMoveMsg(nFlags, point);;
- if( m_nBtnIdxCapture >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxCapture );
- ASSERT_VALID( pTBB );
- ASSERT( ! pTBB->IsSeparator() );
- // UINT nNewStyle = ( pTBB->GetStyle() & (~TBBS_PRESSED) );
- UINT nNewStyle = pTBB->GetStyle();
- int nBtnIdxCapture = m_nBtnIdxCapture;
- if( CExtMouseCaptureSink::GetCapture() != m_hWnd )
- {
- if( HitTest(point) != m_nBtnIdxCapture )
- nNewStyle &= (~TBBS_PRESSED);
- m_nBtnIdxCapture = -1; // lost capture
- }
- else
- {
- // should be pressed if still hitting the captured button
- if( HitTest(point) == m_nBtnIdxCapture )
- nNewStyle |= TBBS_PRESSED;
- }
- // if( (nNewStyle & TBBS_PRESSED) == 0 )
- // pTBB->OnPressedTrackingStop();
- // else
- // pTBB->OnPressedTrackingStart();
- SetButtonStyle( nBtnIdxCapture, nNewStyle );
- UpdateWindow(); // immediate feedback
- return true;
- } // if( m_nBtnIdxCapture >= 0 )
- bool bHoverChanged = _UpdateHoverButton();
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd()
- && m_nBtnIdxHover < 0
- && m_nBtnIdxMenuTracking < 0
- && m_nBtnIdxCapture < 0
- )
- {
- CPoint ptScreen;
- if( ! ::GetCursorPos(&ptScreen) )
- return false;
- bool bOwnMessage = true;
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint != m_hWnd )
- {
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pDockBar == NULL
- && IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl != NULL
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- && hWndFromPoint == ::GetParent( m_hWnd )
- )
- {
- }
- else
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- bOwnMessage = false; // nowhere
- }
- if( bOwnMessage )
- CExtMouseCaptureSink::ReleaseCapture();
- }
- if( (! CExtPopupMenuWnd::IsMenuTracking() ) && m_nBtnIdxHover >= 0 )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite =
- GetCustomizeSite();
- if( pSite == NULL
- || (! pSite->IsCustomizeMode() )
- )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet( pTBB );
- if( pATTW != NULL )
- {
- ASSERT( ! pTBB->IsSeparator() );
- ASSERT_VALID( pTBB );
- TOOLINFO _ti;
- ::memset( &_ti, 0, sizeof(AFX_OLDTOOLINFO) );
- _ti.cbSize = sizeof( TOOLINFO );
- _ti.hinst = ::AfxGetInstanceHandle();
- if( pTBB->OnToolHitTest( point, &_ti ) > 0 )
- {
- if( _ti.lpszText != NULL
- && _ti.lpszText != LPSTR_TEXTCALLBACK
- && _tcslen( _ti.lpszText ) > 0
- )
- {
- CRect rcArea = _ti.rect;
- ClientToScreen( &rcArea );
- if( pATTW->GetSafeHwnd() != NULL )
- {
- CRect rcTest = pATTW->GetExcludeArea();
- if( rcTest != rcArea )
- bHoverChanged = true;
- }
- OnAdvancedPopupMenuTipWndDisplay(
- *pATTW,
- rcArea,
- _ti.lpszText,
- pTBB
- );
- }
- }
- if( _ti.lpszText != NULL
- && _ti.lpszText != LPSTR_TEXTCALLBACK
- )
- ::free( _ti.lpszText );
- } // if( pATTW != NULL )
- }
- } // if( (! CExtPopupMenuWnd::IsMenuTracking() ) && m_nBtnIdxHover >= 0 )
- if( bHoverChanged )
- return true;
- return CExtControlBar::_OnMouseMoveMsg(nFlags,point);
- }
- bool CExtToolControlBar::IsForceHoverWhenMenuTracking() const
- {
- ASSERT_VALID( this );
- return false;
- }
- void CExtToolControlBar::_CheckHitTestablePoint(
- CPoint & point
- )
- {
- ASSERT_VALID( this );
- CPoint ptScreen = point;
- if( point.x < 0 || point.y < 0 )
- {
- if( ! ::GetCursorPos( &ptScreen ) )
- {
- point.x = point.y = 32767;
- return;
- }
- point = ptScreen;
- ScreenToClient( &point );
- }
- else
- ClientToScreen( &ptScreen );
- }
- bool CExtToolControlBar::_UpdateHoverButton(
- CPoint point, // = CPoint(-1,-1) // default is use ::GetCursorPos()
- bool bEnableUpdateWindow // = true
- )
- {
- ASSERT_VALID( this );
- _CheckHitTestablePoint( point );
- bool bHoverChanged = false;
- INT nBtnIdxHoverNew = -1;
- INT nIndex, nCount = GetButtonsCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- CExtBarButton * pTBB = GetButton( nIndex );
- ASSERT_VALID( pTBB );
- if( ( ! pTBB->IsVisible() )
- || ( pTBB->GetStyle() & TBBS_HIDDEN ) != 0
- )
- continue;
- bool bHover = pTBB->IsHover();
- CRect rcTBB = *pTBB;
- if( ( pTBB->IsDisabled()
- && (! pTBB->IsShowTipWhenDisabled() )
- )
- || pTBB->IsSeparator()
- || ( ! rcTBB.PtInRect( point ) )
- )
- {
- if( bHover )
- {
- bHoverChanged = true;
- pTBB->SetHover( false );
- _InvalidateButton( nIndex );
- }
- continue;
- }
- if( pTBB->ChildButtonGetCount() > 0
- && nBtnIdxHoverNew >= 0
- )
- continue;
- nBtnIdxHoverNew = nIndex;
- if( bHover )
- continue;
- bHoverChanged = true;
- pTBB->SetHover( true );
- _InvalidateButton( nIndex );
- } // for( nIndex = 0; nIndex < nCount; nIndex ++ )
- bool bDropDownHT = false;
- if( m_nBtnIdxHover >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- if( pTBB->GetSeparatedDropDown() )
- {
- CRect rcBtnDropDownArea = pTBB->RectDropDown();
- if( rcBtnDropDownArea.PtInRect( point ) )
- bDropDownHT = true;
- } // if( pTBB->GetSeparatedDropDown() )
- } // if( m_nBtnIdxHover >= 0 )
- if( m_nBtnIdxHover != nBtnIdxHoverNew
- || m_bLastDropDownHT != bDropDownHT
- )
- {
- m_bLastDropDownHT = bDropDownHT;
- if( m_nBtnIdxHover >= 0
- && m_nBtnIdxHover != nBtnIdxHoverNew
- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- pTBB->OnHover(
- point,
- false,
- m_bSuspendTips
- );
- } // if( m_nBtnIdxHover >= 0 ...
- bHoverChanged = true;
- // if( CExtControlBar::FindHelpMode( this )
- // && nBtnIdxHoverNew >= 0
- // )
- // {
- // CExtBarButton * pTBB = _GetButtonPtr(nBtnIdxHoverNew);
- // if( pTBB->IsAbleToTrackMenu()
- // && pTBB->OnHelpHitTest(point) == -3
- // )
- // m_nBtnIdxHover = nBtnIdxHoverNew;
- // }
- // else
- // m_nBtnIdxHover = nBtnIdxHoverNew;
- m_nBtnIdxHover = nBtnIdxHoverNew;
- if( m_nBtnIdxHover >= 0 )
- {
- if( m_ptLastClientHover == point )
- {
- m_nBtnIdxHover = -1;
- }
- }
- if( m_nBtnIdxHover >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- bool bEnableHoverOnNewBtn = true;
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- || pTBB->IsDisabled()
- )
- {
- if( g_bMenuTracking )
- bEnableHoverOnNewBtn = false;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( bEnableHoverOnNewBtn )
- {
- CExtCustomizeSite * pSite =
- GetCustomizeSite();
- if( pSite != NULL
- && ( pSite->IsCustomizeMode()
- || pSite->GetPopupDropTargetNode() != NULL
- || pSite->DraggedNodeGet() != NULL
- )
- )
- bEnableHoverOnNewBtn = false;
- } // if( bEnableHoverOnNewBtn )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( bEnableHoverOnNewBtn )
- {
- m_ptLastClientHover = point;
- pTBB->OnHover(
- point,
- true,
- m_bSuspendTips
- );
- pTBB->RedrawButton( false );
- }
- } // if( m_nBtnIdxHover >= 0 )
- } // if( m_nBtnIdxHover != nBtnIdxHoverNew )
- else if( m_nBtnIdxHover >= 0 )
- {
- CExtBarButton * pTBB = _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiRightButton ) ) )
- {
- m_ptLastClientHover = point;
- pTBB->OnHover(
- point,
- true,
- m_bSuspendTips
- );
- pTBB->RedrawButton( false );
- } // if( pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiRightButton ) ) )
- } // else if( m_nBtnIdxHover >= 0 )
- if( m_nBtnIdxHover >= 0 )
- {
- m_ptLastClientHover = point;
- CExtBarButton * pTBB = _GetButtonPtr( m_nBtnIdxHover );
- ASSERT_VALID( pTBB );
- pTBB->OnHovering(
- point,
- m_bSuspendTips
- );
- }
- if( bHoverChanged && bEnableUpdateWindow )
- UpdateWindow();
- CPoint ptScreen = point;
- ClientToScreen( &ptScreen );
- bool bOwnMessage = true;
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint != m_hWnd )
- {
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( m_pDockBar == NULL
- && IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl != NULL
- && ((CExtRibbonBar*)this)->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- && hWndFromPoint == ::GetParent( m_hWnd )
- )
- {
- }
- else
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- bOwnMessage = false; // nowhere
- }
- if( ( ! bOwnMessage )
- && ::GetCapture() == m_hWnd
- )
- ::ReleaseCapture();
- m_nBtnIdxHover = nBtnIdxHoverNew;
- SetTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER, 100, NULL );
- // if( m_nBtnIdxHover >= 0 )
- // {
- // SetTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER, 100, NULL );
- // SendMessage( WM_TIMER, __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
- // }
- // else
- // KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
- return bHoverChanged;
- }
- void CExtToolControlBar::OnLButtonUp(UINT nFlags, CPoint point)
- {
- if( ( m_nBtnIdxCapture < 0 && m_nBtnIdxHover < 0 )
- || m_bRowResizing
- || m_bRowRecalcing
- || m_bDragging
- )
- {
- CExtControlBar::OnLButtonUp(nFlags, point);
- return; // not captured
- }
- _CheckHitTestablePoint( point );
- int nBtnIdxCapture = m_nBtnIdxCapture;
- HWND hWndOwn = m_hWnd;
- if( nBtnIdxCapture >= 0 )
- {
- CExtBarButton * pTempTBB = _GetButtonPtr( nBtnIdxCapture );
- ASSERT_VALID( pTempTBB );
- ASSERT( !(pTempTBB->IsSeparator()) );
- if( pTempTBB->IsPressedTracking() )
- {
- pTempTBB->OnPressedTrackingStop();
- _InvalidateButton( m_nBtnIdxCapture );
- }
- m_nBtnIdxCapture = -1;
- CExtBarButton * pCaptureTBB = NULL;
- UINT nNewStyle = 0;
- if( nBtnIdxCapture == HitTest(point) )
- {
- pCaptureTBB = pTempTBB;
- nNewStyle = ( pCaptureTBB->GetStyle() & ~TBBS_PRESSED );
- // give button a chance to update
- _UpdateButton( nBtnIdxCapture );
- // then check for disabled state
- if( !(pCaptureTBB->IsDisabled()) )
- {
- if( pCaptureTBB->GetStyle() & TBBS_CHECKBOX )
- {
- // auto check: three state => down
- if( nNewStyle & TBBS_INDETERMINATE )
- nNewStyle &= ~TBBS_INDETERMINATE;
- nNewStyle ^= TBBS_CHECKED;
- }
- } // if( !(pCaptureTBB->IsDisabled()) )
- } // if( nBtnIdxCapture == HitTest(point) )
- CExtMouseCaptureSink::ReleaseCapture();
- if( pCaptureTBB != NULL )
- {
- if( _GetIndexOf( pCaptureTBB ) != nBtnIdxCapture )
- nBtnIdxCapture = -1;
- else
- {
- pCaptureTBB->OnClick( point, false );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- if( _GetIndexOf( pCaptureTBB ) != nBtnIdxCapture )
- return;
- } // else from if( _GetIndexOf(pCaptureTBB) != nBtnIdxCapture )
- }
- if( nBtnIdxCapture >= 0 )
- {
- _InvalidateButton( nBtnIdxCapture );
- if( (!g_bMenuTracking) )
- {
- SetButtonStyle( nBtnIdxCapture, nNewStyle );
- _UpdateButton( nBtnIdxCapture );
- } // if( (!g_bMenuTracking) && nBtnIdxCapture >= 0 )
- }
- } // if( nBtnIdxCapture >= 0 )
- // INT nCountOfButtons = _GetButtonsCountImpl();
- // for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- // {
- // CExtBarButton * pTBB =
- // _GetButtonPtr( nBtnIdx );
- // ASSERT_VALID( pTBB );
- // pTBB->m_bHover = false;
- // } // for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- _UpdateHoverButton( CPoint(-1,-1), false );
- }
- void CExtToolControlBar::OnRButtonUp(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- INT nButton = HitTest( point );
- if( nButton < 0 )
- {
- CExtControlBar::OnRButtonUp( nFlags, point );
- return;
- }
- CExtBarButton * pTBB = _GetButtonPtr( nButton );
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator()
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- )
- {
- CExtControlBar::OnRButtonUp( nFlags, point );
- return;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( _IsDockSiteCustomizeMode() )
- {
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite != NULL )
- {
- ASSERT( pSite->IsCustomizeMode() );
- CExtCustomizeCmdTreeNode * pNodeC = pTBB->GetCmdNode( false );
- if( pNodeC == NULL )
- return;
- ASSERT_VALID( pNodeC );
- CExtCustomizeCmdTreeNode * pNodeI = pTBB->GetCmdNode( true );
- #ifdef _DEBUG
- if( pNodeI != NULL )
- {
- ASSERT_VALID( pNodeI );
- }
- #endif // _DEBUG
- pSite->DropTargetPopupCancel();
- pTBB->SetCustomizeActiveItem();
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(m_hWnd),
- pTBB->GetCmdID( false )
- );
- ASSERT( pCmdItem != NULL );
- if( !pSite->CustomizedNodeSet( pNodeC ) )
- return;
- Invalidate();
- //UpdateWindow();
- bool bCanAddRemoveSeparator = false;
- if( OnQueryRevertRTL() )
- {
- int nButtonsCount = GetButtonsCount();
- if( nButton < (nButtonsCount-1)
- && ( ! _GetButtonPtr( nButton + 1 ) ->
- IsKindOf(
- RUNTIME_CLASS(CExtBarMdiDocButton)
- )
- )
- )
- bCanAddRemoveSeparator = true;
- } // if( OnQueryRevertRTL() )
- else
- {
- if( nButton > 0
- && ( ! _GetButtonPtr( nButton - 1 ) ->
- IsKindOf(
- RUNTIME_CLASS(CExtBarMdiDocButton)
- )
- )
- )
- bCanAddRemoveSeparator = true;
- } // else from if( OnQueryRevertRTL() )
- bool bDelete = false;
- if( ! pSite->OnCustomizeTreeNode(
- pNodeI,
- pNodeC,
- pCmdItem,
- bDelete,
- bCanAddRemoveSeparator,
- this
- )
- )
- {
- VERIFY( pSite->CustomizedNodeSet( NULL ) );
- Invalidate();
- //UpdateWindow();
- return;
- }
- VERIFY( pSite->CustomizedNodeSet( NULL ) );
- if( bDelete )
- {
- pNodeC->RemoveSelf( pCmdItem );
- RemoveButton( nButton );
- if( nButton > 0
- && _GetButtonPtr(nButton-1)->IsSeparator()
- )
- RemoveButton( nButton-1 );
- if( nButton < (GetButtonsCount()-1)
- && _GetButtonPtr(nButton)->IsSeparator()
- )
- {
- RemoveButton( nButton );
- CExtBarButton * pTBB = _GetButtonPtr(nButton);
- ASSERT_VALID( pTBB );
- CExtCustomizeCmdTreeNode * pNodeNext = pTBB->GetCmdNode( false );
- ASSERT_VALID( pNodeNext );
- pNodeNext->ModifyFlags( 0, __ECTN_GROUP_START );
- }
- } // if( bDelete )
- else
- {
- if( pNodeC->GetFlags() & __ECTN_GROUP_START )
- {
- if( nButton > 0
- && (! _GetButtonPtr(nButton-1)->IsSeparator() )
- )
- InsertButton( nButton, ID_SEPARATOR, FALSE );
- } // if( pNodeC->GetFlags() & __ECTN_GROUP_START )
- else
- {
- if( nButton > 0
- && _GetButtonPtr(nButton-1)->IsSeparator()
- )
- RemoveButton( nButton-1, FALSE );
- } // else from if( pNodeC->GetFlags() & __ECTN_GROUP_START )
- } // else from if( bDelete )
- if( IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- ((CExtMenuControlBar*)this)->UpdateMenuBar();
- if( m_pDockSite == NULL )
- {
- _RecalcPositionsImpl();
- Invalidate();
- //UpdateWindow();
- return;
- } // if( m_pDockSite == NULL )
- ASSERT_VALID( m_pDockSite );
- if( IsFloating() )
- {
- _RecalcLayoutImpl();
- Invalidate();
- //UpdateWindow();
- }
- else
- m_pDockSite->RecalcLayout();
- return;
- } // if( pSite != NULL )
- } // if( _IsDockSiteCustomizeMode() )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
-
- if( m_nBtnIdxHover >= 0 )
- _UpdateHoverButton( CPoint(LONG_MAX,LONG_MAX), true ); // cancel hover
- if( pTBB->OnRClick( point, false ) )
- return;
- CExtControlBar::OnRButtonUp( nFlags, point );
- }
- void CExtToolControlBar::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- if( m_bRowResizing || m_bRowRecalcing || m_bDragging )
- {
- CExtControlBar::OnLButtonDblClk(nFlags, point);
- return;
- }
- int nBtnIdx = _HitTestImpl(point);
- if( nBtnIdx >= 0 )
- {
- CExtBarButton* pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->OnDblClick( point ) )
- return;
- if( ! IsFloating() )
- {
- if( pTBB->IsSeparator() )
- {
- if( ! _FloatStateChangingIsEnabled( this ) )
- return;
- ToggleDocking();
- return;
- }
- }
- WPARAM wParam = WPARAM(nFlags);
- LPARAM lParam = MAKELPARAM( point.x, point.y );
- SendMessage( WM_LBUTTONUP, wParam, lParam );
- SendMessage( WM_LBUTTONDOWN, wParam, lParam );
- return;
- } // if( nBtnIdx >= 0 )
- if( m_bEnableDblClickToggleDocking || IsFloating() )
- CExtControlBar::OnLButtonDblClk(nFlags,point);
- }
- void CExtToolControlBar::OnCancelMode()
- {
- CExtControlBar::OnCancelMode();