ExtToolControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:409k
- bool bUpdateState = false;
- if( m_nBtnIdxCapture >= 0 )
- {
- CExtBarButton* pTBB =
- _GetButtonPtr(m_nBtnIdxCapture);
- ASSERT_VALID( pTBB );
- ASSERT( !(pTBB->IsSeparator()) );
- if( m_nBtnIdxMenuTracking != m_nBtnIdxCapture )
- {
- UINT nNewStyle = (pTBB->GetStyle() & ~TBBS_PRESSED);
- SetButtonStyle(m_nBtnIdxCapture, nNewStyle);
- }
- pTBB->OnPressedTrackingStop();
- m_nBtnIdxCapture = -1;
- bUpdateState = true;
- }
- if( m_nBtnIdxHover >= 0 )
- _UpdateHoverButton( CPoint(-1,-1), false );
- if( bUpdateState )
- {
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd() )
- CExtMouseCaptureSink::ReleaseCapture();
- Invalidate();
- // UpdateWindow();
- }
- }
- void CExtToolControlBar::OnSettingChange(UINT uFlags, __EXT_MFC_SAFE_LPCTSTR lpszSection)
- {
- CExtControlBar::OnSettingChange(uFlags,lpszSection);
- if( m_bPresubclassDialogMode )
- {
- _RecalcLayoutImpl();
- return;
- }
- CFrameWnd* pFrame = GetParentFrame();
- ASSERT_VALID(pFrame);
- pFrame->DelayRecalcLayout();
- }
- bool CExtToolControlBar::IsRightExpandButton( int nBtnIdx )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nBtnIdx );
- if( pTBB == NULL )
- return false;
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- return true;
- return false;
- }
- void CExtToolControlBar::_UpdateCtrlLock()
- {
- ASSERT_VALID( this );
- ASSERT( m_nUpdateCtrlLockCount >= 0 );
- m_nUpdateCtrlLockCount ++;
- ASSERT( m_nUpdateCtrlLockCount >= 0 );
- // if( m_nUpdateCtrlLockCount == 1 )
- // SetRedraw( FALSE );
- }
- void CExtToolControlBar::_UpdateCtrlUnlock()
- {
- ASSERT_VALID( this );
- ASSERT( m_nUpdateCtrlLockCount >= 0 );
- m_nUpdateCtrlLockCount --;
- ASSERT( m_nUpdateCtrlLockCount >= 0 );
- // if( m_nUpdateCtrlLockCount == 0 )
- // SetRedraw( TRUE );
- }
- bool CExtToolControlBar::_UpdateCtrlIsLocked() const
- {
- ASSERT_VALID( this );
- ASSERT( m_nUpdateCtrlLockCount >= 0 );
- return ( m_nUpdateCtrlLockCount == 0 ) ? false : true;
- }
- bool CExtToolControlBar::_UpdateCtrlIsEnabled(
- CExtBarButton * pTBB
- )
- {
- ASSERT_VALID( this );
- pTBB;
- return _UpdateCtrlIsLocked() ? false : true;
- }
- void CExtToolControlBar::_UpdateCtrlAll()
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return;
- INT nBtnIdx, nCountOfButtons = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->_UpdateCtrl();
- }
- }
- void CExtToolControlBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
- {
- CWnd * pTargetUpdateWnd = pTarget;
- if( ! m_bPresubclassDialogMode )
- {
- CExtControlBar::OnUpdateCmdUI(pTarget, bDisableIfNoHndler);
- //if( CExtPopupMenuWnd::IsMenuTracking() )
- // return;
- if( _DraggingGetBar() != NULL )
- return;
- } // if( ! m_bPresubclassDialogMode )
- else
- {
- if( pTargetUpdateWnd != NULL
- && pTargetUpdateWnd->IsKindOf( RUNTIME_CLASS(CFrameWnd) )
- )
- return;
- //ASSERT( pTargetUpdateWnd == NULL );
- // if( pTargetUpdateWnd == NULL )
- pTargetUpdateWnd = GetOwner();
- if( pTargetUpdateWnd == NULL )
- pTargetUpdateWnd = GetParent();
- ASSERT( pTargetUpdateWnd != NULL );
- }
- if( pTargetUpdateWnd == NULL )
- return;
- ASSERT_VALID( pTargetUpdateWnd );
- if( ( GetStyle() & WS_VISIBLE ) == 0
- && ( ! m_bUseInvisibleCmdUI )
- )
- return;
- int nCountOfButtons = _GetButtonsCountImpl();
- for( int nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- pTBB->OnUpdateCmdUI(
- pTargetUpdateWnd,
- bDisableIfNoHndler,
- nBtnIdx
- );
- }
- // update the dialog controls added to the toolbar
- UpdateDialogControls(pTargetUpdateWnd, bDisableIfNoHndler);
- }
- void CExtToolControlBar::_UpdateButton( int nIndex )
- {
- CWnd * pTarget = GetOwner();
- if( pTarget == NULL && ( ! m_bPresubclassDialogMode ) )
- pTarget = GetParentFrame();
- if( pTarget == NULL )
- return;
- BOOL bDisableIfNoHandler = TRUE;
- if( pTarget->IsKindOf( RUNTIME_CLASS(CFrameWnd) ) )
- bDisableIfNoHandler = ((CFrameWnd *)pTarget)->m_bAutoMenuEnable;
- CExtBarButton * pTBB = _GetButtonPtr( nIndex );
- if( pTBB == NULL )
- return;
- ASSERT_VALID( pTBB );
- pTBB->OnUpdateCmdUI( pTarget, bDisableIfNoHandler, nIndex );
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolControlBar diagnostics
- #ifdef _DEBUG
- void CExtToolControlBar::AssertValid() const
- {
- CExtControlBar::AssertValid();
- }
- void CExtToolControlBar::Dump(CDumpContext& dc) const
- {
- CExtControlBar::Dump(dc);
- }
- #endif
- CSize CExtToolControlBar::_GetDefButtonSize() const
- {
- ASSERT_VALID( this );
- return CSize( 23, 22 );
- }
- int CExtToolControlBar::_GetIndexOf( CExtBarButton * pTBB )
- {
- if( pTBB == NULL )
- return -1;
- int nCountOfButtons = (int)m_buttons.GetSize();
- for( int nBtnIdx=0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- ASSERT( m_buttons[nBtnIdx] != NULL );
- if( m_buttons[nBtnIdx] == pTBB )
- return nBtnIdx;
- }
- return -1;
- }
- // input CRect should be client rectangle size
- void CExtToolControlBar::_CalcInsideRect(CRect& rect, BOOL bHorz) const
- {
- ASSERT_VALID(this);
- if( ! (((CExtToolControlBar*)this)->_AdjustBGInfo()) )
- {
- CControlBar::CalcInsideRect(rect,bHorz);
- return;
- }
- DWORD dwStyle = m_dwStyle;
- if( (dwStyle&CBRS_BORDER_LEFT) != 0 )
- rect.left += afxData.cxBorder2;
- if( (dwStyle&CBRS_BORDER_TOP) != 0 )
- rect.top += afxData.cyBorder2;
- if( (dwStyle&CBRS_BORDER_RIGHT) != 0 )
- rect.right -= afxData.cxBorder2;
- if( (dwStyle&CBRS_BORDER_BOTTOM) != 0 )
- rect.bottom -= afxData.cyBorder2;
- rect.left += m_cxLeftBorder;
- rect.top += m_cyTopBorder;
- rect.right -= m_cxRightBorder;
- rect.bottom -= m_cyBottomBorder;
- // if( (m_dwStyle&(CBRS_GRIPPER|CBRS_FLOATING)) == CBRS_GRIPPER )
- // {
- // if( bHorz )
- // {
- // INT nGripWidth = _GripperWidthAtLeftGet();
- // if( nGripWidth >= 0 )
- // rect.left += nGripWidth;
- // } // if( bHorz )
- // else
- // {
- // INT nGripHeight = _GripperHeightAtTopGet();
- // if( nGripHeight >= 0 )
- // rect.top += nGripHeight;
- // } // else from if( bHorz )
- // } // if( (m_dwStyle&(CBRS_GRIPPER|CBRS_FLOATING)) == CBRS_GRIPPER )
- }
- bool CExtToolControlBar::OnQueryShiftRTL() const
- {
- ASSERT_VALID( this );
- return false;
- }
- bool CExtToolControlBar::OnQueryRevertRTL() const
- {
- ASSERT_VALID( this );
- return false;
- }
- void CExtToolControlBar::_RecalcPositionsImpl()
- {
- if( GetSafeHwnd() == NULL
- || (! ::IsWindow( GetSafeHwnd() ) )
- )
- return;
- ASSERT_VALID(this);
- int nCountOfButtons = _GetButtonsCountImpl();
- if( nCountOfButtons == 0 )
- return;
- CExtBarButton::e_wrap_t _evt = GetBtnWrapCode();
- BOOL bHorz = (m_dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE;
- BOOL bFloating = IsFloating();
- bool bMultiRowLayout = OnQueryMultiRowLayout();
- CRect rcInner;
- GetClientRect( &rcInner );
- CExtPaintManager::e_paint_manager_name_t ePMN =
- PmBridge_GetPM()->OnQueryPaintManagerName();
- if( ! bFloating )
- {
- if( bMultiRowLayout )
- {
- // if( bHorz )
- // rcInner.OffsetRect( 0, 2 /*- PmBridge_GetPM()->GetPushedOffset().cy*/ );
- // else
- // rcInner.OffsetRect( -2, 0 );
- UINT nMetric = 0;
- if( ePMN == CExtPaintManager::Office2000
- || ePMN == CExtPaintManager::OfficeXP
- )
- nMetric = 1;
- if( bHorz )
- rcInner.OffsetRect( 0, 2 - nMetric );
- else
- rcInner.OffsetRect( -2 + nMetric, 0 );
- }
- } // if( ! bFloating )
- CPoint ptLimitTL = rcInner.TopLeft();
- CPoint ptLimitBR = rcInner.BottomRight();
- 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 ))
- ;
- CClientDC dc(this);
- CFont* pOldFont = dc.SelectObject( pFont );
- ASSERT( pOldFont != NULL );
- CSize sizeDefButton = _GetDefButtonSize();
- int nReviewCount = nCountOfButtons;
- CSize sizeTBBRight( 0, 0 );
- if( m_pRightBtn != NULL )
- {
- nReviewCount--;
- ASSERT_VALID( m_pRightBtn );
- ASSERT( m_buttons.GetSize() > 0 );
- ASSERT( m_buttons[nReviewCount] == m_pRightBtn );
- m_pRightBtn->GetButtons().RemoveAll();
- m_pRightBtn->ClearContent();
- sizeTBBRight =
- m_pRightBtn->CalculateLayout(
- dc,
- sizeDefButton,
- bHorz || m_bPaletteMode
- );
- if( bFloating || m_bPaletteMode )
- {
- m_pRightBtn->Show( false );
- m_pRightBtn->SetRect(
- CRect( ptLimitTL, sizeTBBRight )
- );
- if( nReviewCount == 0 )
- return;
- } // if( bFloating || m_bPaletteMode )
- else
- {
- CRect rcCalcRightBtn(
- bHorz ? (ptLimitBR.x - sizeTBBRight.cx) : ptLimitTL.x,
- bHorz ? ptLimitTL.y : (ptLimitBR.y - sizeTBBRight.cy),
- ptLimitBR.x,
- ptLimitBR.y
- );
- if( bMultiRowLayout
- && ( ePMN == CExtPaintManager::Office2000
- || ePMN == CExtPaintManager::OfficeXP
- || ePMN == CExtPaintManager::ProfSkinPainter
- )
- )
- {
- INT nMetric = 1;
- if( ePMN == CExtPaintManager::ProfSkinPainter )
- nMetric = 2;
- if( bHorz )
- rcCalcRightBtn.OffsetRect( 0, -nMetric );
- else
- rcCalcRightBtn.OffsetRect( nMetric, 0 );
- }
- m_pRightBtn->SetRect( rcCalcRightBtn );
- m_pRightBtn->Show( true );
- const CSize _sizeRoundedAreaMerics =
- PmBridge_GetPM()->FixedBar_GetRoundedAreaMerics();
- if( bHorz )
- rcInner.right -= sizeTBBRight.cx + _sizeRoundedAreaMerics.cx;
- else
- rcInner.bottom -= sizeTBBRight.cy + _sizeRoundedAreaMerics.cy;
- } // else from if( bFloating || m_bPaletteMode )
- } // if( m_pRightBtn != NULL )
- // if( bMultiRowLayout
- // //&& (! m_bInsideCalcLayout )
- // && m_pDockBar != NULL
- // && (! IsFloating() )
- // )
- // {
- // CRect rcWrap;
- // if( _GetFullRowMode() )
- // m_pDockBar->GetClientRect( &rcWrap );
- // else
- // rcWrap = rcInner;
- // //if( IsDockedHorizontally() )
- // // _WrapToolBarH( rcWrap.Width(), rcWrap.Height() );
- // //else
- // // _WrapToolBarV( rcWrap.Height() );
- // BOOL bVert = IsDockedVertically();
- // _SizeToolBar(
- // bVert ? rcWrap.Height() : rcWrap.Width(),
- // bVert
- // );
- // }
- CArray < CRect, CRect > arrBtnRects;
- CArray < BOOL, BOOL > arrBtnVisibility;
- CArray < BOOL, BOOL > arrBtnSeparators;
- //CArray < BOOL, BOOL > arrBtnEnabled;
- arrBtnRects.SetSize( nReviewCount );
- arrBtnVisibility.SetSize( nReviewCount );
- arrBtnSeparators.SetSize( nReviewCount );
- // arrBtnEnabled.SetSize( nReviewCount );
- CSize sizeLastWrappedRow( 0, 0 );
- //bool bDockerTrasparentMode =
- // PmBridge_GetPM()->GetCb2DbTransparentMode( this );
- // if( (! bFloating ) && bMultiRowLayout )
- // {
- // if( bHorz && bDockerTrasparentMode )
- // ptLimitTL.y += 1;
- // else if( !bHorz )
- // {
- // if( bDockerTrasparentMode )
- // ptLimitBR.x -= 2;
- // else
- // ptLimitBR.x -= 1;
- // ptLimitTL.y -= 1;
- // }
- // } // if( (! bFloating ) && bMultiRowLayout )
- CPoint ptBtnPosCurr( ptLimitTL );
- INT nRowExtent = sizeDefButton.cy;
- if( bMultiRowLayout && (!bHorz) )
- {
- ptBtnPosCurr.x = ptLimitBR.x;
- nRowExtent = sizeDefButton.cx;
- }
- BOOL bSeparatorPrev = FALSE, bPostResyncAllowed = FALSE;
- INT nRowDistance = PmBridge_GetPM()->FixedBar_GetRowDistance( this );
- int nBtnIdx = 0;
- for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- BOOL bVisibleTBB =
- ( pTBB->GetStyle() & TBBS_HIDDEN ) ? FALSE : TRUE;
- if( pTBB->IsSeparator()
- && nBtnIdx < (nReviewCount-1)
- )
- {
- CExtBarButton * pNextTBB = _GetButtonPtr( nBtnIdx+1 );
- ASSERT_VALID( pNextTBB );
- if( pNextTBB->GetStyle() & TBBS_HIDDEN )
- bVisibleTBB = FALSE;
- }
- arrBtnVisibility.SetAt( nBtnIdx, bVisibleTBB );
- if( ! bVisibleTBB )
- continue;
- pTBB->SetVertDocked( (bHorz || m_bPaletteMode) ? false : true );
- // arrBtnEnabled.SetAt( nBtnIdx, pTBB->IsEnabled() );
- BOOL bSeparator = pTBB->IsSeparator();
- arrBtnSeparators.SetAt( nBtnIdx, bSeparator );
- if( (bSeparatorPrev && bSeparator) || (bSeparator && nBtnIdx == 0) )
- { // remove double separators
- arrBtnVisibility.SetAt( nBtnIdx, FALSE );
- continue;
- } // remove double separators
- CSize sizeTBB =
- pTBB->CalculateLayout(
- dc,
- sizeDefButton,
- bHorz || m_bPaletteMode
- );
-
- CRect rcTBB( ptBtnPosCurr, sizeTBB );
- if( bMultiRowLayout && (!bHorz) )
- nRowExtent = max( nRowExtent, sizeTBB.cx );
- else
- nRowExtent = max( nRowExtent, sizeTBB.cy );
- if( ( bFloating
- || bMultiRowLayout
- || m_bPaletteMode
- )
- && pTBB->IsWrap( _evt )
- )
- {
- if( bMultiRowLayout && (!bHorz) )
- {
- ptBtnPosCurr.y = ptLimitTL.y;
- ptBtnPosCurr.x -=
- nRowExtent
- + nRowDistance;
- sizeLastWrappedRow = CSize( 0, 0 );
- nRowExtent = sizeDefButton.cx;
- } // if( bMultiRowLayout && (!bHorz) )
- else
- {
- ptBtnPosCurr.x = ptLimitTL.x;
- ptBtnPosCurr.y +=
- nRowExtent // sizeDefButton.cy (+ v.2.22)
- + nRowDistance;
- sizeLastWrappedRow = CSize( 0, 0 );
- nRowExtent = sizeDefButton.cy;
- } // else from if( bMultiRowLayout && (!bHorz) )
- } // if( (bFloating || ...
- else
- {
- bool bResyncVisibleTBB = false;
- if( bHorz || m_bPaletteMode )
- {
- ptBtnPosCurr.x += sizeTBB.cx;
- if( (!bMultiRowLayout)
- && ptBtnPosCurr.x > rcInner.right
- )
- bResyncVisibleTBB = true;
- } // if( bHorz || m_bPaletteMode )
- else
- {
- ptBtnPosCurr.y += sizeTBB.cy;
- if( (!bMultiRowLayout)
- && ptBtnPosCurr.y > rcInner.bottom
- )
- bResyncVisibleTBB = true;
- } // else from if( bHorz || m_bPaletteMode )
- if( bResyncVisibleTBB )
- {
- int nSpaceToFind =
- ( bHorz || m_bPaletteMode )
- ? ptBtnPosCurr.x - rcInner.right
- : ptBtnPosCurr.y - rcInner.bottom;
- int nBtnWithNearestWidth = nBtnIdx;
- int nNearestMetric =
- ( bHorz || m_bPaletteMode )
- ? rcTBB.Width() : rcTBB.Height();
- int nNearestDiff = nSpaceToFind - nNearestMetric;
- // hide nearest by size reviewed visible
- int nBtnIdx2 = 0;
- for( nBtnIdx2 = nBtnIdx-1; nBtnIdx2 >= 0; nBtnIdx2-- )
- {
- if( ! arrBtnVisibility[nBtnIdx2] )
- continue;
- if( arrBtnSeparators[nBtnIdx2] )
- continue;
- #ifdef _DEBUG
- CExtBarButton * pTBB2 =
- _GetButtonPtr( nBtnIdx2 );
- ASSERT( (pTBB2->GetStyle() & TBBS_HIDDEN) == 0 );
- #endif // _DEBUG
- int nMetric =
- ( bHorz || m_bPaletteMode )
- ? arrBtnRects[nBtnIdx2].Width()
- : arrBtnRects[nBtnIdx2].Height();
- //if( nMetric <= nNearestMetric ) // <<-- widest search algorithm
- // continue;
- if( nMetric > nSpaceToFind )
- continue;
- int nDiff = nSpaceToFind - nMetric;
- // if( ! arrBtnEnabled[nBtnIdx2] )
- // { // hide disabled buttons first
- // nNearestDiff = nDiff;
- // nNearestMetric = nMetric;
- // nBtnWithNearestWidth = nBtnIdx2;
- // break;
- // } // hide disabled buttons first
- if( nDiff >= nNearestDiff )
- continue;
- nNearestDiff = nDiff;
- nNearestMetric = nMetric;
- nBtnWithNearestWidth = nBtnIdx2;
- } // for( nBtnIdx2 = nBtnIdx-1; nBtnIdx2 >= 0; nBtnIdx2-- )
- if( nBtnWithNearestWidth < nBtnIdx )
- {
- ASSERT( bVisibleTBB );
- arrBtnVisibility.SetAt( nBtnWithNearestWidth, FALSE );
- if( (! m_bPaletteMode )
- && (! bMultiRowLayout )
- && (! IsFloating() )
- )
- bPostResyncAllowed = TRUE;
- if( m_pRightBtn!=NULL && !arrBtnSeparators[nBtnWithNearestWidth] )
- {
- CExtBarButton * pTBB2 =
- _GetButtonPtr( nBtnWithNearestWidth );
- ASSERT_VALID( pTBB2 );
- m_pRightBtn->GetButtons().Add( pTBB2 );
- }
- if( nBtnWithNearestWidth > 0 && nBtnWithNearestWidth < nReviewCount-1 )
- { // remove double separators
- if( arrBtnSeparators[nBtnWithNearestWidth-1]
- && arrBtnSeparators[nBtnWithNearestWidth+1]
- )
- {
- arrBtnVisibility.SetAt( nBtnWithNearestWidth-1, FALSE );
- nNearestMetric +=
- ( bHorz || m_bPaletteMode )
- ? arrBtnRects[nBtnWithNearestWidth-1].Width()
- : arrBtnRects[nBtnWithNearestWidth-1].Height();
- }
- } // remove double separators
- rcTBB.OffsetRect(
- ( bHorz || m_bPaletteMode ) ? -nNearestMetric : 0,
- ( bHorz || m_bPaletteMode ) ? 0 : -nNearestMetric
- );
- ( ( bHorz || m_bPaletteMode ) ? ptBtnPosCurr.x : ptBtnPosCurr.y) -= nNearestMetric;
- for( nBtnIdx2 = nBtnWithNearestWidth+1; nBtnIdx2 < nBtnIdx; nBtnIdx2++ )
- {
- if( !arrBtnVisibility[nBtnIdx2] )
- continue;
- CRect rcTBB2 = arrBtnRects[nBtnIdx2];
- rcTBB2.OffsetRect(
- ( bHorz || m_bPaletteMode ) ? -nNearestMetric : 0,
- ( bHorz || m_bPaletteMode ) ? 0 : -nNearestMetric
- );
- arrBtnRects.SetAt( nBtnIdx2, rcTBB2 );
- } // for( nBtnIdx2 = nBtnWithNearestWidth+1; nBtnIdx2 < nBtnIdx; nBtnIdx2++ )
- } // if( nBtnWithNearestWidth < nBtnIdx )
- else
- {
- ASSERT( nBtnWithNearestWidth == nBtnIdx );
- bVisibleTBB = FALSE;
- if( (! m_bPaletteMode )
- && (! bMultiRowLayout )
- && (! IsFloating() )
- )
- bPostResyncAllowed = TRUE;
- ( (bHorz || m_bPaletteMode ) ? ptBtnPosCurr.x : ptBtnPosCurr.y) -=
- ( (bHorz || m_bPaletteMode ) ? sizeTBB.cx : sizeTBB.cy);
- } // else from if( nBtnWithNearestWidth < nBtnIdx )
- } // if( bResyncVisibleTBB )
- } // else from if( (bFloating || ...
- arrBtnVisibility.SetAt( nBtnIdx, bVisibleTBB );
- if( bMultiRowLayout && (!bHorz) )
- {
- CRect rcTBB2( rcTBB );
- rcTBB2.OffsetRect( -rcTBB.Width(), 0 );
- arrBtnRects.SetAt( nBtnIdx, rcTBB2 );
- }
- else
- {
- arrBtnRects.SetAt( nBtnIdx, rcTBB );
- }
- if( bVisibleTBB )
- bSeparatorPrev = bSeparator;
- if( m_pRightBtn != NULL
- && (!bMultiRowLayout)
- && (!bVisibleTBB)
- && (!bSeparator)
- )
- m_pRightBtn->GetButtons().Add( pTBB );
- } // for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- dc.SelectObject( pOldFont );
- if( bPostResyncAllowed )
- {
- ASSERT( ! IsFloating() );
- ASSERT( ! m_bPaletteMode );
- ASSERT( ! bMultiRowLayout );
- INT nVisIdx0 = -1, nVisIdx1 = -1;
- for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- if( ! arrBtnVisibility[nBtnIdx] )
- continue;
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- break;
- if( nVisIdx0 < 0 )
- nVisIdx0 = nBtnIdx;
- nVisIdx1 = nBtnIdx;
- } // for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- if( nVisIdx0 >= 0 )
- {
- ASSERT( nVisIdx1 >= nVisIdx0 );
- INT nShiftMetric = 0;
- for( ; nVisIdx0 <= nVisIdx1; nVisIdx0++ )
- {
- if( ! arrBtnVisibility[nVisIdx0] )
- break;
- CExtBarButton * pTBB = _GetButtonPtr( nVisIdx0 );
- ASSERT_VALID( pTBB );
- ASSERT( ! pTBB->IsKindOf( RUNTIME_CLASS( CExtBarContentExpandButton ) ) );
- if( ! pTBB->IsSeparator() )
- break;
- arrBtnVisibility[nVisIdx0] = FALSE;
- if( bHorz )
- nShiftMetric -= arrBtnRects[nVisIdx0].Width();
- else
- nShiftMetric -= arrBtnRects[nVisIdx0].Height();
- }
- for( ; nVisIdx1 >= nVisIdx0; nVisIdx1-- )
- {
- if( ! arrBtnVisibility[nVisIdx1] )
- break;
- CExtBarButton * pTBB = _GetButtonPtr( nVisIdx1 );
- ASSERT_VALID( pTBB );
- ASSERT( ! pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) );
- if( ! pTBB->IsSeparator() )
- break;
- arrBtnVisibility[nVisIdx1] = FALSE;
- }
- if( nShiftMetric != 0 )
- {
- for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- if( ! arrBtnVisibility[nBtnIdx] )
- continue;
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton)) )
- break;
- arrBtnRects.ElementAt( nBtnIdx ).OffsetRect(
- bHorz ? nShiftMetric : 0,
- bHorz ? 0 : nShiftMetric
- );
- } // for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- } // if( nShiftMetric != 0 )
- } // if( nVisIdx0 >= 0 )
- } // if( bPostResyncAllowed )
- INT nRowStart = 0;
- INT nSizeRow = 0;
- INT nSubRowCount = 0;
- bool bReAlignHorz =
- ( bHorz
- || bFloating
- || m_bPaletteMode
- ) ? true : false;
- if( bMultiRowLayout && (!bHorz) )
- bReAlignHorz = false;
- bool bShiftRTL = OnQueryShiftRTL();
- if( ! bReAlignHorz )
- bShiftRTL = false;
- if( bShiftRTL )
- { // do content shift to right
- CRect rcAlign = rcInner;
- INT nAdditionalShift = 0;
- for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- BOOL bVis = arrBtnVisibility[nBtnIdx];
- if( ! bVis )
- continue;
- CSize sizeTBB = *pTBB;
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- && (! pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton)) )
- )
- {
- nSizeRow = 0;
- nRowStart = nBtnIdx + 1;
- //Align.left += sizeTBB.cx;
- nAdditionalShift = - sizeTBB.cx;
- if( nAdditionalShift == 0 )
- nAdditionalShift = - 20;
- continue;
- }
- nSizeRow += sizeTBB.cx;
- bool bWrap =
- ( ( bFloating
- || bMultiRowLayout
- || m_bPaletteMode
- )
- && pTBB->IsWrap(_evt)
- )
- ? true : false;
- if( (! bWrap)
- && pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- )
- bWrap = true;
- if( bWrap
- || nBtnIdx == (nReviewCount-1)
- )
- {
- INT nShift =
- rcAlign.Width()
- - nSizeRow
- + nAdditionalShift
- - 7
- ;
- for( INT nBtnIdx2 = nRowStart; nBtnIdx2 <= nBtnIdx; nBtnIdx2++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx2 );
- ASSERT_VALID( pTBB );
- BOOL bVis2 = arrBtnVisibility[nBtnIdx2];
- if( ! bVis2 )
- continue;
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- && (! pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton)) )
- )
- continue;
- CRect rcBtn = arrBtnRects[nBtnIdx2];
- rcBtn.OffsetRect( nShift, 0 );
- // if( bFloating )
- // rcBtn.OffsetRect( -3, 0 );
- arrBtnRects.SetAt( nBtnIdx2, rcBtn );
- }
- nRowStart = nBtnIdx + 1;
- nSizeRow = 0;
- nSubRowCount++;
- rcAlign = rcInner;
- nAdditionalShift = 0;
- }
- } // for( int nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- // reset vars
- nRowStart = 0;
- nSizeRow = 0;
- nSubRowCount = 0;
- } // do content shift to right
- for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- CSize sizeTBB = *pTBB;
- INT nSizeBtn = bReAlignHorz ? sizeTBB.cy : sizeTBB.cx;
- nSizeRow = max( nSizeRow, nSizeBtn );
- if( ( ( bFloating
- || bMultiRowLayout
- || m_bPaletteMode
- )
- && pTBB->IsWrap(_evt)
- )
- || nBtnIdx == ( nReviewCount - 1 )
- )
- {
- for( INT nBtnIdx2 = nRowStart; nBtnIdx2 <= nBtnIdx; nBtnIdx2++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx2 );
- ASSERT_VALID( pTBB );
- BOOL bVis = arrBtnVisibility[nBtnIdx2];
- pTBB->Show( bVis ? true : false );
- if( ! bVis )
- continue;
- CRect rcBtn = arrBtnRects[nBtnIdx2];
- if( pTBB->IsSeparator() )
- {
- if( bReAlignHorz )
- rcBtn.bottom = rcBtn.top + nSizeRow;
- else
- rcBtn.left = rcBtn.right - nSizeRow;
- } // if( pTBB->IsSeparator() )
- else
- {
- if( bReAlignHorz )
- rcBtn.OffsetRect(
- 0,
- ( nSizeRow - rcBtn.Height() ) / 2
- );
- else
- rcBtn.OffsetRect(
- - ( nSizeRow - rcBtn.Width() ) / 2,
- 0
- );
- } // else from if( pTBB->IsSeparator() )
- if( bFloating
- // || bMultiRowLayout
- )
- //rcBtn.OffsetRect( 0, 1 );
- rcBtn.OffsetRect( 2, 1 );
- pTBB->SetRect( rcBtn );
- }
- nRowStart = nBtnIdx + 1;
- nSizeRow = 0;
- nSubRowCount++;
- }
- } // for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- if( nSubRowCount == 1 && (!m_bPaletteMode) && (!bFloating) && (!bMultiRowLayout) )
- {
- CRect rcBarClient;
- GetClientRect( &rcBarClient );
- nSizeRow = bHorz
- ? rcBarClient.Height()
- : rcBarClient.Width()
- ;
- for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- BOOL bVis = arrBtnVisibility[nBtnIdx];
- if( ! bVis )
- continue;
- CRect rcBtn( pTBB->Rect() );
- // if( pTBB->IsSeparator() )
- // {
- // if( bHorz )
- // {
- // rcBtn.top = m_cyTopBorder;
- // rcBtn.bottom = m_cyBottomBorder + nSizeRow;
- // } // if( bHorz )
- // else
- // {
- // rcBtn.left = m_cxLeftBorder;
- // rcBtn.right = m_cxRightBorder + nSizeRow;
- // } // else from if( bHorz )
- // } // if( pTBB->IsSeparator() )
- // else
- {
- rcBtn.OffsetRect(
- bHorz
- ? 0
- : ( ( nSizeRow - rcBtn.Width() ) / 2 - rcBtn.left)
- ,
- bHorz
- ? ( ( nSizeRow - rcBtn.Height() ) / 2 - rcBtn.top)
- : 0
- );
- } // else from if( pTBB->IsSeparator() )
- pTBB->SetRect( rcBtn );
- } // for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- } // if( nSubRowCount == 1 && (!m_bPaletteMode) && (!bFloating) && (!bMultiRowLayout) )
- else if( ! m_bPaletteMode )
- { // just re-align separators in each row
- INT nRowMinLoc = 0, nRowMaxLoc = 0;
- INT nRowStart = 0;
- for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsVisible()
- && (pTBB->GetStyle() & TBBS_HIDDEN) == 0
- )
- {
- CRect rcTBB = *pTBB;
- if( nBtnIdx == nRowStart )
- {
- if( bHorz )
- {
- nRowMinLoc = rcTBB.top;
- nRowMaxLoc = rcTBB.bottom;
- } // if( bHorz )
- else
- {
- nRowMinLoc = rcTBB.left;
- nRowMaxLoc = rcTBB.right;
- } // else from if( bHorz )
- } // if( nBtnIdx == nRowStart )
- else
- {
- if( bHorz )
- {
- nRowMinLoc = min( nRowMinLoc, rcTBB.top );
- nRowMaxLoc = max( nRowMaxLoc, rcTBB.bottom );
- } // if( bHorz )
- else
- {
- nRowMinLoc = min( nRowMinLoc, rcTBB.left );
- nRowMaxLoc = max( nRowMaxLoc, rcTBB.right );
- } // else from if( bHorz )
- } // else from if( nBtnIdx == nRowStart )
- } // if( pTBB->IsVisible() ...
- if( (! pTBB->IsWrap(_evt) )
- && nBtnIdx != (nReviewCount-1)
- )
- continue;
- for( INT nBtnIdx2 = nRowStart; nBtnIdx2 < nBtnIdx; nBtnIdx2++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx2 );
- ASSERT_VALID( pTBB );
- if( (! pTBB->IsVisible() )
- || (pTBB->GetStyle() & TBBS_HIDDEN) != 0
- || (! pTBB->IsSeparator() )
- )
- continue;
- CRect rcTBB = *pTBB;
- if( bHorz )
- {
- rcTBB.top = nRowMinLoc;
- rcTBB.bottom = nRowMaxLoc;
- // rcTBB.InflateRect(
- // 0,
- // bDockerTrasparentMode ? 2 : 1
- // );
- } // if( bHorz )
- else
- {
- rcTBB.left = nRowMinLoc;
- rcTBB.right = nRowMaxLoc;
- // rcTBB.InflateRect(
- // bDockerTrasparentMode ? 2 : 1,
- // 0,
- // bDockerTrasparentMode ? 3 : 2,
- // 0
- // );
- } // else from if( bHorz )
- pTBB->SetRect( rcTBB );
- } // for( INT nBtnIdx2 = nRowStart; nBtnIdx2 < nBtnIdx; nBtnIdx2++ )
- nRowStart = nBtnIdx + 1;
- } // for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- } // just re-align separators in each row
- // remove TBBS_HIDDEN in right menu
- if( (!m_bPaletteMode) && m_pRightBtn != NULL )
- {
- int nMenuCount = (int)m_pRightBtn->GetButtons().GetSize();
- for( int nMenuIdx = 0; nMenuIdx < nMenuCount; )
- {
- CExtBarButton * pTBB =
- m_pRightBtn->GetButtons().
- GetAt( nMenuIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->GetStyle() & TBBS_HIDDEN )
- {
- m_pRightBtn->GetButtons().RemoveAt( nMenuIdx );
- nMenuCount--;
- } // if( pTBB->GetStyle() & TBBS_HIDDEN )
- else
- nMenuIdx++;
- } // for( int nMenuIdx = 0; nMenuIdx < nMenuCount; )
- } // if( (!m_bPaletteMode) && m_pRightBtn != NULL )
-
- if( m_pRightBtn != NULL && m_bPresubclassDialogMode )
- {
- if( m_pRightBtn->GetButtons().GetSize() == 0 )
- m_pRightBtn->ModifyStyle( TBBS_DISABLED, 0 );
- else
- m_pRightBtn->ModifyStyle( 0, TBBS_DISABLED );
- }
- // hide first separator(s)
- if( ! m_bPaletteMode )
- {
- INT nWalkCount = _GetButtonsCountImpl();
- for( nBtnIdx = 0; nBtnIdx < nWalkCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsVisible()
- && ( pTBB->GetStyle() & TBBS_HIDDEN ) == 0
- )
- {
- if( pTBB->IsSeparator() )
- {
- pTBB->ModifyStyle( TBBS_HIDDEN, 0 );
- pTBB->Show( false );
- continue;
- }
- else
- break;
- }
- } // for( nBtnIdx = 0; nBtnIdx < nWalkCount; nBtnIdx++ )
- }
- // insert separators into right button
- if( !( bFloating
- || bMultiRowLayout
- || m_bPaletteMode
- || bMultiRowLayout
- || m_pRightBtn == NULL
- || ( m_pRightBtn != NULL
- && m_pRightBtn->GetButtons().GetSize() == 0
- )
- )
- )
- {
- int nHiddenCount = (int)m_pRightBtn->GetButtons().GetSize();
- if( nHiddenCount >= 2 )
- {
- int nEndMeasure = nHiddenCount-1;
- for( int iHidden = 0; iHidden < nEndMeasure; iHidden++ )
- {
- CExtBarButton * pTbbHidden0 =
- m_pRightBtn->GetButtons().GetAt(iHidden);
- ASSERT( pTbbHidden0 != NULL );
- ASSERT( ! pTbbHidden0->IsSeparator() );
- ASSERT( (! pTbbHidden0->IsVisible()) && (pTbbHidden0->GetStyle() & TBBS_HIDDEN) == 0 );
- CExtBarButton * pTbbHidden1 =
- m_pRightBtn->GetButtons().GetAt(iHidden+1);
- ASSERT( pTbbHidden1 != NULL );
- ASSERT( ! pTbbHidden1->IsSeparator() );
- ASSERT( (! pTbbHidden1->IsVisible()) && (pTbbHidden1->GetStyle() & TBBS_HIDDEN) == 0 );
- CExtBarButton * pTbbSeparatorToInsert = NULL;
- int nIdx0=-1,nIdx1=-1;
- for( nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB == pTbbHidden0 )
- {
- nIdx0 = nBtnIdx;
- ASSERT( nIdx1 < 0 );
- continue;
- }
- if( nIdx0 >= 0
- && pTBB->IsSeparator()
- && pTbbSeparatorToInsert == NULL
- )
- pTbbSeparatorToInsert = pTBB;
- if( pTBB == pTbbHidden1 )
- {
- nIdx1 = nBtnIdx;
- ASSERT( nIdx0 >= 0 && nIdx0 < nIdx1 );
- break;
- }
- }
- ASSERT(
- nIdx0 < nIdx1
- &&
- nIdx0 >= 0 && nIdx0 < nCountOfButtons
- &&
- nIdx1 >= 0 && nIdx1 < nCountOfButtons
- );
- if( (nIdx0+1) == nIdx1 )
- continue;
- if( pTbbSeparatorToInsert != NULL )
- {
- nEndMeasure++;
- iHidden++;
- m_pRightBtn->GetButtons().InsertAt(
- iHidden,
- pTbbSeparatorToInsert
- );
- }
- } // for( int iHidden = 0; iHidden < nEndMeasure; iHidden++ )
- } // if( nHiddenCount >= 2 )
- }
- // offset buttons according to the theme NC metrics
- if( ! bFloating )
- {
- CSize _sizeButtonOffset( 0, 0 );
- if( m_bPaletteMode )
- {
- if( bHorz )
- _sizeButtonOffset.cy = 2;
- else
- _sizeButtonOffset.cx = 2;
- } // if( m_bPaletteMode )
- _sizeButtonOffset += PmBridge_GetPM()->GetToolBarButtonOffset( bHorz );
- if( _sizeButtonOffset.cx != 0 || _sizeButtonOffset.cy != 0 )
- {
- for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsVisible()
- && (pTBB->GetStyle() & TBBS_HIDDEN) == 0
- )
- {
- CRect rcTBB = *pTBB;
- rcTBB.OffsetRect( _sizeButtonOffset );
- pTBB->SetRect( rcTBB );
- }
- } // for( nBtnIdx = 0; nBtnIdx < nReviewCount; nBtnIdx++ )
- } // if( _sizeButtonOffset.cx != 0 || _sizeButtonOffset.cy != 0 )
- } // if( ! bFloating )
- }
- DWORD CExtToolControlBar::RecalcDelayShow(AFX_SIZEPARENTPARAMS* lpLayout)
- {
- DWORD dwRes = CControlBar::RecalcDelayShow( lpLayout );
- if( (!IsFloating()) && IsVisible() )
- _RecalcPositionsImpl();
- return dwRes;
- }
- void CExtToolControlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
- {
- ASSERT_VALID( this );
- if( _AdjustBGInfo() )
- {
- // INT nGripWidthAtLeft = 0, nGripHeightAtTop = 0;
- // if( (GetBarStyle()&CBRS_GRIPPER) != 0 )
- // {
- // nGripWidthAtLeft =
- // PmBridge_GetPM()->Bar_GripperWidthAtLeftGet( this );
- // nGripHeightAtTop =
- // PmBridge_GetPM()->Bar_GripperHeightAtTopGet( this );
- // if( nGripWidthAtLeft < 0 )
- // nGripWidthAtLeft = 0;
- // if( nGripHeightAtTop < 0 )
- // nGripHeightAtTop = 0;
- // } // if( (GetBarStyle()&CBRS_GRIPPER) != 0 )
- // _GripperWidthAtLeftSet( nGripWidthAtLeft );
- // _GripperHeightAtTopSet( nGripHeightAtTop );
- lpncsp->rgrc[0].left += m_cxLeftBorder;
- lpncsp->rgrc[0].top += m_cyTopBorder;
- lpncsp->rgrc[0].right -= m_cxRightBorder;
- lpncsp->rgrc[0].bottom -= m_cyBottomBorder;
- return;
- }
- CExtControlBar::OnNcCalcSize(bCalcValidRects,lpncsp);
- }
- void CExtToolControlBar::OnSize(UINT nType, int cx, int cy)
- {
- CExtControlBar::OnSize(nType, cx, cy);
- if( _DraggingGetBar() != this )
- _RecalcLayoutImpl();
- else
- _RecalcPositionsImpl();
- }
- void CExtToolControlBar::_RecalcLayoutImpl()
- {
- if( GetSafeHwnd() == NULL
- || !::IsWindow( GetSafeHwnd() )
- )
- return;
- CExtControlBar::_RecalcLayoutImpl();
- _RecalcPositionsImpl();
- Invalidate();
- if( m_bPresubclassDialogMode )
- UpdateWindow();
- }
- void CExtToolControlBar::_RibbonPageRslaResetStateData()
- {
- ASSERT_VALID( this );
- }
- LRESULT CExtToolControlBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if( message == WM_TIMER && wParam == 0x444 )
- {
- if( CExtPopupMenuWnd::IsMenuTracking()
- || g_bMenuTracking
- || _DraggingGetBar() != NULL
- )
- return 0;
- KillTimer( 0x444 );
- CFrameWnd * pFrame = GetParentFrame();
- if( pFrame != NULL )
- {
- ASSERT_VALID( pFrame );
- pFrame->RecalcLayout();
- if( pFrame->IsKindOf( RUNTIME_CLASS(CMiniDockFrameWnd) ) )
- pFrame->SendMessage( WM_NCPAINT );
- } // if( pFrame != NULL )
- return 0;
- } // if( message == WM_TIMER && wParam == 0x444 )
- if( message == WM_WINDOWPOSCHANGED )
- {
- _RecalcPositionsImpl();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite != NULL && pSite->IsCustomizeMode() )
- pSite->ActiveItemSet();
- #endif //(!defined __EXT_MFC_NO_CUSTOMIZE)
- // CExtControlBar * pDraggedBar = _DraggingGetBar();
- // if( pDraggedBar == NULL
- // || pDraggedBar != this
- // )
- // _RecalcLayoutImpl();
- } // if( message == WM_WINDOWPOSCHANGED )
- switch( message )
- {
- case WM_WINDOWPOSCHANGED:
- case WM_SIZE:
- _RedrawOnPosChanged();
- break;
- case WM_DESTROY:
- case WM_NCDESTROY:
- m_ptLastClientHover.x = m_ptLastClientHover.y = -32767;
- break;
- } // switch( message )
- return CExtControlBar::WindowProc(message,wParam,lParam);
- }
- #if _MFC_VER < 0x700
- void CExtToolControlBar::OnActivateApp(BOOL bActive, HTASK hTask)
- #else
- void CExtToolControlBar::OnActivateApp(BOOL bActive, DWORD hTask)
- #endif
- {
- CExtControlBar::OnActivateApp( bActive, hTask );
- }
- void CExtToolControlBar::OnTimer(__EXT_MFC_UINT_PTR nIDEvent)
- {
- switch( nIDEvent )
- {
- case __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER:
- {
- bool bStateClear = false;
- 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();
- if( bHover && m_nBtnIdxHover != nIndex )
- {
- bool bCancelHover = true;
- CExtBarButton * pParentTBB = GetButton( m_nBtnIdxHover );
- if( pParentTBB != NULL )
- {
- for( pParentTBB = pParentTBB->ParentButtonGet(); pParentTBB != NULL; pParentTBB = pParentTBB->ParentButtonGet() )
- {
- if( LPVOID(pParentTBB) == LPVOID(pTBB) )
- {
- bCancelHover = false;
- break;
- }
- }
- }
- if( bCancelHover )
- {
- pTBB->SetHover( false );
- _InvalidateButton( nIndex );
- bStateClear = true;
- break;
- }
- }
- }
- if( bStateClear )
- {
- KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
- return;
- }
- bool bActiveHover =
- ( ( m_nBtnIdxHover >= 0 )
- && CExtPopupMenuWnd::TestHoverEnabledFromActiveHWND( m_hWnd )
- ) ? true : false;
- if( bActiveHover )
- {
- CPoint point;
- if( ::GetCursorPos( &point ) )
- {
- if( ::WindowFromPoint( point ) != m_hWnd )
- bActiveHover = false;
- }
- else
- bActiveHover = false;
- }
- if( bActiveHover
- && m_pDockSite->GetSafeHwnd() != NULL
- && ( ! m_pDockSite->IsWindowEnabled() )
- )
- bActiveHover = false;
- if( ! bActiveHover )
- {
- _UpdateHoverButton( CPoint(32767,32767), false );
- KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL
- && pATTW->GetLastParentHWND() == m_hWnd
- )
- pATTW->Hide();
- CWnd::CancelToolTips();
- }
- else
- {
- if( m_nBtnIdxHover >= 0 )
- {
- CPoint pt;
- if( ::GetCursorPos( &pt ) )
- {
- ScreenToClient( &pt );
- INT nHT = HitTest( pt );
- if( nHT != m_nBtnIdxHover )
- {
- KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
- if( ! CExtPopupMenuWnd::IsMenuTracking() )
- _UpdateHoverButton( pt, false );
- }
- }
- }
- }
- }
- return; // case __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER
- } // switch( nIDEvent )
- CExtControlBar::OnTimer(nIDEvent);
- }
- bool CExtToolControlBar::IsPaletteChevronMenu() const
- {
- ASSERT_VALID( this );
- // if( m_bPresubclassDialogMode )
- // return false;
- return true;
- }
- void CExtToolControlBar::_SwitchMenuTrackingIndex(
- int iNewMenuTrackingIndex // = -1
- )
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return;
- if( m_nBtnIdxMenuTracking == iNewMenuTrackingIndex )
- return;
- if( m_nBtnIdxMenuTracking >= 0 )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxMenuTracking );
- ASSERT_VALID( pTBB );
- ASSERT( !(pTBB->IsSeparator()) );
- UINT nNewStyle =
- pTBB->GetStyle()
- &
- ~(TBBS_PRESSED|TBBS_CHECKED|TBBS_INDETERMINATE);
- pTBB->SetStyle( nNewStyle );
- pTBB->OnPressedTrackingStop();
- _InvalidateButton( m_nBtnIdxMenuTracking );
- m_nBtnIdxMenuTracking = -1;
- } // if( m_nBtnIdxMenuTracking >= 0 )
- if( iNewMenuTrackingIndex >= 0 )
- {
- m_nBtnIdxMenuTracking = iNewMenuTrackingIndex;
- CExtBarButton * pTBB =
- _GetButtonPtr( m_nBtnIdxMenuTracking );
- ASSERT_VALID( pTBB );
- ASSERT( !(pTBB->IsSeparator()) );
- UINT nNewStyle =
- pTBB->GetStyle()
- &
- ~(TBBS_CHECKED|TBBS_INDETERMINATE);
- nNewStyle |= TBBS_PRESSED;
- pTBB->SetStyle( nNewStyle );
- pTBB->OnPressedTrackingStart();
- _InvalidateButton( m_nBtnIdxMenuTracking );
- } // if( iNewMenuTrackingIndex >= 0 )
- // UpdateWindow();
- }
- CExtToolControlBar * CExtToolControlBar::_GetMenuTrackingBar()
- {
- //CSingleLock _slCsCB( &g_csCB );
- // _slCsCB.Lock();
- CExtToolControlBar * pRetVal = NULL;
- INT iBar;
- for( iBar = 0; iBar < g_AllBars.GetSize(); ++iBar )
- {
- CExtControlBar * pBar = g_AllBars[iBar];
- ASSERT_VALID( pBar );
- if( pBar->GetSafeHwnd() == NULL )
- continue;
- CExtToolControlBar * pToolControlBar =
- DYNAMIC_DOWNCAST(CExtToolControlBar,pBar);
- if( pToolControlBar == NULL )
- continue;
- if( pToolControlBar->m_nBtnIdxMenuTracking >= 0 )
- {
- pRetVal = pToolControlBar;
- break;
- }
- } // for( iBar = 0; iBar < g_AllBars.GetSize(); ++iBar )
- // _slCsCB.Unlock();
- return pRetVal; // fixed by Mr. Jay Horak
- }
- void CExtToolControlBar::_CloseTrackingMenus()
- {
- __PROF_UIS_MANAGE_STATE;
- // TRACE1(
- // " >> _CloseTrackingMenus()(%s)n",
- // g_bMenuTracking ? " on " : " off "
- // );
- g_bMenuTracking = false;
- //CSingleLock _slCsCB( &g_csCB );
- // _slCsCB.Lock();
- for( INT iBar=0; iBar<g_AllBars.GetSize(); ++iBar )
- {
- CExtControlBar * pBar = g_AllBars[iBar];
- ASSERT( pBar != NULL );
- if( CWnd::FromHandlePermanent(pBar->m_hWnd) != pBar )
- continue;
- ASSERT_VALID( pBar );
- if( pBar->GetSafeHwnd() == NULL )
- continue;
- CExtToolControlBar * pToolControlBar =
- DYNAMIC_DOWNCAST(CExtToolControlBar,pBar);
- if( pToolControlBar == NULL )
- continue;
- pToolControlBar->_SwitchMenuTrackingIndex();
- }
- // _slCsCB.Unlock();
- // CExtPopupMenuWnd::CancelMenuTracking();
- // CWnd::CancelToolTips();
- if( (! CExtPopupMenuSite::g_DefPopupMenuSite.IsEmpty() )
- && (! CExtPopupMenuSite::g_DefPopupMenuSite.IsShutdownMode() )
- )
- {
- CExtPopupMenuWnd * pTopMenu =
- CExtPopupMenuSite::g_DefPopupMenuSite.
- GetInstance();
- if( pTopMenu->GetSafeHwnd() != NULL )
- pTopMenu->PostMessage( WM_CANCELMODE );
- }
- CWnd::CancelToolTips();
- // TO FIX: can be tracked other menu
- // ASSERT( !CExtPopupMenuWnd::IsMenuTracking() );
- }
- void CExtToolControlBar::_CloseCustomMenusAll()
- {
- static bool g_bClosingCustomMenu = false;
- if( g_bClosingCustomMenu )
- return;
- g_bClosingCustomMenu = true;
- for( INT iBar=0; iBar<g_AllBars.GetSize(); ++iBar )
- {
- CExtControlBar * pBar = g_AllBars[iBar];
- ASSERT( pBar != NULL );
- if( CWnd::FromHandlePermanent(pBar->m_hWnd) != pBar )
- continue;
- ASSERT_VALID( pBar );
- if( pBar->GetSafeHwnd() == NULL )
- continue;
- CExtToolControlBar * pToolControlBar =
- DYNAMIC_DOWNCAST(CExtToolControlBar,pBar);
- if( pToolControlBar == NULL )
- continue;
- pToolControlBar->_CloseCustomMenus();
- }
- g_bClosingCustomMenu = false;
- }
- void CExtToolControlBar::_CloseCustomMenus()
- {
- }
- CExtToolControlBar * CExtToolControlBar::_GetMenuTrackingToolControlBar()
- {
- __PROF_UIS_MANAGE_STATE;
- for( INT iBar=0; iBar<g_AllBars.GetSize(); ++iBar )
- {
- CExtControlBar * pBar = g_AllBars[iBar];
- ASSERT( pBar != NULL );
- if( CWnd::FromHandlePermanent(pBar->m_hWnd) != pBar )
- continue;
- ASSERT_VALID( pBar );
- if( pBar->GetSafeHwnd() == NULL )
- continue;
- CExtToolControlBar * pToolControlBar =
- DYNAMIC_DOWNCAST(CExtToolControlBar,pBar);
- if( pToolControlBar == NULL )
- continue;
- if( pToolControlBar->GetMenuTrackingButton() >= 0 )
- return pToolControlBar;
- }
- return NULL;
- }
- CExtMenuControlBar * CExtToolControlBar::_GetMenuTrackingMenuControlBar()
- {
- __PROF_UIS_MANAGE_STATE;
- CExtToolControlBar * pToolControlBar = _GetMenuTrackingToolControlBar();
- if( pToolControlBar == NULL )
- return NULL;
- CExtMenuControlBar * pMenuControlBar = DYNAMIC_DOWNCAST( CExtMenuControlBar, pToolControlBar );
- return pMenuControlBar;
- }
- void CExtToolControlBar::_CbPaintCombinedContent(
- LPVOID pCookie,
- CDC & dc,
- const CWnd & refWndMenu,
- const CRect & rcExcludeArea, // in screen coords
- int eCombineAlign // CExtPopupMenuWnd::e_combine_align_t values
- )
- {
- CExtToolControlBar::g_bMenuTracking = true;
- pCookie;
- dc;
- refWndMenu;
- rcExcludeArea;
- eCombineAlign;
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( refWndMenu.GetSafeHwnd() != NULL );
- CExtToolControlBar * pBar = (CExtToolControlBar *)pCookie;
- ASSERT_VALID( pBar );
- ASSERT( pBar->IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) );
- ASSERT( eCombineAlign != CExtPopupMenuWnd::__CMBA_NONE );
- if( rcExcludeArea.IsRectEmpty() )
- return;
- if( pBar->m_nBtnIdxMenuTracking < 0 )
- return;
- ASSERT(
- pBar->m_nBtnIdxMenuTracking <
- pBar->GetButtonsCount()
- );
- CExtBarButton * pTBB =
- pBar->_GetButtonPtr(
- pBar->m_nBtnIdxMenuTracking
- );
- ASSERT_VALID( pTBB );
- if( pBar->PmBridge_GetPM()->GetCb2DbTransparentMode(pTBB)
- && pTBB->IsKindOf( RUNTIME_CLASS(CExtBarContentExpandButton) )
- && (! pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- && ( (! pBar->m_bPresubclassDialogMode )
- || pBar->m_bForceBalloonGradientInDialogs
- )
- && ::GetDeviceCaps( dc.m_hDC, BITSPIXEL ) > 8
- )
- return;
- UINT nStyle = pTBB->GetStyle();
- bool bHover = pTBB->IsHover();
- pTBB->AnimationClient_CacheGeneratorLock();
- pTBB->SetHover( false );
- pTBB->ModifyStyle(
- 0,
- TBBS_PRESSED|TBBS_CHECKED|TBBS_CHECKBOX
- );
- CRect rcClientBar,rcClientExcludeArea;
- pBar->GetClientRect( &rcClientBar );
- pBar->ClientToScreen( &rcClientBar );
- refWndMenu.GetClientRect( &rcClientExcludeArea );
- refWndMenu.ClientToScreen( &rcClientExcludeArea );
- CPoint ptOffset =
- rcClientBar.TopLeft()
- - rcClientExcludeArea.TopLeft()
- ;
- CPoint ptViewportOrg = dc.GetViewportOrg();
- dc.SetViewportOrg( ptOffset );
- CExtPopupMenuWnd::g_pCombinedHelper = pTBB;
- pBar->PmBridge_GetPM()->PaintBarButtonCombinedArea( dc, pTBB );
- pTBB->Paint( dc );
- CExtPopupMenuWnd::g_pCombinedHelper = NULL;
- dc.SetViewportOrg( ptViewportOrg );
- pTBB->SetHover( bHover );
- pTBB->SetStyle( nStyle );
- pTBB->AnimationClient_CacheGeneratorUnlock();
- }
- CExtBarButton * CExtToolControlBar::GetButton( int nIndex )
- {
- return _GetButtonPtr( nIndex );
- }
- CExtBarContentExpandButton * CExtToolControlBar::GetRightButton()
- {
- return m_pRightBtn;
- }
- void CExtToolControlBar::OnCaptureChanged(CWnd *pWnd)
- {
- if( pWnd != this
- // && pWnd != NULL
- )
- {
- if( m_nBtnIdxCapture >= 0 || m_nBtnIdxHover >= 0 )
- {
- SendMessage( WM_CANCELMODE );
- m_nBtnIdxCapture = m_nBtnIdxHover = -1;
- }
- }
- CExtControlBar::OnCaptureChanged(pWnd);
- }
- BOOL CExtToolControlBar::InitContentExpandButton()
- {
- if( m_pRightBtn != NULL )
- return TRUE;
- m_pRightBtn = OnCreateBarRightBtn();
- if( m_pRightBtn == NULL )
- return FALSE;
- ASSERT_VALID( m_pRightBtn );
- ASSERT_KINDOF( CExtBarContentExpandButton, m_pRightBtn );
- m_buttons.Add( m_pRightBtn );
- return TRUE;
- }
- bool CExtToolControlBar::_CanDockToInnerCircles() const
- {
- return false;
- }
- bool CExtToolControlBar::_CanDockToTabbedContainers(
- CExtControlBar * pDestBar
- ) const
- {
- pDestBar;
- return false;
- }
- void CExtToolControlBar::ToggleDocking()
- {
- ASSERT_VALID( this );
- if( m_pDockSite == NULL || m_pDockBar == NULL )
- return;
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- #ifdef _DEBUG
- if( !IsFloating() )
- {
- ASSERT_KINDOF( CExtDockBar, m_pDockBar );
- }
- #endif // _DEBUG
- ASSERT( m_pDockContext != NULL );
-
- CFrameWnd * pParentFrame = GetParentFrame();
- ASSERT_VALID( pParentFrame );
- if( pParentFrame != m_pDockSite )
- pParentFrame->ShowWindow( SW_HIDE );
- m_pDockContext->ToggleDocking();
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- pFrame->DelayRecalcLayout();
- _RecalcNcArea();
- }
- CExtBarButton::e_wrap_t CExtToolControlBar::GetBtnWrapCode() const
- {
- ASSERT_VALID( this );
- if( m_bPresubclassDialogMode
- || GetSafeHwnd() == NULL
- || ( ! ::IsWindow(GetSafeHwnd()) )
- || IsFloating()
- )
- return CExtBarButton::__EVT_FLOAT;
- if( IsDockedVertically() )
- return CExtBarButton::__EVT_VERT;
- return CExtBarButton::__EVT_HORZ;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtToolControlBar::_IsDockSiteCustomizeMode() const
- {
- ASSERT_VALID( this );
- if( ! m_bCustomizationAllowed )
- return false;
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite == NULL )
- // return CExtControlBar::_IsDockSiteCustomizeMode();
- return false;
- return pSite->IsCustomizeMode();
- }
- CExtCustomizeSite * CExtToolControlBar::GetCustomizeSite()
- {
- ASSERT_VALID( this );
- return m_pCustomizeSite;
- }
- CExtCustomizeSite * CExtToolControlBar::GetCustomizeSite() const
- {
- ASSERT_VALID( this );
- return ((CExtToolControlBar*)this)->GetCustomizeSite();
- }
- bool CExtToolControlBar::OnCustomizeRegisterBar(
- CExtCustomizeSite * pCustomizeSite
- )
- {
- ASSERT_VALID( this );
- ASSERT( m_pCustomizeSite == NULL ); // should called only once
- ASSERT( pCustomizeSite != NULL );
- m_pCustomizeSite = pCustomizeSite;
- if( (! m_bCustomizationAllowed )
- || m_bPaletteMode
- )
- return false;
- return true;
- }
- void CExtToolControlBar::OnCustomizeGetBarInfo(
- CExtCustomizeSite::CToolBarCustomizeInfo * pInfo
- )
- {
- ASSERT_VALID( this );
- ASSERT( m_pCustomizeSite != NULL );
- ASSERT( pInfo != NULL );
- ASSERT( m_hWnd != NULL && ::IsWindow(m_hWnd) );
- UINT nBarID = (UINT)GetDlgCtrlID();
- CExtCmdItem * pCmd =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(m_hWnd),
- nBarID
- );
- if( pCmd != NULL )
- pInfo->m_strDisplayName =
- pCmd->OnGetToolBarCustomizeName();
- if( pInfo->m_strDisplayName.IsEmpty() )
- {
- if( ! g_ResourceManager->LoadString( pInfo->m_strDisplayName, nBarID ) )
- {
- int nTextLen = GetWindowTextLength();
- if( nTextLen > 0 )
- {
- GetWindowText( pInfo->m_strDisplayName.GetBuffer(nTextLen+2), nTextLen+1 );
- pInfo->m_strDisplayName.ReleaseBuffer();
- } // if( nTextLen > 0 )
- if( pInfo->m_strDisplayName.IsEmpty() )
- pInfo->m_strDisplayName.Format(
- _T("Toolbar #%08X"),
- nBarID
- );
- }
- } // if( pInfo->m_strDisplayName.IsEmpty() )
- if( pInfo->m_pHelperBarButtonsI != NULL )
- {
- CExtCustomizeSite * pCustomizeSite = GetCustomizeSite();
- ASSERT( pCustomizeSite != NULL );
- ASSERT_VALID( pInfo->m_pHelperBarButtonsI );
- ASSERT( pInfo->m_pHelperBarButtonsI->GetCmdID() == ((UINT)GetDlgCtrlID()) );
- ASSERT( pInfo->m_pHelperBarButtonsI->GetNodeCount() == 0 );
- pInfo->m_pHelperBarButtonsI->SetTextUser( pInfo->m_strDisplayName );
- bool bRevertRTL = OnQueryRevertRTL();
- INT nCountOfButtons = _GetButtonsCountImpl();
- for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(
- bRevertRTL
- ? (nCountOfButtons - nBtnIdx - 1)
- : nBtnIdx
- );
- ASSERT_VALID( pTBB );
- pTBB->OnCustomizeNodeInit(
- pCustomizeSite,
- pInfo->m_pHelperBarButtonsI
- );
- } // for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- } // if( pInfo->m_pHelperBarButtonsI != NULL )
- }
- void CExtToolControlBar::OnCustomizeUpdateInitialBarState(
- CExtCustomizeCmdTreeNode * pParentNode,
- bool bRecalcLayout
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pParentNode );
- ASSERT( m_pCustomizeSite != NULL );
- INT nNodeCount = pParentNode->GetNodeCount();
- INT nCountOfButtons = _GetButtonsCountImpl();
- ASSERT( nNodeCount <= nCountOfButtons );
- bool bRevertRTL = OnQueryRevertRTL();
- INT nNodePos = bRevertRTL ? (pParentNode->GetNodeCount()-1) : 0;
- for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- CExtCustomizeCmdTreeNode * pCmdNodeI =
- pTBB->GetCmdNode( true );
- if( pCmdNodeI == NULL )
- continue;
- ASSERT( !pTBB->IsSeparator() );
- ASSERT_VALID( pCmdNodeI );
- CExtCustomizeCmdTreeNode * pCmdNodeC =
- pParentNode->ElementAt( nNodePos );
- if( bRevertRTL )
- nNodePos --;
- else
- nNodePos ++;
- ASSERT_VALID( pCmdNodeC );
- // re-init spec buttons
- pTBB =
- m_pCustomizeSite->OnCreateToolbarButton(
- this,
- pCmdNodeI,
- pCmdNodeI
- );
- ASSERT_VALID( pTBB );
- VERIFY(
- InsertSpecButton(
- nBtnIdx,
- pTBB,
- FALSE
- )
- );
- pTBB->SetBasicCmdNode( pCmdNodeI );
- pTBB->SetCustomizedCmdNode( pCmdNodeC );
- pTBB->OnCustomizeUpdateProps();
- RemoveButton( nBtnIdx + 1, FALSE );
- } // for( INT nBtnIdx = 0; nBtnIdx < nCountOfButtons; nBtnIdx++ )
- if( bRecalcLayout )
- _RecalcLayoutImpl();
- }
- void CExtToolControlBar::OnCustomizeModeEnter()
- {
- ASSERT_VALID( this );
- if( (! m_bCustomizationAllowed )
- || m_pDockSite == NULL
- || m_pDockBar == NULL
- || (! m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockOuterBar)) )
- )
- return;
- ASSERT_VALID( m_pDockSite );
- ASSERT_VALID( m_pDockBar );
- CExtCustomizeSite * pSite = GetCustomizeSite();
- if( pSite != NULL )
- pSite->RegisterCommandDropTarget( this, this );
- if( (! IsDocked() )
- || _GetFullRowMode()
- )
- return;
- INT nCountOfButtons = _GetButtonsCountImpl();
- if( nCountOfButtons == 0 )
- return;
- if( m_pRightBtn == NULL )
- return;
- if( m_pRightBtn->GetButtons().GetSize() == 0 )
- return;
- INT nOwnIdxInDocker = m_pDockBar->FindBar(this);
- ASSERT( 0 < nOwnIdxInDocker && nOwnIdxInDocker < (m_pDockBar->m_arrBars.GetSize()-1) );
- if( m_pDockBar->m_arrBars[nOwnIdxInDocker+1] != NULL )
- m_pDockBar->m_arrBars.InsertAt( nOwnIdxInDocker+1, (CControlBar *)NULL );
- if( m_pDockBar->m_arrBars[nOwnIdxInDocker-1] != NULL )
- m_pDockBar->m_arrBars.InsertAt( nOwnIdxInDocker, (CControlBar *)NULL );
- Invalidate();
- }
- void CExtToolControlBar::OnCustomizeModeLeave()
- {
- ASSERT_VALID( this );
- // if( ! m_bCustomizationAllowed )
- // return;
- }
- void CExtToolControlBar::OnCustomizeListBoxUpdate( CExtCustomizeToolbarsListBox * pWndList )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pWndList );
- if( ! m_bCustomizationAllowed )
- return;
- CExtControlBar::OnCustomizeListBoxUpdate( pWndList );
- }
- DROPEFFECT CExtToolControlBar::OnCustomizeTargetOver(
- CExtCustomizeSite::CCmdDragInfo & _dragInfo,
- CPoint point,
- DWORD dwKeyState
- )
- {
- ASSERT_VALID( this );
- ASSERT( !_dragInfo.IsEmpty() );
- _dragInfo;
- if( ! m_bCustomizationAllowed )
- return DROPEFFECT_NONE;
- if( m_pDockBar != NULL
- && IsFloating()
- )
- GetParentFrame()->SetWindowPos(
- &CWnd::wndTop, 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE
- );
- int nCountTest = _GetButtonsCountImpl();
- int nCountReal = nCountTest;
- if( m_pRightBtn != NULL )
- {
- nCountTest--;
- ASSERT( nCountTest >= 0 );
- }
- if( nCountTest > 0
- && _GetButtonPtr(0)->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- )
- {
- nCountTest--;
- ASSERT( nCountTest >= 0 );
- }
- if( nCountReal > 1
- && _GetButtonPtr(
- ( m_pRightBtn != NULL )
- ? (nCountReal-2)
- : (nCountReal-1)
- )->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- )
- {
- nCountTest--;
- ASSERT( nCountTest >= 0 );
- }
- if( nCountTest == 0 )
- {
- if( (dwKeyState & MK_CONTROL) != NULL )
- return DROPEFFECT_COPY;
- return DROPEFFECT_MOVE;
- }
- if( m_pDragTargetTBB != NULL )
- _InvalidateButton( _GetIndexOf(m_pDragTargetTBB) );
- int nHitIdx = _HitTestImpl( point, 0, 0, true );
- if( nHitIdx < 0 )
- {
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- return DROPEFFECT_NONE;
- }
- CExtBarButton * pHitTBB = _GetButtonPtr( nHitIdx );
- ASSERT_VALID( pHitTBB );
- if( pHitTBB->IsSeparator() )
- {
- nHitIdx--;
- if( nHitIdx < 0 )
- {
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- return DROPEFFECT_NONE;
- }
- pHitTBB = _GetButtonPtr( nHitIdx );
- ASSERT_VALID( pHitTBB );
- if( pHitTBB->IsSeparator() )
- {
- ASSERT( FALSE ); // double separators?!
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- return DROPEFFECT_NONE;
- } // if( pHitTBB->IsSeparator() )
- } // if( pHitTBB->IsSeparator() )
- m_nDragTargetShift =
- pHitTBB->CalculateDropOverEffect( point, _dragInfo );
- if( m_nDragTargetShift == 0 )
- {
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- return DROPEFFECT_NONE;
- } // if( m_nDragTargetShift == 0 )
- if( m_pDragTargetTBB != pHitTBB )
- {
- m_pDragTargetTBB = pHitTBB;
- _InvalidateButton( _GetIndexOf(m_pDragTargetTBB) );
- }
- UpdateWindow();
- if( (dwKeyState & MK_CONTROL) != NULL )
- return DROPEFFECT_COPY;
- return DROPEFFECT_MOVE;
- }
- void CExtToolControlBar::OnCustomizeTargetLeave()
- {
- ASSERT_VALID( this );
- if( ! m_bCustomizationAllowed )
- return;
- if( m_pDragTargetTBB == NULL )
- return;
- _InvalidateButton( _GetIndexOf(m_pDragTargetTBB) );
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- }
- bool CExtToolControlBar::OnCustomizeTargetDrop(
- CExtCustomizeSite::CCmdDragInfo & _dragInfo,
- CPoint point,
- DROPEFFECT de
- )
- {
- // returns true if drop with any effect
- // has been performed
- ASSERT_VALID( this );
- ASSERT( !_dragInfo.IsEmpty() );
- _dragInfo;
- point;
- if( ! m_bCustomizationAllowed )
- return false;
- ASSERT(
- de == DROPEFFECT_NONE
- || de == DROPEFFECT_MOVE
- || de == DROPEFFECT_COPY
- );
- if( de == DROPEFFECT_NONE )
- return false;
- if( m_pDragTargetTBB == NULL )
- {
- CExtCustomizeSite * pSite =
- GetCustomizeSite();
- ASSERT( pSite != NULL );
- int nInsertPos = 0;
- if( GetButtonsCount() > 0
- && _GetButtonPtr(0)->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- )
- nInsertPos = 1;
- pSite->OnInsertToolbarCmdNode(
- _dragInfo,
- this,
- nInsertPos,
- true
- );
- if( m_pDockBar != NULL )
- {
- Invalidate();
- GetParentFrame()->RecalcLayout();
- }
- return true;
- } // if( m_pDragTargetTBB == NULL )
- ASSERT_VALID( m_pDragTargetTBB );
-
- int nBtn = _GetIndexOf(m_pDragTargetTBB);
- ASSERT( 0 <= nBtn && nBtn < _GetButtonsCountImpl() );
- _InvalidateButton( nBtn );
- bool bSeparatorAdd = false;
- bool bSeparatorRemove = false;
- if( de == DROPEFFECT_MOVE )
- {
- if( m_pDragSourceTBB == m_pDragTargetTBB )
- {
- if( m_nDragTargetShift == -2 )
- return false; // no reinsert
- if( m_nDragTargetShift < 0 )
- { // if remove separator
- if( nBtn > 0
- && _GetButtonPtr(nBtn-1)->IsSeparator()
- )
- bSeparatorRemove = true;
- else
- return false; // no reinsert
- } // if remove separator
- else
- { // if add separator
- if( ( nBtn > 1
- || ( nBtn == 1
- && (! _GetButtonPtr(0)->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton)) )
- )
- )
- && (! _GetButtonPtr(nBtn-1)->IsSeparator() )
- )
- bSeparatorAdd = true;
- else
- return false; // no reinsert
- } // if add separator
- } // if( m_pDragSourceTBB == m_pDragTargetTBB )
- else if(
- m_pDragSourceTBB != NULL
- && nBtn > 0
- && m_nDragTargetShift < 0
- && _GetIndexOf(m_pDragSourceTBB) == (nBtn-1)
- && (!( nBtn == 2
- && _GetButtonPtr(0)->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- ))
- )
- {
- if( ( nBtn > 1
- && (! _GetButtonPtr(nBtn-2)->IsSeparator() )
- )
- || nBtn <= 1
- )
- { // avoid unwanted separator insert
- bSeparatorAdd = true;
- nBtn--;
- } // avoid unwanted separator insert
- }
- } // if( de == DROPEFFECT_MOVE )
- if( bSeparatorRemove )
- {
- CExtBarButton * pModifyTBB = _GetButtonPtr(nBtn);
- ASSERT_VALID( pModifyTBB );
- CExtCustomizeCmdTreeNode * pNode = pModifyTBB->GetCmdNode();
- ASSERT_VALID( pNode );
- pNode->ModifyFlags( 0, __ECTN_GROUP_START );
- RemoveButton(nBtn-1);
- UpdateWindow();
- if( m_pDockBar != NULL
- //&& IsFloating()
- )
- {
- Invalidate();
- GetParentFrame()->RecalcLayout();
- }
- m_bHelperSeparatorAction = true;
- } // if( bSeparatorRemove )
- else if( bSeparatorAdd )
- {
- CExtBarButton * pModifyTBB = _GetButtonPtr(nBtn);
- ASSERT_VALID( pModifyTBB );
- CExtCustomizeCmdTreeNode * pNode = pModifyTBB->GetCmdNode();
- ASSERT_VALID( pNode );
- pNode->ModifyFlags( __ECTN_GROUP_START );
- InsertButton(nBtn);
- UpdateWindow();
- if( m_pDockBar != NULL
- //&& IsFloating()
- )
- {
- Invalidate();
- GetParentFrame()->RecalcLayout();
- }
- m_bHelperSeparatorAction = true;
- } // else if( bSeparatorAdd )
- else
- { // if command drop
- int nInsertPos = (m_nDragTargetShift < 0) ? nBtn : (nBtn+1);
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- UpdateWindow();
- //InsertButton( nInsertPos, pCmdItem->m_nCmdID );
- CExtCustomizeSite * pSite =
- GetCustomizeSite();
- ASSERT( pSite != NULL );
- pSite->OnInsertToolbarCmdNode(
- _dragInfo,
- this,
- nInsertPos,
- true
- );
- if( m_pDockBar != NULL
- //&& IsFloating()
- )
- {
- Invalidate();
- GetParentFrame()->RecalcLayout();
- }
- } // if command drop
- return true;
- }
- void CExtToolControlBar::OnCustomizeSourceDragComplete(
- DROPEFFECT de,
- bool bCanceled,
- bool * p_bNoResetActiveItem
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pDragSourceTBB );
- ASSERT( p_bNoResetActiveItem != NULL );
- ASSERT(
- de == DROPEFFECT_NONE
- || de == DROPEFFECT_MOVE
- || de == DROPEFFECT_COPY
- );
- if( ! m_bCustomizationAllowed )
- return;
- int nBtnSrc = _GetIndexOf(m_pDragSourceTBB);
- if( (!bCanceled) && (!m_bHelperSeparatorAction) )
- {
- CExtBarButton * pHtCurrTBB = NULL;
- if( GetButtonsCount() > 0 )
- {
- CPoint point( 0, 0 );
- ::GetCursorPos( &point );
- ScreenToClient( &point );
- INT nButton = HitTest( point );
- if( nButton >= 0 )
- pHtCurrTBB = _GetButtonPtr( nButton );
- } // if( GetButtonsCount() > 0 )
- if( de == DROPEFFECT_NONE || de == DROPEFFECT_MOVE )
- {
- if( m_pDragSourceTBB == m_pDragTargetTBB
- || m_pDragSourceTBB == pHtCurrTBB
- )
- { // if keep source button active
- m_pDragSourceTBB = NULL;
- if( _IsDockSiteCustomizeMode() )
- *p_bNoResetActiveItem = true;
- } // if keep source button active
- else
- { // if remove source button
- m_pDragSourceTBB = NULL;
- CExtCustomizeSite * pSite = GetCustomizeSite();
- ASSERT( pSite != NULL );
- CExtCustomizeCmdTreeNode * pNode =
- pSite->DraggedNodeGet();
- ASSERT_VALID( pNode );
- ASSERT( ((LPVOID)pNode) == ((LPVOID)_GetButtonPtr(nBtnSrc)->GetCmdNode(false)) );
- if( pSite->GetPopupDropTargetNode() == pNode )
- {
- pSite->DropTargetPopupCancel();
- ASSERT( pSite->GetPopupDropTargetNode() != pNode );
- }
- RemoveButton( nBtnSrc );
- pSite->DraggedNodeSet( NULL );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(m_hWnd),
- pNode->GetCmdID( false )
- );
- ASSERT( pCmdItem != NULL );
- ASSERT_VALID( pNode->GetParentNode() );
- int nOwnNodeIndex = pNode->GetOwnIndex();
- int nSiblingCount = pNode->GetParentNode()->GetNodeCount();
- bool bRemovePrevSeparator =
- (pNode->GetFlags() & __ECTN_GROUP_START)
- ? true : false;
- bool bRemoveNextSeparator = false;
- if( bRemovePrevSeparator
- && nOwnNodeIndex < (nSiblingCount-1)
- )
- {
- ASSERT( nOwnNodeIndex > 0 );
- ASSERT( nBtnSrc > 0 );
- if( (pNode->GetParentNode()->ElementAt(nOwnNodeIndex+1)
- ->GetFlags()&__ECTN_GROUP_START) == 0
- )
- {
- pNode->GetParentNode()->ElementAt(nOwnNodeIndex+1)
- ->ModifyFlags( __ECTN_GROUP_START );
- bRemovePrevSeparator = false;
- }
- }
- if( nOwnNodeIndex == 0
- && nSiblingCount > 1
- && (pNode->GetParentNode()->ElementAt(1)
- ->GetFlags()&__ECTN_GROUP_START) != 0
- )
- {
- pNode->GetParentNode()->ElementAt(1)->ModifyFlags( 0, __ECTN_GROUP_START );
- bRemoveNextSeparator = true;
- }
- pNode->RemoveSelf( pCmdItem );
- bool bRevertRTL = OnQueryRevertRTL();
- if( bRevertRTL )
- {
- if( bRemovePrevSeparator )
- {
- ASSERT( _GetButtonPtr(nBtnSrc)->IsSeparator() );
- RemoveButton( nBtnSrc );
- }
- if( bRemoveNextSeparator )
- {
- ASSERT( _GetButtonPtr(nBtnSrc-1)->IsSeparator() );
- RemoveButton( nBtnSrc-1 );
- }
- } // if( bRevertRTL )
- else
- {
- if( bRemoveNextSeparator )
- {
- ASSERT( _GetButtonPtr(nBtnSrc)->IsSeparator() );
- RemoveButton( nBtnSrc );
- }
- if( bRemovePrevSeparator )
- {
- ASSERT( _GetButtonPtr(nBtnSrc-1)->IsSeparator() );
- RemoveButton( nBtnSrc-1 );
- }
- } // else from if( bRevertRTL )
- if( m_pDockBar != NULL )
- {
- CFrameWnd * pRecalcFrame = GetParentFrame();
- ASSERT_VALID( pRecalcFrame );
- pRecalcFrame->RecalcLayout();
- if( IsFloating() )
- pRecalcFrame->SendMessage( WM_NCPAINT );
- Invalidate();
- } // if( m_pDockBar != NULL )
- } // if remove source button
- } // if( de == DROPEFFECT_NONE || de == DROPEFFECT_MOVE )
- else
- {
- _InvalidateButton( nBtnSrc );
- if( m_pDockBar != NULL )
- {
- CFrameWnd * pRecalcFrame = GetParentFrame();
- ASSERT_VALID( pRecalcFrame );
- pRecalcFrame->RecalcLayout();
- if( IsFloating() )
- pRecalcFrame->SendMessage( WM_NCPAINT );
- } // if( m_pDockBar != NULL )
- }
- } // if( (!bCanceled) && (!m_bHelperSeparatorAction) )
- else
- _InvalidateButton( nBtnSrc );
- m_pDragSourceTBB = NULL;
- m_pDragTargetTBB = NULL;
- m_nDragTargetShift = 0;
- m_bHelperSeparatorAction = false;
- UpdateWindow();
- }
- INT CExtToolControlBar::OnCustomizeCalcCmdNodePos(
- INT nButtonPos,
- bool * p_bReinitGroupStart // = NULL
- )
- {
- ASSERT_VALID( this );
- if( p_bReinitGroupStart != NULL )
- (*p_bReinitGroupStart) = false;
- if( ! m_bCustomizationAllowed )
- return 0;
- INT nButtonsCount = _GetButtonsCountImpl();
- ASSERT( nButtonPos <= nButtonsCount );
- if( nButtonsCount == 0 )
- return 0;
- INT nCmdPos = 0;
- bool bRevertRTL = OnQueryRevertRTL();
- if( bRevertRTL )
- {
- for( INT nBtnIdx = nButtonsCount-1; nBtnIdx > nButtonPos; nBtnIdx-- )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->GetCmdNode() == NULL )
- continue;
- ASSERT( ! pTBB->IsSeparator() );
- ASSERT_VALID( pTBB->GetCmdNode() );
- nCmdPos ++;
- } // for( INT nBtnIdx = nButtonsCount-1; nBtnIdx > nButtonPos; nBtnIdx-- )
- ASSERT( nCmdPos <= nButtonsCount );
- if( p_bReinitGroupStart != NULL && nButtonPos < nButtonsCount-1 )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nButtonPos + 1 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator() )
- (*p_bReinitGroupStart) = true;
- } // if( p_bReinitGroupStart != NULL && nButtonPos > 0 )
- } // if( bRevertRTL )
- else
- {
- for( INT nBtnIdx = 0; nBtnIdx < nButtonPos; nBtnIdx++ )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->GetCmdNode() == NULL )
- continue;
- ASSERT( ! pTBB->IsSeparator() );
- ASSERT_VALID( pTBB->GetCmdNode() );
- nCmdPos ++;
- } // for( INT nBtnIdx = 0; nBtnIdx < nButtonPos; nBtnIdx++ )
- ASSERT( nCmdPos <= nButtonsCount );
- if( p_bReinitGroupStart != NULL && nButtonPos > 0 )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nButtonPos - 1 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator() )
- (*p_bReinitGroupStart) = true;
- } // if( p_bReinitGroupStart != NULL && nButtonPos > 0 )
- } // else from if( bRevertRTL )
- return nCmdPos;
- }
- bool CExtToolControlBar::OnCustomizeCanShowHideButtons()
- {
- ASSERT_VALID( this );
- if( ( ! m_bCustomizationAllowed )
- || m_bPaletteMode
- || IsKindOf(RUNTIME_CLASS(CExtPanelControlBar))
- || IsKindOf(RUNTIME_CLASS(CExtMenuControlBar))
- || (! IsVisible() )
- )
- return false;
- INT nButtonsCount = _GetButtonsCountImpl();
- if( nButtonsCount == 0 )
- return false;
- for( INT nBtnIdx = 0; nBtnIdx < nButtonsCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator()
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- || pTBB->GetCmdNode() == NULL
- )
- continue;
- ASSERT_VALID( pTBB->GetCmdNode() );
- if( (pTBB->GetCmdNode()->GetFlags()&__ECTN_TBB_CANNOT_HIDE) != 0 )
- continue;
- return true;
- } // for( INT nBtnIdx = 0; nBtnIdx < nButtonPos; nBtnIdx++ )
- return false;
- }
- void CExtToolControlBar::OnCustomizeInitShowHideButtonMenu(
- CExtPopupMenuWnd * pFolder
- )
- {
- ASSERT_VALID( this );
- ASSERT( OnCustomizeCanShowHideButtons() );
- ASSERT_VALID( pFolder );
- ASSERT( IsVisible() );
- if( ! m_bCustomizationAllowed )
- return;
- INT nButtonsCount = _GetButtonsCountImpl();
- ASSERT( nButtonsCount > 0 );
- INT nInsertPos = 0;
- for( INT nBtnIdx = 0; nBtnIdx < nButtonsCount; nBtnIdx++ )
- {
- CExtBarButton * pTBB = _GetButtonPtr( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsSeparator()
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarContentExpandButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton))
- || pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiRightButton))
- || pTBB->GetCmdNode() == NULL
- )
- continue;
- ASSERT_VALID( pTBB->GetCmdNode() );
- if( (pTBB->GetCmdNode()->GetFlags()&__ECTN_TBB_CANNOT_HIDE) != 0 )
- continue;
- VERIFY(
- pFolder->ItemInsert(
- pTBB->GetCmdID(false),
- nInsertPos
- )
- );
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pFolder->ItemGetInfo( nInsertPos );
- mi.SetForceEnabled();
- mi.SetExtraMark(
- (CExtPopupMenuWnd::MENUITEMDATA::pCbItemClick)
- stat_CbXtraMarkState
- );
- mi.LParamSet( (LPARAM)pTBB );
- pFolder->ItemSetDisplayed( nInsertPos, true );
- mi.SetExtraChecked(
- ( (pTBB->GetStyle() & TBBS_HIDDEN) != 0 )
- ? false : true
- );
- nInsertPos++;
- } // for( INT nBtnIdx = 0; nBtnIdx < nButtonPos; nBtnIdx++ )
- }
- bool CExtToolControlBar::stat_CbXtraMarkState(
- CExtPopupMenuWnd * pPopup,
- LPVOID pItemData
- )
- {
- ASSERT_VALID( pPopup );
- pPopup;
- ASSERT( pItemData != NULL );
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- *((CExtPopupMenuWnd::MENUITEMDATA *)pItemData);
- ASSERT( mi.IsExtraMark() );
- mi.SetExtraChecked( !mi.IsExtraChecked() );
- CExtBarButton * pTBB = (CExtBarButton*)mi.LParamGet();
- ASSERT_VALID( pTBB );
- CExtToolControlBar * pBar = pTBB->GetBar();
- ASSERT_VALID( pBar );
- #ifdef _DEBUG
- INT nButtonIndex = pBar->_GetIndexOf( pTBB );
- ASSERT( nButtonIndex >= 0 );
- #endif // _DEBUG
- bool bShow = mi.IsExtraChecked();
- pTBB->ModifyStyle(
- bShow ? 0 : TBBS_HIDDEN,
- bShow ? TBBS_HIDDEN : 0
- );
- pTBB->Show( bShow );
- pBar->_RecalcPositionsImpl();
- pBar->Invalidate();
- pBar->UpdateWindow();
- if( pBar->m_bPresubclassDialogMode )
- return true; // not important
- if( pBar->m_pDockSite != NULL
- && pBar->IsFloating()
- )
- {
- CFrameWnd * pFrame = pBar->GetParentFrame();
- ASSERT_VALID( pFrame );
- ASSERT_KINDOF( CMiniDockFrameWnd, pFrame );
- }
- pBar->SetTimer( 0x444, 1, NULL );
- return true; // not important
- }
- bool CExtToolControlBar::stat_CbCmdDeliver(
- CExtPopupMenuWnd * pPopup,
- LPVOID pItemData
- )
- {
- ASSERT_VALID( pPopup );
- pPopup;
- ASSERT( pItemData != NULL );
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- *((CExtPopupMenuWnd::MENUITEMDATA *)pItemData);
- if( mi.IsExtraMark() )
- return false;
- if( mi.IsSeparator() )
- return false;
- if( mi.IsPopup() )
- return false;
- if( mi.GetCmdID() != ID_EXT_RESET_TOOLBAR )
- return false;
- ASSERT(
- pPopup->GetSafeHwnd() != NULL
- && ::IsWindow( pPopup->GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite(
- pPopup->GetSafeHwnd()
- );
- if( pSite == NULL )
- return false;
- CExtToolControlBar * pBar = (CExtToolControlBar *)
- mi.LParamGet();
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtToolControlBar, pBar );
- ASSERT( pSite->BarIsRegistered( pBar ) );
- pSite->BarDefCmdTargetSet( pBar );
- return false;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtToolControlBar::FtLayoutQuery::FtLayoutQuery()
- : m_pToolBar( NULL )
- , m_pMiniFrame( NULL )
- , m_hWndFor( NULL )
- {
- }
- CExtToolControlBar::FtLayoutQuery::~FtLayoutQuery()
- {
- Empty();
- }
- void CExtToolControlBar::FtLayoutQuery::Empty()
- {
- m_arrRowRects.RemoveAll();
- m_arrRowBtnIndices.RemoveAll();
- m_pToolBar = NULL;
- m_pMiniFrame = NULL;
- m_hWndFor = NULL;
- }
- bool CExtToolControlBar::FtLayoutQuery::Query( HWND hWndFor )
- {
- Empty();
- if( hWndFor == NULL || (! ::IsWindow( hWndFor ) ) )
- return false;
- m_hWndFor = hWndFor;
- HWND hWnd = hWndFor;
- for( ; hWnd != NULL; hWnd = ::GetParent(hWnd) )
- {
- if( m_pMiniFrame != NULL && hWndFor == m_pMiniFrame->m_hWnd )
- break;
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetClassLong( hWnd, GWL_STYLE );
- if( (dwStyle&WS_CHILD) == 0 && m_pMiniFrame == NULL )
- break;
- CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- if( pWnd == NULL )
- continue;
- if( m_pMiniFrame == NULL )
- {
- CFrameWnd * pFrame = pWnd->GetParentFrame();
- if( pFrame == NULL )
- break;
- m_pMiniFrame =
- DYNAMIC_DOWNCAST(
- CExtMiniDockFrameWnd,
- pFrame
- );
- if( m_pMiniFrame == NULL )
- break;
- } // if( m_pMiniFrame == NULL )
- m_pToolBar =
- DYNAMIC_DOWNCAST(
- CExtToolControlBar,
- pWnd
- );
- if( m_pToolBar == NULL )
- continue;
- if( m_pToolBar->m_hWnd == m_hWndFor )
- break; // toolbar performs self-painting
- return m_pToolBar->_DoFtLayoutQuery( this, NULL );
- } // for( ; hWnd != NULL && ::IsWindow(hWnd); hWnd = ::GetParent(hWnd) )
- return false;
- }
- void CExtToolControlBar::FtLayoutQuery::ReMapRectsToTargetClient()
- {
- if( m_hWndFor == NULL
- || (! ::IsWindow( m_hWndFor ) )
- || (m_pToolBar->GetSafeHwnd() == NULL )
- )
- return;
- ASSERT_VALID( m_pToolBar );
- INT nIdx, nCount = (INT)m_arrRowRects.GetSize();
- ASSERT( m_arrRowBtnIndices.GetSize() == nCount );
- for( nIdx = 0; nIdx < nCount; nIdx++ )
- {
- CRect & rcRowBk = m_arrRowRects.ElementAt( nIdx );
- m_pToolBar->ClientToScreen( &rcRowBk );
- LPPOINT pPoints = (LPPOINT)&rcRowBk;
- ::ScreenToClient( m_hWndFor, pPoints );
- pPoints++;
- ::ScreenToClient( m_hWndFor, pPoints );
- } // for( nIdx = 0; nIdx < nCount; nIdx++ )
- }
- void CExtToolControlBar::FtLayoutQuery::ReMapRectsToTargetWindow()
- {
- if( m_hWndFor == NULL
- || (! ::IsWindow( m_hWndFor ) )
- || (m_pToolBar->GetSafeHwnd() == NULL )
- )
- return;
- ASSERT_VALID( m_pToolBar );
- INT nIdx, nCount = (INT)m_arrRowRects.GetSize();
- ASSERT( m_arrRowBtnIndices.GetSize() == nCount );
- CRect rcTargetWnd;
- ::GetWindowRect( m_hWndFor, &rcTargetWnd );
- for( nIdx = 0; nIdx < nCount; nIdx++ )
- {
- CRect & rcRowBk = m_arrRowRects.ElementAt( nIdx );
- m_pToolBar->ClientToScreen( &rcRowBk );
- rcRowBk.OffsetRect( -rcTargetWnd.left, -rcTargetWnd.top );
- } // for( nIdx = 0; nIdx < nCount; nIdx++ )
- }
- void CExtToolControlBar::FtLayoutQuery::DrawRects( CDC & dc )
- {
- if( m_hWndFor == NULL
- || (! ::IsWindow( m_hWndFor ) )
- || (m_pToolBar->GetSafeHwnd() == NULL )
- )
- return;
- ASSERT_VALID( m_pToolBar );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- INT nIdx, nCount = (INT)m_arrRowRects.GetSize();
- ASSERT( m_arrRowBtnIndices.GetSize() == nCount );
- for( nIdx = 0; nIdx < nCount; nIdx++ )
- {
- CRect & rcRowBk = m_arrRowRects.ElementAt( nIdx );
- INT nBtnIdx = m_arrRowBtnIndices[ nIdx ];
- if( dc.RectVisible( &rcRowBk ) )
- m_pToolBar->PmBridge_GetPM()->PaintFloatToolbarRowBk(
- dc,
- m_pToolBar,
- nBtnIdx,
- rcRowBk
- );
- } // for( nIdx = 0; nIdx < nCount; nIdx++ )
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtPanelControlBar
- IMPLEMENT_DYNCREATE(CExtPanelControlBar, CExtToolControlBar)
- CExtPanelControlBar::CExtPanelControlBar()
- : m_rcMargins( 5, 5, 5, 5 )
- {
- m_bPaletteMode = true;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_bVisibleInCustomizeListBox = false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- CExtPanelControlBar::~CExtPanelControlBar()
- {
- }
- BEGIN_MESSAGE_MAP(CExtPanelControlBar, CExtToolControlBar)
- //{{AFX_MSG_MAP(CExtPanelControlBar)
- ON_WM_SIZE()
- ON_WM_PAINT()
- ON_WM_WINDOWPOSCHANGED()
- ON_WM_SETFOCUS()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CExtToolControlBar message handlers
- CSize CExtPanelControlBar::CalcDynamicLayout(int nLength, DWORD dwMode)
- {
- ASSERT_VALID( this );
- 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))
- );
- CSize sizeCalcLayout = _CalcLayout( dwMode, nLength );
- return sizeCalcLayout;
- }
- CSize CExtPanelControlBar::CalcFixedLayout(
- BOOL bStretch,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- DWORD dwMode = bStretch ? LM_STRETCH : 0;
- dwMode |= bHorz ? LM_HORZ : 0;
- ASSERT(
- (dwMode&(LM_HORZ|LM_HORZDOCK))
- ||
- (!(dwMode&LM_HORZDOCK))
- );
- CSize sizeCalcLayout = _CalcLayout( dwMode );
- _RecalcNcArea();
- return sizeCalcLayout;
- }
- CSize CExtPanelControlBar::_CalcLayout(
- DWORD dwMode,
- int nLength // = -1
- )
- {
- ASSERT_VALID( this );
- dwMode;
- nLength;
- CSize sizeCalcLayout( 0, 0 );
- if( !IsFloating() )
- {
- sizeCalcLayout += CSize( 2, 2 );
- bool bGripperAtTop = false;
- if( IsBarWithGripper( &bGripperAtTop ) )
- {
- CSize sizeGrip = _RectGripGet().Size();
- if( bGripperAtTop )
- sizeCalcLayout.cy += sizeGrip.cy;
- else
- sizeCalcLayout.cx += sizeGrip.cx;
- }
- }
- if( IsDockedHorizontally() )
- {
- sizeCalcLayout += _QueryFixedBarNewSize( __FSQ_DOCKED_H );
- SetInitDesiredSizeHorizontal( sizeCalcLayout );
- m_nMinHW = sizeCalcLayout.cx;
- }
- else if( IsDockedVertically() )
- {
- sizeCalcLayout += _QueryFixedBarNewSize( __FSQ_DOCKED_V );
- SetInitDesiredSizeVertical( sizeCalcLayout );
- m_nMinVH = sizeCalcLayout.cy;
- }
- else if( IsFloating() )
- {
- sizeCalcLayout += _QueryFixedBarNewSize( __FSQ_FLOATING );
- SetInitDesiredSizeFloating( sizeCalcLayout );
- }
- else
- {
- sizeCalcLayout += CSize( 20, 20 );
- }
- if( m_pDockSite == NULL )
- { // specific for dialog mode
- if( IsDockedHorizontally() )
- sizeCalcLayout.cy += 4;
- else
- sizeCalcLayout.cx += 4;
- } // specific for dialog mode
- return sizeCalcLayout;
- }
- INT CExtPanelControlBar::_CalcDesiredMinHW() const
- {
- ASSERT_VALID( this );
- CSize sizeCalcLayout = _QueryFixedBarNewSize( __FSQ_DOCKED_H );
- return sizeCalcLayout.cx;
- }
- CSize CExtPanelControlBar::_CalcDesiredMinOuterSize( BOOL bHorz ) const
- {
- ASSERT_VALID( this );
- CSize sizeCalcLayout =
- _QueryFixedBarNewSize(
- bHorz ? __FSQ_DOCKED_H : __FSQ_DOCKED_V
- );
- return sizeCalcLayout;
- }
- INT CExtPanelControlBar::_CalcDesiredMinVH() const
- {
- ASSERT_VALID( this );
- CSize sizeCalcLayout = _QueryFixedBarNewSize( __FSQ_DOCKED_V );
- return sizeCalcLayout.cy;
- }
- CSize CExtPanelControlBar::_CalcDesiredMinFloatedSize() const
- {
- ASSERT_VALID( this );
- CSize sizeCalcLayout = _QueryFixedBarNewSize( __FSQ_FLOATING );
- return sizeCalcLayout;
- }
- CSize CExtPanelControlBar::_QueryFixedBarNewSize(
- CExtPanelControlBar::e_fixed_bar_size_query_t eWhichSizeNeedToKnow
- ) const
- {
- CSize sizeResult( OnQueryFixedBarNewSize(eWhichSizeNeedToKnow) );
- // if( eWhichSizeNeedToKnow != __FSQ_FLOATING )
- // {
- // CRect rcClient, rcWnd;
- // GetClientRect( &rcClient );
- // GetWindowRect( &rcWnd );
- // CSize sizeClient( rcClient.Size() );
- // CSize sizeWnd( rcWnd.Size() );
- // sizeResult += sizeWnd;
- // sizeResult -= sizeClient;
- // }
- return sizeResult;
- }
- CSize CExtPanelControlBar::OnQueryFixedBarNewSize(
- CExtPanelControlBar::e_fixed_bar_size_query_t eWhichSizeNeedToKnow
- ) const
- {
- ASSERT_VALID( this );
- eWhichSizeNeedToKnow;
- //CSize sizeResult;
- // switch( eWhichSizeNeedToKnow )
- // {
- // case __FSQ_DOCKED_H:
- // sizeResult = CSize( 20, 20 );
- // break;
- // case __FSQ_DOCKED_V:
- // sizeResult = CSize( 20, 20 );
- // break;
- // default:
- // ASSERT( eWhichSizeNeedToKnow == __FSQ_FLOATING );
- // sizeResult = CSize( 20, 20 );
- // break;
- // }
- // return sizeResult;
- CSize sizeResult( _GetChildSize() );
- CRect rcMargins = OnQueryFixedBarChildWindowMargins();
- sizeResult.cx += rcMargins.left + rcMargins.right;
- sizeResult.cy += rcMargins.top + rcMargins.bottom;
- return sizeResult;
- }
- CRect CExtPanelControlBar::OnQueryFixedBarChildWindowMargins() const
- {
- ASSERT_VALID( this );
- return m_rcMargins;
- }
- CSize CExtPanelControlBar::_GetChildSize() const
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL
- || (! ::IsWindow(GetSafeHwnd()))
- )
- return CSize( 0, 0 );
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild->GetSafeHwnd() == NULL
- || (! ::IsWindow(pWndChild->GetSafeHwnd()))
- )
- return CSize( 0, 0 );
- CRect rcChild;
- pWndChild->GetWindowRect( &rcChild );
- CSize sizeChild( rcChild.Size() );
- return sizeChild;
- }
- void CExtPanelControlBar::_RepositionChild(
- bool bRedraw // = true
- )
- {
- ASSERT_VALID( this );
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild == NULL )
- return;
- CRect rcMargins = OnQueryFixedBarChildWindowMargins();
- CRect rcRequired, rcReal;
- GetClientRect( &rcRequired );
- rcRequired.DeflateRect( &rcMargins );
- pWndChild->GetWindowRect( &rcReal );
- ScreenToClient( &rcReal );
- // if( rcReal == rcRequired )
- if( rcReal.TopLeft() == rcRequired.TopLeft() )
- return;
- rcReal.OffsetRect( - rcReal.TopLeft() + rcRequired.TopLeft() );
- pWndChild->MoveWindow(
- &rcReal, // &rcRequired,
- bRedraw ? TRUE : FALSE
- );
- }
- void CExtPanelControlBar::OnSize(UINT nType, int cx, int cy)
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnSize(nType, cx, cy);
- _RepositionChild();
- }
- void CExtPanelControlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnWindowPosChanged(lpwndpos);
- _RepositionChild();
- }
- void CExtPanelControlBar::OnSetFocus(CWnd* pOldWnd)
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnSetFocus(pOldWnd);
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild == NULL )
- return;
- pWndChild->SetFocus();
- }
- void CExtPanelControlBar::OnPaint()
- {
- ASSERT_VALID( this );
- CPaintDC dcPaint( this );
- CExtMemoryDC dc( &dcPaint );
- CRect rcClient;
- GetClientRect( &rcClient );
- CWnd * pWndChild = GetWindow( GW_CHILD );
- if( pWndChild == NULL )
- { // if no child - fill entire client area
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
- )
- dc.FillSolidRect(
- &rcClient,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- //
- // DEBUG BLOCK BEGIN: - fill gradient & draw text
- //
- // rcClient.DeflateRect( 2, 2 );
- // COLORREF clrFc = PmBridge_GetPM()->GetColor( COLOR_3DFACE, this );
- // COLORREF clrDk = PmBridge_GetPM()->GetColor( COLOR_3DDKSHADOW, this );
- // COLORREF clrHi = PmBridge_GetPM()->GetColor( COLOR_3DHILIGHT, this );
- // COLORREF clrLo = PmBridge_GetPM()->GetColor( COLOR_3DSHADOW, this );
- // dc.Draw3dRect( &rcClient, clrFc, clrDk );
- // rcClient.DeflateRect( 1, 1 );
- // dc.Draw3dRect( &rcClient, clrHi, clrLo );
- // rcClient.DeflateRect( 1, 1 );
- // dc.Draw3dRect( &rcClient, clrLo, clrHi );
- // rcClient.DeflateRect( 1, 1 );
- // dc.Draw3dRect( &rcClient, clrDk, clrFc );
- // rcClient.DeflateRect( 2, 2 );
- // UINT nDockBarID = GetSafeDockBarDlgCtrlID();
- // CExtPaintManager::stat_PaintGradientRect(
- // dc,
- // rcClient,
- // RGB( 128, 128, 255 ),
- // RGB( 0, 0, 0 ),
- // (nDockBarID==AFX_IDW_DOCKBAR_LEFT || nDockBarID==AFX_IDW_DOCKBAR_RIGHT)
- // ? true : false
- // );
- //
- // CRect rcDrawText( rcClient );
- // rcDrawText.DeflateRect( 5, 5 );
- // CRect rcDrawTextShadow( rcDrawText );
- // CExtSafeString sText;
- // CFont * pFont = &PmBridge_GetPM()->m_FontNormal;
- // switch( nDockBarID )
- // {
- // case AFX_IDW_DOCKBAR_TOP:
- // sText = _T("Docked at top");
- // rcDrawTextShadow.OffsetRect( 1, 1 );
- // break;
- // case AFX_IDW_DOCKBAR_BOTTOM:
- // sText = _T("Docked at bottom");
- // rcDrawTextShadow.OffsetRect( 1, 1 );
- // break;
- // case AFX_IDW_DOCKBAR_LEFT:
- // sText = _T("Docked at left");
- // pFont = &PmBridge_GetPM()->m_FontNormalVert;
- // rcDrawText.OffsetRect( rcDrawText.Width(), 0 );
- // rcDrawText.OffsetRect( -1, -2 );
- // rcDrawTextShadow = rcDrawText;
- // rcDrawTextShadow.OffsetRect( 1, 1 );
- // break;
- // case AFX_IDW_DOCKBAR_RIGHT:
- // sText = _T("Docked at right");
- // pFont = &PmBridge_GetPM()->m_FontNormalVert;
- // rcDrawText.OffsetRect( rcDrawText.Width(), 0 );
- // rcDrawText.OffsetRect( -1, -2 );
- // rcDrawTextShadow = rcDrawText;
- // rcDrawTextShadow.OffsetRect( 1, 1 );
- // break;
- // default:
- // ASSERT( nDockBarID == AFX_IDW_DOCKBAR_FLOAT );
- // sText = _T("Floating");
- // rcDrawTextShadow.OffsetRect( 1, 1 );
- // break;
- // } // switch( nDockBarID )
- // CFont * pOldFont = dc.SelectObject( pFont );
- // int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- // COLORREF clrOldTextColor = dc.SetTextColor( RGB(128,128,128) );
- // dc.DrawText( sText, &rcDrawTextShadow, DT_SINGLELINE|DT_NOCLIP );
- // dc.SetTextColor( RGB(255,255,255) );
- // dc.DrawText( sText, &rcDrawText, DT_SINGLELINE|DT_NOCLIP );
- // dc.SetTextColor( clrOldTextColor );
- // dc.SetBkMode( nOldBkMode );
- // dc.SelectObject( pOldFont );
- //
- // DEBUG BLOCK END: - fill gradient & draw text
- //
- } // if no child - fill entire client area
- else
- { // if has child - fill margins around child
- // CRect rcMargins = OnQueryFixedBarChildWindowMargins();
- // CRect rcExclude( rcClient );
- // rcExclude.DeflateRect( &rcMargins );
- // dc.ExcludeClipRect( &rcExclude );
- CExtPaintManager::stat_ExcludeChildAreas(
- dc,
- m_hWnd
- );
- if( (! PmBridge_GetPM()->GetCb2DbTransparentMode(this) )
- || (! PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
- )
- dc.FillSolidRect(
- &rcClient,
- PmBridge_GetPM()->GetColor(
- CExtPaintManager::CLR_3DFACE_OUT, this
- )
- );
- dc.SelectClipRgn( NULL );
- } // if has child - fill margins around child
- }
- bool CExtPanelControlBar::_AffixmentIsAlignedHW() const
- {
- ASSERT_VALID( this );
- return false;
- }
- LRESULT CExtPanelControlBar::DoHelpHitTest( CPoint ptHelpHitTest )
- {
- ASSERT_VALID( this );
- return CExtControlBar::DoHelpHitTest( ptHelpHitTest );
- }
- bool CExtPanelControlBar::OnQueryMultiRowLayout() const
- {
- ASSERT_VALID( this );
- return false;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * CExtPanelControlBar::GetCustomizeSite()
- {
- ASSERT_VALID( this );
- return NULL;
- }
- bool CExtPanelControlBar::OnCustomizeRegisterBar(
- CExtCustomizeSite * pCustomizeSite
- )
- {
- ASSERT_VALID( this );
- ASSERT( pCustomizeSite != NULL );
- pCustomizeSite;
- return false;
- }
- void CExtPanelControlBar::OnCustomizeModeEnter()
- {
- ASSERT_VALID( this );
- }
- void CExtPanelControlBar::OnCustomizeModeLeave()
- {
- ASSERT_VALID( this );
- }
- void CExtPanelControlBar::OnCustomizeListBoxUpdate( CExtCustomizeToolbarsListBox * pWndList )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pWndList );
- CExtToolControlBar::OnCustomizeListBoxUpdate( pWndList );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- #ifndef __EXT_MFC_NO_UNDO_REDO_POPUP
- /////////////////////////////////////////////////////////////////////////////
- // CExtBarUndoRedoButton
- IMPLEMENT_DYNCREATE(CExtBarUndoRedoButton, CExtBarButton)
- CExtBarUndoRedoButton::CExtBarUndoRedoButton(
- CExtToolControlBar * pBar, // = NULL
- UINT nCmdID, // = ID_SEPARATOR
- UINT nStyle // = 0
- )
- : CExtBarButton( pBar, nCmdID, nStyle )
- , m_lParamCookie( 0L )
- , m_dwListBoxStyles( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_MULTIPLESEL|LBS_NOINTEGRALHEIGHT|LBS_HASSTRINGS|LBS_OWNERDRAWVARIABLE )
- , m_nDropDownWidth( -1 ) // (-1) - auto calc
- , m_nDropDownHeightMax( 250 )
- {
- }
- CExtBarUndoRedoButton::~CExtBarUndoRedoButton()
- {
- }
- LPARAM CExtBarUndoRedoButton::LParamCookieGet() const
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode(false);
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- return pNode->GetLParam();
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return m_lParamCookie;
- }
- void CExtBarUndoRedoButton::LParamCookieSet(
- LPARAM lParamCookie // = 0L
- )
- {
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = ((CExtBarButton*)this)->GetCmdNode(false);
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->SetLParam( lParamCookie );
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_lParamCookie = lParamCookie;
- }
- bool CExtBarUndoRedoButton::CanBePressedInDisabledState()
- {
- return false;
- }
- bool CExtBarUndoRedoButton::IsAbleToTrackMenu(
- bool bCustomizeMode // = false
- ) const
- {
- ASSERT_VALID( this );
- if( bCustomizeMode )
- return false;
- return true;
- }
- LRESULT CExtBarUndoRedoButton::OnHelpHitTest(
- CPoint point
- )
- {
- ASSERT_VALID( this );
- // return
- // CExtBarButton::OnHelpHitTest( point );
- point;
- return GetCmdID();
- }
- CExtPopupMenuWnd * CExtBarUndoRedoButton::OnCreateDropPopup(
- bool bContentExpand // true - inserting to content expand menu, false - tracking dropped popup
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- bContentExpand;
- CWnd * pWndCmdTarget = GetCmdTargetWnd();
- ASSERT_VALID( pWndCmdTarget );
- CExtPopupUndoRedoMenuWnd * pPopup =
- STATIC_DOWNCAST(
- CExtPopupUndoRedoMenuWnd,
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetBar()->GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupUndoRedoMenuWnd),
- this
- )
- );
- pPopup->m_lParamCookie = LParamCookieGet();
- pPopup->m_pCbListBoxSelection =
- (CExtPopupInplaceListBox::pCbListBoxSelection)
- stat_CbListBoxSelection;
- pPopup->m_pSelectionCookie = (LPVOID)this;
-
- pPopup->m_pCbInitListBoxContent =
- (CExtPopupInplaceListBox::pCbInitListBoxContent)
- stat_CbInitListBoxContent;
- pPopup->m_pInitListBoxCookie = (LPVOID)this;
- pPopup->m_pCbListBoxItemDraw =
- (CExtPopupInplaceListBox::pCbListBoxItemDraw)
- stat_CbListBoxItemDraw;
- pPopup->m_pCbListBoxItemMeasure =
- (CExtPopupInplaceListBox::pCbListBoxItemMeasure)
- stat_CbListBoxItemMeasure;
- pPopup->m_pListBoxItemCookie = (LPVOID)this;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite == NULL
- || (! pSite->OnPopupListBoxGetStyles(
- this,
- GetCmdNode( false ),
- pPopup->m_dwListBoxStyles
- )
- )
- )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- pPopup->m_dwListBoxStyles = m_dwListBoxStyles;
- pPopup->m_pCbFormatCaption =
- (CExtPopupUndoRedoMenuWnd::pCbFormatCaption)
- stat_CbFormatCaption;
- pPopup->m_pFormatCaptionCookie = (LPVOID)this;
- CSize sizeMeasure = OnPopupListBoxMeasureTrackSize();
- pPopup->m_sizeChildControl = sizeMeasure;
-
- VERIFY(
- pPopup->CreatePopupMenu( pWndCmdTarget->GetSafeHwnd() )
- );
-
- return pPopup;
- }
- UINT CExtBarUndoRedoButton::OnTrackPopup(
- CPoint point,
- bool bSelectAny,
- bool bForceNoAnimation
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- ASSERT( CtrlGet() == NULL );
- ASSERT( IsAbleToTrackMenu() );
- bool bDockSiteCustomizeMode =
- pBar->_IsDockSiteCustomizeMode();
- if( bDockSiteCustomizeMode )
- return UINT(-1L);
- if( !IsEnabled() )
- return UINT(-1L);
- bool bPrevTBMT = CExtToolControlBar::g_bMenuTracking;
- if( CExtToolControlBar::g_bMenuTracking
- //&& CExtPopupMenuWnd::IsMenuTracking()
- && pBar->_GetIndexOf(this) ==
- pBar->GetMenuTrackingButton()
- )
- return UINT(-1L);
- CExtToolControlBar::_CloseTrackingMenus();
- if( pBar->IsFloating() )
- {
- pBar->ActivateTopParent();
- CFrameWnd * pFrame =
- pBar->GetDockingFrame();
- ASSERT_VALID( pFrame );
- pFrame->BringWindowToTop();
- }
- CExtPopupMenuWnd * pPopup = OnCreateDropPopup( false );
- if( pPopup == NULL )
- {
- ASSERT( FALSE );
- return UINT(-1L);
- }
- ASSERT_VALID( pPopup );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- pPopup->_CmdNodeSet( GetCmdNode(false) );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtToolControlBar::g_bMenuTracking = bPrevTBMT;
- CRect rcBtn = Rect();
- pBar->ClientToScreen( &rcBtn );
- pBar->ClientToScreen( &point );
- DWORD dwTrackFlags =
- OnGetTrackPopupFlags()
- | TPMX_OWNERDRAW_FIXED
- ;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( pBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) ) )
- dwTrackFlags |= TPMX_COMBINE_NONE|TPMX_RIBBON_MODE|TPMX_NO_HIDE_RARELY;
- else
- dwTrackFlags |= TPMX_COMBINE_DEFAULT;
- #else // (!defined __EXT_MFC_NO_RIBBON_BAR)
- dwTrackFlags |= TPMX_COMBINE_DEFAULT;
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( bSelectAny )
- dwTrackFlags |= TPMX_SELECT_ANY;
- if( CExtToolControlBar::g_bMenuTrackingExpanded )
- dwTrackFlags |= TPMX_NO_HIDE_RARELY;
- if( bForceNoAnimation )
- dwTrackFlags |= TPMX_FORCE_NO_ANIMATION;
- pBar->_SwitchMenuTrackingIndex(
- pBar->_GetIndexOf( this )
- );
- UINT nResultCmdID = (UINT)-1L;
- pPopup->m_hWndNotifyMenuClosed = pBar->GetSafeHwnd();
- if( GetSeparatedDropDown() )
- m_bDropDownHT = true;
- g_pTrackingMenuTBB = this;
- if( ! pPopup->TrackPopupMenu(
- dwTrackFlags,
- point.x,
- point.y,
- &rcBtn,
- GetBar(),
- CExtToolControlBar::_CbPaintCombinedContent,
- &nResultCmdID,
- true
- )
- )
- {
- g_pTrackingMenuTBB = NULL;
- //delete pPopup;
- CExtToolControlBar::_CloseTrackingMenus();
- return UINT(-1L);
- }
- CExtToolControlBar::g_bMenuTracking = true;
- pBar->_SwitchMenuTrackingIndex(
- pBar->_GetIndexOf( this )
- );
- return UINT(-1L);
- }
- BOOL CExtBarUndoRedoButton::PutToPopupMenu(
- CExtPopupMenuWnd * pPopup
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( !pPopup->ItemInsert( GetCmdID(true) ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pPopup->ItemGetInfo( pPopup->ItemGetCount() - 1 );
- ASSERT_VALID( pBar->m_pDockSite );
- VERIFY(
- mi.UpdateFromCmdTree(
- pBar->m_pDockSite->m_hWnd,
- GetCmdNode(false),
- GetCmdNode(false)->GetOwnIndex(),
- pPopup
- )
- );
- mi.SetCmdNode( GetCmdNode() );
- mi.SetChildCombine();
- #else
- CExtPopupMenuWnd * pSub = OnCreateDropPopup( true );
- if( pSub == NULL )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- ASSERT_VALID( pSub );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_pBar->GetSafeHwnd() ),
- GetCmdID( false )
- );
- ASSERT( pCmdItem != NULL );
- CExtSafeString sText = pCmdItem->m_sMenuText;
- if( sText.IsEmpty() )
- sText = pCmdItem->m_sToolbarText;
- // added in 2.55
- CExtCmdIcon _emptyIcon, * pCmdIcon = GetIconPtr();
- // commented in 2.55
- // CExtCmdIcon _emptyIcon, * pCmdIcon =
- // g_CmdManager->CmdGetIconPtr(
- // g_CmdManager->ProfileNameFromWnd( m_pBar->GetSafeHwnd() ),
- // GetCmdID( false )
- // );
- CExtCmdIcon & _cmdIcon =
- ( pCmdIcon != NULL )
- ? (*pCmdIcon)
- : _emptyIcon
- ;
- if( ! pPopup->ItemInsertSpecPopup( pSub, -1, sText, _cmdIcon ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
-
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pPopup->ItemGetInfo( pPopup->ItemGetCount() - 1 );
-
- mi.Enable(
- IsEnabled() ? true : false
- );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return TRUE;
- }
- bool CExtBarUndoRedoButton::stat_CbFormatCaption(
- CExtSafeString & strCaption,
- CExtPopupUndoRedoMenuWnd * pUndoRedoPopupMenuWnd,
- CExtBarUndoRedoButton * pUndoRedoTBB
- )
- {
- ASSERT_VALID( pUndoRedoTBB );
- ASSERT_KINDOF( CExtBarUndoRedoButton, pUndoRedoTBB );
- return
- pUndoRedoTBB->OnPopupUndoRedoFormatCaption(
- strCaption,
- pUndoRedoPopupMenuWnd
- );
- }
- bool CExtBarUndoRedoButton::stat_CbInitListBoxContent(
- CExtPopupInplaceListBox & wndListBox,
- CExtBarUndoRedoButton * pUndoRedoTBB
- )
- {
- ASSERT_VALID( pUndoRedoTBB );
- ASSERT_KINDOF( CExtBarUndoRedoButton, pUndoRedoTBB );
- return
- pUndoRedoTBB->OnPopupListBoxInitContent(
- wndListBox
- );
- }
- bool CExtBarUndoRedoButton::stat_CbListBoxSelection(
- CExtPopupInplaceListBox & wndListBox,
- CExtBarUndoRedoButton * pUndoRedoTBB,
- int eSAT // CExtPopupInplaceListBox::e_sel_action_t
- )
- {
- ASSERT_VALID( pUndoRedoTBB );
- ASSERT_KINDOF( CExtBarUndoRedoButton, pUndoRedoTBB );
- switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
- {
- case CExtPopupInplaceListBox::__SAT_SELCHANGE:
- return
- pUndoRedoTBB->OnPopupListBoxSelChange(
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_SELENDOK:
- return
- pUndoRedoTBB->OnPopupListBoxSelEndOK(
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_SELENDCANCEL:
- return
- pUndoRedoTBB->OnPopupListBoxSelEndCancel(
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_CLOSE:
- return
- pUndoRedoTBB->OnPopupListBoxClose(
- wndListBox
- );
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
- return false;
- }
- bool CExtBarUndoRedoButton::stat_CbListBoxItemDraw(
- CExtPopupInplaceListBox & wndListBox,
- CExtBarUndoRedoButton * pUndoRedoTBB,
- LPDRAWITEMSTRUCT pDIS
- )
- {
- ASSERT_VALID( pUndoRedoTBB );
- ASSERT_KINDOF( CExtBarUndoRedoButton, pUndoRedoTBB );
- ASSERT( pDIS != NULL && pDIS->hDC != NULL );
- return
- pUndoRedoTBB->OnPopupListBoxItemDraw(
- wndListBox,
- pDIS
- );
- }
- bool CExtBarUndoRedoButton::stat_CbListBoxItemMeasure(
- CExtPopupInplaceListBox & wndListBox,
- CExtBarUndoRedoButton * pUndoRedoTBB,
- LPMEASUREITEMSTRUCT pMIS
- )
- {
- ASSERT_VALID( pUndoRedoTBB );
- ASSERT_KINDOF( CExtBarUndoRedoButton, pUndoRedoTBB );
- ASSERT( pMIS != NULL );
- return
- pUndoRedoTBB->OnPopupListBoxItemMeasure(
- wndListBox,
- pMIS
- );
- }
- CSize CExtBarUndoRedoButton::OnPopupListBoxMeasureTrackSize() const
- {
- ASSERT_VALID( this );
- const CExtToolControlBar * pBar = GetBar();
- ASSERT_VALID( pBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL )
- {
- CSize _size =
- pSite->OnPopupListBoxMeasureTrackSize(
- this,
- ((CExtBarButton*)this)->GetCmdNode( false )
- );
- if( _size.cx > 0 && _size.cy > 0 )
- return _size;
- } // if( pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- int nCount = (int)m_arrLbItems.GetSize();
- if( (m_dwListBoxStyles & LBS_HASSTRINGS) == 0
- || nCount == 0
- )
- {
- CSize sizeCalc( 150, 100 );
- if( m_nDropDownWidth > 0 )
- sizeCalc.cx = m_nDropDownWidth;
- if( m_nDropDownHeightMax > 0 )
- sizeCalc.cy = m_nDropDownHeightMax;
- // if( m_bComboField )
- // sizeCalc.cx +=
- // //::GetSystemMetrics( SM_CXSIZEFRAME )
- // + GetBar()->PmBridge_GetPM()->GetDropDownButtonWidth( this )
- // ;
- return sizeCalc;
- }
- CWindowDC dc( NULL );
- CSize sizeCalc( 0, 0 );
- for( int i = 0; i < nCount; i++ )
- {
- const CExtSafeString & sItem =
- ((CExtSafeStringArray*)&m_arrLbItems)->ElementAt( i );
- CExtSafeString sMeasure(
- sItem.IsEmpty() ? _T("AaWwPpQqRrWwZz") : sItem
- );
- CRect rcMeasure =
- CExtPaintManager::stat_CalcTextDimension(
- dc,
- pBar->PmBridge_GetPM()->m_FontNormal,
- sMeasure
- );
- if( m_dwListBoxStyles & (LBS_OWNERDRAWVARIABLE|LBS_OWNERDRAWFIXED) )
- rcMeasure.InflateRect( OnPopupListBoxCalcItemExtraSizes() );
- CSize sizeMeasure = rcMeasure.Size();
- if( m_nDropDownWidth == -1 )
- sizeCalc.cx = max( sizeCalc.cx, sizeMeasure.cx );
- sizeCalc.cy += sizeMeasure.cy;
- } // for( int i = 0; i < nCount; i++ )
- if( m_nDropDownWidth == -1 )
- sizeCalc.cx += ::GetSystemMetrics( SM_CXSIZEFRAME )*2;
- sizeCalc.cy += 2;
- ASSERT( m_nDropDownHeightMax > 0 );
- INT nDD = GetBar()->PmBridge_GetPM()->GetDropDownButtonWidth( (CObject*)this );
- if( sizeCalc.cy > m_nDropDownHeightMax )
- {
- sizeCalc.cy = m_nDropDownHeightMax;
- if( m_nDropDownWidth == -1 )
- sizeCalc.cx +=
- ::GetSystemMetrics( SM_CXSIZEFRAME )
- + nDD
- ;
- } // if( sizeCalc.cy > m_nDropDownHeightMax )
- else if( m_dwListBoxStyles & LBS_DISABLENOSCROLL )
- {
- if( m_nDropDownWidth == -1 )
- sizeCalc.cx +=
- ::GetSystemMetrics( SM_CXSIZEFRAME )
- + nDD
- ;
- } // else if( m_dwListBoxStyles & LBS_DISABLENOSCROLL )
- if( m_nDropDownWidth > 0 )
- sizeCalc.cx = m_nDropDownWidth;
- return sizeCalc;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxInitContent(
- CExtPopupInplaceListBox & wndListBox
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxInitContent(
- this,
- GetCmdNode( false ),
- wndListBox
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (wndListBox.GetStyle() & LBS_HASSTRINGS) != 0 )
- {
- int nCount = (int)m_arrLbItems.GetSize();
- for( int i = 0; i < nCount; i++ )
- {
- const CExtSafeString & sItem = m_arrLbItems.ElementAt( i );
- wndListBox.AddString(
- sItem.IsEmpty() ? _T("") : sItem
- );
- } // for( int i = 0; i < nCount; i++ )
- if( nCount > 0 )
- wndListBox.SetSel( 0, TRUE );
- } // if( (wndListBox.GetStyle() & LBS_HASSTRINGS) != 0 )
- return true;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxSelChange(
- CExtPopupInplaceListBox & wndListBox
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- wndListBox;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxSelChange(
- this,
- GetCmdNode( false ),
- wndListBox
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxSelEndOK(
- CExtPopupInplaceListBox & wndListBox
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- wndListBox;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HWND hWndThis = wndListBox.m_hWnd;
- ASSERT( hWndThis != NULL && ::IsWindow(hWndThis) );
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxSelEndOK(
- this,
- GetCmdNode( false ),
- wndListBox
- )
- )
- return true;
- if( ! ::IsWindow( hWndThis ) )
- return false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxSelEndCancel(
- CExtPopupInplaceListBox & wndListBox
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- wndListBox;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxSelEndCancel(
- this,
- GetCmdNode( false ),
- wndListBox
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxClose(
- CExtPopupInplaceListBox & wndListBox
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- wndListBox;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxClose(
- this,
- GetCmdNode( false ),
- wndListBox
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxItemDraw(
- CExtPopupInplaceListBox & wndListBox,
- LPDRAWITEMSTRUCT pDIS
- )
- {
- ASSERT_VALID( this );
- ASSERT( pDIS != NULL && pDIS->hDC != NULL );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxItemDraw(
- this,
- GetCmdNode( false ),
- wndListBox,
- pDIS
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
- return false;
- if( ((INT)pDIS->itemID) < 0 || ((INT)pDIS->itemID) >= wndListBox.GetCount() )
- return true;
- CDC dc;
- dc.Attach( pDIS->hDC );
- CExtToolControlBar * pBar = GetBar();
- if( pDIS->itemAction & (ODA_DRAWENTIRE | ODA_SELECT) )
- {
- CRect rcErase( pDIS->rcItem );
- if( INT(pDIS->itemID) == (wndListBox.GetCount()-1) )
- {
- CRect rcClient;
- wndListBox.GetClientRect( &rcClient );
- if( rcErase.bottom < rcClient.bottom )
- rcErase.bottom = rcClient.bottom;
- }
- dc.FillSolidRect(
- rcErase,
- pBar->PmBridge_GetPM()->GetColor( COLOR_WINDOW )
- );
- dc.FillSolidRect(
- &pDIS->rcItem,
- pBar->PmBridge_GetPM()->GetColor(
- ( pDIS->itemState & ODS_SELECTED )
- ? COLOR_HIGHLIGHT
- : COLOR_WINDOW
- ,
- this
- )
- );
- }
- if( INT(pDIS->itemID) >= 0 )
- {
- CString sText;
- wndListBox.GetText( (INT)pDIS->itemID, sText );
- if( !sText.IsEmpty() )
- {
- COLORREF clrTextOld =
- dc.SetTextColor(
- pBar->PmBridge_GetPM()->GetColor(
- ( pDIS->itemState & ODS_SELECTED )
- ? COLOR_HIGHLIGHTTEXT
- : COLOR_BTNTEXT
- ,
- this
- )
- );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- CRect rcText( pDIS->rcItem );
- rcText.DeflateRect( OnPopupListBoxCalcItemExtraSizes() );
- dc.DrawText(
- sText,
- &rcText,
- DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrTextOld );
- } // if( !sText.IsEmpty() )
- } // if( INT(pDIS->itemID) >= 0 )
- dc.Detach();
- return true;
- }
- bool CExtBarUndoRedoButton::OnPopupListBoxItemMeasure(
- CExtPopupInplaceListBox & wndListBox,
- LPMEASUREITEMSTRUCT pMIS
- )
- {
- ASSERT_VALID( this );
- ASSERT( pMIS != NULL );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupListBoxItemMeasure(
- this,
- GetCmdNode( false ),
- wndListBox,
- pMIS
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
- return false;
- pMIS->itemWidth = pMIS->itemHeight = 10;
- if( ((INT)pMIS->itemID) < 0 || ((INT)pMIS->itemID) >= wndListBox.GetCount() )
- return true;
- CExtSafeString sMeasure;
- wndListBox.GetText( (INT)pMIS->itemID, *((CString*)&sMeasure) );
- if( sMeasure.IsEmpty() )
- return true;
- CExtToolControlBar * pBar = GetBar();
- CWindowDC dc( NULL );
- CRect rcMeasure =
- CExtPaintManager::stat_CalcTextDimension(
- dc,
- pBar->PmBridge_GetPM()->m_FontNormal,
- sMeasure
- );
- rcMeasure.InflateRect( OnPopupListBoxCalcItemExtraSizes() );
- pMIS->itemWidth = rcMeasure.Width();
- pMIS->itemHeight = rcMeasure.Height();
- return true;
- }
- CSize CExtBarUndoRedoButton::OnPopupListBoxCalcItemExtraSizes() const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL )
- {
- CSize _size =
- pSite->OnPopupListBoxCalcItemExtraSizes(
- this,
- ((CExtBarButton*)this)->GetCmdNode( false )
- );
- if( _size.cx > 0 && _size.cy > 0 )
- return _size;
- } // if( pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return CSize( 2, 1 );
- }
- bool CExtBarUndoRedoButton::OnPopupUndoRedoFormatCaption(
- CExtSafeString & strCaption,
- CExtPopupUndoRedoMenuWnd * pUndoRedoPopupMenuWnd
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pBar );
- strCaption;
- pUndoRedoPopupMenuWnd;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = m_pBar->GetCustomizeSite();
- if( pSite != NULL
- && pSite->OnPopupUndoRedoFormatCaption(
- this,
- GetCmdNode( false ),
- pUndoRedoPopupMenuWnd,
- strCaption
- )
- )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- #endif // __EXT_MFC_NO_UNDO_REDO_POPUP