ExtPopupMenuWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:735k
- rcRectRgn,
- m_ctrlShadow.IsAvailable(),
- nSizeShadow,
- this
- );
- if( hRegion == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- if( ( m_ptTrack.x + rcWnd.Width() ) > rcDesktop.right )
- m_bFlipHorz = true;
- if( ( m_ptTrack.y + rcWnd.Height() ) > rcDesktop.bottom )
- m_bFlipVert = true;
- if( pSize != NULL )
- {
- pSize->cx = rcWnd.Width();
- pSize->cy = rcWnd.Height();
- }
- } // rectangle cases
- break;
- default:
- ASSERT( FALSE );
- return NULL;
- } // switch( eTS )
- return hRegion;
- }
- void CExtPopupScreenTipWnd::_DoPaint(
- CDC & dcPaint,
- bool bUseBackBuffer // = true
- )
- {
- //ASSERT_VALID( this );
- if( m_cmdScreenTip.IsEmpty() )
- {
- CExtPopupMenuTipWnd::_DoPaint( dcPaint, bUseBackBuffer );
- return;
- }
- CDC & dc = dcPaint;
- CRect rcLayout;
- GetClientRect( &rcLayout );
- HRGN hRegion = CreateRectRgnIndirect( &rcLayout );
- GetWindowRgn( hRegion );
- CRgn * pRegion = CRgn::FromHandle( hRegion );
- CExtPaintManager * pPM = PmBridge_GetPM();
- ASSERT_VALID( pPM );
- e_tip_style_t eTS = GetTipStyle();
- switch( eTS )
- {
- case __ETS_BALLOON:
- case __ETS_BALLOON_NO_ICON:
- {
- CBrush brushWindow;
- brushWindow.CreateSolidBrush(
- //pPM->GetColor( COLOR_INFOBK, this )
- ::GetSysColor( COLOR_INFOBK )
- );
- CBrush brushFrame;
- brushFrame.CreateSolidBrush(
- //pPM->GetColor( COLOR_3DDKSHADOW, this )
- ::GetSysColor( COLOR_3DDKSHADOW )
- );
- CBrush brushInnerFrame;
- brushInnerFrame.CreateSolidBrush(
- //pPM->GetColor( COLOR_3DFACE, this)
- ::GetSysColor( COLOR_3DFACE )
- );
- // frame
- dc.FillRgn( pRegion, &brushWindow );
- dc.FrameRgn( pRegion, &brushInnerFrame, 3, 3 );
- dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
- // adjust icon's area
- rcLayout.DeflateRect( m_sizeRounders.cx, m_sizeRounders.cy, 0, 0 );
- if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
- rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- int nIconVertPos = m_sizeRounders.cy;
- if( m_bFlipVert )
- {
- rcLayout.OffsetRect( 0, m_sizeLeader.cy );
- nIconVertPos += m_sizeLeader.cy;
- }
- pPM->ScreenTip_Paint( dc, rcLayout, m_cmdScreenTip, this );
- } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
- break;
- case __ETS_RECTANGLE:
- case __ETS_RECTANGLE_NO_ICON:
- case __ETS_INV_RECTANGLE:
- case __ETS_INV_RECTANGLE_NO_ICON:
- {
- int nSizeShadow = CalcShadowSize();
- ASSERT( nSizeShadow >= 0 );
- if( nSizeShadow > 0 )
- {
- rcLayout.DeflateRect( 0, 0, nSizeShadow, nSizeShadow );
- m_shadow.Paint(
- pPM,
- dc,
- rcLayout,
- CRect( 0, 0, 0, 0 ),
- CRect( 0, 0, 0, 0 ),
- nSizeShadow,
- 70,
- 95
- );
- }
- pPM->ScreenTip_Paint( dc, rcLayout, m_cmdScreenTip, this );
- } // rectangle cases
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( eTS )
- ::DeleteObject( hRegion );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupMenuWnd
- CExtSafeString CExtPopupMenuWnd::g_strSpecSymbols( _T("~`!@#$%^&*()_-+={}[]:;"'|\<,>.?/ ") );
- INT CExtPopupMenuWnd::g_nTimeDelayedDisplaying = 300;
- INT CExtPopupMenuWnd::g_nTimeDelayedHiding = 300;
- bool CExtPopupMenuWnd::g_bUseAcceleratedMenuScrolling = false;
- INT CExtPopupMenuWnd::g_nAcceleratedIncreaseStep = 500;
- INT CExtPopupMenuWnd::g_nAcceleratedIncreasePercent = 50;
- INT CExtPopupMenuWnd::g_nAcceleratedPixelsPerStepMax = 400;
- bool CExtPopupMenuWnd::g_bTranslateContextHelpCmd = false;
- ACCEL CExtPopupMenuWnd::g_accelContextHelp = { FVIRTKEY, VK_F1, ID_HELP };
- // is allowed menu item positioning without
- // using only & - marked text
- bool CExtPopupMenuWnd::g_bAllowNonAccelPositioning = false;
- INT CExtPopupMenuWnd::g_nDefaultFadeOutAnimationStepCount = 8;
- INT CExtPopupMenuWnd::g_nDefaultFadeOutAnimationEllapse = 20;
- INT CExtPopupMenuWnd::g_nAutoExpandTime = 4000;
- IMPLEMENT_DYNCREATE( CExtPopupMenuWnd, CExtPopupBaseWnd )
- static CTypedPtrList < CPtrList, CExtPopupMenuWnd * > g_ListDetached;
- CExtPopupMenuWnd::CExtPopupMenuWnd()
- : m_pWndParentMenu( NULL )
- , m_hWndCmdReceiver( NULL )
- , m_hWndNotifyMenuClosed( NULL )
- , m_nLeftAreaWidth( 0 )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_pNode( NULL )
- , m_pDragSrcNode( NULL )
- , m_nDragSrcIdx( -1 )
- , m_bHelperNoRemoveSrc( false )
- , m_bHelperDragOverPassed( false )
- , m_pCustomizeSite( NULL )
- , m_nHelperDropIndexBefore( -1 )
- , m_bHelperNoHideChild( false )
- , m_ptHelperDragStart( 0, 0 )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- , m_nAcceleratedPixelsPerStepCurrent( __SCROLLING_PIXEL_STEP )
- , m_nAcceleratedMilliSecondsPassed( 0 )
- , m_sMenuCaption( _T("") )
- , m_sizeCaptionMeasured( 0, 0 )
- , m_bHelperResizingMode( false )
- , m_sizeResizingMin( 10, 10 )
- , m_sizeResizingMax( 32767, 32767 )
- , m_bHelperAnimationControllerDetected( false )
- , m_nFadeOutAnimationStepIndex( 0 )
- , m_nFadeOutAnimationStepCount( g_nDefaultFadeOutAnimationStepCount )
- , m_nFadeOutAnimationEllapse( g_nDefaultFadeOutAnimationEllapse )
- , m_bCanceling( false )
- , m_bHelperMouseBtnDownOnStart( false )
- , m_ptStartMousePos( -32767, -32767 )
- , m_bHelperReCreateDynamicShadowAtTheEndOfNearestAnimation( false )
- {
- __VPC_INC;
- _Init();
- g_ListDetached.AddTail( this );
- }
- CExtPopupMenuWnd::~CExtPopupMenuWnd()
- {
- POSITION pos = g_ListDetached.Find( this );
- if( pos != NULL )
- g_ListDetached.RemoveAt( pos );
- _OnCancelMode( true );
- if( m_bTopLevel )
- {
- VERIFY( _BuildItems( NULL, true ) );
- }
- __VPC_DEC;
- #ifdef _DEBUG
- if( m_bTopLevel )
- {
- __VPC_VERIFY_0;
- }
- #endif // _DEBUG
- CExtPopupMenuSite::g_DefPopupMenuSite.FadeOutInstanceRemove( this );
- }
- bool CExtPopupMenuWnd::TestHoverEnabledFromActiveHWND(
- HWND hWndTestFrom,
- HWND hWndActive, // = ::GetActiveWindow(),
- bool bCheckEnabled, // = true,
- bool bCheckVisible, // = true,
- bool bCheckExtPopupMenuTracking // = true
- )
- {
- if( bCheckExtPopupMenuTracking )
- {
- if( CExtPopupMenuWnd::IsMenuTracking() )
- return false;
- } // if( bCheckExtPopupMenuTracking )
-
- if( hWndTestFrom == NULL
- || ( ! ::IsWindow( hWndTestFrom ) )
- )
- return false;
- if( hWndActive == NULL
- || ( ! ::IsWindow( hWndActive ) )
- )
- return false;
- if( bCheckEnabled )
- {
- if( ! ::IsWindowEnabled( hWndTestFrom ) )
- return false;
- if( ! ::IsWindowEnabled( hWndActive ) )
- return false;
- } // if( bCheckEnabled )
- __EXT_MFC_LONG_PTR dwWndStyle;
- if( bCheckVisible )
- {
- dwWndStyle = ::__EXT_MFC_GetWindowLong( hWndTestFrom, GWL_STYLE );
- if( (dwWndStyle & WS_VISIBLE) == 0 )
- return false;
- dwWndStyle = ::__EXT_MFC_GetWindowLong( hWndActive, GWL_STYLE );
- if( (dwWndStyle & WS_VISIBLE) == 0 )
- return false;
- } // if( bCheckVisible )
- const DWORD dwTestStyles = (WS_VISIBLE|WS_POPUP);
- for( HWND hWndParentOfTest = ::GetParent( hWndTestFrom );
- hWndParentOfTest != NULL;
- hWndParentOfTest = ::GetParent( hWndParentOfTest )
- )
- { // walk parent popup windows of hWndTestFrom
- ASSERT( ::IsWindow( hWndParentOfTest ) );
- dwWndStyle = ::__EXT_MFC_GetWindowLong( hWndParentOfTest, GWL_STYLE );
- if( (dwWndStyle&dwTestStyles) == 0L )
- continue;
- if( hWndParentOfTest == hWndActive )
- return true;
- for( HWND hWndParentOfActive = hWndActive;
- hWndParentOfActive != NULL;
- hWndParentOfActive = ::GetParent( hWndParentOfActive )
- )
- { // walk parent popup windows of hWndActive
- ASSERT( ::IsWindow( hWndParentOfActive ) );
- dwWndStyle = ::__EXT_MFC_GetWindowLong( hWndParentOfActive, GWL_STYLE );
- if( (dwWndStyle&dwTestStyles) == 0L )
- continue;
- if( hWndParentOfActive == hWndParentOfTest )
- return true;
- } // walk parent popup windows of hWndActive
- } // walk parent popup windows of hWndTestFrom
- return false;
- }
- void CExtPopupMenuWnd::_Init()
- {
- ASSERT_VALID( this );
- m_nDyScrollOffset = 0;
- m_bTopLevel
- = m_bScrollingAvailable
- = m_bExpandAvailable
- = m_bExpandWasPressed
- = m_bCombineWithEA
- = m_bSuspendTips
- = false;
- m_dwTrackFlags = 0;
- m_nWaitingExpandTickCount = 0;
- m_nCurIndex
- = m_nDelayedFocusItemIndex
- = m_nLastMousePick
- = IDX_NOTHING;
- m_bDelayedHiding = false;
- m_nScrollingDirection = 0;
- m_rcScrollTop.SetRectEmpty();
- m_rcScrollBottom.SetRectEmpty();
- m_rcExpandBtn.SetRectEmpty();
- m_rcTearOffBtn.SetRectEmpty();
- m_rcRibbonBtnOptions.SetRectEmpty();
- m_rcRibbonBtnExit.SetRectEmpty();
- m_pCbPaintCombinedCookie = NULL;
- m_pCbPaintCombinedContent = NULL;
- m_bCookieIsObject = false;
- _InitAnimation();
- }
- CObject * CExtPopupBaseWnd::GetCookieAsObject()
- {
- if( (!m_bCookieIsObject)
- || m_pCbPaintCombinedCookie == NULL
- )
- return NULL;
- CObject * pObj = (CObject*)m_pCbPaintCombinedCookie;
- ASSERT_VALID( pObj );
- return pObj;
- }
- bool CExtPopupBaseWnd::IsToolBtnCombinedArea() const
- {
- if( !IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- return false;
- CExtPopupMenuWnd * pPopup = (CExtPopupMenuWnd*)(this);
- if( (LPVOID)(CExtPopupMenuWnd::stat_paint_combined_menu_toolbtn)
- != (LPVOID)(pPopup->GetCbPaintCombinedContent())
- )
- return false;
- return true;
- }
- int CExtPopupMenuWnd::_GetCurIndex() const
- {
- ASSERT_VALID( this );
- return m_nCurIndex;
- }
- int CExtPopupMenuWnd::_GetSpecBtnHeight()
- {
- int nHeight = g_PaintManager->GetMenuExpandButtonHeight();
- ASSERT( nHeight > 0 );
- return nHeight;
- }
- CRect CExtPopupMenuWnd::OnQueryMenuBorderMetrics() const
- {
- ASSERT_VALID( this );
- CExtPaintManager * pPM = PmBridge_GetPM();
- CRect rcMB = pPM->GetMenuBorderMetrics( (CWnd*)this );
- ASSERT( rcMB.left >= 0 );
- ASSERT( rcMB.top >= 0 );
- ASSERT( rcMB.right >= 0 );
- ASSERT( rcMB.bottom >= 0 );
- CSize _sizeCaption = MenuCaptionMeasure();
- rcMB.top += _sizeCaption.cy;
- INT nMarginHeight = 0, nResizingCornerPartWidth = 0;
- pPM->MenuBottomResizingMarginGetInfo(
- nMarginHeight,
- nResizingCornerPartWidth,
- const_cast < CExtPopupMenuWnd * > ( this )
- );
- rcMB.bottom += nMarginHeight;
- return rcMB;
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuWnd::MenuCaptionTextGet() const
- {
- ASSERT_VALID( this );
- return LPCTSTR(m_sMenuCaption);
- }
- void CExtPopupMenuWnd::MenuCaptionTextSet(
- __EXT_MFC_SAFE_LPCTSTR sMenuCaption // = NULL
- )
- {
- ASSERT_VALID( this );
- m_sizeCaptionMeasured.cx = m_sizeCaptionMeasured.cy = 0;
- m_sMenuCaption.Empty();
- if( sMenuCaption != NULL )
- m_sMenuCaption = sMenuCaption;
- }
- CSize CExtPopupMenuWnd::MenuCaptionMeasure() const
- {
- ASSERT_VALID( this );
- if( m_sizeCaptionMeasured.cx > 0 && m_sizeCaptionMeasured.cy > 0 )
- return m_sizeCaptionMeasured;
- CWindowDC dc( NULL );
- m_sizeCaptionMeasured =
- PmBridge_GetPM()->MenuCaption_Measure(
- dc,
- MenuCaptionTextGet(),
- const_cast < CExtPopupMenuWnd * > ( this )
- );
- return m_sizeCaptionMeasured;
- }
- void CExtPopupMenuWnd::MenuCaptionPaint(
- CDC & dc,
- CRect rcMenuCaption
- ) const
- {
- ASSERT_VALID( this );
- if( m_sizeCaptionMeasured.cx <= 0
- || m_sizeCaptionMeasured.cy <= 0
- || rcMenuCaption.IsRectEmpty()
- || ( ! dc.RectVisible( &rcMenuCaption ) )
- )
- return;
- PmBridge_GetPM()->MenuCaption_Paint(
- dc,
- rcMenuCaption,
- MenuCaptionTextGet(),
- const_cast < CExtPopupMenuWnd * > ( this )
- );
- }
- void CExtPopupMenuWnd::_CachedRectsEmpty()
- {
- ASSERT_VALID( this );
- int nItemIndex = 0, nItemCount = (int)m_items_all.GetSize();
- for( ; nItemIndex < nItemCount; nItemIndex++ )
- {
- MENUITEMDATA & _mii = ItemGetInfo( nItemIndex );
- _mii.CacheRectsEmpty();
- } // for( ; nItemIndex < nItemCount; nItemIndex++ )
- }
- void CExtPopupMenuWnd::_RecalcTrackParms(
- bool bMoveWindow // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- m_ptTrack = m_ptTrackOriginal;
- m_eCombineAlign = __CMBA_NONE;
- bool bPointAdjusted = true;
- CSize _size = _CalcTrackSize();
- if( m_bExcludeAreaSpec )
- {
- bool bRTL = OnQueryLayoutRTL();
- if( bRTL && (!m_bTopLevel) )
- {
- CExtPopupMenuWnd * pTop = m_pWndParentMenu;
- for( ; pTop != NULL; pTop = pTop->GetParentMenuWnd() )
- {
- if( pTop->_IsTopLevelPopup() )
- break;
- } // for( ; pTop != NULL; pTop = pTop->GetParentMenuWnd() )
- if( pTop != NULL )
- {
- DWORD dwTrackFlags = pTop->TrackFlagsGet();
- switch( (dwTrackFlags & TPMX_ALIGN_MASK) )
- {
- case TPMX_TOPALIGN:
- case TPMX_BOTTOMALIGN:
- dwTrackFlags &= ~(TPMX_ALIGN_MASK);
- dwTrackFlags |= TPMX_RIGHTALIGN;
- pTop->TrackFlagsSet( dwTrackFlags );
- break;
- } // switch( (pTop->m_dwTrackFlags & TPMX_ALIGN_MASK) )
- } // if( pTop != NULL )
- } // if( bRTL && (!m_bTopLevel) )
- DWORD dwTrackFlags = TrackFlagsGet();
- switch( (dwTrackFlags & TPMX_ALIGN_MASK) )
- {
- case TPMX_LEFTALIGN:
- m_ptTrack.x = m_rcExcludeArea.right;
- m_ptTrack.y = m_rcExcludeArea.top;
- break;
- case TPMX_RIGHTALIGN:
- m_ptTrack.x = m_rcExcludeArea.left - _size.cx;
- m_ptTrack.y = m_rcExcludeArea.top;
- break;
- case TPMX_TOPALIGN:
- m_ptTrack.x = m_rcExcludeArea.left;
- m_ptTrack.y = m_rcExcludeArea.bottom;
- break;
- case TPMX_BOTTOMALIGN:
- m_ptTrack.x = m_rcExcludeArea.left;
- m_ptTrack.y = m_rcExcludeArea.top - _size.cy;
- break;
- default:
- bPointAdjusted = false;
- break;
- } // switch( (dwTrackFlags & TPMX_ALIGN_MASK) )
- } // if( m_bExcludeAreaSpec )
- if( ! bPointAdjusted )
- {
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_RIGHTALIGN )
- m_ptTrack.x -= _size.cx;
- else
- {
- if( (dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_CENTERALIGN )
- m_ptTrack.x -= _size.cx/2;
- }
- if( (dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_BOTTOMALIGN )
- m_ptTrack.y -= _size.cy;
- else
- {
- if( (dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_VCENTERALIGN )
- m_ptTrack.y -= _size.cy/2;
- }
- } // if( !bPointAdjusted )
- if( bMoveWindow )
- {
- CRect wr = _CalcTrackRect();
- MoveWindow( &wr );
- } // if( bMoveWindow )
- }
- void CExtPopupMenuWnd::_RecalcLayoutImpl()
- {
- ASSERT_VALID( this );
- CRect rcClient;
- _GetClientRect( &rcClient );
- bool bTearOff = _IsTearOff();
- int nTearOffCaptionHeight = bTearOff ? _GetTearOffCaptionHeight() : 0;
- int nScrollBtnDy = _GetSpecBtnHeight();
- CRect rcMB = OnQueryMenuBorderMetrics();
- int nMenuShadowSize = 0;
- // OnQueryMenuShadowSize();
- int nScrollBottomOffsetDy = 0;
- if( m_bExpandAvailable )
- {
- m_rcExpandBtn.left =
- rcClient.left + rcMB.left;
- m_rcExpandBtn.right =
- rcClient.right - (rcMB.right + nMenuShadowSize);
- m_rcExpandBtn.bottom =
- rcClient.bottom - (rcMB.bottom + nMenuShadowSize);
- m_rcExpandBtn.top =
- m_rcExpandBtn.bottom - nScrollBtnDy;
- nScrollBottomOffsetDy =
- - m_rcExpandBtn.Height();
- m_rcExpandBtn.left += m_nLeftAreaWidth;
- m_rcExpandBtn.OffsetRect(0,-1);
- } // if( m_bExpandAvailable )
- m_rcRibbonBtnOptions.SetRectEmpty();
- m_rcRibbonBtnExit.SetRectEmpty();
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- {
- CRect rcAlign = rcClient;
- rcAlign.top = rcAlign.bottom - rcMB.bottom;
- rcAlign.right -= 7;
- rcAlign.DeflateRect( 0, 3 );
- if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- {
- INT nButtonWidth = 50;
- RIBBONFILEMENUBUTTONQUERY _rfmbq( this, TPMX_RIBBON_EXIT_BUTTON );
- if( _rfmbq.Notify() )
- {
- nButtonWidth = _rfmbq.m_nMeasuredWidth;
- ASSERT( nButtonWidth >= 0 );
- }
- m_rcRibbonBtnExit = rcAlign;
- m_rcRibbonBtnExit.left = m_rcRibbonBtnExit.right - nButtonWidth;
- rcAlign.right -= m_rcRibbonBtnExit.Width() + 5;
- } // if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- {
- INT nButtonWidth = 50;
- RIBBONFILEMENUBUTTONQUERY _rfmbq( this, TPMX_RIBBON_OPTIONS_BUTTON );
- if( _rfmbq.Notify() )
- {
- nButtonWidth = _rfmbq.m_nMeasuredWidth;
- ASSERT( nButtonWidth >= 0 );
- }
- m_rcRibbonBtnOptions = rcAlign;
- m_rcRibbonBtnOptions.left = m_rcRibbonBtnOptions.right - nButtonWidth;
- rcAlign.right -= m_rcRibbonBtnOptions.Width() + 5;
- } // if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- } // if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- if( m_bScrollingAvailable )
- {
- m_rcScrollTop.left = m_rcScrollBottom.left =
- rcClient.left + rcMB.left;
- m_rcScrollTop.right = m_rcScrollBottom.right =
- rcClient.right - (rcMB.right + nMenuShadowSize);
- m_rcScrollTop.top =
- rcClient.top + rcMB.top;
- m_rcScrollTop.bottom =
- m_rcScrollTop.top + nScrollBtnDy;
-
- m_rcScrollBottom.bottom =
- rcClient.bottom - (rcMB.bottom + nMenuShadowSize);
- m_rcScrollBottom.top =
- m_rcScrollBottom.bottom - nScrollBtnDy;
- m_rcScrollTop.DeflateRect(
- m_nLeftAreaWidth + 1,
- 0,
- 1,
- 0
- );
- m_rcScrollBottom.DeflateRect(
- m_nLeftAreaWidth + 1,
- 0,
- 1,
- 0
- );
- m_rcScrollBottom.OffsetRect( 0, nScrollBottomOffsetDy );
- m_rcScrollBottom.OffsetRect(0,-1);
- m_rcScrollTop.OffsetRect( 0, 1 );
- if( bTearOff )
- {
- m_rcScrollTop.OffsetRect( 0, nTearOffCaptionHeight );
- m_rcScrollBottom.OffsetRect( 0, nTearOffCaptionHeight );
- }
- } // if( m_bScrollingAvailable )
- if( bTearOff )
- {
- m_rcTearOffBtn.left =
- rcClient.left + rcMB.left;
- m_rcTearOffBtn.right =
- rcClient.right - (rcMB.right + nMenuShadowSize);
- m_rcTearOffBtn.top =
- rcClient.top + rcMB.top;
- m_rcTearOffBtn.bottom =
- m_rcTearOffBtn.top + nTearOffCaptionHeight;
- m_rcTearOffBtn.DeflateRect(
- m_nLeftAreaWidth + 1,
- 0,
- 1,
- 0
- );
- m_rcTearOffBtn.OffsetRect( 0, 1 );
- }
- }
- class CExtPopupMenuWnd::CExtPopupMenuCmdUI : public CCmdUI
- {
- public: // re-implementations only
- HWND m_hWndCmdReceiver;
- CExtPopupMenuWnd * m_pPopup;
- CExtPopupMenuWnd::MENUITEMDATA * m_pItemDataActive;
- CExtPopupMenuCmdUI(
- HWND hWndCmdReceiver,
- CExtPopupMenuWnd * pPopup
- )
- : m_hWndCmdReceiver( hWndCmdReceiver )
- , m_pPopup( pPopup )
- , m_pItemDataActive( NULL )
- {
- ASSERT( m_hWndCmdReceiver != NULL && ::IsWindow(m_hWndCmdReceiver) );
- ASSERT_VALID( m_pPopup );
- CCmdUI::m_pOther = NULL; // menu
- CCmdUI::m_nIndexMax = (UINT)m_pPopup->ItemGetCount();
- CCmdUI::m_nIndex = 0;
- }
- void SetActiveIndex( int nIndex )
- {
- ASSERT( m_hWndCmdReceiver != NULL && ::IsWindow(m_hWndCmdReceiver) );
- ASSERT_VALID( m_pPopup );
- CCmdUI::m_nIndex = (UINT)nIndex;
- ASSERT( CCmdUI::m_nIndex >= 0 && CCmdUI::m_nIndex < CCmdUI::m_nIndexMax );
- m_pItemDataActive = &m_pPopup->ItemGetInfo(nIndex);
- ASSERT( m_pItemDataActive != NULL );
- CCmdUI::m_nID = m_pItemDataActive->GetCmdID();
- if( m_pItemDataActive->IsPopup()
- || m_pItemDataActive->IsSeparator()
- || CExtCmdManager::IsSystemCommand( CCmdUI::m_nID )
- )
- return;
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(m_hWndCmdReceiver),
- CCmdUI::m_nID
- );
- if( pCmdItem == NULL )
- return;
- // m_pItemDataActive->SetText( pCmdItem->m_sMenuText );
- m_pItemDataActive->SetAccelText( pCmdItem->m_sAccelText );
- m_pItemDataActive->AccelCharInit();
- int nIconAreaWidthSaved = m_pItemDataActive->GetIconAreaWidth();
- m_pItemDataActive->MeasureItem( NULL );
- m_pItemDataActive->UpdateIconAreaWidth( nIconAreaWidthSaved );
- }
- virtual void Enable(BOOL bOn)
- {
- CCmdUI::m_bEnableChanged = TRUE;
- ASSERT( m_hWndCmdReceiver != NULL && ::IsWindow(m_hWndCmdReceiver) );
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pItemDataActive != NULL );
- if( m_pItemDataActive->IsPopup() && m_pItemDataActive->GetCmd() == NULL )
- return;
- if( m_pItemDataActive->IsForceEnabled() )
- bOn = TRUE;
- m_pItemDataActive->Enable( bOn ? true : false );
- // m_pItemDataActive->MeasureItem( NULL );
- }
- virtual void SetRadio(BOOL bOn)
- {
- ASSERT( m_hWndCmdReceiver != NULL && ::IsWindow(m_hWndCmdReceiver) );
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pItemDataActive != NULL );
- if( m_pItemDataActive->IsPopup() )
- return;
- m_pItemDataActive->Radio( bOn ? true : false );
- // m_pItemDataActive->MeasureItem( NULL );
- }
- virtual void SetCheck(int nCheck)
- {
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pItemDataActive != NULL );
- if( m_pItemDataActive->IsPopup() )
- return;
- m_pItemDataActive->Indeterminate( ( nCheck >= 2 ) ? true : false );
- m_pItemDataActive->Check( nCheck ? true : false );
- // m_pItemDataActive->MeasureItem( NULL );
- }
- virtual void SetText( LPCTSTR lpszText )
- {
- ASSERT( m_hWndCmdReceiver != NULL && ::IsWindow(m_hWndCmdReceiver) );
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pItemDataActive != NULL );
- if( lpszText == NULL )
- return;
- if( m_pItemDataActive->IsPopup() )
- return;
- m_pItemDataActive->SetText( lpszText );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = m_pItemDataActive->GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- pNode->SetTextInMenu( lpszText );
- pNode->SetTextInToolbar( lpszText );
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pItemDataActive->MeasureItem( NULL );
- }
- }; // class CExtPopupMenuWnd::CExtPopupMenuCmdUI
- void CExtPopupMenuWnd::_UpdateCmdUI()
- {
- ASSERT_VALID( this );
- if( _FindHelpMode() )
- return;
- if( m_bTopLevel )
- {
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_NO_CMD_UI) != 0 )
- return;
- }
- ASSERT( m_hWndCmdReceiver != NULL );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- __EXT_MFC_SAFE_LPCTSTR strProfileName = g_CmdManager->ProfileNameFromWnd(m_hWndCmdReceiver);
- CExtCustomizeSite * pSite = CExtCustomizeSite::GetCustomizeSite(m_hWndCmdReceiver);
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- BOOL bDisableIfNoHndler = TRUE;
- CExtPopupMenuCmdUI _state( m_hWndCmdReceiver, this );
- bool bResyncItems = false;
- for( INT _iter = 0;
- _iter < m_items_all.GetSize();
- _iter++
- )
- { // walk all items
- _state.SetActiveIndex( _iter );
- ASSERT( _state.m_pItemDataActive != NULL );
- if( _state.m_pItemDataActive->IsNoCmdUI() )
- continue;
- if( _state.m_pItemDataActive->IsSeparator() )
- continue;
- if( _state.m_pItemDataActive->IsPopup() )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( /* _state.m_pItemDataActive->IsInplaceEdit()
- &&*/ pSite != NULL
- && _state.m_pItemDataActive->GetCmdNode() != NULL
- )
- {
- UINT _nCmdIdSaved = _state.m_pItemDataActive->m_nCmdID;
- _state.m_nID =
- _state.m_pItemDataActive ->
- GetCmdNode() ->
- GetCmdID( false );
- ASSERT( CExtCmdManager::IsCommand( _state.m_nID ) );
- HWND hWndCmdReceiver =
- _state.m_pItemDataActive->GetCmdReceiver();
- ASSERT( hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(hWndCmdReceiver) );
- CWnd * pWndCmdReceiver =
- CWnd::FromHandle( hWndCmdReceiver );
- ASSERT_VALID( pWndCmdReceiver );
- _state.DoUpdate( pWndCmdReceiver, bDisableIfNoHndler );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- _state.m_pItemDataActive->SetForceEnabled( true );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- _state.m_pItemDataActive->m_nCmdID = _nCmdIdSaved;
- _state.m_pItemDataActive->GetPopup()->_UpdateCmdUI();
-
- continue;
- }
- else
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- _state.m_pItemDataActive->GetPopup()->_UpdateCmdUI();
- continue;
- }
- }
- if( _state.m_pItemDataActive->IsExtraMark() )
- {
- bResyncItems = true;
- continue;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pSite != NULL
- && pSite->IsUserBarCommand(
- _state.m_pItemDataActive->GetCmdID()
- )
- && strProfileName != NULL
- )
- {
- _state.m_pItemDataActive->SetForceEnabled( true );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- strProfileName,
- _state.m_pItemDataActive->GetCmdID()
- );
- ASSERT( pCmdItem != NULL );
- CExtToolControlBar * pUserBar =
- pSite->GetUserBar( _state.m_pItemDataActive->GetCmdID() );
- ASSERT_VALID( pUserBar );
- bool bCheck = pUserBar->IsVisible() ? true : false;
- pCmdItem->StateSetCheck( bCheck );
- _state.SetCheck( bCheck );
- continue;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( CExtCmdManager::IsCommandNeedsSpecUpdate(
- _state.m_pItemDataActive->GetCmdID()
- )
- || CExtCmdManager::IsSystemCommand(
- _state.m_pItemDataActive->GetCmdID()
- )
- )
- continue;
- HWND hWndCmdReceiver =
- _state.m_pItemDataActive->GetCmdReceiver();
- ASSERT( hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(hWndCmdReceiver) );
- CWnd * pWndCmdReceiver =
- CWnd::FromHandle( hWndCmdReceiver );
- ASSERT_VALID( pWndCmdReceiver );
- _state.DoUpdate( pWndCmdReceiver, bDisableIfNoHndler );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- _state.m_pItemDataActive->SetForceEnabled( true );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- } // walk all items
- if( bResyncItems )
- _SyncItems();
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::ConstructPopup()
- {
- ASSERT( m_iconPopup.IsEmpty() );
- ASSERT( m_pWndChild == NULL );
- m_pWndChild =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- m_hWndSpecCmdReceiver,
- RUNTIME_CLASS(CExtPopupMenuWnd),
- m_pOwner
- );
- ASSERT( m_hWndSpecCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
- m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
-
- return true;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::DestroyPopup()
- {
- VERIFY( SetPopupIcon(NULL) );
- if( m_pWndChild == NULL )
- return;
- if( m_pWndChild->GetSafeHwnd() != NULL
- && ::IsWindow( m_pWndChild->GetSafeHwnd() )
- )
- {
- CExtPopupMenuWnd * pPopup = m_pWndChild;
- // INT nSaved = pPopup->m_nFadeOutAnimationStepCount;
- // pPopup->m_nFadeOutAnimationStepCount = -1;
- pPopup->DestroyWindow();
- // pPopup->m_nFadeOutAnimationStepCount = nSaved;
- }
- // else
- // delete m_pWndChild;
- delete m_pWndChild;
- m_pWndChild = NULL;
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetCustomTip( __EXT_MFC_SAFE_LPCTSTR sTip )
- {
- m_sCustomTipText.Empty();
- if( sTip != NULL )
- m_sCustomTipText = sTip;
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuWnd::MENUITEMDATA::GetCustomTip() const
- {
- if( m_sCustomTipText.IsEmpty() )
- return NULL;
- return LPCTSTR( m_sCustomTipText );
- }
- void CExtPopupMenuWnd::MENUITEMDATA::SetExtendedText( __EXT_MFC_SAFE_LPCTSTR sExtendedText )
- {
- m_sExtendedText.Empty();
- if( sExtendedText != NULL )
- m_sExtendedText = sExtendedText;
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuWnd::MENUITEMDATA::GetExtendedText() const
- {
- if( m_sExtendedText.IsEmpty() )
- return NULL;
- return LPCTSTR( m_sExtendedText );
- }
- void CExtPopupMenuWnd::MENUITEMDATA::GetTip( CExtSafeString & sTip ) const
- {
- sTip = _T("");
- if( IsPopup() || IsSeparator() )
- return;
- LPCTSTR sCustomTip = GetCustomTip();
- if( sCustomTip != NULL )
- {
- sTip = sCustomTip;
- return;
- }
- if( GetCmd() == NULL )
- return;
- CExtCmdItem * pCmdItem = GetCmd();
- if( pCmdItem == NULL )
- return;
- UINT nTranslatedResourceCmdID = UINT(-1);
- switch( pCmdItem->m_nCmdID )
- {
- case SC_CLOSE:
- nTranslatedResourceCmdID = AFX_IDS_SCCLOSE;
- break;
- case SC_SIZE:
- nTranslatedResourceCmdID = AFX_IDS_SCSIZE;
- break;
- case SC_MOVE:
- nTranslatedResourceCmdID = AFX_IDS_SCMOVE;
- break;
- case SC_MINIMIZE:
- nTranslatedResourceCmdID = AFX_IDS_SCMINIMIZE;
- break;
- case SC_MAXIMIZE:
- nTranslatedResourceCmdID = AFX_IDS_SCMAXIMIZE;
- break;
- case SC_RESTORE:
- nTranslatedResourceCmdID = AFX_IDS_SCRESTORE;
- break;
- case SC_NEXTWINDOW:
- nTranslatedResourceCmdID = AFX_IDS_SCNEXTWINDOW;
- break;
- case SC_PREVWINDOW:
- nTranslatedResourceCmdID = AFX_IDS_SCPREVWINDOW;
- break;
- case SC_TASKLIST:
- nTranslatedResourceCmdID = AFX_IDS_SCTASKLIST;
- break;
- } // switch( pCmdItem->m_nCmdID )
- if( nTranslatedResourceCmdID == UINT(-1) )
- {
- sTip = pCmdItem->m_sTipStatus;
- return;
- } // if( nTranslatedResourceCmdID == UINT(-1) )
- if( ! g_ResourceManager->LoadString( sTip, nTranslatedResourceCmdID ) )
- {
- sTip = pCmdItem->m_sTipStatus;
- return;
- }
- else
- {
- int nSep = sTip.ReverseFind('n');
- if( nSep < 0 )
- return;
- CString sBuffer = sTip.Left( nSep );
- sTip = sBuffer;
- }
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupMenuWnd::MENUITEMDATA::InitSceenTip( CExtPopupScreenTipWnd & _wndScreenTip )
- {
- if( m_pOwner->GetSafeHwnd() == NULL )
- return false;
- ASSERT_VALID( m_pOwner );
- INT nOwnIndex = m_pOwner->ItemGetIndexOf( this );
- if( nOwnIndex < 0 )
- return false;
- CExtCustomizeCmdTreeNode * pNode = GetCmdNode();
- if( pNode == NULL )
- return false;
- ASSERT_VALID( pNode );
- CExtCustomizeCmdScreenTip * pCCST = pNode->CmdScreenTipFindForDisplaying();
- if( pCCST == NULL )
- return false;
- ASSERT_VALID( pCCST );
- if( pCCST->IsEmpty() )
- return false;
- CRect rcOwn( 0, 0, 0, 0 );
- m_pOwner->_GetItemRect( nOwnIndex, rcOwn, true );
- if( rcOwn.IsRectEmpty() )
- return false;
- m_pOwner->ClientToScreen( &rcOwn );
- if( _wndScreenTip.GetSafeHwnd() != NULL )
- {
- CRect rcExisting = _wndScreenTip.GetExcludeArea();
- if( rcOwn == rcExisting )
- return true;
- }
- _wndScreenTip.Hide();
- _wndScreenTip.m_cmdScreenTip = (*pCCST);
- //if( CExtToolControlBar::g_bToolbarShortcutKeysOnScreenTips )
- {
- CExtCmdItem * pCmdItem = GetCmd();
- if( pCmdItem != NULL
- && ( ! pCmdItem->m_sAccelText.IsEmpty() )
- )
- {
- CExtSafeString str = _wndScreenTip.m_cmdScreenTip.CaptionMainGet();
- if( ! str.IsEmpty() )
- {
- str += _T(" (");
- str += pCmdItem->m_sAccelText;
- str += _T(")");
- _wndScreenTip.m_cmdScreenTip.CaptionMainSet( LPCTSTR( str ) );
- }
- else
- {
- CExtSafeString str = _wndScreenTip.m_cmdScreenTip.TextMainGet();
- if( ! str.IsEmpty() )
- {
- str += _T(" (");
- str += pCmdItem->m_sAccelText;
- str += _T(")");
- _wndScreenTip.m_cmdScreenTip.TextMainSet( LPCTSTR( str ) );
- }
- }
- }
- }
- _wndScreenTip.Show( m_pOwner, rcOwn );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupMenuWnd::_BuildItems(
- CMenu * pBuildMenu,
- bool bTopLevel,
- bool bNoRefToCmdMngr // = false
- )
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBuildMenu != NULL )
- {
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- }
- #endif // _DEBUG
- INT iter = 0;
- for( ; iter < m_items_all.GetSize(); iter++)
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( mi.IsPopup() )
- {
- CExtPopupMenuWnd * pPopup = mi.GetPopup();
- pPopup->m_hWndCmdReceiver = m_hWndCmdReceiver;
- INT nSaved = pPopup->m_nFadeOutAnimationStepCount;
- pPopup->m_nFadeOutAnimationStepCount = -1;
- pPopup->_OnCancelMode();
- pPopup->m_nFadeOutAnimationStepCount = nSaved;
- VERIFY( pPopup->_BuildItems( NULL, false, bNoRefToCmdMngr ) );
- mi.DestroyPopup();
- }
- } // for( ; iter < m_items_all.GetSize(); iter++)
- m_items_all.RemoveAll();
- if( pBuildMenu == NULL )
- return true;
- ASSERT( pBuildMenu->GetSafeHmenu() != NULL );
- m_bTopLevel = bTopLevel;
- if( m_bTopLevel )
- m_pWndParentMenu = NULL;
- // build items loop
- bool bPrevWasSeparator = false;
- int nMruUpdateIndex = -1, nInsertedIndex = 0;
- int nMenuItemCount = pBuildMenu->GetMenuItemCount();
- ASSERT( nMenuItemCount >= 0 );
- m_items_all.RemoveAll();
- for( int nItemIndex=0; nItemIndex<nMenuItemCount; nItemIndex++ )
- {
- UINT nMenuItemID =
- pBuildMenu->GetMenuItemID( nItemIndex );
- if( ID_FILE_MRU_FIRST <= nMenuItemID
- && nMenuItemID <= ID_FILE_MRU_LAST
- )
- {
- if( nMruUpdateIndex < 0 )
- nMruUpdateIndex = nInsertedIndex;
- continue;
- }
- MENUITEMDATA mi( this );
- mi.SetCmdReceiver( m_hWndCmdReceiver );
- VERIFY(
- mi.UpdateFromMenu(
- m_hWndCmdReceiver,
- pBuildMenu,
- nItemIndex,
- bNoRefToCmdMngr
- )
- );
- bool bIsSeparator = mi.IsSeparator();
- if( bPrevWasSeparator && bIsSeparator )
- continue;
- bPrevWasSeparator = bIsSeparator;
-
- if( mi.IsPopup() )
- {
- CMenu * pSubMenu =
- pBuildMenu->GetSubMenu(nItemIndex);
- ASSERT( pSubMenu != NULL );
- ASSERT( pSubMenu->GetSafeHmenu() != NULL );
- mi.GetPopup()->m_hWndCmdReceiver = m_hWndCmdReceiver;
- mi.GetPopup()->_BuildItems( pSubMenu, false, bNoRefToCmdMngr );
- mi.GetPopup()->m_pWndParentMenu = this;
- }
- _InsertItem( -1, mi, bNoRefToCmdMngr );
- nInsertedIndex++;
- } // for( int nItemIndex=0; nItemIndex<nMenuItemCount; nItemIndex++ )
- ASSERT( m_items_all.GetSize() <= nMenuItemCount );
- int nMruInsertCount = 0;
- if( nMruUpdateIndex >= 0 && (!bNoRefToCmdMngr) )
- { // insert recently opened file items
- ASSERT( nMruUpdateIndex < nMenuItemCount );
- CRecentFileList * pRecentFileList =
- InternalFriendlyWinApp::_GetFriendlyApp()->
- _GetRecentFileList();
- if( pRecentFileList != NULL )
- { // can be null !?
- int nRecentCount =
- pRecentFileList->GetSize();
- TCHAR sCurrDir[_MAX_PATH+1];
- ::memset(sCurrDir,0,sizeof(sCurrDir));
- ::GetCurrentDirectory(_MAX_PATH,sCurrDir);
- int nLenCurDir = (int)_tcslen(sCurrDir);
- for( int nItemIndex=0; nItemIndex<nRecentCount; nItemIndex++ )
- {
- CExtSafeString sDisplayName( _T("") );
- CExtSafeString sDisplayNameFullPath( _T("") );
- CExtSafeString sDisplayNameMenu( _T("") );
- CExtSafeString sDisplayNameTipTool( _T("") );
- sDisplayNameFullPath = ( ! pRecentFileList->m_arrNames[ nItemIndex ].IsEmpty() ) ? LPCTSTR( pRecentFileList->m_arrNames[ nItemIndex ] ) : _T("");
- pRecentFileList->GetDisplayName( *((CString *)&sDisplayName), nItemIndex, sCurrDir, nLenCurDir, TRUE );
- if( sDisplayName.IsEmpty() || sDisplayNameFullPath.IsEmpty() )
- continue;
- if( g_bMRU_UseFullPathsInMenu )
- sDisplayNameMenu = sDisplayNameFullPath;
- else
- sDisplayNameMenu = sDisplayName;
- if( g_bMRU_UseFullPathsInTipTool )
- sDisplayNameTipTool = sDisplayNameFullPath;
- else
- sDisplayNameTipTool = sDisplayName;
- UINT nCmdID = ID_FILE_MRU_FIRST + nItemIndex;
- ASSERT( nCmdID <= ID_FILE_MRU_LAST );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- if( pCmdItem == NULL )
- pCmdItem =
- g_CmdManager->CmdAllocPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- ASSERT( pCmdItem != NULL );
- if( pCmdItem == NULL )
- return false;
- int nDisplayIndex = nItemIndex+1;
- if( nDisplayIndex < 10 )
- pCmdItem->m_sMenuText.Format(
- _T("&%d %s"),
- nDisplayIndex,
- sDisplayNameMenu
- );
- else
- pCmdItem->m_sMenuText.Format(
- _T("%d&%d %s"),
- nDisplayIndex/10,
- nDisplayIndex%10,
- sDisplayNameMenu
- );
-
- CExtSafeString sRecentFileFmt1,sRecentFileFmt2;
- if( ! g_ResourceManager->LoadString( sRecentFileFmt1, IDS_RECENT_FILE_FMT_1 ) )
- sRecentFileFmt1 = _T("Recent file %d");
- if( ! g_ResourceManager->LoadString( sRecentFileFmt2, IDS_RECENT_FILE_FMT_2 ) )
- sRecentFileFmt2 = _T("Recent file %d ("%s")");
- pCmdItem->m_sToolbarText.Format(
- (LPCTSTR)sRecentFileFmt1,
- nItemIndex + 1
- );
- pCmdItem->m_sTipTool.Format(
- (LPCTSTR)sRecentFileFmt2,
- nItemIndex + 1,
- sDisplayNameTipTool
- );
- pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
- BOOL bInsRetVal =
- ItemInsert(
- nCmdID,
- nMruUpdateIndex + nItemIndex
- );
-
- if( ! bInsRetVal )
- {
- ASSERT( FALSE );
- return false;
- }
- nMruInsertCount++;
- } // for( nItemIndex=0; nItemIndex<nRecentCount; nItemIndex++ )
- } // can be null !?
- if( nMruInsertCount > 0 )
- {
- if( ! ItemInsert(
- ID_SEPARATOR,
- nMruUpdateIndex + nMruInsertCount
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- nMruInsertCount++;
- } // if( nMruInsertCount > 0 )
- } // insert recently opened file items
- _SyncItems();
- return true;
- }
- void CExtPopupMenuWnd::_GetClientRect(RECT * pRectClient)
- {
- ASSERT_VALID( this );
- ASSERT( pRectClient != NULL );
- ASSERT( GetSafeHwnd() != NULL );
- ::CopyRect( pRectClient, &m_rcClient );
- ASSERT( pRectClient->top <= pRectClient->bottom );
- ASSERT( pRectClient->left <= pRectClient->right );
- }
- BOOL CExtPopupMenuWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- ASSERT_VALID( this );
- if( _FindHelpMode() )
- {
- SetCursor( afxData.hcurHelp );
- return TRUE;
- }
- CPoint ptCursor;
- if( ::GetCursorPos(&ptCursor) )
- {
- ScreenToClient( &ptCursor );
- int nIndex = _HitTest( ptCursor );
- if( _IsTearOff() && nIndex == IDX_TEAROFF )
- {
- HCURSOR hCursor = ::LoadCursor( NULL, IDC_SIZEALL );
- ASSERT( hCursor != NULL );
- ::SetCursor( hCursor );
- return TRUE;
- } // if( _IsTearOff() && nIndex == IDX_TEAROFF )
- if( ItemGetCount() > 0 )
- {
- if( nIndex >= 0 )
- {
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( (! mi.IsExtraMark() )
- && mi.IsInplaceEdit()
- && mi.IsAllowInplaceEditActivation()
- && (! _FindHelpMode() )
- )
- {
- CRect rcItem;
- _GetItemRect( nIndex, rcItem );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( _FindCustomizeMode() )
- {
- ASSERT_VALID( mi.GetCmdNode() );
- if( mi.IsSelected()
- && (mi.GetCmdNode()->GetFlags() & __ECTN_TBB_RESIZABLE) != 0
- )
- { // if button can be resized
- int nDdWidth = PmBridge_GetPM()->GetDropDividerMerics().cx / 2;
- if( nDdWidth < 2 )
- nDdWidth = 2;
- CRect rcH( rcItem );
- rcH.right = rcH.left + nDdWidth;
- bool bSetCursor = false;
- if( rcH.PtInRect(ptCursor) )
- bSetCursor = true;
- else
- {
- rcH = rcItem;
- rcH.left = rcH.right - nDdWidth;
- if( rcH.PtInRect(ptCursor) )
- bSetCursor = true;
- } // else from if( rcH.PtInRect(ptCursor) )
- if( bSetCursor )
- {
- CExtLocalResourceHelper _LRH;
- CWinApp * pApp = ::AfxGetApp();
- ASSERT_VALID( pApp );
- HCURSOR hCursor = pApp->LoadCursor( MAKEINTRESOURCE( IDC_EXT_RESIZE_H1 ) );
- if( hCursor == NULL )
- {
- ASSERT( FALSE );
- hCursor = ::LoadCursor( NULL, IDC_SIZEWE );
- } // if( hCursor == NULL )
- ASSERT( hCursor != NULL );
- ::SetCursor( hCursor );
- return TRUE;
- } // if( bSetCursor )
- } // if button can be resized
- } // if( _FindCustomizeMode() )
- else
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- {
- CRect rcInplaceCtrl =
- mi.AdjustInplaceEditRect(
- rcItem,
- OnQueryLayoutRTL()
- );
- if( rcInplaceCtrl.PtInRect(ptCursor) )
- {
- SetCursor( ::LoadCursor( NULL, IDC_IBEAM ) );
- return TRUE;
- } // if( rcInplaceCtrl.PtInRect(ptCursor) )
- SetCursor( ::LoadCursor( NULL, IDC_ARROW ) );
- } // else from if( _FindCustomizeMode() )
- }
- } // if( nIndex >= 0 )
- } // if( ItemGetCount() > 0)
- } // if( ::GetCursorPos(&ptCursor) )
- return CExtPopupBaseWnd::OnSetCursor(pWnd, nHitTest, message);
- }
- int CExtPopupMenuWnd::_HitTest(
- const CPoint & point,
- bool * p_bInplaceControlArea, // = NULL
- bool * p_bInplaceDropDownArea // = NULL
- )
- {
- ASSERT_VALID( this );
- if( p_bInplaceControlArea != NULL )
- *p_bInplaceControlArea = false;
- if( p_bInplaceDropDownArea != NULL )
- *p_bInplaceDropDownArea = false;
- if( GetSafeHwnd() == NULL )
- return IDX_NOTHING;
- CRect rcClient;
- _GetClientRect( &rcClient );
- if( ! rcClient.PtInRect(point) )
- return IDX_NOTHING;
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- {
- if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- {
- CRect rcItem;
- _GetItemRect(IDX_RIBBON_FILE_MENU_EXIT_BUTTON,rcItem);
- if( rcItem.PtInRect(point) )
- return IDX_RIBBON_FILE_MENU_EXIT_BUTTON;
- } // if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- {
- CRect rcItem;
- _GetItemRect(IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON,rcItem);
- if( rcItem.PtInRect(point) )
- return IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON;
- } // if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- } // if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- if( m_bScrollingAvailable )
- {
- CRect rcItem;
- if( m_nDyScrollOffset != 0 )
- {
- _GetItemRect(IDX_SCROLL_TOP,rcItem);
- if( rcItem.PtInRect(point) )
- return IDX_SCROLL_TOP;
- }
- int nMaxScrollPos = _GetMaxScrollPos();
- if( m_nDyScrollOffset != nMaxScrollPos )
- {
- _GetItemRect(IDX_SCROLL_BOTTOM,rcItem);
- if( rcItem.PtInRect(point) )
- return IDX_SCROLL_BOTTOM;
- }
- }
- if( m_bExpandAvailable )
- {
- CRect rcExpand;
- _GetItemRect(IDX_EXPAND,rcExpand);
- if( rcExpand.PtInRect(point) )
- return IDX_EXPAND;
- }
- if( _IsTearOff() )
- {
- CRect rcTearOff;
- _GetItemRect(IDX_TEAROFF,rcTearOff);
- if( rcTearOff.PtInRect(point) )
- {
- if( _FindCustomizeMode()
- || _FindHelpMode()
- )
- return IDX_NOTHING;
- return IDX_TEAROFF;
- }
- }
- bool bRTL = OnQueryLayoutRTL();
- INT iter = 0;
- int nIndex = 0;
- for( ; iter < m_items_all.GetSize(); iter++,nIndex++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( !mi.IsDisplayed() )
- continue;
- CRect rcItem;
- _GetItemRect( nIndex, rcItem );
- if( rcItem.PtInRect(point) )
- {
- int nRetIndex = mi.GetIndex();
- ASSERT(
- nRetIndex >= 0
- && nRetIndex < m_items_all.GetSize()
- );
- if( ( p_bInplaceControlArea != NULL
- || p_bInplaceDropDownArea != NULL
- )
- && mi.IsInplaceEdit()
- )
- {
- CRect rcInplaceCtrl =
- mi.AdjustInplaceEditRect(
- rcItem,
- bRTL
- );
- if( p_bInplaceControlArea != NULL )
- {
- if( rcInplaceCtrl.PtInRect(point) )
- *p_bInplaceControlArea = true;
- }
- if( p_bInplaceDropDownArea != NULL
- && mi.IsPopup()
- )
- {
- rcInplaceCtrl.left = rcInplaceCtrl.right;
- rcInplaceCtrl.right += PmBridge_GetPM()->GetDropDownButtonWidth( this );
- if( rcInplaceCtrl.PtInRect(point) )
- *p_bInplaceDropDownArea = true;
- }
- }
- return nRetIndex;
- }
- } // for( ; iter < m_items_all.GetSize(); iter++,nIndex++ )
- return IDX_NOTHING;
- };
- BEGIN_MESSAGE_MAP(CExtPopupMenuWnd, CExtPopupBaseWnd)
- //{{AFX_MSG_MAP(CExtPopupMenuWnd)
- ON_WM_CANCELMODE()
- ON_WM_TIMER()
- ON_WM_SHOWWINDOW()
- ON_WM_SETCURSOR()
- //}}AFX_MSG_MAP
- ON_WM_ACTIVATEAPP()
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_MBUTTONDOWN()
- ON_WM_MBUTTONUP()
- ON_WM_MBUTTONDBLCLK()
- ON_WM_RBUTTONDOWN()
- ON_WM_RBUTTONUP()
- ON_WM_RBUTTONDBLCLK()
- ON_WM_KEYDOWN()
- ON_WM_KEYUP()
- ON_WM_SYSKEYDOWN()
- ON_WM_SYSKEYUP()
- ON_WM_SYSDEADCHAR()
- ON_WM_CHAR()
- ON_WM_GETMINMAXINFO()
- __EXT_MFC_ON_WM_NCHITTEST()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupMenuWnd message handlers
- UINT CExtPopupMenuWnd::OnNcHitTest(CPoint point)
- {
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_RIBBON_RESIZING) != 0 )
- {
- CRect rcMB = PmBridge_GetPM()->GetMenuBorderMetrics( (CWnd*)this );
- ASSERT( rcMB.left >= 0 );
- ASSERT( rcMB.top >= 0 );
- ASSERT( rcMB.right >= 0 );
- ASSERT( rcMB.bottom >= 0 );
- CRect rcClient;
- _GetClientRect( &rcClient );
- CRect rcResizingArea = rcClient;
- rcResizingArea.left += rcMB.left;
- rcResizingArea.right -= rcMB.right;
- rcResizingArea.bottom -= rcMB.bottom;
- INT nMarginHeight = 0, nResizingCornerPartWidth = 0;
- PmBridge_GetPM()->MenuBottomResizingMarginGetInfo(
- nMarginHeight,
- nResizingCornerPartWidth,
- this
- );
- rcResizingArea.top = rcResizingArea.bottom - nMarginHeight;
- ClientToScreen( &rcResizingArea );
- if( (dwTrackFlags&TPMX_RIBBON_RESIZING_VERTICAL_ONLY) != 0 )
- {
- if( rcResizingArea.PtInRect( point ) )
- return HTBOTTOM;
- }
- else
- {
- rcResizingArea.left = rcResizingArea.right - nResizingCornerPartWidth;
- if( rcResizingArea.PtInRect( point ) )
- return HTBOTTOMRIGHT;
- }
- }
- return (UINT)CExtPopupBaseWnd::OnNcHitTest( point );
- }
- void CExtPopupMenuWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
- {
- CExtPopupBaseWnd::OnGetMinMaxInfo( lpMMI );
- }
- BOOL CExtPopupMenuWnd::LoadMenu(
- HWND hWndCmdRecv,
- UINT nIDResource,
- bool bPopupMenu, // = true
- bool bNoRefToCmdMngr // = false
- )
- {
- ASSERT_VALID( this );
- CMenu menu;
- if( ! g_ResourceManager->LoadMenu( menu, nIDResource ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- return
- UpdateFromMenu(
- hWndCmdRecv,
- &menu,
- bPopupMenu,
- true,
- bNoRefToCmdMngr
- );
- }
- bool CExtPopupMenuWnd::g_bMdiWindowsMenuUsesCheckInsteadOfRadio = false;
- BOOL CExtPopupMenuWnd::UpdateMdiWindowsMenu(
- CWnd * pWndStartSearchMdiFrameWnd // = NULL
- )
- {
- ASSERT_VALID( this );
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- CMDIFrameWnd * pFrame = NULL;
- CWnd * pWnd =
- (pWndStartSearchMdiFrameWnd != NULL)
- ? pWndStartSearchMdiFrameWnd
- : FromHandle(m_hWndCmdReceiver) // ::AfxGetMainWnd()
- ;
- while( true )
- {
- ASSERT( pWnd != NULL );
- ASSERT_VALID( pWnd );
- pFrame =
- DYNAMIC_DOWNCAST(
- CMDIFrameWnd,
- pWnd
- );
- if( pFrame != NULL )
- break;
- pWnd = pWnd->GetParentFrame();
- if( pWnd == NULL )
- return FALSE;
- } // while( true )
- if( pFrame == NULL )
- return FALSE;
- int nItemIndex = ItemGetCount();
- if( nItemIndex > 0 )
- {
- MENUITEMDATA & mi = ItemGetInfo(nItemIndex-1);
- if( ! mi.IsSeparator() )
- {
- ItemInsert(ID_SEPARATOR);
- nItemIndex++;
- ASSERT( nItemIndex == ItemGetCount() );
- }
- }
- HWND m_hWndMDIClient = pFrame->m_hWndMDIClient;
- ASSERT( m_hWndMDIClient != NULL );
- ASSERT( ::IsWindow(m_hWndMDIClient) );
- HWND hWndActiveChildFrame = (HWND)
- ::SendMessage( m_hWndMDIClient, WM_MDIGETACTIVE, 0, NULL );
- if( hWndActiveChildFrame != NULL )
- {
- ASSERT( ::IsWindow( hWndActiveChildFrame ) );
- CWnd * pWndTempAnalyze =
- CWnd::FromHandle( hWndActiveChildFrame );
- if( pWndTempAnalyze != NULL )
- {
- ASSERT_VALID( pWndTempAnalyze );
- CMDIChildWnd * pWndTempMDIChild =
- DYNAMIC_DOWNCAST( CMDIChildWnd, pWndTempAnalyze );
- if( pWndTempMDIChild != NULL
- && pWndTempMDIChild->m_bPseudoInactive
- && (pWndTempMDIChild->GetStyle()&WS_VISIBLE) == 0
- )
- hWndActiveChildFrame = NULL;
- } // if( pWndTempAnalyze != NULL )
- } // if( hWndActiveChildFrame != NULL )
- INT nCmdID = __ID_MDIWNDLIST_FIRST;
- INT nWinCount = 0;
- for( INT nWin = 1; true; nWin++, nCmdID++ )
- {
- HWND hWndChildFrame =
- ::GetDlgItem(m_hWndMDIClient, nCmdID);
- if( hWndChildFrame == NULL )
- break;
- if( !::IsWindowVisible( hWndChildFrame ) )
- continue;
- nWinCount ++;
- if( nWinCount <= __ID_MDIWNDLIST_COUNT )
- { // if head of MDI windows list
- ASSERT( ::IsWindow(hWndChildFrame) );
- CString sWinName( _T("") );
- CWnd::FromHandle( hWndChildFrame )-> GetWindowText( sWinName );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( pWndStartSearchMdiFrameWnd->GetSafeHwnd() ),
- nCmdID
- );
- if( pCmdItem == NULL )
- pCmdItem =
- g_CmdManager->CmdAllocPtr(
- g_CmdManager->ProfileNameFromWnd( pWndStartSearchMdiFrameWnd->GetSafeHwnd() ),
- nCmdID
- );
- ASSERT( pCmdItem != NULL );
- if( pCmdItem == NULL )
- return FALSE;
- pCmdItem->m_sMenuText.Format(
- _T("&%d %s"),
- nWinCount,
- sWinName
- );
- pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
- CExtSafeString sDocumentNameFmt;
- if( ! g_ResourceManager->LoadString( sDocumentNameFmt, IDS_DOCUMENT_NAME_FMT ) )
- sDocumentNameFmt = _T("Document "%s"");
- pCmdItem->m_sTipTool.Format(
- (LPCTSTR)sDocumentNameFmt,
- sWinName
- );
- pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
- bool bRadio =
- (hWndChildFrame == hWndActiveChildFrame)
- ? true : false;
- pCmdItem->StateSetRadio( bRadio );
- if( ! ItemInsert(nCmdID) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- MENUITEMDATA & mi = ItemGetInfo( ItemGetCount()-1 );
- if( g_bMdiWindowsMenuUsesCheckInsteadOfRadio )
- mi.Check( bRadio );
- else
- mi.Radio( bRadio );
- } // if head of MDI windows list
- else
- { // MDI windows list enough long, trim it
- if( ! ItemInsert(TYPE_SEPARATOR) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- HWND hWndSearch = pWndStartSearchMdiFrameWnd->GetSafeHwnd();
- ASSERT( hWndSearch != NULL );
- ASSERT( ::IsWindow(hWndSearch) );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndSearch ),
- __ID_MDIWND_DLGWINDOWS
- );
- if( pCmdItem == NULL )
- pCmdItem =
- g_CmdManager->CmdAllocPtr(
- g_CmdManager->ProfileNameFromWnd( hWndSearch ),
- __ID_MDIWND_DLGWINDOWS
- );
- ASSERT( pCmdItem != NULL );
- if( pCmdItem == NULL )
- return FALSE;
-
- CExtSafeString sMoreWindows,sManageWindows;
- if( ! g_ResourceManager->LoadString( sMoreWindows, IDS_MDI_MORE_WINDOWS ) )
- sMoreWindows = _T("More Windows");
- if( ! g_ResourceManager->LoadString( sManageWindows, IDS_MDI_MANAGE_OPENED_WINDOWS ) )
- sManageWindows = _T("Manage opened document windows");
- pCmdItem->m_sMenuText = sMoreWindows;
- pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
- pCmdItem->m_sTipTool = sManageWindows;
- pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
- if( ! ItemInsert(nCmdID) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- break;
- } // MDI windows list enough long, trim it
- } // for( INT nWin = 1; true; nWin++, nCmdID++ )
-
- _SyncItems();
- return TRUE;
- }
- HMENU CExtPopupMenuWnd::ExportToMenu(
- BOOL bDeep // = TRUE
- ) const
- {
- ASSERT_VALID( this );
- CMenu menu;
- if( !menu.CreatePopupMenu() )
- {
- ASSERT( FALSE );
- return NULL;
- }
- OSVERSIONINFO ov;
- ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- VERIFY( ::GetVersionEx( &ov ) );
- bool bStupidNT4XX =
- (
- ( ov.dwPlatformId == VER_PLATFORM_WIN32_NT )
- &&
- ( ov.dwMajorVersion < 5 )
- );
- int nCount = ItemGetCount();
- for( int nItem = 0; nItem < nCount; nItem++ )
- {
- const MENUITEMDATA & mi =
- ItemGetInfo( nItem );
- if( mi.IsPopup() )
- {
- CExtSafeString sMiText( mi.GetText() );
- CExtSafeString sMiAccelText( _T("") );
- if( ( TrackFlagsGet() & TPMX_HIDE_KEYBOARD_ACCELERATORS ) == 0 )
- sMiAccelText = mi.GetAccelText();
- if( !sMiAccelText.IsEmpty() )
- {
- sMiText += _T("t");
- sMiText += sMiAccelText;
- }
- const CExtPopupMenuWnd * pPopup = mi.GetPopup();
- ASSERT( pPopup != NULL );
- HMENU hPopupData;
- if( bDeep )
- hPopupData = pPopup->ExportToMenu();
- else
- hPopupData = ::CreatePopupMenu();
- if( ( ! (::IsMenu(hPopupData)) )
- ||
- (! menu.AppendMenu(
- MF_STRING|MF_POPUP,
- __EXT_MFC_UINT_PTR(hPopupData),
- sMiText
- )
- )
- )
- {
- ASSERT( FALSE );
- //continue;
- }
- if( bStupidNT4XX )
- {
- VERIFY( ::DestroyMenu( hPopupData ) );
- }
- continue;
- } // if( mi.IsPopup() )
- if( mi.IsSeparator() )
- {
- VERIFY( menu.AppendMenu( MF_SEPARATOR ) );
- continue;
- } // if( mi.IsSeparator() )
- CExtSafeString sMiText( mi.GetText() );
- CExtSafeString sMiAccelText( _T("") );
- if( ( TrackFlagsGet() & TPMX_HIDE_KEYBOARD_ACCELERATORS ) == 0 )
- sMiAccelText = mi.GetAccelText();
- if( ! sMiAccelText.IsEmpty() )
- {
- sMiText += _T("t");
- sMiText += sMiAccelText;
- }
- VERIFY(
- menu.AppendMenu(
- MF_STRING,
- mi.GetCmdID(),
- sMiText
- )
- );
- } // for( int nItem = 0; nItem < nCount; nItem++ )
- return menu.Detach();
- }
- BOOL CExtPopupMenuWnd::UpdateFromMenu(
- HWND hWndCmdRecv,
- CMenu * pBuildMenu,
- bool bPopupMenu, // = true
- bool bTopLevel, // = true
- bool bNoRefToCmdMngr // = false
- )
- {
- ASSERT_VALID( this );
- if( hWndCmdRecv != NULL )
- m_hWndCmdReceiver = hWndCmdRecv;
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- if( pBuildMenu == NULL
- || ( !( ::IsMenu( pBuildMenu->GetSafeHmenu() ) ) )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- if( bPopupMenu )
- {
- pBuildMenu = pBuildMenu->GetSubMenu(0);
- if( pBuildMenu == NULL
- || ( ! ( ::IsMenu( pBuildMenu->GetSafeHmenu() ) ) )
- )
- {
- // ASSERT( FALSE );
- return false;
- }
- }
- if( ! bNoRefToCmdMngr )
- {
- if( ! g_CmdManager->UpdateFromMenu(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- pBuildMenu->GetSafeHmenu()
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- } // if( ! bNoRefToCmdMngr )
- if( ! _BuildItems(
- pBuildMenu,
- bTopLevel,
- bNoRefToCmdMngr
- )
- )
- return FALSE;
- return TRUE;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupMenuWnd::UpdateFromCmdTree(
- HWND hWndCmdRecv,
- CExtCustomizeCmdTreeNode * pNode,
- bool bTopLevel // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pNode );
- m_pNode = pNode;
- if( hWndCmdRecv != NULL )
- m_hWndCmdReceiver = hWndCmdRecv;
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- __EXT_MFC_SAFE_LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver );
- bool bCustomizeMode = false;
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( m_hWndCmdReceiver );
- if( pSite != NULL )
- bCustomizeMode = pSite->IsCustomizeMode();
- INT iter = 0;
- for( ; iter < m_items_all.GetSize(); iter++)
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( mi.IsPopup() )
- {
- CExtPopupMenuWnd * pPopup = mi.GetPopup();
- pPopup->m_hWndCmdReceiver = m_hWndCmdReceiver;
- INT nSaved = pPopup->m_nFadeOutAnimationStepCount;
- pPopup->m_nFadeOutAnimationStepCount = -1;
- pPopup->_OnCancelMode();
- pPopup->m_nFadeOutAnimationStepCount = nSaved;
- VERIFY( pPopup->_BuildItems( NULL, false ) );
- mi.DestroyPopup();
- }
- } // for( ; iter < m_items_all.GetSize(); iter++)
- m_items_all.RemoveAll();
- if( pNode == NULL )
- return true;
- ASSERT_VALID( pNode );
- m_bTopLevel = bTopLevel;
- if( m_bTopLevel )
- m_pWndParentMenu = NULL;
- // build items loop
- int nMruUpdateIndex = -1, nInsertedIndex = 0;
- int nMenuItemCount = pNode->GetNodeCount();
- m_items_all.RemoveAll();
- bool bSeparatorMode = false;
- for( int nItemIndex = 0; nItemIndex < nMenuItemCount; nItemIndex++ )
- {
- CExtCustomizeCmdTreeNode * pChildNode =
- pNode->ElementAt( nItemIndex );
- ASSERT_VALID( pChildNode );
- if( ( pChildNode->GetFlags() & __ECTN_GROUP_START ) )
- {
- if( ! bSeparatorMode )
- {
- bSeparatorMode = true;
- VERIFY( ItemInsert( CExtPopupMenuWnd::TYPE_SEPARATOR, nInsertedIndex++ ) );
- }
- } // if( pChildNode->GetFlags() & __ECTN_GROUP_START )
- if( pChildNode->GetFlags() & __ECTN_TBB_HIDDEN )
- continue;
- UINT nMenuItemID = pChildNode->GetCmdID( false );
- if( ID_FILE_MRU_FIRST <= nMenuItemID
- && nMenuItemID <= ID_FILE_MRU_LAST
- && (! bCustomizeMode )
- )
- {
- if( nMruUpdateIndex < 0 )
- nMruUpdateIndex = nInsertedIndex;
- continue;
- }
- MENUITEMDATA mi( this );
- mi.SetCmdReceiver( m_hWndCmdReceiver );
- VERIFY( mi.UpdateFromCmdTree( m_hWndCmdReceiver, pChildNode, nInsertedIndex ) );
- if( ! mi.IsSeparator() )
- {
- bSeparatorMode = false;
- CExtCmdItem * pCmdItem = NULL;
- if( mi.IsPopup() )
- {
- CExtPopupMenuWnd * pDesc = mi.GetPopup();
- pDesc->m_hWndCmdReceiver = m_hWndCmdReceiver;
- pDesc->UpdateFromCmdTree( hWndCmdRecv, pChildNode, false );
- pDesc->m_pWndParentMenu = this;
- } // if( mi.IsPopup() )
- else
- {
- pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, mi.GetCmdID() );
- /*
- // HASH Added this because during our Alpha release
- // some commands were deleted but the menus were
- // still loaded from resource
- if( pCmdItem == NULL )
- continue;
- */
- if( pCmdItem != NULL )
- mi.SetAccelText( pCmdItem->m_sAccelText );
- } // else from if( mi.IsPopup() )
- mi.SetText( pChildNode->GetTextInMenu( pCmdItem ) );
- mi.AccelCharInit();
- mi.MeasureItem( NULL );
- } // if( ! mi.IsSeparator() )
- _InsertItem( -1, mi );
- nInsertedIndex++;
- } // for( int nItemIndex = 0; nItemIndex < nMenuItemCount; nItemIndex++ )
- int nMruInsertCount = 0;
- if( nMruUpdateIndex >= 0 )
- { // insert recently opened file items
- //ASSERT( nMruUpdateIndex <= nMenuItemCount );
- CRecentFileList * pRecentFileList =
- InternalFriendlyWinApp::_GetFriendlyApp()->
- _GetRecentFileList();
- if( pRecentFileList != NULL )
- { // can be null !?
- int nRecentCount =
- pRecentFileList->GetSize();
- TCHAR sCurrDir[_MAX_PATH+1];
- ::memset(sCurrDir,0,sizeof(sCurrDir));
- ::GetCurrentDirectory(_MAX_PATH,sCurrDir);
- int nLenCurDir = (int)_tcslen(sCurrDir);
- for( int nItemIndex=0; nItemIndex<nRecentCount; nItemIndex++ )
- {
- CExtSafeString sDisplayName( _T("") );
- CExtSafeString sDisplayNameFullPath( _T("") );
- CExtSafeString sDisplayNameMenu( _T("") );
- CExtSafeString sDisplayNameTipTool( _T("") );
- sDisplayNameFullPath = ( ! pRecentFileList->m_arrNames[ nItemIndex ].IsEmpty() ) ? LPCTSTR( pRecentFileList->m_arrNames[ nItemIndex ] ) : _T("");
- pRecentFileList->GetDisplayName( *((CString *)&sDisplayName), nItemIndex, sCurrDir, nLenCurDir, TRUE );
- if( sDisplayName.IsEmpty() || sDisplayNameFullPath.IsEmpty() )
- continue;
- if( g_bMRU_UseFullPathsInMenu )
- sDisplayNameMenu = sDisplayNameFullPath;
- else
- sDisplayNameMenu = sDisplayName;
- if( g_bMRU_UseFullPathsInTipTool )
- sDisplayNameTipTool = sDisplayNameFullPath;
- else
- sDisplayNameTipTool = sDisplayName;
- UINT nCmdID = ID_FILE_MRU_FIRST + nItemIndex;
- ASSERT( nCmdID <= ID_FILE_MRU_LAST );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- if( pCmdItem == NULL )
- pCmdItem =
- g_CmdManager->CmdAllocPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- ASSERT( pCmdItem != NULL );
- if( pCmdItem == NULL )
- return false;
- int nDisplayIndex = nItemIndex+1;
- if( nDisplayIndex < 10 )
- pCmdItem->m_sMenuText.Format(
- _T("&%d %s"),
- nDisplayIndex,
- sDisplayNameMenu
- );
- else
- pCmdItem->m_sMenuText.Format(
- _T("%d&%d %s"),
- nDisplayIndex/10,
- nDisplayIndex%10,
- sDisplayNameMenu
- );
-
- CExtSafeString sRecentFileFmt1,sRecentFileFmt2;
- if( ! g_ResourceManager->LoadString( sRecentFileFmt1, IDS_RECENT_FILE_FMT_1 ) )
- sRecentFileFmt1 = _T("Recent file %d");
- if( ! g_ResourceManager->LoadString( sRecentFileFmt2, IDS_RECENT_FILE_FMT_2 ) )
- sRecentFileFmt2 = _T("Recent file %d ("%s")");
- pCmdItem->m_sToolbarText.Format(
- (LPCTSTR)sRecentFileFmt1,
- nItemIndex + 1
- );
- pCmdItem->m_sTipTool.Format(
- (LPCTSTR)sRecentFileFmt2,
- nItemIndex + 1,
- sDisplayNameTipTool
- );
- pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool;
- BOOL bInsRetVal =
- ItemInsert(
- nCmdID,
- nMruUpdateIndex + nItemIndex
- );
-
- if( !bInsRetVal )
- {
- ASSERT( FALSE );
- return false;
- }
- nMruInsertCount++;
- } // for( nItemIndex=0; nItemIndex<nRecentCount; nItemIndex++ )
- } // can be null !?
- /*
- if( nMruInsertCount > 0 )
- {
- if( nMruUpdateIndex > 0
- && (! ItemGetInfo( nMruUpdateIndex - 1 ).IsSeparator() )
- )
- {
- if( ! ItemInsert(
- ID_SEPARATOR,
- nMruUpdateIndex
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- nMruInsertCount++;
- nMruUpdateIndex++;
- }
- if( ( nMruUpdateIndex + nMruInsertCount ) < m_items_all.GetSize()
- && (! ItemGetInfo( nMruUpdateIndex + nMruInsertCount ).IsSeparator() )
- )
- {
- if( ! ItemInsert(
- ID_SEPARATOR,
- nMruUpdateIndex + nMruInsertCount
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- nMruInsertCount++;
- }
- } // if( nMruInsertCount > 0 )
- */
- if( nMruInsertCount == 0
- && nMruUpdateIndex > 0
- && nMruUpdateIndex < (ItemGetCount()-1)
- && ItemGetInfo( nMruUpdateIndex ).IsSeparator()
- && ItemGetInfo( nMruUpdateIndex-1 ).IsSeparator()
- )
- m_items_all.RemoveAt( nMruUpdateIndex );
- } // insert recently opened file items
- _SyncItems();
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupMenuSite & CExtPopupMenuWnd::GetSite() const
- {
- return CExtPopupMenuSite::g_DefPopupMenuSite;
- }
- CExtPopupMenuWnd * CExtPopupMenuWnd::GetTrackingMenu()
- {
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuSite::g_DefPopupMenuSite.GetInstance();
- if( !(::IsWindow(pPopup->GetSafeHwnd())) )
- return NULL;
- ASSERT_VALID( pPopup );
- return pPopup;
- }
- void CExtPopupMenuWnd::CancelMenuTracking()
- {
- if( (! CExtPopupMenuSite::g_DefPopupMenuSite.IsEmpty() )
- && (! CExtPopupMenuSite::g_DefPopupMenuSite.IsShutdownMode() )
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON == NULL
- )
- {
- CExtPopupMenuSite::g_DefPopupMenuSite.DoneInstance();
- ASSERT( CExtPopupMenuSite::g_DefPopupMenuSite.IsEmpty() );
- ASSERT( !CExtPopupMenuSite::g_DefPopupMenuSite.IsShutdownMode() );
- }
- }
- BOOL CExtPopupMenuWnd::IsMenuTracking()
- {
- if( CExtPopupMenuSite::g_DefPopupMenuSite.IsEmpty()
- //|| CExtPopupMenuSite::g_DefPopupMenuSite.GetCapture() == NULL
- )
- return FALSE;
- return TRUE;
- }
- BOOL CExtPopupMenuWnd::TrackPopupMenu(
- DWORD dwTrackFlags,
- int x,
- int y,
- LPCRECT lpRect, // = NULL
- LPVOID pCbPaintCombinedCookie, // = NULL
- pCbPaintCombinedContent pCbPCC, // = NULL
- UINT * lpnResultCmdID, // = NULL
- bool bCookieIsObject // = false
- )
- {
- ASSERT_VALID( this );
- CExtPopupMenuSite & _site = GetSite();
- CExtPopupMenuWnd * pOldPopup = _site.GetInstance();
- if( pOldPopup != NULL )
- {
- ASSERT_VALID( pOldPopup );
- DWORD dwTrackFlagsOld = pOldPopup->TrackFlagsGet();
- dwTrackFlagsOld |= TPMX_NO_FADE_OUT_ANIMATION;
- dwTrackFlags |= TPMX_FORCE_NO_ANIMATION;
- pOldPopup->TrackFlagsSet( dwTrackFlagsOld );
- }
- POSITION pos = g_ListDetached.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CExtPopupMenuWnd * pPopup = g_ListDetached.GetNext( pos );
- if( pPopup == this )
- continue;
- if( pPopup->GetParentMenuWnd() != NULL )
- continue;
- ASSERT_VALID( pPopup );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( pPopup->IsKindOf( RUNTIME_CLASS(CExtRibbonPopupMenuWnd) ) )
- continue;
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( pPopup->GetSafeHwnd() != NULL
- && (pPopup->TrackFlagsGet()&(TPMX_NO_SITE|TPMX_RIBBON_MODE)) != 0
- )
- {
- pPopup->TrackFlagsSet( pPopup->TrackFlagsGet() | TPMX_NO_FADE_OUT_ANIMATION );
- pPopup->DestroyWindow();
- if( _site.GetInstance() == pPopup )
- _site.DoneInstance();
- CExtToolControlBar::_CloseCustomMenusAll();
- CExtToolControlBar::_CloseTrackingMenus();
- break;
- }
- }
- if( (dwTrackFlags&TPMX_RIBBON_RESIZING) != 0
- && (! m_ctrlShadow.IsAvailable() )
- )
- dwTrackFlags |= TPMX_NO_SHADOWS;
- bool bLetSurfacesUpdate = false;
- CExtPopupMenuTipWnd & _tipWndSite = GetSite().GetTip();
- if( _tipWndSite.GetSafeHwnd() != NULL
- && (_tipWndSite.GetStyle()&WS_VISIBLE) != 0
- )
- {
- _tipWndSite.Hide();
- _tipWndSite.DestroyWindow();
- bLetSurfacesUpdate = true;
- }
- CWnd::CancelToolTips();
- CExtPopupMenuTipWnd & _tipWnd = GetTip();
- if( _tipWnd.GetSafeHwnd() != NULL
- && (_tipWnd.GetStyle()&WS_VISIBLE) != 0
- )
- {
- _tipWnd.Hide();
- _tipWndSite.DestroyWindow();
- bLetSurfacesUpdate = true;
- }
- if( bLetSurfacesUpdate )
- CExtPaintManager::stat_PassPaintMessages();
- if( lpnResultCmdID != NULL )
- *lpnResultCmdID = 0;
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- CWnd * pWndCmdReceiver =
- CWnd::FromHandlePermanent( m_hWndCmdReceiver );
- if( pWndCmdReceiver != NULL
- && CExtControlBar::FindHelpMode( pWndCmdReceiver )
- )
- dwTrackFlags |= TPMX_HELP_CTX_MODE;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- m_pCustomizeSite =
- CExtCustomizeSite::GetCustomizeSite( m_hWndCmdReceiver );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
-
- ASSERT(
- (dwTrackFlags&(TPMX_CUSTOMIZE_MODE|TPMX_HELP_CTX_MODE))
- != (TPMX_CUSTOMIZE_MODE|TPMX_HELP_CTX_MODE)
- );
- if( (dwTrackFlags&TPMX_CUSTOMIZE_MODE) != 0 )
- {
- dwTrackFlags &= ~
- ( TPMX_COMBINE_MASK
- |TPMX_SELECT_ANY
- |TPMX_DO_MESSAGE_LOOP
- |TPMX_OWNERDRAW_FIXED
- );
- dwTrackFlags |=
- TPMX_NO_SHADOWS
- | TPMX_NO_DYNAMIC_SHADOWS
- | TPMX_NO_HIDE_RARELY
- | TPMX_NO_WM_COMMAND
- | TPMX_NO_CMD_UI
- ;
- } // if( (dwTrackFlags&TPMX_CUSTOMIZE_MODE) != 0 )
- if( (dwTrackFlags&TPMX_HELP_CTX_MODE) != 0 )
- dwTrackFlags |= TPMX_NO_HIDE_RARELY;
- HWND hWndCurrentFocus = ::GetFocus();
- if( hWndCurrentFocus != NULL )
- {
- CWnd * pWndTest = CWnd::FromHandlePermanent( hWndCurrentFocus );
- if( pWndTest == NULL )
- {
- HWND hWnd = ::GetParent( hWndCurrentFocus );
- if( hWnd != NULL )
- pWndTest = CWnd::FromHandlePermanent( hWnd );
- } // if( pWndTest == NULL )
- if( pWndTest != NULL )
- {
- CComboBox * pComboTest =
- DYNAMIC_DOWNCAST( CComboBox, pWndTest );
- if( pComboTest == NULL )
- {
- pWndTest = pWndTest->GetParent();
- if( pWndTest != NULL )
- {
- pComboTest =
- DYNAMIC_DOWNCAST( CComboBox, pWndTest );
- }
- } // if( pComboTest == NULL )
- if( pComboTest != NULL
- && (pComboTest->GetStyle() & (CBS_DROPDOWN|CBS_DROPDOWNLIST)) != 0
- && pComboTest->GetDroppedState()
- )
- pComboTest->ShowDropDown( FALSE );
- } // if( pWndTest != NULL )
- } // if( hWndCurrentFocus != NULL )
- //CExtPopupMenuSite & _site = GetSite();
- bool bSiteWasEmpty = _site.IsEmpty();
- if( ! bSiteWasEmpty )
- {
- if( _site.IsShutdownMode() )
- return FALSE;
- if( (TrackFlagsGet()&TPMX_NO_SITE) == 0 )
- _site.DoneInstance();
- }
- //bool bCaptureChanged = false;
- HWND hWndCapture = ::GetCapture();
- CWnd * pWndCapture = FromHandlePermanent( hWndCapture );
- if( pWndCapture != NULL )
- {
- ReleaseCapture();
- if( ::IsWindow(hWndCapture) )
- {
- ASSERT_VALID( pWndCapture );
- pWndCapture->SendMessage(WM_CANCELMODE);
- }
- // bCaptureChanged = true;
- }
- if( ! _site.IsEmpty() )
- _site._Done();
- ASSERT( _site.IsEmpty() );
- ASSERT( !_site.IsShutdownMode() );
- // ASSERT( m_hWndCmdReceiver != NULL );
- // ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- if( m_hWndCmdReceiver == NULL
- || ( !::IsWindow( m_hWndCmdReceiver ) )
- )
- return FALSE;
- // if( !bSiteWasEmpty
- // || CExtToolControlBar::g_bMenuTracking
- // || bCaptureChanged
- // )
- // {
- // PassMsgLoop( CExtPopupBaseWnd::g_bEnableOnIdleCalls );
- // if( ! ::IsWindow(m_hWndCmdReceiver) )
- // return FALSE;
- // }
- // if( !_site.IsEmpty() )
- // return FALSE;
- ASSERT( m_bTopLevel );
- ASSERT( _site.IsEmpty() );
- if( (dwTrackFlags&(TPMX_CUSTOMIZE_MODE|TPMX_NO_SITE)) == 0 )
- {
- _site.SetInstance( this );
- if( lpnResultCmdID != NULL )
- _site.SetTargetCmdIdPtr( lpnResultCmdID );
- }
- m_dwTrackFlags = dwTrackFlags;
- if( (dwTrackFlags&(TPMX_CUSTOMIZE_MODE|TPMX_HELP_CTX_MODE)) == 0 )
- _UpdateCmdUI();
- if( ! _TrackPopupMenu(
- dwTrackFlags,
- x,
- y,
- lpRect,
- pCbPaintCombinedCookie,
- pCbPCC,
- bCookieIsObject
- )
- )
- {
- //ASSERT( FALSE );
- if( (dwTrackFlags&(TPMX_CUSTOMIZE_MODE|TPMX_NO_SITE)) == 0 )
- {
- _site.DoneInstance();
- ASSERT( _site.IsEmpty() );
- ASSERT( !_site.IsShutdownMode() );
- } // if( (dwTrackFlags&TPMX_CUSTOMIZE_MODE) == 0 )
- return FALSE;
- }
- if( (dwTrackFlags&TPMX_DO_MESSAGE_LOOP) == 0 )
- return TRUE;
- // do popup menu message loop
- HWND hWndThis = GetSafeHwnd();
- while( IsMenuTracking() )
- {
- WaitMessage();
- CExtPopupMenuWnd::PassMsgLoop( CExtPopupBaseWnd::g_bEnableOnIdleCalls );
- if( ! ::IsWindow( hWndThis ) )
- break;
- } // while( IsMenuTracking() )
-
- if( ! CExtToolControlBar::g_bMenuTracking )
- {
- if( (dwTrackFlags&TPMX_NO_SITE) == 0 )
- {
- if( _site.GetInstance() == this )
- _site.DoneInstance();
- // ASSERT( _site.IsEmpty() );
- // ASSERT( !_site.IsShutdownMode() );
- }
- } // if( ! CExtToolControlBar::g_bMenuTracking )
- return TRUE;
- }
- void CExtPopupMenuWnd::PassMsgLoop(
- bool bEnableOnIdleCalls
- )
- {
- __PROF_UIS_MANAGE_STATE;
- MSG msg;
- // Process all the messages in the message queue
- while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- if( !AfxGetThread()->PumpMessage() )
- {
- PostQuitMessage(0);
- return;
- } // if( !AfxGetThread()->PumpMessage() )
- } // while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- if( bEnableOnIdleCalls )
- {
- for( LONG nIdleCounter = 0L;
- ::AfxGetThread()->OnIdle(nIdleCounter);
- nIdleCounter ++
- );
- }
- }
- CSize CExtPopupMenuWnd::_CalcTrackSize()
- {
- ASSERT_VALID( this );
- int nMenuShadowSize = OnQueryMenuShadowSize();
- CRect rcMB = OnQueryMenuBorderMetrics();
- int nXtraSzX = rcMB.left + rcMB.right + nMenuShadowSize;
- int nXtraSzY = rcMB.top + rcMB.bottom + nMenuShadowSize;
- CSize _size( m_sizeFullItems );
- if( m_bExpandAvailable )
- _size.cy += _GetSpecBtnHeight(); // expand button
- _size += CSize( nXtraSzX + m_nLeftAreaWidth, nXtraSzY );
- if( _size.cx < (nMenuShadowSize*2 + 10) )
- _size.cx = nMenuShadowSize*2 + 10;
- if( _size.cy < (nMenuShadowSize*2 + 10) )
- _size.cy = nMenuShadowSize*2 + 10;
- _size.cy += 1; // +/- 2.28
- bool bFoundVisibleItem = false;
- for( int nIndex = 0; nIndex != m_items_all.GetSize(); nIndex++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( mi.IsDisplayed() )
- {
- bFoundVisibleItem = true;
- break;
- }
- }
- if( ! bFoundVisibleItem )
- _size.cy += 1; // + 2.31
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtPopupMenuWnd * pParent = GetParentMenuWnd();
- if( pParent != NULL
- && pParent->_IsTopLevelPopup()
- && (pParent->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
- )
- {
- CExtRibbonGalleryPopupMenuWnd * pGalleryMenu =
- DYNAMIC_DOWNCAST( CExtRibbonGalleryPopupMenuWnd, pParent );
- if( pGalleryMenu != NULL )
- {
- CSize _sizeAdjust = pGalleryMenu->m_sizeChildControl;
- _sizeAdjust.cx -= nMenuShadowSize;
- _sizeAdjust.cy -= nMenuShadowSize;
- _size.cx = max( _size.cx, _sizeAdjust.cx );
- _size.cy = max( _size.cy, _sizeAdjust.cy );
- }
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return _size;
- }
- CRect CExtPopupMenuWnd::_CalcTrackRect()
- {
- ASSERT_VALID( this );
- m_eCombineAlign = __CMBA_NONE;
- bool bRTL = OnQueryLayoutRTL();
- CExtPaintManager::monitor_parms_t _mp;
- if( m_bExcludeAreaSpec )
- CExtPaintManager::stat_GetMonitorParms( _mp, m_rcExcludeArea );
- else if( m_pWndParentMenu != NULL )
- {
- ASSERT_VALID( m_pWndParentMenu );
- ASSERT( m_pWndParentMenu->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( m_pWndParentMenu->GetSafeHwnd() ) );
- CExtPaintManager::stat_GetMonitorParms( _mp, m_pWndParentMenu );
- } // else if( m_pWndParentMenu != NULL )
- else
- CExtPaintManager::stat_GetMonitorParms( _mp, m_ptTrack );
- CRect rcDesktop = g_bUseDesktopWorkArea
- ? _mp.m_rcWorkArea
- : _mp.m_rcMonitor
- ;
- CSize _size = _CalcTrackSize();
- bool bTearOff = _IsTearOff();
- int nTearOffCaptionHeight = bTearOff ? _GetTearOffCaptionHeight() : 0;
- if( bTearOff )
- _size.cy += nTearOffCaptionHeight;
- int nMenuShadowSize =
- OnQueryMenuShadowSize();
- CRect rcMB = OnQueryMenuBorderMetrics();
- int nGapShift = 0;
- if( ! m_bCombineWithEA )
- nGapShift = rcMB.top + nMenuShadowSize;
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == 0 && (!m_bCombineWithEA) )
- {
- if( m_pWndParentMenu->GetSafeHwnd() != NULL )
- {
- if( (m_pWndParentMenu->m_dwTrackFlags&TPMX_ALIGN_MASK) != 0 )
- m_dwTrackFlags |=
- m_pWndParentMenu->m_dwTrackFlags
- & (~(TPMX_ALIGN_MASK|TPMX_PALETTE|TPMX_PALETTE_TB_BKGND|TPMX_RIBBON_RESIZING|TPMX_RIBBON_RESIZING_VERTICAL_ONLY));
- else
- {
- CRect rc1;
- m_pWndParentMenu->GetWindowRect( &rc1 );
- if( m_pWndParentMenu->m_pWndParentMenu->GetSafeHwnd() != NULL )
- {
- CRect rc2;
- m_pWndParentMenu->m_pWndParentMenu->GetWindowRect(&rc2);
- int x1 = rc1.left + rc1.Width()/2;
- int x2 = rc2.left + rc2.Width()/2;
- if( x1 >= x2 )
- m_dwTrackFlags |= TPMX_LEFTALIGN;
- else
- m_dwTrackFlags |= TPMX_RIGHTALIGN;
- } // if( m_pWndParentMenu->m_pWndParentMenu->GetSafeHwnd() != NULL )
- } // else from if( (m_pWndParentMenu->m_dwTrackFlags&TPMX_ALIGN_MASK) != 0 )
- } // if( m_pWndParentMenu->GetSafeHwnd() != NULL )
- } // if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == 0 && (!m_bCombineWithEA) )
- CRect wr( m_ptTrack, _size );
- int nCombineOffset = 0;
- if( m_bCombineWithEA )
- {
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_TOPALIGN )
- {
- nCombineOffset = 1;
- wr.OffsetRect( 0, -nCombineOffset );
- }
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_LEFTALIGN )
- {
- nCombineOffset = 1;
- wr.OffsetRect( -nCombineOffset, 0 );
- }
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_BOTTOMALIGN )
- {
- nCombineOffset = -nMenuShadowSize - 1;
- wr.OffsetRect( 0 , -nCombineOffset );
- }
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_RIGHTALIGN )
- {
- if( (! bRTL) || m_bTopLevel )
- nCombineOffset = -nMenuShadowSize - 1;
- wr.OffsetRect( -nCombineOffset, 0 );
- }
- } // if( m_bCombineWithEA )
- if( bRTL
- && ( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_TOPALIGN
- || (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_BOTTOMALIGN
- )
- )
- {
- wr.OffsetRect(
- - wr.Width() + m_rcExcludeArea.Width()
- + nMenuShadowSize,
- 0
- );
- }
-
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- CExtPopupMenuWnd * pParent = GetParentMenuWnd();
- if( pParent != NULL
- && pParent->_IsTopLevelPopup()
- && (pParent->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
- && pParent->GetSafeHwnd() != NULL
- )
- {
- CExtRibbonGalleryPopupMenuWnd * pGalleryMenu =
- DYNAMIC_DOWNCAST( CExtRibbonGalleryPopupMenuWnd, pParent );
- if( pGalleryMenu != NULL )
- {
- CRect wr;
- ::GetWindowRect( pGalleryMenu->GetChildCtrlHWND(), &wr );
- CSize _sizeTrack = pGalleryMenu->m_sizeChildControl;
- _sizeTrack.cx = max( _sizeTrack.cx, _size.cx );
- _sizeTrack.cy = max( _sizeTrack.cy, _size.cy );
- _sizeTrack.cx -= nMenuShadowSize;
- _sizeTrack.cy -= nMenuShadowSize;
- wr.right = wr.left + _sizeTrack.cx;
- wr.bottom = wr.top + _sizeTrack.cy;
- m_rcClient = wr;
- m_rcClient.OffsetRect( -wr.TopLeft() );
- m_rcClient.DeflateRect( 0, 0, nMenuShadowSize, nMenuShadowSize );
- return wr;
- }
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( wr.bottom > rcDesktop.bottom )
- {
- if( m_bExcludeAreaSpec )
- {
- wr.OffsetRect(
- 0,
- -wr.Height()
- + m_rcExcludeArea.Height()
- + nGapShift
- + (m_bCombineWithEA ? nMenuShadowSize : 0)
- );
- } // if( m_bExcludeAreaSpec )
- if( wr.bottom > rcDesktop.bottom )
- wr.OffsetRect(
- 0,
- m_bExcludeAreaSpec
- ? -(wr.bottom - rcDesktop.bottom)
- : - wr.Height()
- );
- } // if( wr.bottom > rcDesktop.bottom )
- if( wr.top < rcDesktop.top )
- wr.OffsetRect( 0, rcDesktop.top - wr.top );
- if( wr.right > rcDesktop.right )
- {
- if( (!m_bTopLevel) && m_bExcludeAreaSpec )
- wr.OffsetRect(
- -wr.Width() - m_rcExcludeArea.Width(),
- 0
- );
- if( wr.right > rcDesktop.right )
- wr.OffsetRect(
- m_bExcludeAreaSpec
- ? -(wr.right - rcDesktop.right)
- : -wr.Width(),
- 0
- );
- } // if( wr.right > rcDesktop.right )
- if( wr.left < rcDesktop.left )
- {
- if( (!m_bTopLevel) && m_bExcludeAreaSpec )
- wr.OffsetRect(
- wr.Width() + m_rcExcludeArea.Width(),
- 0
- );
- if( wr.left < rcDesktop.left )
- wr.OffsetRect( rcDesktop.left - wr.left, 0 );
- } // if( wr.left < rcDesktop.left )
- if( m_bExcludeAreaSpec || m_bCombineWithEA )
- {
- CRect rcIntersection;
- if( rcIntersection.IntersectRect(
- &wr,
- &m_rcExcludeArea
- )
- || m_bCombineWithEA
- )
- { // if need adjust with exclude area
- CRect rcFree( 0, 0, 0, 0 );
- if( m_rcExcludeArea.left > rcDesktop.left )
- rcFree.left = m_rcExcludeArea.left - rcDesktop.left;
- if( m_rcExcludeArea.right < rcDesktop.right )
- rcFree.right = rcDesktop.right - m_rcExcludeArea.right;
- if( m_rcExcludeArea.top > rcDesktop.top )
- rcFree.top = m_rcExcludeArea.top - rcDesktop.top;
- if( m_rcExcludeArea.bottom < rcDesktop.bottom )
- rcFree.bottom = rcDesktop.bottom - m_rcExcludeArea.bottom;
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_LEFTALIGN
- && rcFree.right > wr.Width()
- )
- wr.OffsetRect(
- wr.left - m_rcExcludeArea.right
- + (m_bCombineWithEA ? nCombineOffset : 0)
- ,
- 0
- );
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_RIGHTALIGN
- && rcFree.left > wr.Width()
- )
- wr.OffsetRect(
- m_rcExcludeArea.left - wr.right
- - (m_bCombineWithEA ? nCombineOffset : 0)
- ,
- 0
- );
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_TOPALIGN )
- {
- if( rcFree.bottom > wr.Height() )
- wr.OffsetRect(
- 0,
- wr.top - m_rcExcludeArea.bottom
- + (m_bCombineWithEA ? nCombineOffset : 0)
- );
- else
- {
- if( ::IsWindow(GetSafeHwnd()) )
- {
- CRect rcWndOld;
- GetWindowRect( &rcWndOld );
- ShowWindow( SW_HIDE );
- _FreeWinObjects();
- HWND hWndThis = GetSafeHwnd();
- bool bWasCreated =
- (hWndThis != NULL && ::IsWindow(hWndThis))
- ? true : false;
- // CExtPopupMenuWnd::PassMsgLoop(
- // CExtPopupBaseWnd::g_bEnableOnIdleCalls
- // );
- if( bWasCreated && (!::IsWindow(hWndThis)) )
- return CRect( 0, 0, 0, 0 );
- if( ! rcWndOld.IsRectEmpty() )
- {
- CWnd * pWndTLP = GetTopLevelParent();
- if( pWndTLP != NULL )
- {
- ASSERT_VALID( pWndTLP );
- if( pWndTLP->IsWindowVisible() )
- {
- CRect rcTLP;
- pWndTLP->GetWindowRect( &rcTLP );
- if( ! rcTLP.IsRectEmpty() )
- {
- CRect rcIntersection;
- if( rcIntersection.IntersectRect(
- &rcTLP,
- &rcWndOld
- )
- )
- pWndTLP->UpdateWindow();
- } // if( !rcTLP.IsRectEmpty() )
- } // if( pWndTLP->IsWindowVisible() )
- } // if( pWndTLP != NULL )
- } // if( ! rcWndOld.IsRectEmpty() )
- } // if( ::IsWindow(GetSafeHwnd()) )
- m_dwTrackFlags &= ~(TPMX_ALIGN_MASK);
- //m_dwTrackFlags |= TPMX_BOTTOMALIGN;
- m_dwTrackFlags |= TPMX_BOTTOMALIGN; // TPMX_RIGHTALIGN;
- return _CalcTrackRect();
- } // else from if( rcFree.bottom > wr.Height() )
- } // if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_TOPALIGN )
- if( (m_dwTrackFlags&TPMX_ALIGN_MASK) == TPMX_BOTTOMALIGN
- && rcFree.top > wr.Height()
- )
- wr.OffsetRect(
- 0,
- m_rcExcludeArea.top - wr.bottom
- - (m_bCombineWithEA ? nCombineOffset : 0)
- );
- } // if need adjust with exclude area
- } // if( m_bExcludeAreaSpec || m_bCombineWithEA )
- if( wr.right > rcDesktop.right )
- {
- wr.OffsetRect( -(wr.right - rcDesktop.right), 0 );
- if( m_bTopLevel )
- {
- m_bExcludeAreaSpec = false;
- m_bCombineWithEA = false;
- }
- } // if( wr.right > rcDesktop.right )
- if( wr.left < rcDesktop.left )
- {
- wr.OffsetRect( rcDesktop.left - wr.left, 0 );
- if( m_bTopLevel )
- {
- m_bExcludeAreaSpec = false;
- m_bCombineWithEA = false;
- }
- } // if( wr.left < rcDesktop.left )
- if( wr.bottom > rcDesktop.bottom )
- {
- wr.OffsetRect( 0, -(wr.bottom - rcDesktop.bottom) );
- if( m_bTopLevel )
- {
- m_bExcludeAreaSpec = false;
- m_bCombineWithEA = false;
- }
- } // if( wr.bottom > rcDesktop.bottom )
- if( wr.top < rcDesktop.top )
- {
- wr.OffsetRect( 0, rcDesktop.top - wr.top );
- if( m_bTopLevel )
- {
- m_bExcludeAreaSpec = false;
- m_bCombineWithEA = false;
- }
- } // if( wr.top < rcDesktop.top )
- if( wr.bottom > rcDesktop.bottom )
- {
- wr.bottom = rcDesktop.bottom;
- m_bScrollingAvailable = true;
- } // if( wr.bottom > rcDesktop.bottom )
- if( m_bCombineWithEA )
- {
- ASSERT( m_bExcludeAreaSpec );
- if( wr.bottom == m_rcExcludeArea.top - nCombineOffset )
- m_eCombineAlign = __CMBA_BOTTOM;
- if( wr.top == m_rcExcludeArea.bottom - nCombineOffset )
- m_eCombineAlign = __CMBA_TOP;
- if( wr.left == m_rcExcludeArea.right - nCombineOffset )
- m_eCombineAlign = __CMBA_LEFT;
- if( wr.right == m_rcExcludeArea.left - nCombineOffset )
- m_eCombineAlign = __CMBA_RIGHT;
- if( m_eCombineAlign == __CMBA_NONE )
- {
- m_bCombineWithEA = false;
- return _CalcTrackRect();
- } // if( m_eCombineAlign == __CMBA_NONE )
- // init window region
- if( m_rgnWnd.GetSafeHandle() != NULL )
- {
- VERIFY( m_rgnWnd.DeleteObject() );
- }
- CRect rcExcludeArea(m_rcExcludeArea);
- rcExcludeArea.InflateRect(
- 0,
- 0,
- nMenuShadowSize,
- nMenuShadowSize
- );
- CRect rcFullWnd(
- min( wr.left, rcExcludeArea.left ),
- min( wr.top, rcExcludeArea.top ),
- max( wr.right, rcExcludeArea.right ),
- max( wr.bottom, rcExcludeArea.bottom )
- );
- if( ! m_bTopLevel )
- {
- if( m_eCombineAlign == __CMBA_LEFT
- || m_eCombineAlign == __CMBA_RIGHT
- )
- rcExcludeArea.DeflateRect( 0, 0, 0, nMenuShadowSize );
- else if( m_eCombineAlign == __CMBA_TOP
- || m_eCombineAlign == __CMBA_BOTTOM
- )
- rcExcludeArea.DeflateRect( 0, 0, nMenuShadowSize, 0 );
- } // if( ! m_bTopLevel )
-
- CRgn rgnAreaWnd, rgnAreaExclude;
- if( (! m_rgnWnd.CreateRectRgnIndirect( &rcFullWnd ) )
- || (! rgnAreaExclude.CreateRectRgnIndirect( &rcExcludeArea ) )
- || (! rgnAreaWnd.CreateRectRgnIndirect( &wr ) )
- || m_rgnWnd.CombineRgn(
- &rgnAreaWnd,
- &rgnAreaExclude,
- RGN_OR
- ) == ERROR
- || m_rgnWnd.OffsetRgn(
- -rcFullWnd.TopLeft()
- ) == ERROR
- )
- {
- if( m_rgnWnd.GetSafeHandle() != NULL )
- {
- VERIFY( m_rgnWnd.DeleteObject() );
- }
- m_bCombineWithEA = false;
- return _CalcTrackRect();
- }
- ASSERT( m_rgnWnd.GetSafeHandle() != NULL );
-
- m_rcClient = wr;
- m_rcClient.OffsetRect( -rcFullWnd.TopLeft() );
- m_rcClient.DeflateRect( 0, 0, nMenuShadowSize, nMenuShadowSize );
- ASSERT( m_rcClient.top <= m_rcClient.bottom );
- ASSERT( m_rcClient.left <= m_rcClient.right );
- // if( bTearOff )
- // m_rcClient.top += nTearOffCaptionHeight;
- if( ! m_bTopLevel )
- {
- if( m_eCombineAlign == __CMBA_RIGHT )
- rcFullWnd.OffsetRect( nMenuShadowSize + 1, 0 );
- else if( m_eCombineAlign == __CMBA_LEFT )
- rcFullWnd.OffsetRect( -2, 0 );
- }
- return rcFullWnd;
- } // if( m_bCombineWithEA )
- m_rcClient = wr;
- m_rcClient.OffsetRect( -wr.TopLeft() );
- m_rcClient.DeflateRect( 0, 0, nMenuShadowSize, nMenuShadowSize );
- // if( bTearOff )
- // m_rcClient.top += nTearOffCaptionHeight;
- ASSERT( m_rcClient.top <= m_rcClient.bottom );
- ASSERT( m_rcClient.left <= m_rcClient.right );
- return wr;
- }
- bool CExtPopupMenuWnd::OnQueryLayoutRTL() const
- {
- ASSERT_VALID( this );
- if( m_pWndParentMenu != NULL )
- {
- ASSERT_VALID( this );
- return m_pWndParentMenu->OnQueryLayoutRTL();
- } // if( m_pWndParentMenu != NULL )
- return CExtPopupBaseWnd::OnQueryLayoutRTL();
- }
- void CExtPopupMenuWnd::_CancelingSet()
- {
- ASSERT_VALID( this );
- if( m_bCanceling )
- return;
- m_bCanceling = true;
- //if( ( GetStyle() & WS_VISIBLE ) != 0 )
- {
- if( m_pWndParentMenu != NULL )
- {
- if( ! m_pWndParentMenu->_CancelingGet() )
- m_pWndParentMenu->_CancelingSet();
- }
- if( m_nCurIndex >= 0
- && ItemGetInfo( m_nCurIndex ).IsPopup()
- )
- {
- CExtPopupMenuWnd * pPopup = ItemGetInfo( m_nCurIndex ).GetPopup();
- if( ! pPopup->_CancelingGet() )
- pPopup->_CancelingSet();
- }
- }
- }
- bool CExtPopupMenuWnd::_CancelingGet() const
- {
- ASSERT_VALID( this );
- return m_bCanceling;
- }
- BOOL CExtPopupMenuWnd::_TrackPopupMenu(
- DWORD dwTrackFlags,
- int x,
- int y,
- LPCRECT lpRect,
- LPVOID pCbPaintCombinedCookie, // = NULL
- pCbPaintCombinedContent pCbPCC, // = NULL
- bool bCookieIsObject // = false
- )
- {
- ///////////////////////////// dwTrackFlags |= TPMX_COMBINE_NONE|TPMX_FORCE_NO_ANIMATION|TPMX_NO_DYNAMIC_SHADOWS|TPMX_NO_SHADOWS;
- ASSERT_VALID( this );
- m_bCanceling = false;
- CExtPaintManager::stat_PassPaintMessages();
- ::GetCursorPos( &m_ptTrackInvoked );
- m_ptTrackWatched = m_ptTrackInvoked;
- if( _IsTopLevelPopup() )
- m_bHelperMouseBtnDownOnStart =
- ( IsKeyPressed( VK_LBUTTON )
- || IsKeyPressed( VK_RBUTTON )
- ) ? true : false;
- else
- m_bHelperMouseBtnDownOnStart = false;
- if( m_bHelperMouseBtnDownOnStart )
- ::GetCursorPos( &m_ptStartMousePos );
- bool bForceExpandRarelyUsed = (dwTrackFlags&TPMX_NO_HIDE_RARELY)
- ? true : false;
- if( ! g_bMenuExpanding )
- bForceExpandRarelyUsed = true;
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- if( GetSafeHwnd() != NULL )
- ::DestroyWindow( m_hWnd ); // fade out animation effect
- CExtPopupMenuSite & _site = GetSite();
- if( (!_FindCustomizeMode())
- && ( _site.IsTopPopup(this)
- || GetParentMenuWnd() == NULL
- )
- )
- {
- ASSERT( m_bTopLevel );
- MsgPrepareMenuData_t _mpmEntireTree( this );
- _mpmEntireTree.SendMessage( m_hWndCmdReceiver, false );
- if( _mpmEntireTree.m_bMenuCanceled )
- return FALSE;
- if( _mpmEntireTree.m_bMenuChanged )
- {
- _SyncItems();
- _UpdateCmdUI();
- }
- ASSERT( m_bTopLevel );
- // ASSERT( _site.IsTopPopup(this) );
- }
- MsgPrepareMenuData_t _mpmOneTreeLevel( this );
- _mpmOneTreeLevel.SendMessage( m_hWndCmdReceiver, true );
- if( _mpmOneTreeLevel.m_bMenuCanceled )
- return FALSE;
- if( _mpmOneTreeLevel.m_bMenuChanged )
- {
- _SyncItems();
- _UpdateCmdUI();
- }
- if( !_FindCustomizeMode() )
- { // BLOCK: update system commands
- INT iter = 0;
- for(; iter < m_items_all.GetSize(); ++iter )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( mi.IsSeparator() )
- continue;
- UINT nCmdID = mi.GetCmdID();
- if( ! CExtCmdManager::IsSystemCommand( nCmdID ) )
- continue;
- WINDOWPLACEMENT wndpl;
- ::memset(&wndpl,0,sizeof(WINDOWPLACEMENT));
- wndpl.length = sizeof(WINDOWPLACEMENT);
- VERIFY(
- ::GetWindowPlacement(
- mi.GetCmdReceiver(),
- &wndpl
- )
- );
- __EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( mi.GetCmdReceiver(), GWL_STYLE );
- __EXT_MFC_LONG_PTR dwWndExStyle = ::__EXT_MFC_GetWindowLong( mi.GetCmdReceiver(), GWL_EXSTYLE );
- bool bSysCmdEnabled = false;
- switch( nCmdID )
- {
- case SC_CLOSE:
- {
- bSysCmdEnabled = true;
- HMENU hSysMenu = ::GetSystemMenu( mi.GetCmdReceiver(), FALSE );
- MENUITEMINFO _mii;
- ::memset( &_mii, 0, sizeof(MENUITEMINFO) );
- _mii.cbSize = sizeof(MENUITEMINFO);
- _mii.fMask = MIIM_STATE;
- if( hSysMenu != NULL
- && ::GetMenuItemInfo(
- hSysMenu,
- SC_CLOSE,
- FALSE,
- &_mii
- )
- )
- {
- if( (_mii.fState & MFS_DISABLED) != 0 )
- bSysCmdEnabled = false;
- } // if( hSysMenu != NULL ...
- }
- break;
- case SC_SIZE:
- case SC_MOVE:
- if( wndpl.showCmd != SW_SHOWMINIMIZED
- && wndpl.showCmd != SW_SHOWMAXIMIZED
- && !g_bFullScreenMode
- )
- bSysCmdEnabled = true;
- break;
- case SC_MINIMIZE:
- if( (dwWndStyle & WS_MINIMIZEBOX) != 0
- && wndpl.showCmd != SW_SHOWMINIMIZED
- )
- bSysCmdEnabled = true;
- break;
- case SC_MAXIMIZE:
- if( (dwWndStyle & WS_MAXIMIZEBOX) != 0
- && wndpl.showCmd != SW_SHOWMAXIMIZED
- && !g_bFullScreenMode
- )
- bSysCmdEnabled = true;
- break;
- case SC_RESTORE:
- if( (dwWndStyle & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)) != 0
- && ( wndpl.showCmd == SW_SHOWMAXIMIZED
- || wndpl.showCmd == SW_SHOWMINIMIZED
- //||wndpl.showCmd == SW_SHOWNORMAL
- )
- )
- bSysCmdEnabled = true;
- break;
- case SC_CONTEXTHELP:
- if( (dwWndExStyle & WS_EX_CONTEXTHELP) != 0 )
- bSysCmdEnabled = true;
- break;
- // case SC_NEXTWINDOW:
- // case SC_PREVWINDOW:
- // case SC_VSCROLL:
- // case SC_HSCROLL:
- // case SC_MOUSEMENU:
- // case SC_KEYMENU:
- // case SC_ARRANGE:
- // case SC_TASKLIST:
- // case SC_SCREENSAVE:
- //#if(WINVER >= 0x0400)
- // case SC_DEFAULT:
- // case SC_MONITORPOWER:
- // case SC_SEPARATOR:
- //#endif /* WINVER >= 0x0400 */
- case SC_HOTKEY:
- default:
- continue;
- } // switch( nCmdID )
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- if( pCmdItem == NULL )
- {
- pCmdItem =
- g_CmdManager->CmdAllocPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- ASSERT( pCmdItem != NULL );
- }
- pCmdItem->StateEnable( bSysCmdEnabled );
- mi.Enable( bSysCmdEnabled );
- ASSERT( CExtCmdManager::IsSystemCommand( nCmdID ) );
- HWND hWndItemCmdReceiver = mi.GetCmdReceiver();
- HMENU hSysMenu = ::GetSystemMenu( hWndItemCmdReceiver, FALSE );
- if( hSysMenu != NULL )
- {
- MENUITEMINFO _mii;
- ::memset( &_mii, 0, sizeof(MENUITEMINFO) );
- _mii.cbSize = sizeof(MENUITEMINFO);
- _mii.fMask =
- MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE
- |MIIM_SUBMENU|MIIM_TYPE;
- _mii.cch = __MAX_UI_ITEM_TEXT;
- CExtSafeString sMenuItemText;
- _mii.dwTypeData = sMenuItemText.GetBuffer( __MAX_UI_ITEM_TEXT );
- ASSERT( _mii.dwTypeData != NULL );
- if( _mii.dwTypeData != NULL )
- {
- if( ::GetMenuItemInfo(
- hSysMenu,
- nCmdID,
- FALSE,
- &_mii
- )
- )
- {
- sMenuItemText.ReleaseBuffer();
- sMenuItemText.Replace( _T("n"), _T("") );
- sMenuItemText.Replace( _T("r"), _T("") );
- sMenuItemText.TrimLeft();
- sMenuItemText.TrimRight();
- if( ! sMenuItemText.IsEmpty() )
- {
- int nSep =
- sMenuItemText.ReverseFind( _T('t') );
- if( nSep >= 0 )
- {
- int nLen = sMenuItemText.GetLength();
- pCmdItem->m_sAccelText = sMenuItemText.Right( nLen - nSep );
- pCmdItem->m_sAccelText.TrimLeft();
- pCmdItem->m_sAccelText.TrimRight();
- pCmdItem->m_sMenuText = sMenuItemText.Left( nSep );
- pCmdItem->m_sMenuText.TrimLeft();
- pCmdItem->m_sMenuText.TrimRight();
- }
- else
- {
- pCmdItem->m_sMenuText = sMenuItemText;
- pCmdItem->m_sAccelText = _T("");
- }
- if( pCmdItem->m_nCmdID == SC_CLOSE )
- {
- CWnd * pWnd = CWnd::FromHandlePermanent( hWndItemCmdReceiver );
- if( pWnd != NULL
- && pWnd->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
- )
- pCmdItem->m_sAccelText = _T("Ctrl+F4");
- }
- mi.SetPopupText( pCmdItem->m_sMenuText );
- mi.SetAccelText( pCmdItem->m_sAccelText );
- } // if( ! sMenuItemText.IsEmpty() )
- }
- else
- sMenuItemText.ReleaseBuffer();
- } // if( _mii.dwTypeData != NULL )
- if( (_mii.fState&MFS_DEFAULT) != 0 )
- mi.SetDefault();
- } // if( hSysMenu != NULL )
- } // for(; iter < m_items_all.end(); ++iter )
- } // BLOCK: update system commands
- CWnd * pWndCmdReceiver =
- CWnd::FromHandle( m_hWndCmdReceiver );
- ASSERT_VALID( pWndCmdReceiver );
- // pWndCmdReceiver->ActivateTopParent();
- // pWndCmdReceiver->BringWindowToTop();
- // pWndCmdReceiver->SetFocus();
-
- //_site._Hook( true );
- // adjust own data
- bool bOldTopLevel = m_bTopLevel;
- bool bOldExpandAvailable = m_bExpandAvailable;
- DWORD dwPortedTrackFlags = m_dwTrackFlags&(TPMX_PALETTE|TPMX_PALETTE_TB_BKGND);
- _Init();
- m_bTopLevel = bOldTopLevel;
- m_bExpandAvailable = bOldExpandAvailable;
- m_dwTrackFlags = dwTrackFlags | dwPortedTrackFlags;
- m_pCbPaintCombinedCookie = pCbPaintCombinedCookie;
- m_pCbPaintCombinedContent = pCbPCC;
- m_bCookieIsObject = bCookieIsObject;
- if( !m_bTopLevel )
- {
- ASSERT( m_pWndParentMenu != NULL );
- if( m_pWndParentMenu->m_bExpandWasPressed )
- {
- if( m_bExpandAvailable )
- {
- m_bExpandAvailable = false;
- m_bExpandWasPressed = true;
- _SyncItems();
- }
- else
- m_bExpandWasPressed = true;
- }
- } // if( !m_bTopLevel )
- else
- {
- if( bForceExpandRarelyUsed )
- {
- if( m_bExpandAvailable )
- {
- m_bExpandAvailable = false;
- m_bExpandWasPressed = true;
- _SyncItems();
- }
- else
- m_bExpandWasPressed = true;
- } // if( bForceExpandRarelyUsed )
- else
- _SyncItems();
- } // else from if( !m_bTopLevel )
- // adjust screen position
- m_ptTrack.x = m_ptTrackOriginal.x = x;
- m_ptTrack.y = m_ptTrackOriginal.y = y;
- if( ( m_ptTrack.x < -32000 || m_ptTrack.y < -32000 )
- && (dwTrackFlags&TPMX_RIBBON_MODE) == 0
- )
- {
- if( ! ::GetCursorPos(&m_ptTrack) )
- return FALSE;
- }
- if( lpRect != NULL )
- {
- m_rcExcludeArea = *lpRect;
- m_bExcludeAreaSpec = true;
- }
- else
- {
- m_bExcludeAreaSpec = false;
- m_rcExcludeArea.left = m_ptTrack.x - __EXCLUDE_AREA_GAP_DX;
- m_rcExcludeArea.right = m_ptTrack.x + __EXCLUDE_AREA_GAP_DX;
- m_rcExcludeArea.top = m_ptTrack.y - __EXCLUDE_AREA_GAP_DY;
- m_rcExcludeArea.bottom = m_ptTrack.y + __EXCLUDE_AREA_GAP_DY;
- }
- // adjust combine with exclude area mode
- m_bCombineWithEA = false;
- if( m_bExcludeAreaSpec )
- {
- switch( (dwTrackFlags&TPMX_COMBINE_MASK) )
- {
- case TPMX_COMBINE_ANY_SUITABLE:
- m_bCombineWithEA = true;
- break;
- case TPMX_COMBINE_DEFAULT:
- m_bCombineWithEA =
- PmBridge_GetPM()->
- IsMenuMustCombineExcludeArea(
- bCookieIsObject
- ? ((CObject*)pCbPaintCombinedCookie)
- : NULL
- );
- break;
- } // switch( (dwTrackFlags&TPMX_COMBINE_MASK) )
- } // if( m_bExcludeAreaSpec )
- CSize _size = _CalcTrackSize();
- bool bPointAdjusted = true;
- if( m_bExcludeAreaSpec )
- {
- bool bRTL = OnQueryLayoutRTL();
- if( bRTL && (!m_bTopLevel) )
- {
- CExtPopupMenuWnd * pTop = m_pWndParentMenu;
- for( ; pTop != NULL; pTop = pTop->GetParentMenuWnd() )
- {
- if( pTop->_IsTopLevelPopup() )
- break;
- } // for( ; pTop != NULL; pTop = pTop->GetParentMenuWnd() )
- if( pTop != NULL )
- {
- switch( (pTop->m_dwTrackFlags & TPMX_ALIGN_MASK) )
- {
- case TPMX_TOPALIGN:
- case TPMX_BOTTOMALIGN:
- m_dwTrackFlags &= ~(TPMX_ALIGN_MASK);
- m_dwTrackFlags |= TPMX_RIGHTALIGN;
- break;
- } // switch( (pTop->m_dwTrackFlags & TPMX_ALIGN_MASK) )
- } // if( pTop != NULL )
- } // if( bRTL && (!m_bTopLevel) )
- switch( (m_dwTrackFlags & TPMX_ALIGN_MASK) )
- {
- case TPMX_LEFTALIGN:
- m_ptTrack.x = m_rcExcludeArea.right;
- m_ptTrack.y = m_rcExcludeArea.top;
- break;
- case TPMX_RIGHTALIGN:
- m_ptTrack.x = m_rcExcludeArea.left - _size.cx;
- m_ptTrack.y = m_rcExcludeArea.top;
- break;
- case TPMX_TOPALIGN:
- m_ptTrack.x = m_rcExcludeArea.left;
- m_ptTrack.y = m_rcExcludeArea.bottom;
- break;
- case TPMX_BOTTOMALIGN:
- m_ptTrack.x = m_rcExcludeArea.left;
- m_ptTrack.y = m_rcExcludeArea.top - _size.cy;
- break;
- default:
- bPointAdjusted = false;
- break;
- } // switch( (m_dwTrackFlags & TPMX_ALIGN_MASK) )
- } // if( m_bExcludeAreaSpec )
- if( ! bPointAdjusted )
- {
- if( (m_dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_RIGHTALIGN )
- m_ptTrack.x -= _size.cx;
- else
- {
- if( (m_dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_CENTERALIGN )
- m_ptTrack.x -= _size.cx/2;
- }
- if( (m_dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_BOTTOMALIGN )
- m_ptTrack.y -= _size.cy;
- else
- {
- if( (m_dwTrackFlags & TPMX_ALIGN_MASK) == TPMX_VCENTERALIGN )
- m_ptTrack.y -= _size.cy/2;
- }
- } // if( !bPointAdjusted )
- //#ifdef _DEBUG
- bool bCreateResult =
- //#endif // _DEBUG
- _CreateHelper( pWndCmdReceiver );
- //ASSERT( bCreateResult );
- if( !bCreateResult )
- return FALSE;
- if( dwTrackFlags & TPMX_SELECT_ANY )
- {
- int nItem = _GetNextItem(__NI_ANY);
- if( nItem >= 0 )
- {
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet(
- nItem,
- FALSE,
- FALSE
- );
- if( ! ::IsWindow( hWndOwn ) )
- return FALSE;
- }
- }
- HWND hWndOwn = m_hWnd;
- if( (dwTrackFlags&TPMX_FORCE_NO_ANIMATION) != 0
- || _FindCustomizeMode()
- )
- m_AnimationType = __AT_NONE;
- else
- {
- m_AnimationType = g_DefAnimationType;
- if( CExtToolControlBar::g_bMenuTracking )
- m_AnimationType = __AT_NONE;
- m_ePlaySoundOnAnimationFinished =
- CExtSoundPlayer::__ON_MENU_POPUP_DISPLAYED;
- _StartAnimation();
- if( ! ::IsWindow( hWndOwn ) )
- return FALSE;
- } // if( _FindCustomizeMode() )
- if( m_AnimationType == __AT_NONE )
- {
- m_AnimationType = __AT_CONTENT_DISPLAY;
- m_ePlaySoundOnAnimationFinished =
- CExtSoundPlayer::__ON_MENU_POPUP_DISPLAYED;
- _StartAnimation();
- if( ! ::IsWindow( hWndOwn ) )
- return FALSE;
- ASSERT( m_AnimationType == __AT_CONTENT_DISPLAY );
- }
- if( m_rgnWnd.GetSafeHandle() != NULL )
- {
- ASSERT( m_bExcludeAreaSpec );
- ASSERT( m_bCombineWithEA );
- ASSERT( m_eCombineAlign != __CMBA_NONE );
- CRgn rgnTmp;
- VERIFY( rgnTmp.CreateRectRgn(0,0,0,0) );
- rgnTmp.CopyRgn( &m_rgnWnd );
- ASSERT( rgnTmp.GetSafeHandle() != NULL );
- VERIFY(
- SetWindowRgn(
- (HRGN)rgnTmp.Detach(),
- FALSE
- )
- );
- } // if( m_rgnWnd.GetSafeHandle() != NULL )
- if( ! g_PaintManager.m_bIsWin2000orLater )
- CExtPaintManager::stat_PassPaintMessages();
- bool bFadeOut = _IsFadeOutAnimation();
- bool bForceLayered = false;
- if( (! bFadeOut)
- && g_PaintManager.m_bIsWin2000orLater
- && g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL
- && ( m_AnimationType == __AT_NONE || m_AnimationType == __AT_CONTENT_DISPLAY )
- //&& ( TrackFlagsGet() & TPMX_RIBBON_RESIZING ) == 0
- )
- bForceLayered = true;
- if( bFadeOut || bForceLayered )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
- } // if( bFadeOut )
- if( g_PaintManager.m_bIsWinVistaOrLater
- && g_PaintManager.m_DWM.IsCompositionEnabled()
- )
- {
- CRect rcCapture;
- GetWindowRect( &rcCapture );
- HBITMAP hBmpScreenSrcAlt = CExtPaintManager::stat_GetScreenSurfacePart( rcCapture );
- if( hBmpScreenSrcAlt != NULL )
- {
- if( m_bmpScreenSrcAlt.GetSafeHandle() != NULL )
- m_bmpScreenSrcAlt.DeleteObject();
- m_bmpScreenSrcAlt.Attach( hBmpScreenSrcAlt );
- }
- }
- SetWindowPos(
- &CWnd::wndTopMost, 0, 0, 0, 0,
- SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
- |SWP_SHOWWINDOW|SWP_NOZORDER
- );
- if( bFadeOut || bForceLayered )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- CExtPaintManager::stat_PassPaintMessages();
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 255, __EXT_MFC_LWA_ALPHA );
- } // if( bFadeOut )
- else if( ! g_PaintManager.m_bIsWin2000orLater )
- CExtPaintManager::stat_PassPaintMessages();
- ASSERT( IsWindowVisible() );
- if( ! _FindCustomizeMode() )
- {
- _SetCapture();
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- else
- {
- CExtCustomizeSite * pSite = _FindCustomizeSite();
- ASSERT( pSite != NULL );
- pSite->RegisterCommandDropTarget( this, this );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_bTopLevel && (! m_bExpandWasPressed ) && m_bExpandAvailable && g_nAutoExpandTime > 0 )
- SetTimer( ID_TIMER_AUTO_EXPAND, g_nAutoExpandTime, NULL );
- return TRUE;
- }
- CExtPopupMenuTipWnd & CExtPopupMenuWnd::GetTip()
- {
- return m_wndToolTip;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupScreenTipWnd & CExtPopupMenuWnd::GetScreenTip()
- {
- return m_wndScreenTip;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupMenuWnd::_CreateHelper(
- CWnd * pWndCmdReceiver
- )
- {
- ASSERT_VALID( this );
- bool bHasInplaceItems = false;
- int nCount = ItemGetCount();
- for( int i = 0; i < nCount; i++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( i );
- if( !mi.IsInplaceEdit() )
- continue;
- //ASSERT( mi.GetInplaceEditPtr() == NULL );
- mi.ResetActiveInplaceEditPtr();
- bHasInplaceItems = true;
- break;
- } // for( int i = 0; i < nCount; i++ )
- if( bHasInplaceItems || _IsPalette() )
- _SyncItems();
- CRect wr = _CalcTrackRect();
- if( wr.IsRectEmpty() )
- return false;
- UINT nClassStyle = __POPUP_WNDCLASS_STYLES__;
- // if( (TrackFlagsGet()&TPMX_FORCE_NO_ANIMATION) != 0 )
- // nClassStyle &= ~(CS_SAVEBITS);
- HCURSOR hCursor = ::LoadCursor( NULL, IDC_ARROW );
- ASSERT( hCursor != NULL );
- CExtSafeString strMenuClassName =
- ::AfxRegisterWndClass(
- nClassStyle,
- hCursor,
- (HBRUSH)(COLOR_BTNFACE + 1),
- NULL
- );
- ASSERT( !strMenuClassName.IsEmpty() );
- pWndCmdReceiver->SendMessage(
- g_nMsgPrepareDesktopBk,
- WPARAM( this )
- );
- bool bFadeOut = _IsFadeOutAnimation(), bForceLayered = false;
- if( (! bFadeOut)
- && g_PaintManager.m_bIsWin2000orLater
- && g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL
- && ( m_AnimationType == __AT_NONE || m_AnimationType == __AT_CONTENT_DISPLAY )
- //&& ( TrackFlagsGet() & TPMX_RIBBON_RESIZING ) == 0
- )
- bForceLayered = true;
- BOOL bCreateResult =
- __BaseClassOfCExtPopupBaseWnd::CreateEx(
- _FindCustomizeMode()
- ? 0
- : WS_EX_TOPMOST
- | ( g_PaintManager.m_bIsWin2000orLater ? (WS_EX_NOINHERITLAYOUT) : 0 )
- | ( ( bFadeOut || bForceLayered ) ? (__EXT_MFC_WS_EX_LAYERED) : 0 )
- ,
- strMenuClassName,
- NULL,
- WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
- wr,
- pWndCmdReceiver,
- 0 // IDC_STATIC
- );
- if( ! bCreateResult )
- {
- ASSERT( FALSE );
- return false;
- }
- if( bFadeOut || bForceLayered )
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 0, __EXT_MFC_LWA_ALPHA );
- if( IsSyncFullRowItems() )
- _SyncItems();
- _RecalcLayoutImpl();
- if( !_FindHelpMode() )
- ::SetCursor( hCursor );
- if( bHasInplaceItems )
- {
- bool bRTL = OnQueryLayoutRTL();
- nCount = ItemGetCount();
- for( int i = 0; i < nCount; i++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( i );
- if( !mi.IsInplaceEdit() )
- continue;
- //ASSERT( mi.GetInplaceEditPtr() == NULL );
- mi.ResetActiveInplaceEditPtr();
- CRect rc( 0, 0, 0, 0 );
- if( mi.IsDisplayed() )
- {
- CRect rcItem;
- _GetItemRect( i, rcItem );
- rc = mi.AdjustInplaceEditRect( rcItem, bRTL );
- } // if( mi.IsDisplayed() )
- mi.CreateInplaceEdit( this, rc );
- } // for( i = 0; i < nCount; i++ )
- } // if( bHasInplaceItems )
- // if( _IsPopupWithShadowsDynamic() )
- // m_ctrlShadow.Create( m_hWnd, PmBridge_GetPM()->GetMenuShadowSize() );
- return true;
- }
- bool CExtPopupMenuWnd::IsNoHighlightIconArea()
- {
- ASSERT_VALID( this );
- if( _IsTopLevelPopup()
- && (TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
- )
- return true;
- CExtPopupMenuWnd * pParent = GetParentMenuWnd();
- if( pParent != NULL
- && pParent->_IsTopLevelPopup()
- && (pParent->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
- )
- return true;
- return false;
- }
- bool CExtPopupMenuWnd::IsSyncFullRowItems()
- {
- ASSERT_VALID( this );
- if( (TrackFlagsGet()&(TPMX_RIBBON_RESIZING)) != 0 )
- return true;
- CExtPopupMenuWnd * pParent = GetParentMenuWnd();
- if( pParent != NULL
- && pParent->_IsTopLevelPopup()
- && (pParent->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU) != 0
- )
- return true;
- return false;
- }
- BOOL CExtPopupMenuWnd::DestroyWindow()
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _KeyTipsShow( false );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- int nCount = ItemGetCount();
- for( int i = 0; i < nCount; i++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( i );
- if( mi.IsInplaceEdit() )
- {
- if( mi.GetInplaceEditPtr() != NULL )
- {
- ASSERT_VALID( mi.GetInplaceEditPtr() );
- ASSERT( mi.GetInplaceEditPtr()->GetSafeHwnd() != NULL && (::IsWindow(mi.GetInplaceEditPtr()->GetSafeHwnd())) );
- mi.GetInplaceEditPtr()->DestroyWindow();
- } // if( mi.GetInplaceEditPtr() != NULL )
- mi.ResetActiveInplaceEditPtr();
- }
- } // for( int i = 0; i < nCount; i++ )
- bool bAutoDestroy = false;
- if( _IsFadeOutAnimation() )
- {
- CExtPopupMenuSite & _site = GetSite();
- DWORD dwTrackFlags = TrackFlagsGet();
- if( m_bTopLevel )
- {
- bAutoDestroy = true;
- _site.SetCapture( NULL );
- ASSERT( m_hWndCmdReceiver != NULL );
- if( ::IsWindow(m_hWndCmdReceiver) )
- ::SendMessage(
- m_hWndCmdReceiver,
- g_nMsgNotifyMenuClosed,
- 0,
- LPARAM( this )
- );
- if( m_hWndNotifyMenuClosed != NULL
- && ::IsWindow( m_hWndNotifyMenuClosed )
- )
- ::SendMessage(
- m_hWndNotifyMenuClosed,
- g_nMsgNotifyMenuClosed,
- 0,
- LPARAM( this )
- );
- CExtControlBar::stat_SetMessageString(
- GetOwner()
- );
- } // if( m_bTopLevel )
- CExtToolControlBar::_CloseCustomMenusAll();
- if( CExtToolControlBar::g_bMenuTracking )
- CExtToolControlBar::_CloseTrackingMenus();
- bool bAnimateSequence = false;
- if( ! m_bHelperAnimationControllerDetected )
- {
- if( m_nCurIndex < 0 )
- bAnimateSequence = true;
- else if(
- ( ! ItemGetInfo( m_nCurIndex ).IsPopup() )
- || ItemGetInfo( m_nCurIndex ).GetPopup()->GetSafeHwnd() == NULL
- )
- bAnimateSequence = true;
- }
- if( bAnimateSequence )
- {
- if( (! _site.IsEmpty() )
- // && (! _site.IsShutdownMode() )
- && (dwTrackFlags&TPMX_NO_SITE) == 0
- )
- {
- if( _site.GetInstance() == this )
- _site.DoneInstance();
- //ASSERT( _site.IsEmpty() );
- //ASSERT( !_site.IsShutdownMode() );
- }
- CExtPopupMenuWnd * pPopup = this;
- for( ; pPopup != NULL; )
- {
- CExtPopupMenuWnd * pParent = pPopup->m_pWndParentMenu;
- pPopup->m_bHelperAnimationControllerDetected = true;
- if( pParent == NULL )
- CExtPopupMenuSite::g_DefPopupMenuSite.FadeOutInstanceAdd( pPopup );
- pPopup = pParent;
- }
- m_nFadeOutAnimationStepIndex = 0;
- SetTimer(
- ID_TIMER_FADE_OUT_ANIMATION,
- UINT(m_nFadeOutAnimationEllapse),
- NULL
- );
- }
- return TRUE;
- } // if( _IsFadeOutAnimation() )
- if( m_ctrlShadow.GetSafeHwnd() != NULL )
- m_ctrlShadow.DestroyWindow();
- if( GetSafeHwnd() == NULL )
- {
- ASSERT( ! bAutoDestroy );
- return TRUE;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( _FindCustomizeMode() )
- {
- CExtCustomizeSite * pSite = _FindCustomizeSite();
- ASSERT( pSite != NULL );
- pSite->UnRegisterCommandDropTarget( this );
- } // if( _FindCustomizeMode() )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return CExtPopupBaseWnd::DestroyWindow();
- }
- void CExtPopupMenuWnd::_GetItemRect(
- int nIndex,
- RECT & rectItem,
- bool bIncludeIndents // = true
- )
- {
- ASSERT_VALID( this );
- int nCountOfItems = (int)m_items_all.GetSize();
- if( 0 <= nIndex && nIndex < nCountOfItems )
- {
- if( _IsPalette() )
- {
- _GetItemRectPalette(
- nIndex,
- rectItem,
- bIncludeIndents
- );
- return;
- }
- }
- if( nIndex == IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON )
- {
- rectItem = m_rcRibbonBtnOptions;
- return;
- }
- if( nIndex == IDX_RIBBON_FILE_MENU_EXIT_BUTTON )
- {
- rectItem = m_rcRibbonBtnExit;
- return;
- }
- CRect rcClient;
- _GetClientRect( &rcClient );
- rcClient.left += m_nLeftAreaWidth;
- if( m_bScrollingAvailable )
- {
- ASSERT( ! m_rcScrollTop.IsRectEmpty() );
- ASSERT( ! m_rcScrollBottom.IsRectEmpty() );
- if( nIndex == IDX_SCROLL_TOP )
- {
- rectItem = m_rcScrollTop;
- return;
- }