ExtPopupMenuWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:735k
- if( nIndex == IDX_SCROLL_BOTTOM )
- {
- rectItem = m_rcScrollBottom;
- return;
- }
- }
- if( m_bExpandAvailable
- && nIndex == IDX_EXPAND
- )
- {
- rectItem = m_rcExpandBtn;
- if( bIncludeIndents )
- ((CRect *)(&rectItem))->DeflateRect(1,0);
- return;
- }
- bool bTearOff = _IsTearOff();
- int nTearOffCaptionHeight = bTearOff ? _GetTearOffCaptionHeight() : 0;
- if( bTearOff
- && nIndex == IDX_TEAROFF
- )
- {
- rectItem = m_rcTearOffBtn;
- if( bIncludeIndents )
- ((CRect *)(&rectItem))->DeflateRect(1,0);
- return;
- }
- if( nCountOfItems == 0 )
- {
- ::SetRectEmpty( &rectItem );
- return;
- }
- if( nIndex < 0 )
- {
- ::SetRectEmpty( &rectItem );
- return;
- }
- ASSERT( nIndex >= 0 && nIndex < nCountOfItems );
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( ! mi.IsDisplayed() )
- {
- ::SetRectEmpty( &rectItem );
- return;
- }
- CRect rcCache = mi.GetCachedRect( bIncludeIndents );
- if( ! rcCache.IsRectEmpty() )
- {
- ::CopyRect( &rectItem, rcCache );
- return;
- }
- CRect rcMB = OnQueryMenuBorderMetrics();
- int y = m_nDyScrollOffset + rcMB.top;
- CRect rcItem;
- rcItem.SetRectEmpty();
- if( mi.IsToolButton() )
- {
- rcItem.left =
- rcMB.left;
- // + __EXT_MENU_TOOLBTN_GAP; // - 2.28
- rcItem.right =
- mi.GetMeasuredWidth();
- } // if( mi.IsToolButton() )
- else
- {
- rcItem.left =
- rcMB.left;
- rcItem.right =
- m_sizeFullItems.cx
- + rcMB.left;
- } // else from if( mi.IsToolButton() )
- if( bIncludeIndents )
- {
- INT nMarginLeft = 0, nMarginRight = 0;
- mi.GetOuterMargins(
- &nMarginLeft,
- NULL,
- &nMarginRight,
- NULL
- );
- rcItem.DeflateRect(
- nMarginLeft,
- 0,
- nMarginRight,
- 0
- );
- } // if( bIncludeIndents )
- INT iter = 0;
- for( int i = 0;
- i < nIndex
- && iter != m_items_all.GetSize();
- i++, iter++
- )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( ! mi.IsDisplayed() )
- continue;
- const RECT & rcBase = mi.GetBaseRect();
- y += (rcBase.bottom - rcBase.top);
- INT nMarginTop = 0, nMarginBottom = 0;
- mi.GetOuterMargins(
- NULL,
- &nMarginTop,
- NULL,
- &nMarginBottom
- );
- if( mi.GetIndex() == ItemGetCount() - 1 )
- nMarginBottom--;
- y += (nMarginTop + nMarginBottom);
- }
- ASSERT( iter != m_items_all.GetSize() );
- rcItem.OffsetRect( 0, y + 1 );
- mi = ItemGetInfo( iter );
- ASSERT( mi.IsDisplayed() );
- const RECT & rcBase = mi.GetBaseRect();
- rcItem.bottom =
- rcItem.top + rcBase.bottom - rcBase.top;
-
- INT nMarginTop = 0, nMarginBottom = 0;
- mi.GetOuterMargins(
- NULL,
- &nMarginTop,
- NULL,
- &nMarginBottom
- );
- if( mi.GetIndex() == ItemGetCount() - 1 )
- nMarginBottom--;
- rcItem.bottom += (nMarginTop + nMarginBottom);
- if( bIncludeIndents )
- {
- rcItem.DeflateRect(
- 0,
- nMarginTop,
- 0,
- nMarginBottom
- );
- } // if( bIncludeIndents )
-
- // FIX for combined exclude area
- rcItem.OffsetRect( rcClient.TopLeft() );
- if( bTearOff )
- rcItem.OffsetRect( 0, nTearOffCaptionHeight );
- rectItem = rcItem;
- mi.CacheRect( rectItem, bIncludeIndents );
- }
- void CExtPopupMenuWnd::_GetItemRectPalette(
- int nIndex,
- RECT & rectItem,
- bool bIncludeIndents // = true
- )
- {
- ASSERT_VALID( this );
- int nCountOfItems = (int)m_items_all.GetSize();
- if( nCountOfItems == 0 )
- {
- ::SetRectEmpty( &rectItem );
- return;
- }
- if( nIndex < 0 || nIndex >= nCountOfItems )
- {
- CExtPopupMenuWnd::_GetItemRect(
- nIndex,
- rectItem,
- bIncludeIndents
- );
- return;
- }
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( ! mi.IsDisplayed() )
- {
- ::SetRectEmpty( &rectItem );
- return;
- }
- CRect rcCache = mi.GetCachedRect( bIncludeIndents );
- if( ! rcCache.IsRectEmpty() )
- {
- ::CopyRect( &rectItem, rcCache );
- return;
- }
- CRect rcClient;
- _GetClientRect( &rcClient );
- rcClient.left += m_nLeftAreaWidth;
- CRect rcMB = OnQueryMenuBorderMetrics();
- int y = m_nDyScrollOffset + rcMB.top;
- CRect rcItem;
- rcItem.SetRectEmpty();
- if( mi.IsSeparator() )
- {
- rcItem.left = rcItem.right = rcMB.left + 2;
- }
- else if( mi.IsToolButton() )
- {
- rcItem.left = rcMB.left + 2;
- rcItem.right = rcItem.left + mi.GetMeasuredWidth();
- }
- else
- {
- rcItem.left = rcMB.left;
- rcItem.right = m_sizeFullItems.cx + rcMB.left;
- }
- int x = rcItem.left;
- int xRow = x, dyRow = 0;
- int iter = 0, i = 0, nRowStart = 0;
- for( ; i < nIndex && iter != nCountOfItems; i++, iter++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( ! mi.IsDisplayed() )
- continue;
- bool bWrap = _IsPaletteItemWrap( iter );
- const RECT & rcBase = mi.GetBaseRect();
- if( mi.IsSeparator() )
- bWrap = true;
- int nWidth = rcBase.right - rcBase.left;
- int nHeight = rcBase.bottom - rcBase.top;
- dyRow = max( dyRow, nHeight );
- if( bWrap )
- {
- xRow = x;
- y += dyRow;
- dyRow = 0;
- if( mi.IsSeparator() )
- y +=
- PmBridge_GetPM()->GetSeparatorHeight()
- + __EXT_MENU_GAP
- ;
- if( i < nIndex )
- nRowStart = i+1;
- }
- else
- {
- xRow += nWidth;
- if( mi.IsInplaceEdit() )
- xRow += (iter == 0) ? __EXT_MENU_GAP : (__EXT_MENU_GAP*2);
- // else
- // xRow += (nRowStart == i) ? 0 : __EXT_MENU_GAP;
- xRow += 2;
- }
- } // for( ; i < nIndex && iter != nCountOfItems; i++, iter++ )
- ASSERT( iter != m_items_all.GetSize() );
- bool bTearOff = _IsTearOff();
- int nTearOffCaptionHeight = bTearOff ? _GetTearOffCaptionHeight() : 0;
- mi = ItemGetInfo( iter );
- ASSERT( mi.IsDisplayed() );
- if( mi.IsSeparator() )
- {
- rcItem.OffsetRect( 0, y + 2 );
- rcItem.OffsetRect( rcClient.TopLeft() );
- rcItem.right =
- rcClient.right
- - rcItem.left + rcClient.left
- ;
- rcItem.top += __EXT_MENU_GAP / 2;
- rcItem.bottom =
- rcItem.top
- + PmBridge_GetPM()->GetSeparatorHeight()
- + __EXT_MENU_GAP;
- ;
- if( bTearOff )
- rcItem.OffsetRect( 0, nTearOffCaptionHeight );
- rectItem = rcItem;
- return;
- }
- rcItem.OffsetRect( xRow - rcItem.left, 0 );
- if( iter != 0 && mi.IsInplaceEdit() )
- rcItem.OffsetRect( __EXT_MENU_GAP, 0 );
- rcItem.OffsetRect( 0, y + 2 );
- const RECT & rcBase = mi.GetBaseRect();
- rcItem.bottom =
- rcItem.top + rcBase.bottom - rcBase.top;
- dyRow = 0;
- for( iter = nRowStart; iter != nCountOfItems; iter++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( ! mi.IsDisplayed() )
- continue;
- bool bWrap = _IsPaletteItemWrap( iter );
- const RECT & rcBase = mi.GetBaseRect();
- if( mi.IsSeparator() )
- bWrap = true;
- int nHeight = rcBase.bottom - rcBase.top;
- dyRow = max( dyRow, nHeight );
- if( bWrap )
- break;
- } // for( iter = nRowStart; iter != nCountOfItems; iter++ )
- if( dyRow > 0 )
- {
- ASSERT( iter >= nIndex );
- int nHeight = rcItem.Height();
- ASSERT( nHeight <= dyRow );
- rcItem.OffsetRect(
- 0,
- ( dyRow - nHeight ) / 2
- );
- }
- rcItem.OffsetRect( rcClient.TopLeft() );
- if( bTearOff )
- rcItem.OffsetRect( 0, nTearOffCaptionHeight );
- rectItem = rcItem;
- mi.CacheRect( rectItem, bIncludeIndents );
- }
- void CExtPopupMenuWnd::_GetVisibleItems(
- HDC hDcTest, // may be NULL
- visible_items_t & v
- )
- {
- ASSERT_VALID( this );
- if( _IsPalette() )
- {
- _GetVisibleItemsPalette( hDcTest, v );
- return;
- }
- v.RemoveAll();
- INT iter = 0;
- for( int nIndex = 0;
- iter != m_items_all.GetSize();
- iter++, nIndex++
- )
- { // find visible items
- MENUITEMDATA & mi = ItemGetInfo( iter );
- if( !mi.IsDisplayed() )
- continue;
- CRect rcItem;
- _GetItemRect( nIndex, rcItem, true );
- CRect rcItemWithIndents;
- _GetItemRect( nIndex, rcItemWithIndents, false );
- if( rcItem.IsRectEmpty()
- || rcItemWithIndents.IsRectEmpty()
- )
- continue;
- if( hDcTest != NULL
- && ( !::RectVisible( hDcTest, &rcItem )
- || !::RectVisible( hDcTest, &rcItemWithIndents )
- )
- )
- continue;
- VisibleItemDefinition_t vi;
- vi.m_nIndex = nIndex;
- vi.m_nHelperCmdID = mi.GetCmdID();
- vi.m_rcItem = rcItem;
- vi.m_rcItemWithIndents = rcItemWithIndents;
- if( mi.IsSeparator() )
- {
- vi.m_bHelperIsSeparator = true;
- v.Add( vi );
- continue;
- }
- if( mi.IsPopup() )
- {
- vi.m_bHelperIsPopup = true;
- CExtCmdItem * pCmdItem = mi.GetCmd();
- if( pCmdItem != NULL )
- {
- vi.m_bRarelyUsed =
- ( (!_FindCustomizeMode())
- && pCmdItem->StateIsRarelyUsed()
- ) ? true : false;
- } // if( pCmdItem != NULL )
- else
- vi.m_bRarelyUsed =
- (!_FindCustomizeMode())
- && mi.IsAllItemsRarelyUsed()
- && (!mi.IsForceDisplayed())
- ;
- v.Add( vi );
- continue;
- }
- if( mi.IsExtraMark() )
- vi.m_bRarelyUsed = false;
- else
- {
- CExtCmdItem * pCmdItem = mi.GetCmd();
- if( pCmdItem != NULL )
- vi.m_bRarelyUsed =
- ( (!_FindCustomizeMode())
- && pCmdItem->StateIsRarelyUsed()
- ) ? true : false;
- else
- vi.m_bRarelyUsed = false;
- } // else from if( mi.IsExtraMark() )
- v.Add( vi );
- } // find visible items
- INT vis_iter = 0;
- for( ; vis_iter < v.GetSize(); ++vis_iter )
- { // setup prev/next rarely used flags
- VisibleItemDefinition_t & vi = v[ vis_iter ];
- INT iter_prev = vis_iter;
- INT iter_next = vis_iter;
- if( vis_iter != 0 )
- {
- --iter_prev;
- if( v[iter_prev].m_bRarelyUsed )
- vi.m_bRarelyUsedPrev = true;
- } // if( vis_iter != v.begin() )
- ++iter_next;
- if( iter_next != v.GetSize() )
- {
- if( v[iter_next].m_bRarelyUsed )
- vi.m_bRarelyUsedNext = true;
- } // if( iter_next != v.end() )
- if( vi.m_bHelperIsSeparator )
- {
- if( vi.m_bRarelyUsedPrev
- && vi.m_bRarelyUsedNext
- && (!_FindCustomizeMode())
- )
- {
- vi.m_bRarelyUsed = true;
- ASSERT( vis_iter != 0 );
- v[iter_prev].m_bRarelyUsedNext = true;
- ASSERT( iter_next != 0 );
- v[iter_next].m_bRarelyUsedPrev = true;
- }
- }
- } // setup prev/next rarely used flags
- }
- void CExtPopupMenuWnd::_GetVisibleItemsPalette(
- HDC hDcTest, // may be NULL
- CExtPopupMenuWnd::visible_items_t & v
- )
- {
- ASSERT_VALID( this );
- v.RemoveAll();
- int nItemIndex = 0, nItemCount = (int)m_items_all.GetSize();
- for( ; nItemIndex < nItemCount; nItemIndex++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( nItemIndex );
- if( ! mi.IsDisplayed() )
- mi.SetDisplayed( true );
- CRect rcItem;
- _GetItemRect( nItemIndex, rcItem, true );
- if( hDcTest != NULL
- && (! ::RectVisible( hDcTest, &rcItem ) )
- )
- continue;
- VisibleItemDefinition_t vi;
- vi.m_nIndex = nItemIndex;
- vi.m_nHelperCmdID = mi.GetCmdID();
- vi.m_rcItem = rcItem;
- vi.m_rcItemWithIndents = rcItem;
- if( mi.IsSeparator() )
- vi.m_bHelperIsSeparator = true;
- else if( mi.IsPopup() )
- vi.m_bHelperIsPopup = true;
- v.Add( vi );
- } // for( ; nItemIndex < nItemCount; nItemIndex++ )
- }
- bool CExtPopupMenuWnd::_IsPaletteItemWrap(
- int nIndex
- ) const
- {
- ASSERT_VALID( this );
- if( ! _IsPalette() )
- return false;
- if( nIndex < 0 )
- return false;
- int nCountOfItems = ItemGetCount();
- if( nIndex >= nCountOfItems )
- return false;
- if( nIndex < (nCountOfItems-1) )
- {
- const MENUITEMDATA & miNext = ItemGetInfo( nIndex + 1 );
- if( miNext.IsSeparator() )
- return true;
- }
- const MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( mi.IsToolWrap() )
- return true;
- return false;
- }
- void CExtPopupMenuWnd::stat_paint_combined_menu_toolbtn(
- LPVOID pCookie,
- CDC & dc,
- const CWnd & refWndMenu,
- const CRect & rcExcludeArea, // in screen coords
- int eCombineAlign // CExtPopupMenuWnd::e_combine_align_t values
- )
- {
- eCombineAlign;
- INT nIndex = (INT)(__EXT_MFC_INT_PTR)pCookie;
- ASSERT( refWndMenu.GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( refWndMenu.GetSafeHwnd() ) );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( rcExcludeArea.IsRectEmpty() )
- return;
- ASSERT_KINDOF( CExtPopupMenuWnd, (&refWndMenu) );
- CExtPopupMenuWnd * pPopup =
- (CExtPopupMenuWnd *)(&refWndMenu);
- ASSERT_VALID( pPopup );
- ASSERT( ! pPopup->m_bTopLevel );
- CExtPopupMenuWnd * pPopup2 = pPopup->m_pWndParentMenu;
- ASSERT_VALID( pPopup2 );
- ASSERT( 0 <= nIndex && nIndex < pPopup2->ItemGetCount() );
- CExtPopupMenuWnd::MENUITEMDATA & mi = pPopup2->ItemGetInfo(nIndex);
- CRect rcItem;
- pPopup2->_GetItemRect( nIndex, rcItem );
- CRect rcClientExcludeArea( rcExcludeArea );
- pPopup->ScreenToClient( &rcClientExcludeArea );
- rcItem.OffsetRect( - rcItem.TopLeft() );
- rcItem.OffsetRect( rcClientExcludeArea.TopLeft() );
- CRect rcTargetClient;
- pPopup->_GetClientRect( &rcTargetClient );
- dc.ExcludeClipRect( &rcTargetClient );
- CExtPopupMenuWnd::DRAWITEMDATA _DrawItemData(
- &dc,
- &rcItem,
- &rcItem,
- &mi,
- pPopup,
- ( pPopup->GetSite()->m_dwTrackFlags&TPMX_OWNERDRAW_FIXED ) ? true : false,
- mi.IsPopup(),
- false, // g_bMenuHighlightRarely && vi.m_bRarelyUsed,
- false, // g_bMenuHighlightRarely && vi.m_bRarelyUsedPrev,
- false // g_bMenuHighlightRarely && vi.m_bRarelyUsedNext
- );
- bool bPainted =
- (_DrawItemData.m_bMenuOwnerDrawFixed)
- ? _DrawItemData.DoOwnerDrawPainting()
- : false
- ;
- bool bForceNoIcon = false, bForceNoText = false;
- if( (pPopup2->TrackFlagsGet()&TPMX_PALETTE) != 0 )
- {
- CExtCmdIcon * pIcon = mi.GetIconPtr();
- if( pIcon != NULL && pIcon->IsEmpty() )
- pIcon = NULL;
- if( mi.IsInplaceEdit() )
- bForceNoIcon = bForceNoText = true;
- else if( pIcon == NULL || ( pIcon != NULL && (! mi.IsIconMode() ) ) )
- {
- //bForceNoIcon = true;
- }
- else
- bForceNoText = true;
- }
- if( ! bPainted )
- _DrawItemData.PaintDefault(
- bForceNoIcon,
- bForceNoText
- );
- dc.SelectClipRgn( NULL );
- }
- void CExtPopupMenuWnd::DRAWITEMDATA::PaintDefault(
- bool bForceNoIcon, // = false
- bool bForceNoText, // = false
- bool bForceNoCheck, // = false
- bool bForceEnabled, // = false
- bool bForceUnselected // = false
- )
- {
- ASSERT( m_pDC != NULL );
- ASSERT( m_pDC->GetSafeHdc() != NULL );
- ASSERT( m_pRectItem != NULL );
- ASSERT( m_pRectItemWithIndents != NULL );
- ASSERT( m_pItemData != NULL );
- ASSERT( m_pPopup != NULL );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = NULL;
- bool bCustomizeMode = false;
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- bool bResizingNode = false;
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( m_pPopup->_FindCustomizeMode() )
- {
- pSite = m_pPopup->_FindCustomizeSite();
- ASSERT( pSite != NULL );
- bCustomizeMode = true;
- bForceNoCheck = bForceEnabled = true;
- bForceUnselected = m_pItemData->IsPopup() ? false : true;
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- CExtCustomizeCmdTreeNode * pNode = ((MENUITEMDATA *)m_pItemData)->GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- if( pNode == pSite->GetResizingNode() )
- bResizingNode = true;
- }
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_pItemData->IsToolButton()
- && (! m_pItemData->IsInplaceEdit() )
- )
- {
- bool bSelDraw =
- bForceUnselected
- ? false
- : m_pItemData->IsSelected();
- bool bTransparent = ! m_pItemData->IsSelected();
- bool bIsPopupAndPopupVisible = false;
- if( m_pItemData->IsPopup() )
- {
- const CExtPopupMenuWnd * pChildPopup = m_pItemData->GetPopup();
- if( pChildPopup->GetSafeHwnd() != NULL
- && ::IsWindow( pChildPopup->GetSafeHwnd() )
- && (pChildPopup->GetStyle() & WS_VISIBLE) != 0
- )
- bIsPopupAndPopupVisible = true;
- }
- if( bSelDraw
- && bIsPopupAndPopupVisible
- )
- {
- bSelDraw = false;
- bTransparent = true;
- }
- bool bPushed =
- bSelDraw
- && m_pItemData->IsPopup();
- if( (! bForceNoCheck)
- && ( m_pItemData->GetCheck()
- || m_pItemData->GetRadio()
- )
- )
- {
- bPushed = true;
- bTransparent = false;
- }
- bool bSeparatedDropDown = false;
- bool bPushedDropDown = false;
- bool bHoverDropDown = false;
- if( bSelDraw
- && m_pItemData->IsPopup()
- && (!bIsPopupAndPopupVisible)
- )
- {
- bPushedDropDown = false;
- bHoverDropDown = true;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- const CExtCustomizeCmdTreeNode * pNode =
- m_pItemData->GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- bSeparatedDropDown =
- (pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN)
- ? true : false;
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool bCombiningEnabled =
- m_pPopup->PmBridge_GetPM()->IsMenuMustCombineExcludeArea(
- NULL // should be NULL
- );
- if( (!bCombiningEnabled)
- && bIsPopupAndPopupVisible
- )
- {
- bPushed = true;
- bTransparent = false;
- if( bSeparatedDropDown )
- {
- bHoverDropDown = true;
- bPushedDropDown = true;
- }
- }
- CExtCmdIcon _iconLarge;
- CExtCmdIcon * pIcon = ( bForceNoIcon ) ? NULL : ((MENUITEMDATA *)m_pItemData)->GetIconPtr();
- if( g_bMenuLargeIcons && pIcon != NULL )
- {
- CSize _sizeIcon = pIcon->GetSize();
- _sizeIcon.cx *= 2;
- _sizeIcon.cy *= 2;
- if( _iconLarge.CreateScaledCopy(
- *pIcon,
- _sizeIcon
- )
- )
- pIcon = &_iconLarge;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- } // if( g_bMenuLargeIcons && pIcon != NULL )
- bool bDrawBorder =
- m_pItemData->IsSelected()
- || bPushed
- || bSelDraw
- ;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbd(
- m_pPopup,
- true,
- *m_pRectItem,
- bForceNoText ? _T("") : m_pItemData->GetText(),
- pIcon,
- true,
- bSelDraw, // hover
- bPushed, // pushed
- false,
- bForceEnabled
- || m_pItemData->IsEnabled()
- || m_pItemData->IsForceEnabled()
- || m_pItemData->IsEnabledAppearance()
- ,
- bDrawBorder, // border
- false,
- false,
- 0,
- m_pItemData->IsBold()
- ? ((HFONT)(m_pPopup->PmBridge_GetPM()->m_FontBold.GetSafeHandle()))
- : NULL,
- m_pItemData->IsPopup() ? true : false,
- 0,
- bTransparent // transparent
- );
- _ppbd.m_rcBorderSizes = CRect( 1, 1, 1, 1 );
- _ppbd.m_nIconAlignment = ( CExtPaintManager::__ALIGN_HORIZ_LEFT | CExtPaintManager::__ALIGN_VERT_CENTER );
- _ppbd.m_nTextAlignment = ( CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_CENTER );
- _ppbd.m_rcIconMargins = CRect( 2, 1, 1, 1 );
- _ppbd.m_rcTextMargins = CRect( 1, 1, 1, 1 );
- _ppbd.m_bSeparatedDropDown = bSeparatedDropDown;
- _ppbd.m_bPushedDropDown = bPushedDropDown;
- _ppbd.m_bHoverDropDown = bHoverDropDown;
-
- m_pPopup->PmBridge_GetPM()->PaintPushButton( *m_pDC, _ppbd );
- } // if( m_pItemData->IsToolButton() ...
- else
- {
- CExtCmdIcon * pIcon =
- ( bForceNoIcon )
- ? NULL
- : ((MENUITEMDATA *)m_pItemData)->GetIconPtr();
- if( pIcon != NULL && pIcon->IsEmpty() )
- pIcon = NULL;
- CExtCmdIcon _iconLarge;
- if( g_bMenuLargeIcons && pIcon != NULL )
- {
- CSize _sizeIcon = pIcon->GetSize();
- _sizeIcon.cx *= 2;
- _sizeIcon.cy *= 2;
- if( _iconLarge.CreateScaledCopy(
- *pIcon,
- _sizeIcon
- )
- )
- pIcon = &_iconLarge;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- } // if( g_bMenuLargeIcons && pIcon != NULL )
- CExtPaintManager::PAINTMENUITEMDATA _pmid(
- m_pPopup,
- CRect( *m_pRectItem ),
- CRect( *m_pRectItemWithIndents ),
- m_pItemData->GetIconAreaWidth(),
- bForceNoText ? _T("") : m_pItemData->GetText(),
- ( bForceNoText || ( m_pPopup->TrackFlagsGet() & TPMX_HIDE_KEYBOARD_ACCELERATORS ) != 0 )
- ? _T("") : m_pItemData->GetAccelText(),
- pIcon,
- m_bPopupItem,
- bForceUnselected ? false : m_pItemData->IsSelected(),
- bForceNoCheck ? false : m_pItemData->GetCheck(),
- bForceNoCheck ? false : m_pItemData->GetRadio(),
- m_pItemData->IsIndeterminated(),
- bForceEnabled
- || m_pItemData->IsEnabled()
- || m_pItemData->IsForceEnabled()
- || m_pItemData->IsEnabledAppearance()
- ,
- m_bRarelyUsed,
- m_bRarelyUsedPrevious,
- m_bRarelyUsedNext,
- m_pItemData->GetCmdID(),
- m_pItemData->IsBold()
- ? ((HFONT)(m_pPopup->PmBridge_GetPM()->m_FontBold.GetSafeHandle()))
- : NULL
- );
- _pmid.m_bBigAccent = m_pItemData->IsBigAccent();
- _pmid.m_bForceNoLeftGradient =
- ( m_pItemData->IsForceNoLeftGradient()
- || m_pPopup->IsNoHighlightIconArea()
- ) ? true : false;
- if( ((MENUITEMDATA *)m_pItemData)->IsInplaceEdit() )
- {
- _pmid.m_rcInPlaceWnd =
- m_pItemData->AdjustInplaceEditRect(
- *m_pRectItem,
- m_pPopup->OnQueryLayoutRTL()
- );
- _pmid.m_strInPlaceText =
- m_pItemData->GetInplaceEditText();
- } // if( ((MENUITEMDATA *)m_pItemData)->IsInplaceEdit() )
- if( m_pItemData->IsExtraMark()
- && (! m_pPopup->_FindHelpMode() )
- )
- {
- _pmid.m_bXtraMark = true;
- _pmid.m_bXtraChecked = m_pItemData->IsExtraChecked();
- } // if( m_pItemData->IsExtraMark() ...
- ASSERT( !_pmid.m_bHelperPopupDropped );
- if( m_pItemData->IsPopup()
- && m_pItemData->GetPopup()->GetSafeHwnd() != NULL
- && m_pItemData->GetPopup()->IsWindowVisible()
- )
- _pmid.m_bHelperPopupDropped = true;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( bResizingNode )
- _pmid.m_bSelected = true;
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- const CExtCustomizeCmdTreeNode * pNode =
- m_pItemData->GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- _pmid.m_bSeparatedDropDown =
- (pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN)
- ? true : false;
- } // if( pNode != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- _pmid.m_sExtendedText = m_pItemData->GetExtendedText();
- m_pPopup->PmBridge_GetPM()->PaintMenuItem( *m_pDC, _pmid );
- } // else from if( m_pItemData->IsToolButton() )
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( m_pPopup->m_nHelperDropIndexBefore >= 0 )
- {
- int nCount = m_pPopup->ItemGetCount();
- ASSERT( m_pPopup->m_nHelperDropIndexBefore <= nCount );
- int nAlignAt = 0;
- int nItemIndex = m_pItemData->GetIndex();
- if( nItemIndex == m_pPopup->m_nHelperDropIndexBefore )
- nAlignAt = -1;
- else if( nItemIndex == ( nCount - 1 )
- && m_pPopup->m_nHelperDropIndexBefore == nCount
- )
- nAlignAt = 1;
- else if( ( nItemIndex + 1 ) == m_pPopup->m_nHelperDropIndexBefore
- && m_pPopup->ItemGetInfo( nItemIndex + 1 ).IsSeparator()
- )
- {
- nItemIndex;
- nAlignAt = 1;
- }
- if( nAlignAt != 0 )
- { // if paint drop divider
- CSize _sizeDDM = m_pPopup->PmBridge_GetPM()->GetDropDividerMerics();
- CRect rcItem;
- ASSERT( !m_pPopup->ItemGetInfo(nItemIndex).IsSeparator() );
- m_pPopup->_GetItemRect( nItemIndex, rcItem );
- int nY =
- ( nAlignAt > 0 )
- ? rcItem.bottom - _sizeDDM.cy/2
- : rcItem.top + _sizeDDM.cy/2
- ;
- rcItem.top = rcItem.bottom = nY;
- m_pPopup->PmBridge_GetPM()->PaintDropDivider(
- *m_pDC,
- rcItem,
- true,
- false
- );
- } // if( nAlignAt != 0 )
- } // if( m_pPopup->m_nHelperDropIndexBefore >= 0 )
- if( bCustomizeMode )
- {
- ASSERT( pSite != NULL );
- if(
- (
- pSite != NULL
- &&
- ( pSite->CustomizedNodeGet() != NULL
- && pSite->CustomizedNodeGet() == ((MENUITEMDATA*)m_pItemData)->GetCmdNode()
- )
- )
- ||
- ( m_pPopup->m_pDragSrcNode != NULL
- && ((MENUITEMDATA*)m_pItemData)->GetCmdNode() == m_pPopup->m_pDragSrcNode
- )
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- || bResizingNode
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- )
- {
- CRect rcItem = m_pRectItem;
- m_pPopup->PmBridge_GetPM()->PaintDragSourceRect(
- *m_pDC,
- rcItem
- );
- }
- } // if( bCustomizeMode )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- bool CExtPopupMenuWnd::DRAWITEMDATA::DoOwnerDrawPainting()
- {
- ASSERT( m_pDC != NULL );
- ASSERT( m_pDC->GetSafeHdc() != NULL );
- ASSERT( m_pRectItem != NULL );
- ASSERT( m_pItemData != NULL );
- ASSERT( m_pPopup != NULL );
- HWND hWndNotify =
- m_pPopup->m_hWndCmdReceiver;
- ASSERT( hWndNotify != NULL );
- ASSERT( ::IsWindow(hWndNotify) );
- LRESULT lResult =
- ::SendMessage(
- hWndNotify,
- CExtPopupMenuWnd::g_nMsgPopupDrawItem,
- 0,
- LPARAM( *this )
- );
- return lResult ? true : false;
- }
- void CExtPopupMenuWnd::DRAWBACKGROUNDDATA::Notify()
- {
- ASSERT( m_DC.GetSafeHdc() != NULL );
- ASSERT( m_pPopup != NULL );
- ASSERT( m_pPopup != NULL );
- HWND hWndNotify =
- m_pPopup->GetCmdReceiverHWND();
- ASSERT( hWndNotify != NULL );
- ASSERT( ::IsWindow(hWndNotify) );
- ::SendMessage(
- hWndNotify,
- CExtPopupMenuWnd::g_nMsgPopupDrawBackground,
- 0,
- LPARAM( *this )
- );
- }
- bool CExtPopupMenuWnd::DRAWLEFTAREADATA::DoOwnerDrawPainting()
- {
- ASSERT( m_pDC != NULL );
- ASSERT( m_pDC->GetSafeHdc() != NULL );
- ASSERT( m_pRectLeftArea != NULL );
- ASSERT( m_pPopup != NULL );
- HWND hWndNotify =
- m_pPopup->m_hWndCmdReceiver;
- ASSERT( hWndNotify != NULL );
- ASSERT( ::IsWindow(hWndNotify) );
- LRESULT lResult =
- ::SendMessage(
- hWndNotify,
- CExtPopupMenuWnd::g_nMsgPopupDrawLeftArea,
- 0,
- LPARAM( *this )
- );
- return lResult ? true : false;
- }
- void CExtPopupMenuWnd::_DoPaint(
- CDC & dcPaint,
- bool bUseBackBuffer // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dcPaint) );
- ASSERT( dcPaint.GetSafeHdc() != NULL );
- if( m_hWnd != NULL )
- {
- ASSERT( ::IsWindow(m_hWnd) );
- CExtPaintManager::stat_ExcludeChildAreas( dcPaint.GetSafeHdc(), m_hWnd );
- } // if( m_hWnd != NULL )
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- CRect rcMB = OnQueryMenuBorderMetrics();
- int nMenuShadowSize = OnQueryMenuShadowSize();
- CRect rcRealClient, rcClient;
- GetClientRect( &rcRealClient );
- _GetClientRect( &rcClient );
- CPalette * pOldPalette = NULL, * pOldPalette2 = NULL;
- if( ::GetDeviceCaps(dcPaint.m_hDC,RASTERCAPS) & RC_PALETTE )
- {
- pOldPalette = dcPaint.SelectPalette( &PmBridge_GetPM()->m_PaletteWide, FALSE );
- dcPaint.RealizePalette();
- }
- PmBridge_GetPM()->AdjustMenuDC( this, dcPaint, false );
- CSize _sizeCaption = MenuCaptionMeasure();
- CExtMemoryDC mdc;
- if( bUseBackBuffer )
- {
- CRect rcMemDC = rcClient;
- if( _sizeCaption.cx > 0 && _sizeCaption.cy > 0 )
- rcMemDC.top -= _sizeCaption.cy;
- mdc.__InitMemoryDC( &dcPaint, &rcMemDC );
- if( pOldPalette != NULL )
- {
- pOldPalette2 = mdc.SelectPalette( &PmBridge_GetPM()->m_PaletteWide, FALSE );
- mdc.RealizePalette();
- }
- PmBridge_GetPM()->AdjustMenuDC( this, dcPaint, true );
- }
- CDC & dcDummyRef = mdc;
- CDC & dc = bUseBackBuffer ? dcDummyRef : dcPaint;
- CFont * pOldFont = (CFont *) dc.SelectObject( &PmBridge_GetPM()->m_FontNormal );
- COLORREF clrFill = COLORREF(-1L);
- DRAWBACKGROUNDDATA _dbkgnd( dc, rcClient, this );
- _dbkgnd.Notify();
- if( ! _dbkgnd.m_bCustomBackgroundDrawn )
- {
- if( _IsPalette()
- && ( TrackFlagsGet() & TPMX_PALETTE_TB_BKGND ) != NULL
- )
- {
- CRgn rgnClient;
- if( rgnClient.CreateRectRgnIndirect( &rcClient ) )
- dc.SelectClipRgn( &rgnClient );
- if( ! PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
- clrFill = PmBridge_GetPM()->GetColor( CExtPaintManager::CLR_3DFACE_OUT );
- dc.SelectClipRgn( NULL );
- }
- else
- clrFill = PmBridge_GetPM()->GetMenuFrameFillColor( this );
- if( clrFill != COLORREF(-1L) )
- dc.FillSolidRect( &rcClient, clrFill );
- } // if( ! _dbkgnd.m_bCustomBackgroundDrawn )
- if( ! _dbkgnd.m_bCustomBorderDrawn )
- PmBridge_GetPM()->PaintMenuBorder( dc, rcClient, this );
- if( _sizeCaption.cx > 0 && _sizeCaption.cy > 0 )
- {
- CRect rcMenuCaption = rcClient;
- rcMenuCaption.DeflateRect( &rcMB );
- rcMenuCaption.bottom = rcMenuCaption.top;
- rcMenuCaption.top -= _sizeCaption.cy;
- MenuCaptionPaint( dc, rcMenuCaption );
- } // if( _sizeCaption.cx > 0 && _sizeCaption.cy > 0 )
- if( (TrackFlagsGet()&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 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;
- PmBridge_GetPM()->MenuBottomResizingMarginPaint( dc, rcResizingArea, this );
- }
- CRect rcExpand;
- if( m_bExpandAvailable )
- {
- _GetItemRect( IDX_EXPAND, rcExpand, false );
- dc.ExcludeClipRect( rcExpand );
- CRect rcExcludePart( rcExpand );
- rcExcludePart.left = rcRealClient.left;
- rcExcludePart.right = rcRealClient.right;
- dc.ExcludeClipRect( rcExcludePart );
- }
- CRect rcTearOff(0,0,0,0);
- bool bTearOff = _IsTearOff();
- if( bTearOff )
- {
- _GetItemRect( IDX_TEAROFF, rcTearOff, false );
- dc.ExcludeClipRect( rcTearOff );
- CRect rcExcludePart( rcTearOff );
- rcExcludePart.left = rcRealClient.left;
- rcExcludePart.right = rcRealClient.right;
- dc.ExcludeClipRect( rcExcludePart );
- }
- CRect rcScrollTop;
- CRect rcScrollBottom;
- int nMaxScrollPos = 0;
- if( m_bScrollingAvailable )
- {
- if( m_nDyScrollOffset != 0 )
- {
- _GetItemRect( IDX_SCROLL_TOP, rcScrollTop );
- dc.ExcludeClipRect( rcScrollTop );
- CRect rcExcludePart( rcScrollTop );
- rcExcludePart.InflateRect( 0, 1 );
- rcExcludePart.left = rcRealClient.left;
- rcExcludePart.right = rcRealClient.right;
- dc.ExcludeClipRect( rcExcludePart );
- }
- nMaxScrollPos = _GetMaxScrollPos();
- if( m_nDyScrollOffset != nMaxScrollPos )
- {
- _GetItemRect( IDX_SCROLL_BOTTOM, rcScrollBottom );
- dc.ExcludeClipRect( rcScrollBottom );
- CRect rcExcludePart( rcScrollBottom );
- rcExcludePart.InflateRect( 0, 1 );
- rcExcludePart.left = rcRealClient.left;
- rcExcludePart.right = rcRealClient.right;
- dc.ExcludeClipRect( rcExcludePart );
- }
- }
- if( rcClient.top >= rcRealClient.top )
- {
- CRect rcExcludePart( rcRealClient );
- rcExcludePart.bottom = rcClient.top + rcMB.top;
- dc.ExcludeClipRect( rcExcludePart );
- }
- if( rcClient.bottom <= rcRealClient.bottom )
- {
- CRect rcExcludePart( rcRealClient );
- rcExcludePart.top = rcClient.bottom - rcMB.bottom;
- dc.ExcludeClipRect( rcExcludePart );
- }
- _DoPaintMenuItems( dc );
- CPoint point( 0, 0 );
- ::GetCursorPos( &point );
- ScreenToClient( &point );
- dc.SelectClipRgn( NULL );
- if( m_bExpandAvailable )
- {
- bool bHover =
- ( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON == NULL
- && rcExpand.PtInRect(point)
- ) ? true : false;
- bool bPushed = bHover;
- PmBridge_GetPM()->PaintMenuExpandButton( dc, rcExpand, bHover, bPushed, this );
- } // if( m_bExpandAvailable )
- if( bTearOff )
- {
- bool bHover = (rcTearOff.PtInRect(point))? true : false;
- if( bHover && _FindCustomizeMode() )
- bHover = false;
- bool bPushed = bHover;
- PmBridge_GetPM()->PaintMenuTearOffButton( dc, rcTearOff, bHover, bPushed, this );
- }
- if( m_bScrollingAvailable )
- {
- if( m_nDyScrollOffset != 0 )
- {
- bool bHover =
- ( rcScrollTop.PtInRect(point)
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON == NULL
- ) ? true : false;
- bool bPushed = ( m_nScrollingDirection > 0 ) ? true : false;
- PmBridge_GetPM()->PaintMenuScrollButton( dc, bHover, bPushed, true, rcScrollTop, this );
- }
- if( m_nDyScrollOffset != nMaxScrollPos )
- {
- bool bHover =
- ( rcScrollBottom.PtInRect(point)
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON == NULL
- ) ? true : false;
- bool bPushed =
- ( m_nScrollingDirection < 0 ) ? true : false;
- PmBridge_GetPM()->PaintMenuScrollButton( dc, bHover, bPushed, false, rcScrollBottom, this );
- }
- } // if( m_bScrollingAvailable )
- if( m_nLeftAreaWidth > 0 )
- {
- CRect rcLeftArea( rcClient );
- rcLeftArea.right = rcLeftArea.left + m_nLeftAreaWidth;
- rcLeftArea.OffsetRect( rcMB.left, 0 );
- rcLeftArea.DeflateRect( 0, rcMB.top, 0, rcMB.bottom );
- DRAWLEFTAREADATA _DrawLeftAreaData( &dc, &rcLeftArea, this );
- _DrawLeftAreaData.DoOwnerDrawPainting();
- }
- if( m_bCombineWithEA )
- {
- ASSERT( m_eCombineAlign != __CMBA_NONE );
- dc.SelectClipRgn( NULL );
- CRect rcExcludeClient( m_rcExcludeArea );
- ScreenToClient( &rcExcludeClient );
- PmBridge_GetPM()->PaintMenuCombinedArea( dc, rcExcludeClient, rcClient, m_eCombineAlign, this );
- dc.SelectClipRgn( NULL );
- if( m_pCbPaintCombinedContent != NULL )
- {
- CExtMemoryDC dcCA( &dc, &rcExcludeClient, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY );
- m_pCbPaintCombinedContent( m_pCbPaintCombinedCookie, dcCA, *this, m_rcExcludeArea, m_eCombineAlign );
- } // if( m_pCbPaintCombinedContent != NULL )
- } // if( m_bCombineWithEA )
- #ifdef _DEBUG_TEAROFF_TRANSPARENCY
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL
- && (!CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_bHelperForceFloatInvisible)
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat != NULL
- && ::IsWindow( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat )
- )
- {
- CRect rcFloatingArea = CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_rcCustomFloatPos;
- if( rcFloatingArea.IsRectEmpty() )
- ::GetWindowRect(
- CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat,
- &rcFloatingArea
- );
- if( _IsFloatingAreaInstersectsWithMenu( rcFloatingArea, false ) )
- {
- HBITMAP hBmpSufrace =
- CExtPaintManager::stat_PrintWnd(
- CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat
- );
- if( hBmpSufrace != NULL )
- {
- CBitmap bmpSurface;
- bmpSurface.Attach( hBmpSufrace );
- CDC dcSurface;
- if( dcSurface.CreateCompatibleDC(NULL) )
- {
- CBitmap * pBmpOld = dcSurface.SelectObject( &bmpSurface );
- CRect rcWndThis;
- GetWindowRect( &rcWndThis );
- dc.BitBlt(
- rcFloatingArea.left - rcWndThis.left,
- rcFloatingArea.top - rcWndThis.top,
- rcFloatingArea.Width(),
- rcFloatingArea.Height(),
- &dcSurface,
- 0,
- 0,
- SRCCOPY
- );
- dcSurface.SelectObject( pBmpOld );
- }
- }
- }
- }
- #endif // _DEBUG_TEAROFF_TRANSPARENCY
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- {
- if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- {
- dc.SelectClipRgn( NULL );
- // dc.FillSolidRect( &m_rcRibbonBtnExit, 255 );
- RIBBONFILEMENUBUTTONQUERY _rfmbq( this, TPMX_RIBBON_EXIT_BUTTON, &dc );
- _rfmbq.m_rcButton = m_rcRibbonBtnExit;
- _rfmbq.m_nMeasuredWidth = _rfmbq.m_rcButton.Width();
- _rfmbq.m_bHover = ( m_nCurIndex == INT(IDX_RIBBON_FILE_MENU_EXIT_BUTTON) ) ? true : false;
- _rfmbq.m_bPressed = ( _rfmbq.m_bHover && IsKeyPressed(VK_LBUTTON) ) ? true : false;
- _rfmbq.Notify();
- } // if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0 )
- if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- {
- dc.SelectClipRgn( NULL );
- // dc.FillSolidRect( &m_rcRibbonBtnOptions, 255 );
- RIBBONFILEMENUBUTTONQUERY _rfmbq( this, TPMX_RIBBON_OPTIONS_BUTTON, &dc );
- _rfmbq.m_rcButton = m_rcRibbonBtnOptions;
- _rfmbq.m_nMeasuredWidth = _rfmbq.m_rcButton.Width();
- _rfmbq.m_bHover = ( m_nCurIndex == INT(IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON) ) ? true : false;
- _rfmbq.m_bPressed = ( _rfmbq.m_bHover && IsKeyPressed(VK_LBUTTON) ) ? true : false;
- _rfmbq.Notify();
- } // if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0 )
- } // if( (dwTrackFlags&TPMX_RIBBON_FILE_MENU) != 0 )
- dc.SelectObject( pOldFont );
- if( bUseBackBuffer )
- {
- ASSERT( mdc.GetSafeHdc() != NULL );
- if( pOldPalette2 != NULL )
- mdc.SelectPalette( pOldPalette2, FALSE );
- mdc.__Flush();
- }
- if( _IsPopupWithShadows()
- && m_bAnimFinished
- && nMenuShadowSize > 0
- )
- { // if we need to paint shadow for client area (and combined exclude area)
- dcPaint.SelectClipRgn(NULL);
- //dcPaint.ExcludeClipRect( &rcClient );
- CRect
- rcExcludeClient( 0,0,0,0 ),
- rcExcludeScreen( 0,0,0,0 ),
- rcBaseScreen( 0,0,0,0 );
- HWND hWndFloat = NULL;
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL
- && (!CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_bHelperForceFloatInvisible)
- && CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat != NULL
- && ::IsWindow( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat )
- )
- {
- hWndFloat = CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_hWndHelperFloat;
- if( hWndFloat != NULL )
- {
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong( hWndFloat, GWL_STYLE );
- if( (dwStyle&WS_VISIBLE) == 0 )
- hWndFloat = NULL;
- }
- }
- if( m_bCombineWithEA )
- {
- if( _IsPopupWithShadows()
- && m_bAnimFinished
- && nMenuShadowSize > 0
- && m_bTopLevel
- )
- { // if we need to paint shadow for combined exclude area
- rcExcludeScreen = m_rcExcludeArea;
- rcExcludeClient = rcExcludeScreen;
- ScreenToClient( &rcExcludeClient );
- dcPaint.ExcludeClipRect( &rcClient );
- rcBaseScreen = rcClient;
- ClientToScreen( &rcBaseScreen );
- VERIFY(
- m_ShadowCMBA.Paint(
- PmBridge_GetPM(),
- dcPaint,
- rcExcludeClient,
- rcExcludeScreen,
- rcBaseScreen,
- nMenuShadowSize,
- CExtWndShadow::DEF_BRIGHTNESS_MIN,
- CExtWndShadow::DEF_BRIGHTNESS_MAX,
- true,
- true,
- false,
- m_hWnd,
- hWndFloat,
- ( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL
- && (! CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_rcCustomFloatPos.IsRectEmpty() )
- )
- ? (&CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_rcCustomFloatPos)
- : NULL
- )
- );
- dcPaint.SelectClipRgn(NULL);
- } // if we need to paint shadow for combined exclude area
- CRect rcExcludePart( m_rcExcludeArea );
- ScreenToClient( &rcExcludePart );
- dcPaint.ExcludeClipRect( &rcExcludePart );
- } // if( m_bCombineWithEA )
- VERIFY(
- m_ShadowMain.Paint(
- PmBridge_GetPM(),
- dcPaint,
- rcClient,
- rcBaseScreen,
- rcExcludeScreen,
- nMenuShadowSize,
- CExtWndShadow::DEF_BRIGHTNESS_MIN,
- CExtWndShadow::DEF_BRIGHTNESS_MAX,
- true,
- true,
- false,
- m_hWnd,
- hWndFloat,
- ( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL
- && (! CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_rcCustomFloatPos.IsRectEmpty() )
- )
- ? (&CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON->m_rcCustomFloatPos)
- : NULL
- )
- );
- } // if we need to paint shadow for client area (and combined exclude area)
- if( m_bCombineWithEA )
- {
- ASSERT( m_eCombineAlign != __CMBA_NONE );
- dcPaint.SelectClipRgn( NULL );
- CRect rcExcludeClient( m_rcExcludeArea );
- ScreenToClient( &rcExcludeClient );
- CRect rx( rcExcludeClient );
- CExtMemoryDC dc( &dcPaint, &rx );
- PmBridge_GetPM()->PaintMenuCombinedArea(
- dc,
- rcExcludeClient,
- rcClient,
- m_eCombineAlign,
- this
- );
- if( m_pCbPaintCombinedContent != NULL )
- {
- CExtMemoryDC dcCA( &dc, &rcExcludeClient, CExtMemoryDC::MDCOPT_TO_MEMORY|CExtMemoryDC::MDCOPT_FILL_BITS|CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY );
- m_pCbPaintCombinedContent(
- m_pCbPaintCombinedCookie,
- dcCA,
- *this,
- m_rcExcludeArea,
- m_eCombineAlign
- );
- } // if( m_pCbPaintCombinedContent != NULL )
- } // if( m_bCombineWithEA )
- if( pOldPalette != NULL )
- dcPaint.SelectPalette( pOldPalette, FALSE );
- }
- HWND CExtPopupMenuWnd::GetCmdReceiverHWND()
- {
- ASSERT_VALID( this );
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow( m_hWndCmdReceiver ) );
- return m_hWndCmdReceiver;
- }
- HWND CExtPopupMenuWnd::GetCmdReceiverHWND() const
- {
- ASSERT_VALID( this );
- return
- ( const_cast < CExtPopupMenuWnd * > ( this ) )
- -> GetCmdReceiverHWND();
- }
- DWORD CExtPopupMenuWnd::TrackFlagsGet() const
- {
- ASSERT_VALID( this );
- if( ! m_bTopLevel )
- return (m_dwTrackFlags&(~(TPMX_RIBBON_FILE_MENU)));
- return m_dwTrackFlags;
- }
- void CExtPopupMenuWnd::TrackFlagsSet(
- DWORD dwTrackFlags // = 0
- )
- {
- ASSERT_VALID( this );
- m_dwTrackFlags = dwTrackFlags;
- }
- int CExtPopupMenuWnd::_GetTearOffCaptionHeight() const
- {
- ASSERT_VALID( this );
- int nTearOffCaptionHeight =
- PmBridge_GetPM()->TearOff_GetCaptionHeight();
- return nTearOffCaptionHeight;
- }
- bool CExtPopupMenuWnd::_IsTearOff() const
- {
- ASSERT_VALID( this );
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_TEAROFF) != 0 )
- return true;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- HWND hWndCmdReceiver = GetCmdReceiverHWND();
- if( hWndCmdReceiver == NULL )
- return false;
- const CExtCustomizeCmdTreeNode * pNode = _CmdNodeGet();
- if( pNode == NULL )
- return false;
- ASSERT_VALID( pNode );
- UINT nCmdID = pNode->GetCmdID( false );
- LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd( hWndCmdReceiver );
- if( strProfileName == NULL )
- return false;
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr( strProfileName, nCmdID );
- if( pCmdItem == NULL )
- return false;
- if( pCmdItem->StateIsTearOff() )
- return true;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- return false;
- }
- bool CExtPopupMenuWnd::_IsPalette() const
- {
- ASSERT_VALID( this );
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_PALETTE) != 0 )
- return true;
- return false;
- }
- void CExtPopupMenuWnd::_DoPaintMenuItems( CDC & dc )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _IsPalette() )
- {
- _DoPaintMenuItemsPalette( dc );
- return;
- }
- visible_items_t v;
- _GetVisibleItems( dc.GetSafeHdc(), v );
- INT vis_iter = 0;
- bool bPrevToolButton = false;
- for( ; vis_iter < v.GetSize(); ++vis_iter )
- { // paint visible items
- VisibleItemDefinition_t & vi = v[ vis_iter ];
- ASSERT(
- vi.m_nIndex >= 0
- && vi.m_nIndex < m_items_all.GetSize()
- );
- ASSERT( !vi.m_rcItem.IsRectEmpty() );
- ASSERT( !vi.m_rcItemWithIndents.IsRectEmpty() );
- ASSERT( dc.RectVisible(&vi.m_rcItem) );
- ASSERT( dc.RectVisible(&vi.m_rcItemWithIndents) );
- MENUITEMDATA & mi =
- ItemGetInfo( vi.m_nIndex );
- ASSERT( mi.IsDisplayed() );
- ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
- if( vi.m_bHelperIsSeparator )
- {
- ASSERT( mi.IsSeparator() );
- if( bPrevToolButton )
- {
- PmBridge_GetPM()->PaintSeparator( dc, vi.m_rcItemWithIndents, false, true, this );
- }
- else
- PmBridge_GetPM()->PaintMenuSeparator(
- dc,
- vi.m_rcItemWithIndents,
- mi.GetIconAreaWidth(),
- g_bMenuHighlightRarely && vi.m_bRarelyUsed,
- ( mi.IsForceNoLeftGradient() || IsNoHighlightIconArea() ) ? true : false,
- this
- );
- bPrevToolButton = false;
- continue;
- }
- ASSERT( !mi.IsSeparator() );
- ASSERT( mi.IsPopup() == vi.m_bHelperIsPopup );
-
- DRAWITEMDATA _DrawItemData(
- &dc,
- &vi.m_rcItem,
- &vi.m_rcItemWithIndents,
- &mi,
- this,
- ( (! _FindCustomizeMode() )
- && ( TrackFlagsGet()&TPMX_OWNERDRAW_FIXED ) != 0 // fix 2.23 ( == replaced with != )
- ) ? true : false,
- vi.m_bHelperIsPopup,
- g_bMenuHighlightRarely && vi.m_bRarelyUsed,
- g_bMenuHighlightRarely && vi.m_bRarelyUsedPrev,
- g_bMenuHighlightRarely && vi.m_bRarelyUsedNext
- );
-
- bool bPainted =
- (_DrawItemData.m_bMenuOwnerDrawFixed)
- ? _DrawItemData.DoOwnerDrawPainting()
- : false
- ;
- if( ! bPainted )
- _DrawItemData.PaintDefault();
- bPrevToolButton = mi.IsToolButton();
- } // paint visible items
- }
- void CExtPopupMenuWnd::_DoPaintMenuItemsPalette( CDC & dc )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- visible_items_t v;
- _GetVisibleItems( dc.GetSafeHdc(), v );
- INT vis_iter = 0;
- for( ; vis_iter < v.GetSize(); ++vis_iter )
- { // paint visible items
- VisibleItemDefinition_t & vi = v[ vis_iter ];
- ASSERT(
- vi.m_nIndex >= 0
- && vi.m_nIndex < m_items_all.GetSize()
- );
- ASSERT( !vi.m_rcItem.IsRectEmpty() );
- ASSERT( !vi.m_rcItemWithIndents.IsRectEmpty() );
- ASSERT( dc.RectVisible(&vi.m_rcItem) );
- ASSERT( dc.RectVisible(&vi.m_rcItemWithIndents) );
- MENUITEMDATA & mi =
- ItemGetInfo( vi.m_nIndex );
- ASSERT( mi.IsDisplayed() );
- ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
- if( vi.m_bHelperIsSeparator )
- {
- ASSERT( mi.IsSeparator() );
- CRect rc = vi.m_rcItemWithIndents;
- PmBridge_GetPM()->PaintSeparator( dc, vi.m_rcItemWithIndents, false, true, this );
- continue;
- }
- ASSERT( !mi.IsSeparator() );
- ASSERT( mi.IsPopup() == vi.m_bHelperIsPopup );
-
- DRAWITEMDATA _DrawItemData(
- &dc,
- &vi.m_rcItem,
- &vi.m_rcItemWithIndents,
- &mi,
- this,
- ( (! _FindCustomizeMode() )
- && ( GetSite()->TrackFlagsGet()&TPMX_OWNERDRAW_FIXED ) != 0 // fix 2.23 ( == replaced with != )
- ) ? true : false,
- vi.m_bHelperIsPopup,
- g_bMenuHighlightRarely && vi.m_bRarelyUsed,
- g_bMenuHighlightRarely && vi.m_bRarelyUsedPrev,
- g_bMenuHighlightRarely && vi.m_bRarelyUsedNext
- );
-
- bool bPainted =
- (_DrawItemData.m_bMenuOwnerDrawFixed)
- ? _DrawItemData.DoOwnerDrawPainting()
- : false
- ;
- bool bForceNoIcon = false, bForceNoText = false;
- CExtCmdIcon * pIcon = mi.GetIconPtr();
- if( pIcon != NULL && pIcon->IsEmpty() )
- pIcon = NULL;
- if( mi.IsInplaceEdit() )
- bForceNoIcon = bForceNoText = true;
- else if( pIcon == NULL || ( pIcon != NULL && (! mi.IsIconMode() ) ) )
- {
- //bForceNoIcon = true;
- }
- else
- bForceNoText = true;
- if( ! bPainted )
- _DrawItemData.PaintDefault( bForceNoIcon, bForceNoText );
- } // paint visible items
- }
- #if _MFC_VER < 0x700
- void CExtPopupMenuWnd::OnActivateApp(BOOL bActive, HTASK hTask)
- #else
- void CExtPopupMenuWnd::OnActivateApp(BOOL bActive, DWORD hTask)
- #endif
- {
- ASSERT_VALID( this );
- bActive;
- hTask;
- if( ( GetStyle() & WS_VISIBLE ) == 0 )
- {
- m_pWndParentMenu = NULL;
- m_dwTrackFlags &= ~(TPMX_CUSTOMIZE_MODE);
- }
- _CancelingSet();
- _OnCancelMode();
- }
- bool CExtPopupMenuWnd::_StartScrolling(int nButtonIndex)
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return FALSE;
- if( (nButtonIndex == IDX_SCROLL_TOP
- || nButtonIndex == IDX_SCROLL_BOTTOM)
- )
- {
- ASSERT( m_bScrollingAvailable );
- HWND hWndOwn = m_hWnd;
- _ItemFocusDelay();
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- _ItemFocusCancel( FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- m_nCurIndex = nButtonIndex;
- Invalidate( FALSE );
- m_nAcceleratedPixelsPerStepCurrent = __SCROLLING_PIXEL_STEP;
- m_nAcceleratedMilliSecondsPassed = 0;
- SetTimer(
- ID_TIMER_SCROLLING,
- ID_PERIOD_SCROLLING,
- NULL
- );
- if( !_FindCustomizeMode() )
- _SetCapture();
- return true;
- }
- return false;
- }
- bool CExtPopupMenuWnd::_PtInWndArea( CPoint ptClient )
- {
- if( GetSafeHwnd() == NULL )
- return false;
- ClientToScreen( &ptClient );
- HWND hWndFromPoint = ::WindowFromPoint(ptClient);
- if( hWndFromPoint == NULL )
- return false;
- if( hWndFromPoint == m_hWnd )
- return true;
- return false;
- }
- LRESULT CExtPopupMenuWnd::WindowProc(
- UINT message,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- switch( message )
- {
- case __WM_START_RESIZING:
- //if( _IsResizingMode() )
- {
- m_bHelperResizingMode = true;
- CPoint ptScreenClick( short(LOWORD(lParam)), short(HIWORD(lParam)) );
- _DoResizing(
- ptScreenClick,
- ( (TrackFlagsGet()&TPMX_RIBBON_RESIZING_VERTICAL_ONLY) != 0 ) ? true : false
- );
- }
- return 0;
- //break;
- case WM_NCDESTROY:
- case WM_DESTROY:
- m_bDelayedHiding = false;
- if( m_ctrlShadow.GetSafeHwnd() != NULL )
- m_ctrlShadow.DestroyWindow();
- break;
- } // switch( message )
- LRESULT lResult = CExtPopupBaseWnd::WindowProc( message, wParam, lParam );
- return lResult;
- }
- bool CExtPopupMenuWnd::_OnMouseClick(
- UINT nFlags,
- CPoint point,
- bool & bNoEat
- )
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return false;
- // - 2.27 (for command processing in separated dropdown item)
- // if( ! m_bAnimFinished )
- // return true;
- CExtPopupMenuSite & _site = GetSite();
- if( _site.IsShutdownMode()
- || _site.IsEmpty()
- || _site.GetAnimated() != NULL
- )
- {
- if( ( TrackFlagsGet() & TPMX_SYSMENU ) != 0 )
- {
- bNoEat = true;
- return false;
- }
- return true;
- }
- TranslateMouseClickEventData_t _td( this, nFlags, point, bNoEat );
- if( _td.Notify() )
- {
- bNoEat = _td.m_bNoEat;
- return true;
- }
- bool bLButtonUpCall =
- (nFlags==WM_LBUTTONUP || nFlags==WM_NCLBUTTONUP)
- ? true : false;
- CPoint ptScreenClick( point );
- ClientToScreen( &ptScreenClick );
- if( (TrackFlagsGet()&TPMX_RIBBON_RESIZING) != 0 )
- {
- UINT nHT = (UINT) ::SendMessage( m_hWnd, WM_NCHITTEST, 0L, MAKELPARAM(ptScreenClick.x,ptScreenClick.y) );
- switch( nHT )
- {
- case HTLEFT:
- case HTRIGHT:
- case HTTOP:
- case HTBOTTOM:
- case HTTOPLEFT:
- case HTTOPRIGHT:
- case HTBOTTOMLEFT:
- case HTBOTTOMRIGHT:
- if( ! bLButtonUpCall )
- {
- m_bHelperResizingMode = true;
- PostMessage( __WM_START_RESIZING, 0, MAKELPARAM(ptScreenClick.x,ptScreenClick.y) );
- } // if( ! bLButtonUpCall )
- m_bHelperResizingMode = false;
- bNoEat = false;
- return true;
- } // switch( nHT )
- m_bHelperResizingMode = false;
- } // if( (TrackFlagsGet()&TPMX_RIBBON_RESIZING) != 0 )
- HWND hWndFromPoint = ::WindowFromPoint( ptScreenClick );
- if( hWndFromPoint != NULL )
- {
- if( (::__EXT_MFC_GetWindowLong(hWndFromPoint,GWL_STYLE)&WS_CHILD) != 0
- && ::GetParent(hWndFromPoint) == m_hWnd
- )
- {
- CWnd * pWnd = CWnd::FromHandlePermanent( hWndFromPoint );
- if( pWnd != NULL )
- {
- int nCount = ItemGetCount();
- for( int i = 0; i < nCount; i++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( i );
- if( !mi.IsInplaceEdit() )
- continue;
- if( ((LPVOID)mi.GetInplaceEditPtr()) != ((LPVOID)pWnd) )
- continue;
- if( m_nCurIndex == i )
- break;
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet( i, FALSE, TRUE, FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- break;
- } // for( int i = 0; i < nCount; i++ )
- } // if( pWnd != NULL )
- bNoEat = true;
- return false;
- }
- if( ! bLButtonUpCall )
- {
- CWnd * pWndPermanent = CWnd::FromHandlePermanent( hWndFromPoint );
- if( pWndPermanent != NULL )
- {
- if( pWndPermanent->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- {
- CPoint ptClientPermanent = ptScreenClick;
- pWndPermanent->ScreenToClient( &ptClientPermanent );
- int nBtnIdx = ((CExtMenuControlBar*)pWndPermanent)->HitTest( ptClientPermanent );
- if( nBtnIdx >= 0 )
- {
- CExtBarButton * pTBB = ((CExtMenuControlBar*)pWndPermanent)->GetButton( nBtnIdx );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiDocButton ) ) )
- {
- _OnCancelMode();
- bNoEat = true;
- return false;
- } // if( pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiDocButton ) ) )
- } // if( nBtnIdx >= 0 )
- } // if( pWndPermanent->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- } // if( pWndPermanent != NULL )
- } // if( ! bLButtonUpCall )
- } // if( hWndFromPoint != NULL )
- /*
- CRect rectWindow;
- GetWindowRect( &rectWindow );
- ScreenToClient( &rectWindow );
- if( !rectWindow.PtInRect(point) )
- */
- if( bLButtonUpCall && (!_PtInWndArea(point)) )
- {
- CExtPopupMenuTipWnd & _tipWnd = GetTip();
- if( _tipWnd.GetSafeHwnd() != NULL )
- {
- CPoint ptScreen( point );
- ClientToScreen( &ptScreen );
- if( _tipWnd.GetSafeHwnd() == ::WindowFromPoint(ptScreen) )
- return true; // eat!
- }
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL );
- ASSERT( ::IsWindow(hWndOwn) );
- if( m_pWndParentMenu != NULL
- && m_pWndParentMenu->GetSafeHwnd() != NULL
- )
- {
- ASSERT_VALID( m_pWndParentMenu );
- ClientToScreen( &point );
- m_pWndParentMenu->ScreenToClient( &point );
- CExtPopupMenuWnd * pWndParentMenu = m_pWndParentMenu;
- if( pWndParentMenu->_OnMouseClick(
- nFlags,
- point,
- bNoEat
- )
- )
- {
- if( bNoEat )
- return false;
- if( ::IsWindow(hWndOwn) )
- {
- INT nSaved = m_nFadeOutAnimationStepCount;
- m_nFadeOutAnimationStepCount = -1;
- GetTopLevelMenuWnd()->PostMessage( WM_CANCELMODE );
- _OnCancelMode();
- m_nFadeOutAnimationStepCount = nSaved;
- }
- return true;
- }
- return false;
- }
- // fixed in v. 2.20
- if( nFlags == WM_RBUTTONUP
- || nFlags == WM_LBUTTONUP
- )
- {
- // + 2.83
- CExtPopupMenuWnd * pTopLevelPopup = GetTopLevelMenuWnd();
- ASSERT_VALID( pTopLevelPopup );
- bool bHelperMouseBtnDownOnStart = pTopLevelPopup->m_bHelperMouseBtnDownOnStart;
- pTopLevelPopup->m_bHelperMouseBtnDownOnStart = false;
- // + 2.25
- if( ::IsWindow(hWndOwn)
- && CExtToolControlBar::g_bMenuTracking
- && hWndFromPoint != NULL
- )
- {
- CWnd * pWndCmp =
- CWnd::FromHandlePermanent( hWndFromPoint );
- if( pWndCmp != NULL )
- {
- CExtToolControlBar * pToolBar =
- DYNAMIC_DOWNCAST( CExtToolControlBar, pWndCmp );
- if( pToolBar != NULL )
- {
- ASSERT_VALID( pToolBar );
- int nBtnIdx = pToolBar->GetMenuTrackingButton();
- if( nBtnIdx >= 0 )
- {
- CExtBarButton * pTBB = pToolBar->GetButton( nBtnIdx );
- if( pTBB != NULL )
- {
- ASSERT_VALID( pTBB );
- CRect rcBtn = pTBB->Rect();
- pToolBar->ClientToScreen( &rcBtn );
- if( rcBtn.PtInRect(ptScreenClick) )
- return true;
- } // if( pTBB != NULL )
- } // if( nBtnIdx >= 0 )
- } // if( pToolBar == pWndCmp )
- } // if( pWndCmp != NULL )
- if( ! bHelperMouseBtnDownOnStart ) // + 2.83
- _OnCancelMode();
- }
- return true;
- }
- if( nFlags == WM_NCLBUTTONUP
- && g_PaintManager.m_DWM.IsCompositionEnabled()
- )
- return true;
- _OnCancelMode();
- return false;
- } // if( bLButtonUpCall && (!_PtInWndArea(point)) )
- bool bInplaceControlArea = false, bInplaceDropDownArea = false;
- int nHitTest =
- _HitTest(
- point,
- &bInplaceControlArea,
- &bInplaceDropDownArea
- );
- if( _IsTearOff() && nHitTest == IDX_TEAROFF )
- {
- bool bLButtonUpCall =
- ( nFlags == WM_LBUTTONUP || nFlags == WM_NCLBUTTONUP )
- ? true : false;
- if( ! bLButtonUpCall )
- _DoTearOff();
- return true;
- }
- if( bLButtonUpCall )
- {
- HWND hWndOwn = m_hWnd;
- if( _StartScrolling(nHitTest) )
- return true;
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- }
- if( nHitTest < 0 )
- {
- if( nHitTest == IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON
- || nHitTest == IDX_RIBBON_FILE_MENU_EXIT_BUTTON
- )
- {
- if( bLButtonUpCall )
- {
- DWORD dwButtonType = 0;
- switch( nHitTest )
- {
- case IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON:
- dwButtonType = TPMX_RIBBON_OPTIONS_BUTTON;
- break;
- case IDX_RIBBON_FILE_MENU_EXIT_BUTTON:
- dwButtonType = TPMX_RIBBON_EXIT_BUTTON;
- break;
- } // switch( nHitTest )
- RIBBONFILEMENUBUTTONINVOCATION _rfmbi( dwButtonType, this );
- m_nCurIndex = IDX_NOTHING;
- _SetCapture();
- if( nHitTest == IDX_RIBBON_FILE_MENU_EXIT_BUTTON )
- m_dwTrackFlags |= TPMX_NO_FADE_OUT_ANIMATION;
- DestroyWindow();
- g_SoundPlayer->PlaySound( CExtSoundPlayer::__ON_MENU_CMD_CLICKED );
- _rfmbi.Notify();
- } // if( bLButtonUpCall )
- else
- {
- CRect rcItem;
- _GetItemRect( nHitTest, rcItem );
- if( ! rcItem.IsRectEmpty() )
- InvalidateRect( &rcItem );
- } // else from if( bLButtonUpCall )
- return true;
- }
- if( bLButtonUpCall )
- {
- if( ( nHitTest == IDX_SCROLL_TOP
- || nHitTest == IDX_SCROLL_BOTTOM
- )
- //&& m_nCurIndex != nHitTest
- )
- {
- return true;
- }
- if( nHitTest == IDX_EXPAND )
- {
- if( ( ! m_bExpandWasPressed )
- && m_bExpandAvailable
- )
- _DoExpand();
- return true;
- }
- // fixed in v. 2.20
- if( nFlags != WM_RBUTTONUP
- && nFlags != WM_LBUTTONUP
- )
- {
- _OnCancelMode();
- return true;
- }
- } // if( bLButtonUpCall )
- if( m_eCombineAlign != __CMBA_NONE
- && m_bTopLevel
- && (!bLButtonUpCall)
- )
- {
- CRect rcExcludeAreaTest( m_rcExcludeArea );
- ScreenToClient( &rcExcludeAreaTest );
- if( rcExcludeAreaTest.PtInRect( point ) )
- {
- _OnCancelMode();
- return true;
- } // if( rcExcludeAreaTest.PtInRect( point ) )
- } // if( m_eCombineAlign != __CMBA_NONE ...
- if( nFlags != WM_LBUTTONUP
- && nFlags != WM_LBUTTONDOWN
- && nFlags != WM_NCLBUTTONUP
- && nFlags != WM_NCLBUTTONDOWN
- && nFlags != WM_RBUTTONDOWN
- && nFlags != WM_NCRBUTTONDOWN
- && nFlags != WM_MBUTTONDOWN
- && nFlags != WM_NCMBUTTONDOWN
- )
- {
- bNoEat = false;
- return true;
- }
- return false;
- }
- ASSERT( nHitTest < m_items_all.GetSize() );
- if( !bLButtonUpCall )
- return true;
- MENUITEMDATA & mi = ItemGetInfo(nHitTest);
- if( ( ! mi.IsEnabled() ) || mi.IsSeparator() )
- {
- _ItemFocusCancel( TRUE );
- _SetCapture();
- return true;
- }
- if( mi.IsInplaceEdit()
- && mi.IsPopup()
- && (! mi.IsAllowInplaceEditActivation() )
- )
- {
- bInplaceControlArea = false;
- bInplaceDropDownArea = true;
- }
- if( mi.IsInplaceEdit()
- && ( ! mi.IsPopup() )
- && ( ! bInplaceDropDownArea )
- && ( ! _FindHelpMode() )
- )
- {
- _SetCapture();
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet( nHitTest, FALSE, TRUE, FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- CWnd * pWndInplace = mi.GetInplaceEditPtr();
- if( pWndInplace != NULL )
- {
- ASSERT_VALID( pWndInplace );
- ASSERT( pWndInplace->GetSafeHwnd() != NULL && (::IsWindow(pWndInplace->GetSafeHwnd())) );
- if( mi.IsAllowInplaceEditActivation() )
- {
- if( (pWndInplace->GetStyle() & WS_VISIBLE) == 0 )
- {
- CRect rcInplaceEdit;
- _GetItemRect( nHitTest, rcInplaceEdit );
- rcInplaceEdit =
- mi.AdjustInplaceEditRect(
- rcInplaceEdit,
- OnQueryLayoutRTL()
- );
- pWndInplace->SetWindowPos(
- NULL,
- rcInplaceEdit.left, rcInplaceEdit.top,
- rcInplaceEdit.Width(), rcInplaceEdit.Height(),
- SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_SHOWWINDOW
- );
- } // if( (pWndInplace->GetStyle() & WS_VISIBLE) == 0 )
- pWndInplace->SetFocus();
- } // if( mi.IsAllowInplaceEditActivation() )
- } // if( pWndInplace != NULL )
- return true;
- } // if( mi.IsInplaceEdit() ...
- bool bContinueAsCommand = false;
- if( mi.IsPopup() )
- {
- bool bPopupOpened = false;
- if( mi.GetPopup()->GetSafeHwnd() != NULL )
- bPopupOpened = true;
- // if( bPopupOpened )
- // return false;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (!bPopupOpened) && mi.IsInplaceEdit() && _FindHelpMode() )
- {
- CExtCustomizeCmdTreeNode * pNode = mi.GetCmdNode();
- if( pNode != NULL )
- _EndSequence(
- pNode->GetCmdID( false ),
- mi.GetCmdReceiver()
- );
- } // if( (!bPopupOpened) && mi.IsInplaceEdit() && _FindHelpMode() )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (!bPopupOpened) && mi.IsInplaceEdit() && bInplaceDropDownArea )
- {
- HWND hWndOwn = m_hWnd;
- _ItemFocusCancel( FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- }
- // - 2.27 (for command processing in separated dropdown item)
- // if( m_nDelayedFocusItemIndex < 0 )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool bSeparatedDropDown = false;
- const CExtCustomizeCmdTreeNode * pNode = mi.GetCmdNode();
- if( pNode != NULL )
- {
- ASSERT_VALID( pNode );
- bSeparatedDropDown =
- (pNode->GetFlags() & __ECTN_TBB_SEPARATED_DROPDOWN)
- ? true : false;
- } // if( pNode != NULL )
- if( bSeparatedDropDown )
- {
- bool bRTL = OnQueryLayoutRTL();
- CRect rcItem;
- _GetItemRect( nHitTest, rcItem );
- CRect rcPopupArrow( rcItem );
- //rcPopupArrow.DeflateRect(__EXT_MENU_GAP,__EXT_MENU_GAP);
- if( bRTL )
- rcPopupArrow.right = rcPopupArrow.left + __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcPopupArrow.left = rcPopupArrow.right - __EXT_MENU_POPUP_ARROW_AREA_DX;
- ClientToScreen( &rcPopupArrow );
- if( ! rcPopupArrow.PtInRect( ptScreenClick ) )
- {
- _SetCapture();
- _ItemFocusCancel( FALSE, TRUE );
- _ItemFocusSet( nHitTest, FALSE, FALSE, FALSE );
- bContinueAsCommand = true;
- }
- } // if( bSeparatedDropDown )
- else
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( ! bPopupOpened )
- {
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet(
- nHitTest,
- TRUE,
- TRUE,
- FALSE
- );
- if( ! ::IsWindow( hWndOwn ) )
- return true;
- }
- else
- return false;
- } // if( m_nDelayedFocusItemIndex < 0 )
- if( ! bContinueAsCommand )
- {
- _SetCapture();
- return true;
- }
- } // if( mi.IsPopup() )
- if( mi.IsExtraMark() && (! _FindHelpMode() ) )
- {
- ASSERT( mi.GetExtraMarkCallback() != NULL );
- mi.GetExtraMarkCallback()( this, &mi );
- CClientDC dc( this );
- _DoPaint( dc );
- } // if( mi.IsExtraMark() ...
- else if(
- mi.IsExecutableCmdID()
- || bContinueAsCommand
- || ( mi.IsPopup()
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- && mi.GetCmdNode() != NULL
- && (mi.GetCmdNode()->GetFlags()&__ECTN_TBB_SEPARATED_DROPDOWN) != 0
- && (mi.GetCmdNode()->GetFlags()&(__ECTN_TBB_COLOR|__ECTN_TBB_UNDO_REDO|__ECTN_TBB_DATE)) != 0
- #else // (!defined __EXT_MFC_NO_CUSTOMIZE)
- && ( mi.GetPopup()->IsKindOf( RUNTIME_CLASS(CExtPopupColorMenuWnd) )
- #if (!defined __EXT_MFC_NO_UNDO_REDO_POPUP)
- || mi.GetPopup()->IsKindOf( RUNTIME_CLASS(CExtPopupUndoRedoMenuWnd) )
- #endif // (!defined __EXT_MFC_NO_UNDO_REDO_POPUP)
- #if (!defined __EXT_MFC_NO_DATE_PICKER_POPUP)
- || mi.GetPopup()->IsKindOf( RUNTIME_CLASS(CExtPopupDatePickerMenuWnd) )
- #endif // (!defined __EXT_MFC_NO_DATE_PICKER_POPUP)
- )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- )
- )
- {
- CExtPopupMenuWnd * pTopLevelPopup = GetTopLevelMenuWnd();
- ASSERT_VALID( pTopLevelPopup );
- bool bHelperMouseBtnDownOnStart = pTopLevelPopup->m_bHelperMouseBtnDownOnStart;
- pTopLevelPopup->m_bHelperMouseBtnDownOnStart = false;
- bool bContinue = true;
- if( mi.IsExecutableCmdID() )
- {
- if( bHelperMouseBtnDownOnStart )
- {
- CPoint pt;
- ::GetCursorPos( &pt );
- if( m_ptStartMousePos == pt )
- bContinue = false;
- }
- }
- if( bContinue )
- {
- if( !( mi.GetCmdDeliverCb() != NULL
- && mi.GetCmdDeliverCb()( this, &mi )
- )
- )
- {
- _CancelingSet();
- _EndSequenceEx( mi );
- }
- }
- } // else if( mi.IsExecutableCmdID() ...
- else
- _OnCancelMode();
- return true;
- }
- void CExtPopupMenuWnd::_EndSequenceEx(
- CExtPopupMenuWnd::MENUITEMDATA & mi
- )
- {
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _KeyTipsShow( false );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (! _IsFadeOutAnimation() )
- && m_ctrlShadow.GetSafeHwnd() != NULL
- )
- m_ctrlShadow.DestroyWindow();
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * pNode = mi.GetCmdNode();
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite(
- mi.GetCmdReceiver()
- );
- if( pNode != NULL && pSite != NULL )
- {
- if( mi.IsExecutableCmdID() )
- {
- ASSERT_VALID( pNode );
- if( ( pNode->GetFlags() & (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) ) == 0 )
- {
- CExtCustomizeCmdTreeNode * pNodeParent = pNode->GetParentNode();
- if( pNodeParent != NULL )
- {
- ASSERT_VALID( pNodeParent );
- if( ( pNodeParent->GetFlags() &
- ( __ECTN_TBB_COLOR
- | __ECTN_TBB_SEPARATED_DROPDOWN
- | __ECTN_TBB_AUTOCHANGE_ID
- )
- )
- == ( __ECTN_TBB_SEPARATED_DROPDOWN
- | __ECTN_TBB_AUTOCHANGE_ID
- )
- )
- {
- pNodeParent->SetCmdID(
- pNode->GetCmdID(),
- true
- );
- HWND hWnd = mi.GetCmdReceiver();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr( g_CmdManager->ProfileNameFromWnd( hWnd ), pNode->GetCmdID() );
- if( pCmdItem != NULL )
- {
- pNodeParent->SetTextInMenu(
- pNode->GetTextInMenu( pCmdItem, true )
- );
- pNodeParent->SetTextInToolbar(
- pNode->GetTextInToolbar( pCmdItem, true )
- );
- } // if( pCmdItem != NULL )
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- }
- } // if( pNodeParent != NULL )
- } // if( ( pNode->GetFlags() & (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) ) == 0 )
- } // if( mi.IsExecutableCmdID() )
- else if( ( pNode->GetFlags() & (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) ) == (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) )
- {
- _EndSequence();
- COLORREF clr;
- if( pSite->OnColorItemValueGet(
- NULL,
- pNode,
- clr,
- true
- )
- )
- pSite->OnColorItemValueSet(
- NULL,
- pNode,
- clr,
- true
- );
- return;
- } // else if( ( pNode->GetFlags() & (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) ) == (__ECTN_TBB_COLOR|__ECTN_TBB_SEPARATED_DROPDOWN) )
- } // if( pNode != NULL && pSite != NULL )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- _EndSequence( mi.GetCmdID(), mi.GetCmdReceiver() );
- }
- void CExtPopupMenuWnd::_EndSequence(
- UINT nCmdID, // = 0
- HWND hWndDeliver // = NULL
- )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID( this );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _KeyTipsShow( false );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL );
- bool bCustomizeMode = _FindCustomizeMode();
- if( (! _IsFadeOutAnimation() )
- && m_ctrlShadow.GetSafeHwnd() != NULL
- )
- m_ctrlShadow.DestroyWindow();
- #ifdef _DEBUG
- if( hWndDeliver != NULL )
- {
- ASSERT( ::IsWindow(hWndDeliver) );
- }
- #endif // _DEBUG
- ASSERT( m_hWndCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndCmdReceiver) );
- CExtPopupMenuSite & _site = GetSite();
- UINT * lpnResultCmdID = _site.GetTargetCmdIdPtr();
- if( lpnResultCmdID != NULL )
- *lpnResultCmdID = nCmdID;
- DWORD dwTrackFlags = TrackFlagsGet();
- CExtCmdItem * pCmdItem = NULL;
- if( nCmdID > 0 && ((dwTrackFlags&TPMX_NO_WM_COMMAND)==0) )
- {
- pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWndCmdReceiver ),
- nCmdID
- );
- //ASSERT( pCmdItem != NULL );
- } // if( nCmdID > 0 && ((dwTrackFlags&TPMX_NO_WM_COMMAND)==0) )
- CExtPopupMenuWnd * pTopPopup = _site.GetInstance();
- ASSERT_VALID( pTopPopup );
- HWND hWndTopPopup = pTopPopup->GetSafeHwnd();
- ASSERT(
- hWndTopPopup != NULL
- && ::IsWindow( hWndTopPopup )
- );
- if( hWndDeliver == NULL )
- hWndDeliver = m_hWndCmdReceiver;
- CWnd * pTopLevelParent = GetTopLevelParent();
- HWND hWndTopLevelParent = pTopLevelParent->GetSafeHwnd();
- CRect rcBkUpdate( 0, 0, 0, 0 );
- // hide all sequence
- bool bFadeOut = _IsFadeOutAnimation();
- if( ! bFadeOut )
- {
- CExtPopupMenuWnd * pPopup = this;
- for( ; pPopup != NULL; pPopup = pPopup->m_pWndParentMenu )
- {
- ASSERT_VALID( pPopup );
- ASSERT( pPopup->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( pPopup->GetSafeHwnd() ) );
- CRect rcPopup;
- pPopup->GetWindowRect( &rcPopup );
- if( rcBkUpdate.IsRectEmpty() )
- rcBkUpdate = rcPopup;
- else
- {
- CRect rcPrev( rcBkUpdate );
- rcBkUpdate.UnionRect( &rcPrev, &rcPopup );
- }
- CExtPopupMenuTipWnd & _tipWnd = pPopup->GetTip();
- if( _tipWnd.GetSafeHwnd() != NULL
- && ::IsWindow( _tipWnd.GetSafeHwnd() )
- && _tipWnd.IsWindowVisible()
- )
- {
- CRect rcToolTip;
- _tipWnd.GetWindowRect( &rcToolTip );
- CRect rcPrev( rcBkUpdate );
- rcBkUpdate.UnionRect( &rcPrev, &rcToolTip );
- }
- pPopup->ShowWindow( SW_HIDE );
- } // for( ; pPopup != NULL; pPopup = pPopup->m_pWndParentMenu )
- if( ! g_PaintManager.m_bIsWin2000orLater )
- CExtPaintManager::stat_PassPaintMessages();
- // allow bottom windows repaint
- if( !rcBkUpdate.IsRectEmpty()
- && hWndTopLevelParent != NULL
- && ::IsWindow(hWndTopLevelParent)
- )
- {
- ::ScreenToClient(
- hWndTopLevelParent, (LPPOINT)&rcBkUpdate);
- ::ScreenToClient(
- hWndTopLevelParent, ((LPPOINT)&rcBkUpdate)+1
- );
- }
- } // if( ! bFadeOut )
- if( m_hWndNotifyMenuClosed != NULL
- && ::IsWindow( m_hWndNotifyMenuClosed )
- )
- ::SendMessage(
- m_hWndNotifyMenuClosed,
- g_nMsgNotifyMenuClosed,
- WPARAM(nCmdID),
- LPARAM( this )
- );
- // top popup (and all children) finally must be closed
- if( ! bFadeOut )
- {
- if( ::IsWindow( hWndTopPopup ) )
- ::PostMessage( hWndTopPopup, WM_CLOSE, 0, 0 );
- CExtToolControlBar::_CloseCustomMenusAll();
- if( CExtToolControlBar::g_bMenuTracking )
- CExtToolControlBar::_CloseTrackingMenus();
- } // if( ! bFadeOut )
- bool bOwnWindowDestroyed = ::IsWindow( hWndOwn ) ? false : true;
- if( ::IsWindow( hWndDeliver )
- && ( bOwnWindowDestroyed || (! bCustomizeMode ) )
- )
- {
- if( pCmdItem != NULL )
- {
- // if command target still exists -> deliver command to it
- if( (dwTrackFlags&TPMX_NO_WM_COMMAND)==0 )
- {
- if( ! bFadeOut )
- _site.DoneInstance();
- VERIFY( pCmdItem->Deliver( hWndDeliver ) );
- }
- } // if( pCmdItem != NULL )
- else
- {
- if( (! bOwnWindowDestroyed )
- && bFadeOut
- && m_nCurIndex >= 0
- && ItemGetInfo( m_nCurIndex ).IsPopup()
- )
- {
- CExtPopupMenuWnd * pPopup = ItemGetInfo( m_nCurIndex ).GetPopup();
- if( pPopup->GetSafeHwnd() != NULL )
- {
- INT nSaved = pPopup->m_nFadeOutAnimationStepCount;
- if( nCmdID == 0 )
- pPopup->m_nFadeOutAnimationStepCount = -1;
- pPopup->_EndSequence( nCmdID, hWndDeliver );
- pPopup->m_nFadeOutAnimationStepCount = nSaved;
- return;
- }
- }
- if( (dwTrackFlags&TPMX_NO_WM_COMMAND) == 0
- && nCmdID != 0
- )
- ::PostMessage(
- hWndDeliver,
- WM_COMMAND,
- WPARAM(nCmdID),
- 0L
- );
- } // else from if( pCmdItem != NULL )
- g_SoundPlayer->PlaySound( CExtSoundPlayer::__ON_MENU_CMD_CLICKED );
- } // if( pCmdItem != NULL && ...
- if( bOwnWindowDestroyed )
- return;
- if( bFadeOut )
- DestroyWindow();
- else
- _site.DoneInstance();
- }
- void CExtPopupMenuWnd::OnMouseMove(UINT nFlags, CPoint point)
- {
- nFlags;
- point;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (!_FindCustomizeMode()) )
- return;
- int nIndex = _HitTest( point );
- if( nIndex >= 0 )
- return;
- if( nIndex == IDX_SCROLL_TOP
- || nIndex == IDX_SCROLL_BOTTOM
- )
- {
- HWND hWndOwn = m_hWnd;
- _StartScrolling( nIndex );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtPopupMenuWnd::OnLButtonDown(UINT nFlags, CPoint point)
- {
- nFlags;
- point;
- if( _IsResizingMode() )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (!_FindCustomizeMode()) )
- return;
- int nIndex = _HitTest( point );
- if( nIndex < 0 )
- return;
- ASSERT( nIndex < ItemGetCount() );
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( mi.IsSeparator() )
- return;
- CExtCustomizeSite * pSite = _FindCustomizeSite();
- ASSERT( pSite != NULL );
- CExtCustomizeCmdTreeNode * pClickedCmdNode = mi.GetCmdNode();
- if( pClickedCmdNode == NULL )
- return;
- ASSERT_VALID( pClickedCmdNode );
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( mi.IsSelected()
- && (pClickedCmdNode->GetFlags() & __ECTN_TBB_RESIZABLE) != 0
- )
- { // if button can be resized
- int nDdWidth = PmBridge_GetPM()->GetDropDividerMerics().cx / 2;
- if( nDdWidth < 2 )
- nDdWidth = 2;
- CRect rcItem( 0, 0, 0, 0 );
- _GetItemRect( nIndex, rcItem );
- CRect rcH( rcItem );
- rcH.right = rcH.left + nDdWidth;
- int nInitialResizingStateH = 0;
- if( rcH.PtInRect(point) )
- nInitialResizingStateH = -1;
- else
- {
- rcH = rcItem;
- rcH.left = rcH.right - nDdWidth;
- if( rcH.PtInRect(point) )
- nInitialResizingStateH = 1;
- } // else from if( rcH.PtInRect(point) )
- if( nInitialResizingStateH != 0 )
- {
- int nWidthMin = 0, nWidthMax = 0;
- pSite->OnGetCmdItemMinMaxSizeH(
- NULL,
- pClickedCmdNode,
- &nWidthMin,
- &nWidthMax
- );
- CRect rcInplaceEdit =
- mi.AdjustInplaceEditRect(
- rcItem,
- OnQueryLayoutRTL()
- );
- rcInplaceEdit.top = rcItem.top;
- rcInplaceEdit.bottom = rcItem.bottom;
- INT nDD = PmBridge_GetPM()->GetDropDownButtonWidth( this );
- if( mi.IsPopup() )
- rcInplaceEdit.right += nDD;
- if( !pSite->OnCmdNodeResizeH(
- nInitialResizingStateH,
- m_hWnd,
- NULL,
- pClickedCmdNode,
- nWidthMin,
- nWidthMax,
- rcInplaceEdit // rcItem
- )
- )
- return; // resizing is canceled
- // if( nDD != 0 )
- // pClickedCmdNode->TextFieldWidthSet(
- // pClickedCmdNode->TextFieldWidthGet() - nDD
- // );
- int nSavedIndex = m_nCurIndex;
- m_nCurIndex = -1;
- _BuildItems( NULL, m_bTopLevel );
- VERIFY( UpdateFromCmdTree( m_hWndCmdReceiver, m_pNode, m_bTopLevel ) );
- _SyncItems();
- ShowWindow( SW_HIDE );
- _RecalcLayoutImpl();
- VERIFY( SetWindowRgn( NULL, FALSE ) );
- ASSERT( !IsWindowVisible() );
- _FreeWinObjects();
- // adjust screen position
- CRect rcWnd = _CalcTrackRect();
- 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 )
- SetWindowPos(
- NULL,
- rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(),
- SWP_NOACTIVATE
- |SWP_NOZORDER //|SWP_NOOWNERZORDER
- );
- if( m_bScrollingAvailable )
- _RecalcLayoutImpl();
- ShowWindow( SW_SHOWNA );
- UpdateWindow();
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet( nSavedIndex, FALSE, FALSE, FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- ASSERT( m_pDragSrcNode == NULL );
- m_pDragSrcNode = pClickedCmdNode;
- CClientDC dc( this );
- _DoPaint( dc );
- m_pDragSrcNode = NULL;
- return;
- } // if( nInitialResizingStateH != 0 )
- } // if button can be resized
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- ASSERT( m_pDragSrcNode == NULL );
- ASSERT( m_nDragSrcIdx < 0 );
- m_pDragSrcNode = pClickedCmdNode;
- m_nDragSrcIdx = nIndex;
- m_bHelperNoRemoveSrc = false;
- CRect rcItem( 0, 0, 1, 1 );
- _DoResetChainPositions();
- m_ptHelperDragStart = point;
- m_bHelperNoHideChild = true;
- m_bHelperDragOverPassed = false;
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet( nIndex, TRUE, TRUE, FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- if( ! CExtControlBar::stat_DoDragDetect( hWndOwn, point ) )
- {
- m_pDragSrcNode = NULL;
- m_bHelperNoHideChild = false;
- m_nDragSrcIdx = -1;
- m_bHelperNoRemoveSrc = false;
- m_bHelperDragOverPassed = false;
- return;
- }
- pSite->DoDragCmdNode(
- this,
- NULL,
- m_pDragSrcNode,
- rcItem
- );
- if( ! ::IsWindow(hWndOwn) )
- return;
- m_pDragSrcNode = NULL;
- m_bHelperNoHideChild = false;
- m_nDragSrcIdx = -1;
- m_bHelperNoRemoveSrc = false;
- m_bHelperDragOverPassed = false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtPopupMenuWnd::OnRButtonDown(UINT nFlags, CPoint point)
- {
- nFlags;
- point;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( (!_FindCustomizeMode()) )
- return;
- int nIndex = _HitTest( point );
- if( nIndex < 0 )
- return;
- ASSERT( nIndex < ItemGetCount() );
- MENUITEMDATA & mi = ItemGetInfo( nIndex );
- if( mi.IsSeparator() )
- return;
- HWND hWndOwn = m_hWnd;
- _ItemFocusSet( mi.GetIndex(), TRUE, TRUE, FALSE );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtCustomizeCmdTreeNode * pNode = mi.GetCmdNode();
- ASSERT_VALID( pNode );
- CExtCustomizeSite * pSite = _FindCustomizeSite();
- ASSERT( pSite != NULL );
- CRect rcItem( 0, 0, 1, 1 );
- _DoResetChainPositions();
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd(m_hWnd),
- pNode->GetCmdID( false )
- );
- ASSERT( pCmdItem != NULL );
- if( !pSite->CustomizedNodeSet( pNode ) )
- return;
- { // BLOCK
- CClientDC dc( this );
- _DoPaint( dc );
- } // BLOCK
- bool bCanAddRemoveSeparator = (nIndex > 0) ? true : false;
- bool bDelete = false;
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- if( !pSite->OnCustomizeTreeNode(
- NULL,
- pNode,
- pCmdItem,
- bDelete,
- bCanAddRemoveSeparator,
- this
- )
- )
- {
- if( pSite->CustomizedNodeGet() == pNode )
- {
- VERIFY( pSite->CustomizedNodeSet( NULL ) );
- }
- if( hWndOwn == NULL
- || (! ::IsWindow(hWndOwn) )
- )
- return;
- CClientDC dc( this );
- _DoPaint( dc );
- return;
- }
- VERIFY( pSite->CustomizedNodeSet( NULL ) );
- if( !::IsWindow(hWndOwn) )
- return;
-
- m_nCurIndex = -1;
- _BuildItems( NULL, m_bTopLevel );
- if( bDelete )
- {
- ASSERT_VALID( pNode->GetParentNode() );
- int nOwnNodeIndex = pNode->GetOwnIndex();
- if( nOwnNodeIndex < (pNode->GetParentNode()->GetNodeCount()-1) )
- pNode->GetParentNode()->ElementAt(nOwnNodeIndex+1)
- ->ModifyFlags( 0, __ECTN_GROUP_START );
- pNode->RemoveSelf( pCmdItem );
- }
- ASSERT_VALID( m_pNode );
- VERIFY( UpdateFromCmdTree( m_hWndCmdReceiver, m_pNode, m_bTopLevel ) );
- _SyncItems();
- ShowWindow( SW_HIDE );
- _RecalcLayoutImpl();
- VERIFY( SetWindowRgn( NULL, FALSE ) );
- ASSERT( !IsWindowVisible() );
- _FreeWinObjects();
- // adjust screen position
- CRect rcWnd = _CalcTrackRect();
- 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 )
- SetWindowPos(
- NULL,
- rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(),
- SWP_NOACTIVATE
- |SWP_NOZORDER //|SWP_NOOWNERZORDER
- );
- if( m_bScrollingAvailable )
- _RecalcLayoutImpl();
- ShowWindow( SW_SHOWNA );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- }
- void CExtPopupMenuWnd::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- ASSERT_VALID( this );
- HWND hWndThis = m_hWnd;
- CExtPopupBaseWnd::OnShowWindow(bShow, nStatus);
- if( ! ::IsWindow(hWndThis) )
- return;
- if( _FindCustomizeMode()
- && bShow
- )
- {
- CClientDC dc( this );
- _DoPaint( dc );
- }
- }
- void CExtPopupMenuWnd::OnCancelMode()
- {
- ASSERT_VALID( this );
- if( CExtPopupMenuWnd::TEAROFFNOTIFICATON::g_pCurrentTEAROFFNOTIFICATON != NULL )
- return;
- if( _FindCustomizeMode() )
- return;
- TrackFlagsSet( TrackFlagsGet() | TPMX_NO_FADE_OUT_ANIMATION );
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL );
- if( (TrackFlagsGet()&TPMX_NO_SITE) == 0
- && (! m_bHelperAnimationControllerDetected )
- )
- {
- CExtPopupMenuSite & _site = GetSite();
- if( _site.GetInstance() == this )
- _site.DoneInstance();
- // ASSERT( _site.IsEmpty() );
- // ASSERT( !_site.IsShutdownMode() );
- }
- if( ( ! ::IsWindow( hWndOwn ) )
- // || ( ! _IsFadeOutAnimation() )
- )
- {
- CExtToolControlBar::_CloseCustomMenusAll();
- if( CExtToolControlBar::g_bMenuTracking )
- CExtToolControlBar::_CloseTrackingMenus();
- }
- }
- void CExtPopupMenuWnd::_FreeWinObjects()
- {
- ASSERT_VALID( this );
- if( m_rgnWnd.GetSafeHandle() != NULL )
- {
- VERIFY(
- m_rgnWnd.DeleteObject()
- );
- }
- m_ShadowMain.Destroy();
- m_ShadowCMBA.Destroy();
- _SurfacesDelete();
- if( !(::IsWindow(GetSafeHwnd())) )
- return;
- KillTimer(ID_TIMER_ANIMATION);
- //KillTimer(ID_TIMER_DELAY_SHOW);
- //KillTimer(ID_TIMER_ITEM_FOCUS_DELAY);
- //KillTimer(ID_TIMER_ITEM_HIDE_DELAY);
- //KillTimer(ID_TIMER_SCROLLING);
- //m_nAcceleratedPixelsPerStepCurrent = __SCROLLING_PIXEL_STEP;
- //m_nAcceleratedMilliSecondsPassed = 0;
- //KillTimer(ID_TIMER_DELAY_KILL);
- //KillTimer(ID_TIMER_LIFE_STEP);
- }
- void CExtPopupMenuWnd::_OnCancelMode(
- bool bNcDestroy // = false
- )
- {
- ASSERT_VALID( this );
- // update status bar message
- CExtControlBar::stat_SetMessageString(
- GetSafeOwner()
- );
- bool bCusomizeMode = _FindCustomizeMode();
- if( ! bCusomizeMode )
- {
- HWND hWndOwn = m_hWnd;
- _CoolTipHide( false );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- _FreeWinObjects();
- _ReleaseCapture();
- } // if( !bCusomizeMode )
- INT iter = 0;
- for( ; iter < m_items_all.GetSize(); iter++ )
- {
- MENUITEMDATA & mi = ItemGetInfo( iter );
- mi.SetSelected( false );
- if( mi.IsPopup() )
- {
- if( mi.GetPopup()->GetSafeHwnd() != NULL )
- mi.GetPopup()->_OnCancelMode();
- }
- }
- m_nCurIndex = m_nLastMousePick = IDX_NOTHING;
- if( bNcDestroy )
- return;
- HWND hWndOwn = GetSafeHwnd();
- if( ! ::IsWindow( hWndOwn ) )
- return;
- // if( ( GetStyle() & WS_VISIBLE ) == 0 )
- // return;
- bool bFadeOut = _IsFadeOutAnimation();
- bool bTopLevel = m_bTopLevel;
- if( ! bFadeOut )
- {
- if( m_ctrlShadow.GetSafeHwnd() != NULL
- && (m_ctrlShadow.GetStyle()&WS_VISIBLE)
- )
- m_ctrlShadow.ShowWindow( SW_HIDE );
- ShowWindow( SW_HIDE );
- }
- if( ! bCusomizeMode )
- {
- HWND hWndOwn = m_hWnd;
- _ItemFocusDelay();
- if( ! ::IsWindow( hWndOwn ) )
- return;
- // INT nSaved = m_nFadeOutAnimationStepCount;
- // m_nFadeOutAnimationStepCount = -1;
- DestroyWindow();
- // m_nFadeOutAnimationStepCount = nSaved;
- } // if( ! bCusomizeMode )
- if( CExtToolControlBar::g_bMenuTracking
- && bTopLevel
- && ( ! bCusomizeMode )
- && ( ! bFadeOut )
- )
- {
- CExtToolControlBar::_CloseCustomMenusAll();
- CExtToolControlBar::_CloseTrackingMenus();
- }
- }
- const UINT CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonInvocation =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonInvocation")
- );
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONINVOCATION::RIBBONFILEMENUBUTTONINVOCATION(
- DWORD dwButtonType,
- CExtPopupMenuWnd * pPopup
- )
- : m_dwButtonType( dwButtonType )
- , m_hWndTarget1( NULL )
- , m_hWndTarget2( NULL )
- , m_bQueryHandled( false )
- {
- ASSERT_VALID( pPopup );
- m_hWndTarget1 = pPopup->GetCmdReceiverHWND();
- m_hWndTarget2 = pPopup->m_hWndNotifyMenuClosed;
- }
- bool CExtPopupMenuWnd::RIBBONFILEMENUBUTTONINVOCATION::Notify()
- {
- m_bQueryHandled = false;
- if( m_hWndTarget1 != NULL
- && ::IsWindow( m_hWndTarget1 )
- )
- {
- ::SendMessage(
- m_hWndTarget1,
- CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonInvocation,
- *this,
- 0L
- );
- if( m_bQueryHandled )
- return true;
- }
- if( m_hWndTarget2 != NULL
- && ::IsWindow( m_hWndTarget2 )
- )
- {
- ::SendMessage(
- m_hWndTarget2,
- CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonInvocation,
- *this,
- 0L
- );
- if( m_bQueryHandled )
- return true;
- }
- return false;
- }
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONINVOCATION::operator WPARAM() const
- {
- return WPARAM( this );
- }
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONINVOCATION * CExtPopupMenuWnd::RIBBONFILEMENUBUTTONINVOCATION::FromWPARAM( WPARAM wParam )
- {
- RIBBONFILEMENUBUTTONINVOCATION * pICN =
- reinterpret_cast < RIBBONFILEMENUBUTTONINVOCATION * > ( wParam );
- ASSERT( pICN != NULL );
- return pICN;
- }
- const UINT CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonQuery =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonQuery")
- );
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONQUERY::RIBBONFILEMENUBUTTONQUERY(
- CExtPopupMenuWnd * pPopup,
- DWORD dwButtonType,
- CDC * pDC // = NULL
- )
- : m_pPopup( pPopup )
- , m_dwButtonType( dwButtonType )
- , m_pDC( pDC )
- , m_nMeasuredWidth( 0 )
- , m_rcButton( 0, 0, 0, 0 )
- , m_bHover( false )
- , m_bPressed( false )
- , m_bQueryHandled( false )
- {
- }
- bool CExtPopupMenuWnd::RIBBONFILEMENUBUTTONQUERY::Notify()
- {
- if( m_pPopup == NULL )
- return false;
- ASSERT_VALID( m_pPopup );
- m_bQueryHandled = false;
- HWND hWndTarget = m_pPopup->GetCmdReceiverHWND();
- if( hWndTarget == NULL
- || (! ::IsWindow( hWndTarget ) )
- )
- {
- ::SendMessage(
- hWndTarget,
- CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonQuery,
- *this,
- 0L
- );
- if( m_bQueryHandled )
- return true;
- }
- hWndTarget = m_pPopup->m_hWndNotifyMenuClosed;
- if( hWndTarget == NULL
- || (! ::IsWindow( hWndTarget ) )
- )
- return false;
- ::SendMessage(
- hWndTarget,
- CExtPopupMenuWnd::g_nMsgRibbonFileMenuButtonQuery,
- *this,
- 0L
- );
- return m_bQueryHandled;
- }
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONQUERY::operator WPARAM() const
- {
- return WPARAM( this );
- }
- CExtPopupMenuWnd::RIBBONFILEMENUBUTTONQUERY * CExtPopupMenuWnd::RIBBONFILEMENUBUTTONQUERY::FromWPARAM( WPARAM wParam )
- {
- RIBBONFILEMENUBUTTONQUERY * pICN =
- reinterpret_cast < RIBBONFILEMENUBUTTONQUERY * > ( wParam );
- ASSERT( pICN != NULL );
- return pICN;
- }
- const UINT CExtPopupMenuWnd::g_nMsgItemCoveringNotification =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgItemCoveringNotification")
- );
- const UINT CExtPopupMenuWnd::g_nMsgTearOff =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgTearOff")
- );
- const UINT CExtPopupMenuWnd::g_nMsgCustomFloatPos =
- ::RegisterWindowMessage(
- _T("CExtPopupMenuWnd::g_nMsgCustomFloatPos")
- );
- CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::ITEMCOVERINGNOTIFICATON(
- CExtPopupMenuWnd * pPopup,
- CExtBarButton * pTBB,
- CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::eICN_t eICN,
- INT nPopupItemIndex, // = -1
- bool bEnableDropChild, // = false
- bool bSelectAnyInChild // = false
- )
- : m_pPopup( pPopup )
- , m_pTBB( pTBB )
- , m_nPopupItemIndex( nPopupItemIndex )
- , m_eICN( eICN )
- , m_bEnableDropChild( bEnableDropChild )
- , m_bSelectAnyInChild( bSelectAnyInChild )
- , m_bSuspendTips( false )
- {
- #ifdef _DEBUG
- if( m_pPopup != NULL )
- {
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pTBB == NULL );
- INT nPopupItemCount = m_pPopup->ItemGetCount();
- ASSERT( 0 <= m_nPopupItemIndex && m_nPopupItemIndex <= nPopupItemCount );
- ASSERT(
- m_eICN == __EICN_CANCEL
- || m_eICN == __EICN_SET
- || m_eICN == __EICN_DELAY
- );
- } // if( m_pPopup != NULL )
- else
- {
- ASSERT( m_pPopup == NULL );
- ASSERT_VALID( m_pTBB );
- ASSERT( m_nPopupItemIndex == -1 );
- ASSERT( m_bEnableDropChild == false );
- ASSERT( m_bSelectAnyInChild == false );
- ASSERT(
- m_eICN == __EICN_CANCEL
- || m_eICN == __EICN_SET
- );
- CExtToolControlBar * pToolBar = m_pTBB->GetBar();
- ASSERT_VALID( pToolBar );
- } // else from if( m_pPopup != NULL )
- #endif // _DEBUG
- }
- bool CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::Notify()
- {
- if( m_pPopup != NULL )
- {
- ASSERT_VALID( m_pPopup );
- ASSERT( m_pTBB == NULL );
- #ifdef _DEBUG
- INT nPopupItemCount = m_pPopup->ItemGetCount();
- ASSERT( 0 <= m_nPopupItemIndex && m_nPopupItemIndex <= nPopupItemCount );
- #endif // _DEBUG
- ASSERT(
- m_eICN == __EICN_CANCEL
- || m_eICN == __EICN_SET
- || m_eICN == __EICN_DELAY
- );
- HWND hWndTarget = m_pPopup->GetCmdReceiverHWND();
- if( hWndTarget == NULL
- || (! ::IsWindow( hWndTarget ) )
- )
- return false;
- if( m_pPopup->_FindHelpMode()
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- || m_pPopup->_FindCustomizeMode()
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- )
- return false;
- //
- // CWnd * pWndTarget = CWnd::FromHandle( hWndTarget );
- // CString strTrace;
- // strTrace.Format(
- // " popup menu item covering notification to "%s" class, %d - code, %d - item index, id=%dn",
- // pWndTarget->GetRuntimeClass()->m_lpszClassName,
- // int(m_eICN),
- // m_nPopupItemIndex,
- // m_pPopup->ItemGetInfo(m_nPopupItemIndex).GetCmdID()
- // );
- // TRACE( LPCSTR(strTrace) );
- //
- ::SendMessage(
- hWndTarget,
- CExtPopupMenuWnd::g_nMsgItemCoveringNotification,
- *this,
- 0L
- );
- return true;
- } // if( m_pPopup != NULL )
- else
- {
- ASSERT( m_pPopup == NULL );
- ASSERT_VALID( m_pTBB );
- ASSERT( m_nPopupItemIndex == -1 );
- ASSERT( m_bEnableDropChild == false );
- ASSERT( m_bSelectAnyInChild == false );
- ASSERT(
- m_eICN == __EICN_CANCEL
- || m_eICN == __EICN_SET
- );
- CExtToolControlBar * pToolBar = m_pTBB->GetBar();
- ASSERT_VALID( pToolBar );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( pToolBar->_IsDockSiteCustomizeMode() )
- return false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- HWND hWndTarget = NULL;
- if( pToolBar->m_pDockSite != NULL )
- {
- ASSERT_VALID( pToolBar->m_pDockSite );
- hWndTarget = pToolBar->m_pDockSite->GetSafeHwnd();
- if( hWndTarget != NULL
- && pToolBar->m_pDockSite->m_bHelpMode
- )
- return false;
- }
- if( hWndTarget == NULL )
- hWndTarget = pToolBar->GetParent()->GetSafeHwnd();
- if( hWndTarget == NULL
- || (! ::IsWindow( hWndTarget ) )
- )
- return false;
- //
- // CWnd * pWndTarget = CWnd::FromHandle( hWndTarget );
- // CString strTrace;
- // strTrace.Format(
- // " toolbar item covering notification: "%s" class, %d - code, id=%dn",
- // pWndTarget->GetRuntimeClass()->m_lpszClassName,
- // int(m_eICN),
- // m_pTBB->GetCmdID( true )
- // );
- // TRACE( LPCSTR(strTrace) );
- //
- ::SendMessage(
- hWndTarget,
- CExtPopupMenuWnd::g_nMsgItemCoveringNotification,
- *this,
- 0L
- );
- return true;
- } // else from if( m_pPopup != NULL )
- }
- CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::operator WPARAM() const
- {
- return WPARAM( this );
- }
- CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON *
- CExtPopupMenuWnd::ITEMCOVERINGNOTIFICATON::FromWPARAM( WPARAM wParam )
- {
- ITEMCOVERINGNOTIFICATON * pICN =
- reinterpret_cast < ITEMCOVERINGNOTIFICATON * > ( wParam );
- ASSERT( pICN != NULL );
- return pICN;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupMenuWnd::_KeyTipsEnabledGet() const
- {
- ASSERT_VALID( this );
- if( ( TrackFlagsGet() & TPMX_RIBBON_KEYTIPS ) != 0 )
- return true;
- const CExtPopupMenuWnd * pParent = GetParentMenuWnd();
- if( pParent != NULL )
- return pParent->_KeyTipsEnabledGet();
- return false;
- }
- void CExtPopupMenuWnd::_KeyTipsShow( bool bShow )
- {
- ASSERT_VALID( this );
- if( ! _KeyTipsEnabledGet() )
- return;
- if( _FindCustomizeMode() )
- return;
- if( _FindHelpMode() )
- return;
- HDWP hPassiveModeDWP = NULL;
- if( bShow
- // && g_PaintManager.m_bIsWinVistaOrLater
- // && g_PaintManager.m_DWM.IsCompositionEnabled()
- )
- hPassiveModeDWP = ::BeginDeferWindowPos( 64 );
- visible_items_t v;
- { // block for DC
- CWindowDC dcDesktop( NULL );
- _GetVisibleItems( dcDesktop.GetSafeHdc(), v );
- } // block for DC
- INT vis_iter, vis_count = INT( v.GetSize() );
- for( vis_iter = 0; vis_iter < vis_count; vis_iter++ )
- {
- VisibleItemDefinition_t & vi = v[ vis_iter ];
- ASSERT(
- vi.m_nIndex >= 0
- && vi.m_nIndex < m_items_all.GetSize()
- );
- ASSERT( !vi.m_rcItem.IsRectEmpty() );
- ASSERT( !vi.m_rcItemWithIndents.IsRectEmpty() );
- MENUITEMDATA & mi = ItemGetInfo( vi.m_nIndex );
- ASSERT( mi.IsDisplayed() );
- ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
- mi.KeyTipTrackingQuery( bShow, &m_keyTipChain, hPassiveModeDWP );
- } // for( vis_iter = 0; vis_iter < vis_count; vis_iter++ )
- if( ! bShow )
- m_keyTipChain.KeyCodeRemoveAll();
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_RIBBON_OPTIONS_BUTTON) != 0
- && m_keyTipOptionsButton.KeyCodeGetCount() > 0
- )
- {
- if( bShow )
- {
- if( m_keyTipOptionsButton.KeyCodeGetCount() > 0 )
- {
- if( m_wndKeyTipOptionsButton.GetSafeHwnd() == NULL )
- {
- CExtSafeString strKeyTipText = m_keyTipOptionsButton.GetTipText();
- ASSERT( ! strKeyTipText.IsEmpty() );
- CRect rc;
- _GetItemRect( IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON, rc, false );
- ClientToScreen( &rc );
- CPoint ptGuideLines(
- rc.left + ( rc.Width() / 2 ),
- rc.bottom
- );
- if( m_wndKeyTipOptionsButton.Create(
- this,
- ptGuideLines,
- strKeyTipText,
- true,
- hPassiveModeDWP
- )
- )
- m_wndKeyTipOptionsButton.ShowWindow( SW_SHOWNOACTIVATE );
- }
- else
- m_wndKeyTipOptionsButton.ShowWindow( SW_SHOWNOACTIVATE );
- }
- }
- else
- m_wndKeyTipOptionsButton.Hide();
- }
- if( (dwTrackFlags&TPMX_RIBBON_EXIT_BUTTON) != 0
- && m_keyTipExitButton.KeyCodeGetCount() > 0
- )
- {
- if( bShow )
- {
- if( m_keyTipExitButton.KeyCodeGetCount() > 0 )
- {
- if( m_wndKeyTipExitButton.GetSafeHwnd() == NULL )
- {
- CExtSafeString strKeyTipText = m_keyTipExitButton.GetTipText();
- ASSERT( ! strKeyTipText.IsEmpty() );
- CRect rc;
- _GetItemRect( IDX_RIBBON_FILE_MENU_EXIT_BUTTON, rc, false );
- ClientToScreen( &rc );
- CPoint ptGuideLines(
- rc.left + ( rc.Width() / 2 ),
- rc.bottom
- );
- if( m_wndKeyTipExitButton.Create(
- this,
- ptGuideLines,
- strKeyTipText,
- true,
- hPassiveModeDWP
- )
- )
- m_wndKeyTipExitButton.ShowWindow( SW_SHOWNOACTIVATE );
- }
- else
- m_wndKeyTipExitButton.ShowWindow( SW_SHOWNOACTIVATE );
- }
- }
- else
- m_wndKeyTipExitButton.Hide();
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( hPassiveModeDWP != NULL )
- {
- ::EndDeferWindowPos( hPassiveModeDWP );
- CExtPaintManager::stat_PassPaintMessages();
- }
- if( bShow )
- CExtPopupMenuTipWnd::UpdateDelayedLayeredBehaviorAll();
- }
- bool CExtPopupMenuWnd::_KeyTipsTranslate(
- DWORD dwKeyCode,
- INT * p_nIndex // = NULL
- )
- {
- ASSERT_VALID( this );
- if( p_nIndex != NULL )
- (*p_nIndex) = -1;
- HWND hWndOwn = GetSafeHwnd();
- if( hWndOwn == NULL
- || ( ! ::IsWindow( hWndOwn ) )
- )
- return false;
- if( ! _KeyTipsEnabledGet() )
- return false;
- if( _GetCapture() != this )
- return false;
- if( _FindCustomizeMode() )
- return false;
- if( _FindHelpMode() )
- return false;
- visible_items_t v;
- { // block for DC
- CWindowDC dcDesktop( NULL );
- _GetVisibleItems( dcDesktop.GetSafeHdc(), v );
- } // block for DC
- INT vis_iter, vis_count = INT( v.GetSize() );
- for( vis_iter = 0; vis_iter < vis_count; vis_iter++ )
- {
- VisibleItemDefinition_t & vi = v[ vis_iter ];
- ASSERT(
- vi.m_nIndex >= 0
- && vi.m_nIndex < m_items_all.GetSize()
- );
- ASSERT( !vi.m_rcItem.IsRectEmpty() );
- ASSERT( !vi.m_rcItemWithIndents.IsRectEmpty() );
- MENUITEMDATA & mi = ItemGetInfo( vi.m_nIndex );
- ASSERT( mi.IsDisplayed() );
- ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
- INT nIndexOf = ItemGetIndexOf( &mi );
- if( mi.KeyTipTranslate( dwKeyCode, &m_keyTipChain ) )
- {
- if( p_nIndex != NULL )
- (*p_nIndex) = nIndexOf;
- return true;
- }
- } // for( vis_iter = 0; vis_iter < vis_count; vis_iter++ )
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- INT nKTI, nKeyCodeCountChain = m_keyTipChain.KeyCodeGetCount();
- for( nKTI = 0; nKTI < 2; nKTI++ )
- {
- CExtPopupKeyTipWnd & wndKeyTip = ( nKTI == 0 ) ? m_wndKeyTipOptionsButton : m_wndKeyTipExitButton;
- CExtCustomizeCmdKeyTip & keyTipInfo = ( nKTI == 0 ) ? m_keyTipOptionsButton : m_keyTipExitButton;
- if( wndKeyTip.GetSafeHwnd() == NULL
- || ( wndKeyTip.GetStyle() & WS_VISIBLE ) == 0
- )
- continue;
- if( ! keyTipInfo.CompareWidthChain( m_keyTipChain ) )
- continue;
- INT nKeyCodeCountOwn = keyTipInfo.KeyCodeGetCount();
- ASSERT( nKeyCodeCountOwn > nKeyCodeCountChain );
- DWORD dwKeyCodeOwn = keyTipInfo.KeyCodeGetAt( nKeyCodeCountChain );
- if( dwKeyCodeOwn != dwKeyCode )
- continue;
- m_keyTipChain.KeyCodeAdd( dwKeyCode );
- nKeyCodeCountChain++;
- if( nKeyCodeCountOwn > nKeyCodeCountChain )
- continue;
- INT nHitTest = ( nKTI == 0 ) ? IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON : IDX_RIBBON_FILE_MENU_EXIT_BUTTON;
- DWORD dwButtonType = 0;
- switch( nHitTest )
- {
- case IDX_RIBBON_FILE_MENU_OPTIONS_BUTTON:
- dwButtonType = TPMX_RIBBON_OPTIONS_BUTTON;
- break;
- case IDX_RIBBON_FILE_MENU_EXIT_BUTTON:
- dwButtonType = TPMX_RIBBON_EXIT_BUTTON;
- break;
- } // switch( nHitTest )
- RIBBONFILEMENUBUTTONINVOCATION _rfmbi( dwButtonType, this );
- m_nCurIndex = IDX_NOTHING;
- _SetCapture();
- if( nHitTest == IDX_RIBBON_FILE_MENU_EXIT_BUTTON )
- m_dwTrackFlags |= TPMX_NO_FADE_OUT_ANIMATION;
- DestroyWindow();
- _rfmbi.Notify();
- return true;
- } // for( nKTI = 0; nKTI < 2; nKTI++ )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return false;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtPopupMenuWnd::_ItemFocusSet(
- int nCurIndex,
- BOOL bEnableDropChild,
- BOOL bRepaint,
- BOOL bSelectAnyInChild, // = TRUE
- BOOL bDelayHiding // = FALSE // delay hiding previous
- )
- {
- ASSERT_VALID( this );
- HWND hWndOwn = m_hWnd;
- ItemFocusTracker_t _ift( this );
- if( m_nCurIndex != nCurIndex )
- {
- _ItemFocusCancel( FALSE, TRUE, bDelayHiding );
- //ASSERT( m_nCurIndex < 0 );
- m_nCurIndex = nCurIndex;
- if( m_nCurIndex < 0 )
- return;
- ITEMCOVERINGNOTIFICATON _icn(
- this,
- NULL,
- ITEMCOVERINGNOTIFICATON::__EICN_SET,
- m_nCurIndex,
- bEnableDropChild ? true : false,
- bSelectAnyInChild ? true : false
- );
- _icn.Notify();
- m_bSuspendTips = _icn.m_bSuspendTips;
- if( ! ::IsWindow( hWndOwn ) )
- return;
- }
- if( (! bDelayHiding) && bEnableDropChild && nCurIndex >= 0 )
- {
- int nCount = ItemGetCount();
- for( int i = 0; i < nCount; i++ )
- {
- if( i == nCurIndex )
- continue;
- MENUITEMDATA & mii_child = ItemGetInfo( i );
- if( i == nCount )
- continue;
- if( ! mii_child.IsPopup() )
- continue;
- CExtPopupMenuWnd * pChildPopup = mii_child.GetPopup();
- ASSERT_VALID( pChildPopup );
- if( pChildPopup->GetSafeHwnd() == NULL )
- continue;
- INT nSaved = pChildPopup->m_nFadeOutAnimationStepCount;
- pChildPopup->m_nFadeOutAnimationStepCount = -1;
- pChildPopup->_OnCancelMode();
- pChildPopup->m_nFadeOutAnimationStepCount = nSaved;
- if( ! ::IsWindow( hWndOwn ) )
- return;
- }
- KillTimer( ID_TIMER_ITEM_FOCUS_DELAY );
- }
- bool bResetMessageString = true;
- bool bWasSet = false;
- MENUITEMDATA & mi = ItemGetInfo(m_nCurIndex);
- if( mi.IsEnabled() && mi.IsDisplayed() )
- {
- mi.SetSelected( true );
- bWasSet = true;
- // adjust scrolling
- CRect rcMB = OnQueryMenuBorderMetrics();
- if( m_bScrollingAvailable )
- {
- bool bResetRectsCache = false;
- int nMetric;
- int nMaxScrollPos = _GetMaxScrollPos();
- CRect rcItem,rcClient,
- rcScrollBtnUp,rcScrollBtnDown;
- _GetItemRect( IDX_SCROLL_TOP, rcScrollBtnUp );
- _GetItemRect( IDX_SCROLL_BOTTOM, rcScrollBtnDown );
- _GetClientRect( rcClient );
- _GetItemRect( m_nCurIndex, rcItem );
- nMetric = rcClient.bottom;
- if( m_nDyScrollOffset != nMaxScrollPos )
- {
- nMetric -= rcScrollBtnDown.Height();
- if( m_bExpandAvailable )
- {
- CRect rcExpand;
- _GetItemRect( IDX_EXPAND, rcExpand );
- nMetric -= rcExpand.Height();
- }
- }
- if( rcItem.bottom >= nMetric )
- {
- m_nDyScrollOffset -=
- rcItem.bottom
- - nMetric
- + rcMB.top + rcMB.bottom
- ;
- bResetRectsCache = true;
- }
- nMetric = rcClient.top;
- if( m_nDyScrollOffset != 0 )
- {
- nMetric += rcScrollBtnUp.Height();
- }
- if( rcItem.top <= nMetric )
- {
- m_nDyScrollOffset +=
- nMetric
- - rcItem.top
- + rcMB.top + rcMB.bottom
- ;
- bResetRectsCache = true;
- }
- if( m_nDyScrollOffset > 0 )
- {
- m_nDyScrollOffset = 0;
- bResetRectsCache = true;
- }
- else
- {
- if( m_nDyScrollOffset < nMaxScrollPos )
- {
- m_nDyScrollOffset = nMaxScrollPos;
- bResetRectsCache = true;
- }
- }
- if( bResetRectsCache )
- _CachedRectsEmpty();
- } // if( m_bScrollingAvailable )
- } // if( mi.IsEnabled() && mi.IsDisplayed() )
- bool bSetStatusMsg = bWasSet;
- if( (! bSetStatusMsg) && (! mi.IsEnabled() ) && mi.IsDisplayed() && g_bShowStatusTipsOverDisabledItems )
- bSetStatusMsg = true;
- // update status bar message
- CWnd * pWndOwner = GetOwner();
- if( pWndOwner != NULL )
- {
- ASSERT_VALID( pWndOwner );
- if( bSetStatusMsg && (!mi.IsPopup()) && (!mi.IsSeparator()) && (!mi.IsNoCmdUI()) )
- {
- UINT nCmdID = mi.GetCmdID();
- if( CExtCmdManager::IsCommand( nCmdID ) )
- {
- UINT nCmdIDToSend = nCmdID;
- bool bAbandonSend = false;
- if( CExtCmdManager::IsSystemCommand( nCmdID ) )
- {
- switch( nCmdID )
- {
- case SC_CLOSE:
- nCmdIDToSend = AFX_IDS_SCCLOSE;
- break;
- case SC_SIZE:
- nCmdIDToSend = AFX_IDS_SCSIZE;
- break;
- case SC_MOVE:
- nCmdIDToSend = AFX_IDS_SCMOVE;
- break;
- case SC_MINIMIZE:
- nCmdIDToSend = AFX_IDS_SCMINIMIZE;
- break;
- case SC_MAXIMIZE:
- nCmdIDToSend = AFX_IDS_SCMAXIMIZE;
- break;
- case SC_RESTORE:
- nCmdIDToSend = AFX_IDS_SCRESTORE;
- break;
- case SC_NEXTWINDOW:
- nCmdIDToSend = AFX_IDS_SCNEXTWINDOW;
- break;
- case SC_PREVWINDOW:
- nCmdIDToSend = AFX_IDS_SCPREVWINDOW;
- break;
- case SC_TASKLIST:
- nCmdIDToSend = AFX_IDS_SCTASKLIST;
- break;
- default:
- bAbandonSend = true;
- break;
- } // switch( nCmdID )
- } // if( CExtCmdManager::IsSystemCommand( nCmdID ) )
- if( !bAbandonSend )
- {
- CExtControlBar::stat_SetMessageString(
- pWndOwner,
- nCmdIDToSend
- );
- bResetMessageString = false;
- } // if( !bAbandonSend )
- } // if( CExtCmdManager::IsCommand( nCmdID ) )
- } // if( bSetStatusMsg && (!mi.IsPopup()) && (!mi.IsSeparator()) && (!mi.IsNoCmdUI()) )
- if( bResetMessageString )
- CExtControlBar::stat_SetMessageString( pWndOwner );
- } // if( bWasSet )
-
- if( bRepaint && ::IsWindowVisible( GetSafeHwnd() ) )
- {
- CClientDC dc( this );
- _DoPaint( dc );
- } // if( bRepaint && ::IsWindowVisible( GetSafeHwnd() ) )
- if( mi.IsPopup() )
- {
- if( mi.IsInplaceEdit() )
- {
- HWND hWndInplaceEdit = mi.GetInplaceEditPtr()->GetSafeHwnd();
- if( hWndInplaceEdit != NULL
- && ::IsWindow( hWndInplaceEdit )
- && (::__EXT_MFC_GetWindowLong(hWndInplaceEdit,GWL_STYLE)&WS_VISIBLE) != 0
- )
- bEnableDropChild = false;
- } // if( mi.IsInplaceEdit() )
- } // if( mi.IsPopup() )
- else
- bEnableDropChild = false;
- bool bDelayExpanding = true;
- if( bWasSet
- && bEnableDropChild
- && mi.GetPopup()->_CanStartLevelTracking()
- )
- { // if new popup tracking
- if( !_FindCustomizeMode() )
- _ReleaseCapture();
- CRect rectItem;
- _GetItemRect(
- m_nCurIndex,
- rectItem
- );
- rectItem.left -= m_nLeftAreaWidth;
- CPoint point;
- point.x = rectItem.right;
- point.y = rectItem.top,
- ClientToScreen(&point);
- ClientToScreen( &rectItem );
- ASSERT( mi.GetPopup()->m_pWndParentMenu == this );
- bool bDisplayedSuccessfully = false;
- if( mi.GetPopup()->GetSafeHwnd() == NULL )
- {
- DWORD dwChildTrackFlags =
- mi.IsChildCombine() ? TPMX_COMBINE_DEFAULT : 0;
- dwChildTrackFlags |=
- m_dwTrackFlags &
- ( TPMX_NO_SHADOWS
- | TPMX_NO_DYNAMIC_SHADOWS
- | TPMX_NO_CMD_UI
- | TPMX_NO_WM_COMMAND
- | TPMX_RIBBON_MODE
- );
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- _KeyTipsShow( false );
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bDisplayedSuccessfully =
- mi.GetPopup()->
- _TrackPopupMenu(
- dwChildTrackFlags,
- point.x,point.y,
- &rectItem,
- (LPVOID)(__EXT_MFC_INT_PTR)m_nCurIndex,
- stat_paint_combined_menu_toolbtn
- ) ? true : false;
- } // if( mi.GetPopup()->GetSafeHwnd() == NULL )
- else
- {
- bDisplayedSuccessfully = true;
- if( !mi.GetPopup()->IsWindowVisible() )
- {
- mi.GetPopup()->SetWindowPos(
- &CWnd::wndTopMost, 0, 0, 0, 0,
- SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOREDRAW
- |SWP_SHOWWINDOW
- );
- CClientDC dc( mi.GetPopup() );
- mi.GetPopup()->_DoPaint( dc );
- } // if( !mi.GetPopup()->IsWindowVisible() )
- } // else from
- if( bDisplayedSuccessfully && bSelectAnyInChild )
- { // if track-popup succeeded and we need to select any child item
- int nCountOfPopupItems = (int)
- mi.GetPopup()->m_items_all.GetSize();
- if( nCountOfPopupItems > 0 )
- {
- int nIndex = mi.GetPopup()->_GetNextItem(__NI_ANY);
- if( nIndex >= 0 )
- {
- mi.GetPopup()->_ItemFocusSet(
- nIndex,
- FALSE,
- ( GetSite().GetAnimated() == NULL ) ?
- TRUE : FALSE
- );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- }
- }
- } // if track-popup succeeded and we need to select any child item
- if( bDisplayedSuccessfully /*&& mi.IsInplaceEdit()*/ )
- {
- CClientDC dc( this );
- _DoPaint( dc );
- bDelayExpanding = false;
- }
- } // if new popup tracking
- _ift.FocusChangingUnRegister();
- KillTimer( ID_TIMER_AUTO_EXPAND );
- if( bDelayExpanding )
- {
- if( m_bTopLevel && (! m_bExpandWasPressed ) && m_bExpandAvailable && g_nAutoExpandTime > 0 )
- SetTimer( ID_TIMER_AUTO_EXPAND, g_nAutoExpandTime, NULL );
- }
- }
- bool CExtPopupMenuWnd::_CoolTipIsVisible()
- {
- ASSERT_VALID( this );
- if( _FindCustomizeMode() )
- return false;
- if( !(::IsWindow(GetSafeHwnd())) )
- return false;
- if( _IsRibbonMode() )
- return false;
- if( CExtPopupMenuSite::g_DefPopupMenuSite.GetCapture() != this )
- return false;
- CExtPopupMenuTipWnd & _tipWnd = GetTip();
- HWND hWndToolTip = _tipWnd.GetSafeHwnd();
- if( hWndToolTip != NULL
- && ::IsWindow( hWndToolTip )
- && ::IsWindowVisible( hWndToolTip )
- )
- return true;
- return false;
- }
- void CExtPopupMenuWnd::_CoolTipHide(
- bool bAdvOperation // = true
- )
- {
- ASSERT_VALID( this );
- if( !(::IsWindow(GetSafeHwnd())) )
- return;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupScreenTipWnd & _wndScreenTip = GetScreenTip();
- _wndScreenTip.Hide();
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtPopupMenuTipWnd & _tipWnd = GetTip();
- HWND hWndToolTip = _tipWnd.GetSafeHwnd();
- if( hWndToolTip == NULL
- || (! ::IsWindow( hWndToolTip ) )
- )