ExtPopupMenuWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:735k
- m_sizeItem.cx += __DROPDOWN_ARROW_GAP * 2 + __EXT_MENU_GAP + 3;
- if( ! bForceNoText )
- m_sizeItem.cx += __EXT_MENU_GAP;
- }
- //m_sizeItem.cx += __EXT_MENU_TOOLBTN_GAP * 2;
- m_sizeItem.cx += __EXT_MENU_TOOLBTN_GAP;
- // if( bForceNoText )
- // {
- // m_sizeItem.cx += 3;
- // m_sizeItem.cy += 3;
- // }
- } // if( IsToolButton() )
- else
- {
- m_sizeItem.cx +=
- m_nIconAreaWidth // sizeIcon.cx
- + __EXT_MENU_POPUP_ARROW_AREA_DX;
- } // else from if( IsToolButton() )
- if( IsToolButton() )
- {
- CExtPopupMenuWnd * pOwner = GetOwner();
- ASSERT_VALID( pOwner );
- CSize _size = pPM->Toolbar_GetMinButtonSize( pOwner );
- ASSERT( _size.cx >= 0 && _size.cy >= 0 );
- // if( m_sizeItem.cx < _size.cx )
- // m_sizeItem.cx = _size.cx;
- if( m_sizeItem.cy < _size.cy )
- m_sizeItem.cy = _size.cy;
- if( pPM->OnQueryPaintManagerName() == CExtPaintManager::ProfSkinPainter )
- {
- m_sizeItem.cx += _size.cx;
- }
- else
- {
- if( m_sizeItem.cx < _size.cx )
- m_sizeItem.cx = _size.cx;
- }
- } // if( IsToolButton() )
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::UpdateFromMenu(
- HWND hWndCmdProfileInfo,
- CMenu * pTrackMenu,
- int nItemIndex,
- bool bNoRefToCmdMngr // = false
- )
- {
- ASSERT( pTrackMenu != NULL );
- ASSERT( pTrackMenu->GetSafeHmenu() != NULL );
-
- #ifdef _DEBUG
- int nMenuItemCount = pTrackMenu->GetMenuItemCount();
- ASSERT( nMenuItemCount > 0 );
- ASSERT( nItemIndex >= 0 && nItemIndex<nMenuItemCount );
- #endif // _DEBUG
- MENUITEMINFO _mii;
- ::memset( &_mii, 0, sizeof(MENUITEMINFO) );
- _mii.cbSize = sizeof(MENUITEMINFO);
- _mii.fMask = MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE;
- _mii.cch = __MAX_UI_ITEM_TEXT;
- CExtSafeString _sItemText;
- _mii.dwTypeData =
- _sItemText.GetBuffer(__MAX_UI_ITEM_TEXT);
- ASSERT( _mii.dwTypeData != NULL );
- if( _mii.dwTypeData == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- if( ! pTrackMenu->GetMenuItemInfo(
- nItemIndex,
- &_mii,
- TRUE
- )
- )
- {
- _sItemText.ReleaseBuffer();
- ASSERT( FALSE );
- return false;
- }
- _sItemText.ReleaseBuffer();
- m_nItemIndex = nItemIndex;
- if( (_mii.fType&MFT_SEPARATOR) != 0 )
- {
- m_sItemText.Empty();
- m_nCmdID = TYPE_SEPARATOR;
- MeasureItem( NULL );
- return true;
- }
- SetBold( ( (_mii.fState&MFS_DEFAULT) != 0 ) ? true : false );
- if( _mii.hSubMenu != NULL )
- {
- if( ! ConstructPopup() )
- {
- ASSERT( FALSE );
- return false;
- }
- m_nCmdID = (UINT)TYPE_POPUP;
- SetPopupText( _sItemText );
- MeasureItem( NULL );
- return true;
- }
- // m_sItemText.Empty();
- if( ! CExtCmdManager::IsCommand(_mii.wID) )
- {
- ASSERT( FALSE );
- return false;
- }
- m_nCmdID = _mii.wID;
- if( bNoRefToCmdMngr )
- {
- // use text as is
- SetNoCmdUI( true );
- Enable( ( (_mii.fState&MFS_DISABLED) != 0 ) ? false : true );
- Check( ( (_mii.fState&MFS_CHECKED) != 0 ) ? true : false );
- } // if( bNoRefToCmdMngr )
- else
- {
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndCmdProfileInfo ),
- m_nCmdID
- );
- ASSERT( pCmdItem != NULL );
- if( pCmdItem == NULL )
- return false;
- // if( _sItemText.IsEmpty() )
- // _sItemText = pCmdItem->m_sMenuText;
- // if( _sItemText.IsEmpty() )
- // _sItemText = pCmdItem->m_sToolbarText;
- if( ! pCmdItem->m_sMenuText.IsEmpty() )
- _sItemText = pCmdItem->m_sMenuText;
- else if( ! pCmdItem->m_sToolbarText.IsEmpty() )
- _sItemText = pCmdItem->m_sToolbarText;
- SetAccelText( pCmdItem->m_sAccelText );
- } // else from if( bNoRefToCmdMngr )
- SetPopupText( _sItemText );
- MeasureItem( NULL );
- return true;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbVerifyTextInput(
- CInPlaceEditWnd & wndEdit,
- CExtCustomizeCmdTreeNode * pNode,
- __EXT_MFC_SAFE_LPCTSTR sTextOld,
- __EXT_MFC_SAFE_LPCTSTR sTextNew
- )
- {
- ASSERT_VALID( pNode );
- ASSERT( sTextOld != NULL );
- ASSERT( sTextNew != NULL );
- ASSERT(
- wndEdit.GetSafeHwnd() != NULL
- && ::IsWindow( wndEdit.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
- if( pSite == NULL )
- return true;
- return
- pSite->OnTextFieldVerify(
- NULL,
- pNode,
- sTextOld,
- sTextNew
- );
- }
- void CExtPopupMenuWnd::MENUITEMDATA::stat_CbPutTextInputResult(
- CInPlaceEditWnd & wndEdit,
- CExtCustomizeCmdTreeNode * pNode,
- __EXT_MFC_SAFE_LPCTSTR sTextNew
- )
- {
- ASSERT_VALID( pNode );
- ASSERT( sTextNew != NULL );
- ASSERT(
- wndEdit.GetSafeHwnd() != NULL
- && ::IsWindow( wndEdit.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
- if( pSite == NULL )
- return;
- pSite->OnTextFieldInplaceTextSet(
- NULL,
- pNode,
- pNode->m_sDefInplaceEditBuffer,
- sTextNew
- );
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInplaceEditWndProc(
- LRESULT & lResult,
- UINT message,
- WPARAM wParam,
- LPARAM lParam,
- CEdit & wndEdit,
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- if( message == CExtCustomizeSite::g_nMsgQueryCustomizeSite )
- return false;
- if( (wndEdit.GetStyle() & WS_VISIBLE) == 0 )
- return false;
- ASSERT_VALID( pNode );
- ASSERT(
- wndEdit.GetSafeHwnd() != NULL
- && ::IsWindow( wndEdit.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- return
- pSite->OnTextFieldWndProcHook(
- lResult,
- message,
- wParam,
- lParam,
- wndEdit,
- NULL,
- pNode
- );
- }
- #ifndef __EXT_MFC_NO_BUILTIN_DATEFIELD
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInitDatePickerContent(
- CExtDatePickerWnd & wndDatePicker,
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( pNode );
- ASSERT(
- wndDatePicker.GetSafeHwnd() != NULL
- && ::IsWindow( wndDatePicker.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndDatePicker.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- return
- pSite->OnPopupDatePickerInitContent(
- NULL,
- pNode,
- wndDatePicker
- );
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbDatePickerSelection(
- LPVOID pSelectionNotification,
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( pNode );
- const CExtDatePickerWnd::SELECTION_NOTIFICATION * pSN =
- CExtDatePickerWnd::SELECTION_NOTIFICATION::
- FromWPARAM( (WPARAM)pSelectionNotification );
- ASSERT( pSN != NULL );
- if( pSN == NULL )
- return false;
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( pSN->m_hWndDatePicker );
- if( pSite == NULL )
- return false;
- return
- pSite->OnPopupDatePickerSelChange(
- NULL,
- pNode,
- pSelectionNotification
- );
- }
- #endif // __EXT_MFC_NO_BUILTIN_DATEFIELD
- #ifndef __EXT_MFC_NO_UNDO_REDO_POPUP
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbFormatCaption(
- CExtSafeString & strCaption,
- CExtPopupUndoRedoMenuWnd * pUndoRedoPopupMenuWnd,
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( pNode );
- if( pUndoRedoPopupMenuWnd == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- ASSERT_VALID( pUndoRedoPopupMenuWnd );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( pUndoRedoPopupMenuWnd->m_hWnd );
- if( pSite == NULL )
- return false;
- return
- pSite->OnPopupUndoRedoFormatCaption(
- NULL,
- pNode,
- pUndoRedoPopupMenuWnd,
- strCaption
- );
- }
- #endif // __EXT_MFC_NO_UNDO_REDO_POPUP
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInitListBoxContent(
- CExtPopupInplaceListBox & wndListBox,
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( pNode );
- ASSERT(
- wndListBox.GetSafeHwnd() != NULL
- && ::IsWindow( wndListBox.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- return
- pSite->OnPopupListBoxInitContent(
- NULL,
- pNode,
- wndListBox
- );
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxSelection(
- CExtPopupInplaceListBox & wndListBox,
- CExtCustomizeCmdTreeNode * pNode,
- int eSAT // CExtPopupInplaceListBox::e_sel_action_t
- )
- {
- ASSERT_VALID( pNode );
- ASSERT(
- wndListBox.GetSafeHwnd() != NULL
- && ::IsWindow( wndListBox.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
- {
- case CExtPopupInplaceListBox::__SAT_SELCHANGE:
- return
- pSite->OnPopupListBoxSelChange(
- NULL,
- pNode,
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_SELENDOK:
- return
- pSite->OnPopupListBoxSelEndOK(
- NULL,
- pNode,
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_SELENDCANCEL:
- return
- pSite->OnPopupListBoxSelEndCancel(
- NULL,
- pNode,
- wndListBox
- );
- case CExtPopupInplaceListBox::__SAT_CLOSE:
- return
- pSite->OnPopupListBoxClose(
- NULL,
- pNode,
- wndListBox
- );
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
- return false;
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxItemDraw(
- CExtPopupInplaceListBox & wndListBox,
- CExtCustomizeCmdTreeNode * pNode,
- LPDRAWITEMSTRUCT pDIS
- )
- {
- ASSERT_VALID( pNode );
- ASSERT( pDIS != NULL && pDIS->hDC != NULL );
- ASSERT(
- wndListBox.GetSafeHwnd() != NULL
- && ::IsWindow( wndListBox.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- if( pSite->OnPopupListBoxItemDraw(
- NULL,
- pNode,
- wndListBox,
- pDIS
- )
- )
- return true;
- INT nIndex = INT( pDIS->itemID );
- if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
- return false;
- if( nIndex < 0 || nIndex >= wndListBox.GetCount() )
- return true;
- CExtPopupMenuWnd * pPopup =
- STATIC_DOWNCAST( CExtPopupMenuWnd, wndListBox.GetParent() );
- CExtPaintManager * pPM = pPopup->PmBridge_GetPM();
- bool bEnabled = wndListBox.LbItemIsEnabled( nIndex );
- bool bSelected = ( pDIS->itemState & ODS_SELECTED ) != 0 ? true : false;
- COLORREF clrText = wndListBox.LbItemTextColorGet( nIndex );
- COLORREF clrBack = wndListBox.LbItemBackColorGet( nIndex );
- CDC dc;
- dc.Attach( pDIS->hDC );
- if( pDIS->itemAction & (ODA_DRAWENTIRE | ODA_SELECT) )
- {
- CRect rcErase( pDIS->rcItem );
- if( nIndex == (wndListBox.GetCount()-1) )
- {
- CRect rcClient;
- wndListBox.GetClientRect( &rcClient );
- if( rcErase.bottom < rcClient.bottom )
- rcErase.bottom = rcClient.bottom;
- }
- dc.FillSolidRect(
- rcErase,
- pPM->GetColor( COLOR_WINDOW )
- );
- dc.FillSolidRect(
- &pDIS->rcItem,
- (clrBack != COLORREF(-1L) && (!bSelected))
- ? clrBack
- : pPM->GetColor(
- ( bSelected && bEnabled )
- ? COLOR_HIGHLIGHT
- : COLOR_WINDOW,
- &wndListBox
- )
- );
- }
- if( nIndex >= 0 )
- {
- CString sText;
- wndListBox.GetText( (INT)pDIS->itemID, sText );
- if( ! sText.IsEmpty() )
- {
- COLORREF clrTextOld =
- dc.SetTextColor(
- (clrText != COLORREF(-1L) && (!bSelected))
- ? clrText
- : pPM->GetColor(
- ( bSelected && bEnabled )
- ? COLOR_HIGHLIGHTTEXT
- : bEnabled
- ? COLOR_BTNTEXT
- : CExtPaintManager::CLR_TEXT_DISABLED,
- &wndListBox
- )
- );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- CRect rcText( pDIS->rcItem );
- rcText.DeflateRect(
- pSite->OnPopupListBoxCalcItemExtraSizes(
- NULL,
- pNode
- )
- );
- dc.DrawText(
- sText,
- &rcText,
- DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrTextOld );
- } // if( ! sText.IsEmpty() )
- } // if( nIndex >= 0 )
- if( bSelected && bEnabled )
- {
- COLORREF clrTextOld =
- dc.SetTextColor( RGB(255,255,255) );
- COLORREF clrBkOld =
- dc.SetBkColor( RGB(0,0,0) );
- dc.DrawFocusRect( &pDIS->rcItem );
- dc.SetBkColor( clrBkOld );
- dc.SetTextColor( clrTextOld );
- }
- dc.Detach();
- return true;
- }
- bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxItemMeasure(
- CExtPopupInplaceListBox & wndListBox,
- CExtCustomizeCmdTreeNode * pNode,
- LPMEASUREITEMSTRUCT pMIS
- )
- {
- ASSERT_VALID( pNode );
- ASSERT( pMIS != NULL );
- ASSERT(
- wndListBox.GetSafeHwnd() != NULL
- && ::IsWindow( wndListBox.GetSafeHwnd() )
- );
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
- if( pSite == NULL )
- return false;
- if( pSite->OnPopupListBoxItemMeasure(
- NULL,
- pNode,
- wndListBox,
- pMIS
- )
- )
- return true;
- if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
- return false;
- pMIS->itemWidth = pMIS->itemHeight = 10;
- if( ((INT)pMIS->itemID) < 0 || ((INT)pMIS->itemID) >= wndListBox.GetCount() )
- return true;
- CExtSafeString sMeasure;
- wndListBox.GetText( (INT)pMIS->itemID, *((CString*)&sMeasure) );
- if( sMeasure.IsEmpty() )
- return true;
- CExtPopupMenuWnd * pPopup =
- STATIC_DOWNCAST( CExtPopupMenuWnd, wndListBox.GetParent() );
- CExtPaintManager * pPM = pPopup->PmBridge_GetPM();
- CWindowDC dc( NULL );
- CRect rcMeasure =
- CExtPaintManager::stat_CalcTextDimension(
- dc,
- pPM->m_FontNormal,
- sMeasure
- );
- rcMeasure.InflateRect(
- pSite->OnPopupListBoxCalcItemExtraSizes(
- NULL,
- pNode
- )
- );
- pMIS->itemWidth = rcMeasure.Width();
- pMIS->itemHeight = rcMeasure.Height();
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- bool CExtPopupMenuWnd::MENUITEMDATA::UpdateFromCmdTree(
- HWND hWndCmdRecv,
- CExtCustomizeCmdTreeNode * pNode,
- int nItemIndex,
- CExtPopupMenuWnd * pPopupParent // = NULL
- )
- {
- ASSERT_VALID( pNode );
- m_nItemIndex = nItemIndex;
- if( pNode->PreConstructMenuItem(
- this,
- hWndCmdRecv,
- nItemIndex,
- pPopupParent
- )
- )
- return true;
- if( pNode->GetFlags()&__ECTN_BOLD_IN_MENU )
- m_bBold = true;
- if( pNode->GetFlags()&__ECTN_BIG_ACCENT_IN_MENU )
- m_bBigAccent = true;
- m_sExtendedText = pNode->GetTextMenuExtended();
- LPCTSTR sCaptionText = LPCTSTR( pNode->GetTextMenuCaption() );
- CExtCustomizeSite * pSite = NULL;
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( (pNode->GetFlags() & __ECTN_TBB_TEXT_FIELD) != 0 )
- {
- ASSERT( m_hWndSpecCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
- pSite =
- CExtCustomizeSite::GetCustomizeSite(
- m_hWndSpecCmdReceiver
- );
- // if( pSite == NULL )
- // {
- // ASSERT( FALSE );
- // return false;
- // }
- bool bComboField =
- ( (pNode->GetFlags() & __ECTN_TBB_COMBO) != 0 )
- ? true : false;
- bool bDateField =
- ( (pNode->GetFlags() & __ECTN_TBB_DATE) != 0 )
- ? true : false;
-
- m_nCmdID =
- ( bComboField || bDateField )
- ? ((UINT)TYPE_POPUP)
- : pNode->GetCmdID( false )
- ;
- m_pCmdNode = pNode;
- if( bComboField )
- {
- // construct a popup
- //ASSERT( m_iconPopup.IsEmpty() );
- //ASSERT( m_pWndChild == NULL );
- if( ! m_iconPopup.IsEmpty() )
- m_iconPopup.Empty();
- if( m_pWndChild != NULL )
- {
- m_pWndChild->m_pWndParentMenu = NULL;
- delete m_pWndChild;
- m_pWndChild = NULL;
- }
-
- CExtPopupControlMenuWnd * pExtCrtPopup = NULL;
- if( pSite != NULL )
- pExtCrtPopup =
- pSite->OnTextFieldCreateDropPopup(
- NULL,
- pNode,
- m_hWndSpecCmdReceiver,
- false
- );
- if( pExtCrtPopup != NULL )
- {
- m_pWndChild = pExtCrtPopup;
- if( pPopupParent != NULL )
- m_pWndChild->m_pWndParentMenu = pPopupParent;
- if( sCaptionText != NULL )
- pExtCrtPopup->MenuCaptionTextSet( sCaptionText );
- } // if( pExtCrtPopup != NULL )
- else
- {
- CExtPopupListBoxMenuWnd * pPopup =
- STATIC_DOWNCAST(
- CExtPopupListBoxMenuWnd,
- CExtPopupMenuWnd::InstantiatePopupMenu(
- hWndCmdRecv,
- RUNTIME_CLASS(CExtPopupListBoxMenuWnd),
- pNode // this
- )
- );
- if( sCaptionText != NULL )
- pPopup->MenuCaptionTextSet( sCaptionText );
- if( pPopupParent != NULL )
- pPopup->m_pWndParentMenu = pPopupParent;
- pPopup->m_lParamListCookie = pNode->GetLParam();
- pPopup->m_pCbListBoxSelection =
- (CExtPopupInplaceListBox::pCbListBoxSelection)
- stat_CbListBoxSelection;
- pPopup->m_pSelectionCookie = (LPVOID)pNode;
- pPopup->m_pCbInitListBoxContent =
- (CExtPopupInplaceListBox::pCbInitListBoxContent)
- stat_CbInitListBoxContent;
- pPopup->m_pInitListBoxCookie = (LPVOID)pNode;
- pPopup->m_pCbListBoxItemDraw =
- (CExtPopupInplaceListBox::pCbListBoxItemDraw)
- stat_CbListBoxItemDraw;
- pPopup->m_pCbListBoxItemMeasure =
- (CExtPopupInplaceListBox::pCbListBoxItemMeasure)
- stat_CbListBoxItemMeasure;
- pPopup->m_pListBoxItemCookie = (LPVOID)pNode;
- CSize sizeMeasure( 0, 0 );
- if( pSite != NULL )
- {
- pSite->OnPopupListBoxGetStyles(
- NULL,
- pNode,
- pPopup->m_dwListBoxStyles
- );
- sizeMeasure =
- pSite->OnPopupListBoxMeasureTrackSize(
- NULL,
- pNode
- );
- } // if( pSite != NULL )
- if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
- {
- pPopup->m_sizeChildControl.cx = pNode->TextFieldWidthGet();
- pPopup->m_sizeChildControl.cy = pNode->DropDownHeightMaxGet();
- } // if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
- else
- pPopup->m_sizeChildControl = sizeMeasure;
- m_pWndChild = pPopup;
- } // else from if( pExtCrtPopup != NULL )
- m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
- //
- m_sItemText = _T("");
- m_sAccelText = _T("");
- SetPopupText( pNode->GetTextInMenu( NULL ) );
- } // if( bComboField )
- #ifndef __EXT_MFC_NO_BUILTIN_DATEFIELD
- else if( bDateField )
- {
-
- // construct a popup
- ASSERT( m_iconPopup.IsEmpty() );
- ASSERT( m_pWndChild == NULL );
-
- CExtPopupControlMenuWnd * pExtCrtPopup =
- pSite->OnTextFieldCreateDropPopup(
- NULL,
- pNode,
- m_hWndSpecCmdReceiver,
- false
- );
- if( pExtCrtPopup != NULL )
- {
- m_pWndChild = pExtCrtPopup;
- if( sCaptionText != NULL )
- pExtCrtPopup->MenuCaptionTextSet( sCaptionText );
- } // if( pExtCrtPopup != NULL )
- else
- {
- CSize szCalendarDimensions = CSize(1,1);
- DWORD dwDatePickerWindowStyle = WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN;
- DWORD dwDatePickerStyle = __EDPWS_DEFAULT;
- pSite->OnPopupDatePickerGetStyles(
- NULL,
- pNode,
- szCalendarDimensions,
- dwDatePickerStyle
- );
- CExtPopupDatePickerMenuWnd * pPopup =
- STATIC_DOWNCAST(
- CExtPopupDatePickerMenuWnd,
- CExtPopupMenuWnd::InstantiatePopupMenu(
- m_hWndSpecCmdReceiver,
- RUNTIME_CLASS(CExtPopupDatePickerMenuWnd),
- pNode // this
- )
- );
- pPopup->Construct(
- pNode->GetLParam(),
- szCalendarDimensions,
- dwDatePickerWindowStyle,
- dwDatePickerStyle
- );
- if( sCaptionText != NULL )
- pPopup->MenuCaptionTextSet( sCaptionText );
-
- pPopup->m_pCbDatePickerSelection =
- (CExtPopupInplaceDatePicker::pCbDatePickerSelection)
- stat_CbDatePickerSelection;
- pPopup->m_pDatePickerSelectionCookie = (LPVOID)pNode;
-
- pPopup->m_pCbInitDatePickerContent =
- (CExtPopupInplaceDatePicker::pCbInitDatePickerContent)
- stat_CbInitDatePickerContent;
- pPopup->m_pInitDatePickerCookie = (LPVOID)pNode;
-
- m_pWndChild = pPopup;
- } // else from if( pExtCrtPopup != NULL )
- m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
- m_sItemText = _T("");
- m_sAccelText = _T("");
- SetPopupText( pNode->GetTextInMenu( NULL ) );
- } // if( bDateField )
- #endif // __EXT_MFC_NO_BUILTIN_DATEFIELD
- else
- m_sItemText = pNode->GetTextInMenu( NULL );
- if( pSite != NULL )
- pSite->OnTextFieldInplaceTextGet(
- NULL,
- pNode,
- pNode->m_sDefInplaceEditBuffer
- );
- SetInplaceEdit(
- &pNode->m_sDefInplaceEditBuffer,
- (CExtPopupMenuWnd::pCbVerifyTextInput)stat_CbVerifyTextInput,
- (CExtPopupMenuWnd::pCbPutTextInputResult)stat_CbPutTextInputResult,
- (CExtPopupMenuWnd::pCbInplaceEditWndProc)stat_CbInplaceEditWndProc,
- (LPVOID)pNode,
- pNode->TextFieldWidthGet()
- );
- bool bTextFieldIsNotEditable =
- ( (pNode->GetFlags() & __ECTN_TBB_TF_NE) != 0 )
- ? true : false;
- AllowInplaceEditActivation( ! bTextFieldIsNotEditable );
- SetDisplayed( true );
- SetAccelText( _T("") );
-
- MeasureItem( NULL );
- return true;
- } // if( (pNode->GetFlags() & __ECTN_TBB_TEXT_FIELD) != 0 )
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( pNode->GetFlags() & __ECTN_TBB_COLOR )
- {
- ASSERT( m_iconPopup.IsEmpty() );
- ASSERT( m_pWndChild == NULL );
- CExtPopupColorMenuWnd * pColorPopup =
- STATIC_DOWNCAST(
- CExtPopupColorMenuWnd,
- CExtPopupMenuWnd::InstantiatePopupMenu(
- hWndCmdRecv,
- RUNTIME_CLASS(CExtPopupColorMenuWnd),
- pPopupParent // this
- )
- );
- if( sCaptionText != NULL )
- pColorPopup->MenuCaptionTextSet( sCaptionText );
- m_pWndChild = pColorPopup;
- if( pPopupParent != NULL )
- m_pWndChild->m_pWndParentMenu = pPopupParent;
-
- ASSERT( m_hWndSpecCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
- m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
- m_nCmdID = (UINT)TYPE_POPUP;
- m_sItemText = pNode->GetTextInMenu( NULL );
- m_pCmdNode = pNode;
- ASSERT( m_pWndChild != NULL );
- m_pWndChild->m_pNode = pNode;
- pColorPopup->m_lParamCookie = pNode->GetLParam();
- pColorPopup->m_bEnableBtnColorDefault =
- ( (pNode->GetFlags() & __ECTN_TBB_MCB_DEFAULT) != 0 ) ? true : false;
- pColorPopup->m_bEnableBtnColorCustom =
- ( (pNode->GetFlags() & __ECTN_TBB_MCB_CUSTOM) != 0 ) ? true : false;
- if( pSite == NULL && m_hWndSpecCmdReceiver != NULL )
- pSite =
- CExtCustomizeSite::GetCustomizeSite(
- m_hWndSpecCmdReceiver
- );
- if( pSite == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- pSite->OnColorItemValueGet(
- NULL,
- pNode,
- pColorPopup->m_clrDefault,
- false
- );
- pSite->OnColorItemValueGet(
- NULL,
- pNode,
- pColorPopup->m_clrInitial,
- true
- );
- CExtSafeString sBtnText;
- if( pSite->OnColorItemGetBtnTextDefault(
- NULL,
- pNode,
- sBtnText
- )
- )
- pColorPopup->m_sBtnTextColorDefault = sBtnText;
- sBtnText.Empty();
- if( pSite->OnColorItemGetBtnTextCustom(
- NULL,
- pNode,
- sBtnText
- )
- )
- pColorPopup->m_sBtnTextColorCustom = sBtnText;
- pSite->OnColorItemGenerateIcon(
- NULL,
- pNode,
- pColorPopup->m_clrInitial,
- m_iconPopup
- );
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
- pNode->GetCmdID()
- );
- if( pCmdItem != NULL )
- SetAccelText( pCmdItem->m_sAccelText );
- MeasureItem( NULL );
- return true;
- } // if( pNode->GetFlags() & __ECTN_TBB_COLOR )
- #ifndef __EXT_MFC_NO_UNDO_REDO_POPUP
- else if( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO )
- {
- ASSERT( m_iconPopup.IsEmpty() );
- ASSERT( m_pWndChild == NULL );
-
- CExtPopupUndoRedoMenuWnd * pPopup =
- STATIC_DOWNCAST(
- CExtPopupUndoRedoMenuWnd,
- CExtPopupMenuWnd::InstantiatePopupMenu(
- hWndCmdRecv,
- RUNTIME_CLASS(CExtPopupUndoRedoMenuWnd),
- m_pOwner
- )
- );
- if( sCaptionText != NULL )
- pPopup->MenuCaptionTextSet( sCaptionText );
- pPopup->m_lParamCookie = pNode->GetLParam();
- pPopup->m_pCbListBoxSelection =
- (CExtPopupInplaceListBox::pCbListBoxSelection)
- stat_CbListBoxSelection;
- pPopup->m_pSelectionCookie = (LPVOID)pNode;
- pPopup->m_pCbInitListBoxContent =
- (CExtPopupInplaceListBox::pCbInitListBoxContent)
- stat_CbInitListBoxContent;
- pPopup->m_pInitListBoxCookie = (LPVOID)pNode;
- pPopup->m_pCbListBoxItemDraw =
- (CExtPopupInplaceListBox::pCbListBoxItemDraw)
- stat_CbListBoxItemDraw;
- pPopup->m_pCbListBoxItemMeasure =
- (CExtPopupInplaceListBox::pCbListBoxItemMeasure)
- stat_CbListBoxItemMeasure;
- pPopup->m_pListBoxItemCookie = (LPVOID)pNode;
- if( pSite == NULL )
- pSite = CExtCustomizeSite::GetCustomizeSite( m_hWndSpecCmdReceiver );
- if( pSite == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- pSite->OnPopupListBoxGetStyles(
- NULL,
- pNode,
- pPopup->m_dwListBoxStyles
- );
- pPopup->m_pCbFormatCaption =
- (CExtPopupUndoRedoMenuWnd::pCbFormatCaption)
- stat_CbFormatCaption;
- pPopup->m_pFormatCaptionCookie = (LPVOID)pNode;
-
- CSize sizeMeasure =
- pSite->OnPopupListBoxMeasureTrackSize(
- NULL,
- pNode
- );
- if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
- {
- pPopup->m_sizeChildControl.cx = pNode->TextFieldWidthGet();
- pPopup->m_sizeChildControl.cy = pNode->DropDownHeightMaxGet();
- } // if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
- else
- pPopup->m_sizeChildControl = sizeMeasure;
- m_pWndChild = pPopup;
-
- if( pPopupParent != NULL )
- m_pWndChild->m_pWndParentMenu = pPopupParent;
-
- ASSERT( m_hWndSpecCmdReceiver != NULL );
- ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
- m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
- SetPopupText( pNode->GetTextInMenu( NULL ) );
- // m_nCmdID = pNode->GetCmdID( true );
- m_nCmdID = (UINT)TYPE_POPUP;
- m_pCmdNode = pNode;
- ASSERT( m_pWndChild != NULL );
- m_pWndChild->m_pNode = pNode;
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
- pNode->GetCmdID()
- );
- if( pCmdItem != NULL )
- SetAccelText( pCmdItem->m_sAccelText );
- MeasureItem( NULL );
- return true;
- } // else if( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO )
- #endif // __EXT_MFC_NO_UNDO_REDO_POPUP
- if( (pNode->GetFlags() & __ECTN_AUTO_POPUP) != 0
- || pNode->GetNodeCount() > 0
- )
- {
- if( ! ConstructPopup() )
- {
- ASSERT( FALSE );
- return false;
- }
- if( sCaptionText != NULL && m_pWndChild != NULL )
- m_pWndChild->MenuCaptionTextSet( sCaptionText );
- m_nCmdID = (UINT)TYPE_POPUP;
- m_sItemText = pNode->GetTextInMenu( NULL );
- m_pCmdNode = pNode;
- ASSERT( m_pWndChild != NULL );
- m_pWndChild->m_pNode = pNode;
- MeasureItem( NULL );
- return true;
- }
- // m_sItemText.Empty();
- UINT nNodeCmdID = pNode->GetCmdID();
- if( nNodeCmdID == ID_SEPARATOR )
- {
- SetSeparator( nItemIndex );
- return true;
- }
- else if( ! CExtCmdManager::IsCommand( nNodeCmdID ) )
- {
- ASSERT( FALSE );
- return false;
- }
- #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- if( (pNode->GetFlags() & (__ECTN_TBB_COMBO|__ECTN_TBB_DATE|__ECTN_TBB_TEXT_FIELD) ) == 0 )
- #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
- m_nCmdID = pNode->GetCmdID();
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
- pNode->GetCmdID()
- );
- // ASSERT( pCmdItem != NULL );
- // if( pCmdItem == NULL )
- // return false;
- m_sItemText = pNode->GetTextInMenu( pCmdItem );
- m_pCmdNode = pNode;
- if( pCmdItem != NULL )
- SetAccelText( pCmdItem->m_sAccelText );
-
- pNode->PostConstructMenuItem(
- this,
- hWndCmdRecv,
- nItemIndex,
- pPopupParent
- );
- MeasureItem( NULL );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupBaseWnd
- IMPLEMENT_DYNCREATE( CExtPopupBaseWnd, __BaseClassOfCExtPopupBaseWnd )
- IMPLEMENT_CExtPmBridge_MEMBERS( CExtPopupBaseWnd );
- CExtPopupBaseWnd::CExtPopupBaseWnd()
- : m_bPrintState( false )
- , m_eCombineAlign( __CMBA_NONE )
- , m_hFont( NULL )
- {
- m_clrFadeBitsSrc
- = m_clrFadeBitsDst
- = m_clrFadeBitsTmp
- = NULL;
- m_AnimationType = g_DefAnimationType;
- _InitAnimation();
- m_ePlaySoundOnAnimationFinished =
- CExtSoundPlayer::__NO_SOUND;
- m_sizeFullItems.cx = m_sizeFullItems.cy = 1;
- m_bExcludeAreaSpec
- = m_bCombineWithEA
- = false;
- m_rcExcludeArea.SetRectEmpty();
- m_ptTrack.x = m_ptTrack.y
- = m_ptTrackOriginal.x = m_ptTrackOriginal.y
- = m_ptTrackInvoked.x = m_ptTrackInvoked.y
- = m_ptTrackWatched.x = m_ptTrackWatched.y
- = 0;
- PmBridge_Install();
- }
- CExtPopupBaseWnd::~CExtPopupBaseWnd()
- {
- PmBridge_Uninstall();
- }
- void CExtPopupBaseWnd::_AdjustAnimation(
- CExtPopupBaseWnd::e_animation_type_t & eAT
- )
- {
- ASSERT_VALID( this );
- eAT;
- }
- void CExtPopupMenuWnd::_AdjustAnimation(
- CExtPopupBaseWnd::e_animation_type_t & eAT
- )
- {
- ASSERT_VALID( this );
- if( _IsRibbonMode() )
- eAT = __AT_CONTENT_DISPLAY;
- }
- CExtSafeString CExtPopupBaseWnd::GetAnimaptionName( CExtPopupBaseWnd::e_animation_type_t eAT )
- {
- CExtSafeString strAT;
- switch( eAT )
- {
- case __AT_NONE:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_NONE ) )
- strAT = _T("(none)");
- break;
- case __AT_RANDOM:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_RANDOM ) )
- strAT = _T("Random select");
- break;
- case __AT_ROLL:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_ROLL ) )
- strAT = _T("Roll");
- break;
- case __AT_SLIDE:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_SLIDE ) )
- strAT = _T("Slide");
- break;
- case __AT_FADE:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_FADE ) )
- strAT = _T("Fade");
- break;
- case __AT_ROLL_AND_STRETCH:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_ROLL_AND_STRETCH ) )
- strAT = _T("Roll and stretch");
- break;
- case __AT_SLIDE_AND_STRETCH:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_SLIDE_AND_STRETCH ) )
- strAT = _T("Slide and stretch");
- break;
- case __AT_NOISE:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_NOISE ) )
- strAT = _T("Noise");
- break;
- case __AT_BOXES:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_BOXES ) )
- strAT = _T("Boxes");
- break;
- case __AT_CIRCLES:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_CIRCLES ) )
- strAT = _T("Circles");
- break;
- case __AT_HOLES:
- if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_HOLES ) )
- strAT = _T("Holes");
- break;
- } // switch( eAT )
- return strAT;
- }
- void CExtPopupBaseWnd::_InitAnimation()
- {
- ASSERT_VALID( this );
- m_nAnimPercent = m_nAnimPercentOld = 0;
- _AdjustAnimation( m_AnimationType );
- if( ( m_AnimationType < 0
- || m_AnimationType > __AT_MAX_VALID_VALUE
- )
- && m_AnimationType != __AT_CONTENT_DISPLAY
- && m_AnimationType != __AT_CONTENT_EXPAND
- )
- m_AnimationType = __AT_NONE;
- if( m_AnimationType == __AT_RANDOM )
- {
- int nRand = rand() % (__AT_MAX_VALID_VALUE+1);
- ASSERT( nRand >= 0 && nRand <= __AT_MAX_VALID_VALUE );
- if( nRand == __AT_NONE || nRand == __AT_RANDOM )
- nRand = __AT_FADE; // most cool of all effects
- m_AnimationType = (e_animation_type_t)nRand;
- }
- int nBitsPerPixel = CExtPaintManager::stat_GetBPP();
- if( nBitsPerPixel <= 8
- && m_AnimationType != __AT_CONTENT_EXPAND
- && m_AnimationType != __AT_CONTENT_DISPLAY
- )
- {
- m_AnimationType = __AT_NONE;
- m_bAnimFinished = true;
- }
- else
- {
- m_bAnimFinished =
- (m_AnimationType == __AT_NONE) ? true : false;
- }
- // ASSERT(
- // m_bmpScreenDst.GetSafeHandle() == NULL
- // && m_bmpScreenSrc.GetSafeHandle() == NULL
- // && m_bmpScreenTmp.GetSafeHandle() == NULL
- // && m_clrFadeBitsSrc == NULL
- // && m_clrFadeBitsDst == NULL
- // && m_clrFadeBitsTmp == NULL
- // );
- if( m_bmpScreenDst.GetSafeHandle() != NULL )
- m_bmpScreenDst.DeleteObject();
- if( m_bmpScreenSrc.GetSafeHandle() != NULL )
- m_bmpScreenSrc.DeleteObject();
- // if( m_bmpScreenSrcAlt.GetSafeHandle() != NULL )
- // m_bmpScreenSrcAlt.DeleteObject();
- if( m_bmpScreenTmp.GetSafeHandle() != NULL )
- m_bmpScreenTmp.DeleteObject();
- m_clrFadeBitsSrc = NULL;
- m_clrFadeBitsDst = NULL;
- m_clrFadeBitsTmp = NULL;
-
- }
- void CExtPopupBaseWnd::_StartAnimation()
- {
- ASSERT_VALID( this );
- _InitAnimation();
- if( m_AnimationType != __AT_NONE )
- {
- SetTimer( ID_TIMER_ANIMATION, ID_PERIOD_ANIMATION, NULL );
- g_nLastAnimTime = clock();
- }
- }
- void CExtPopupMenuWnd::_StartAnimation()
- {
- ASSERT_VALID( this );
- if( _FindCustomizeMode() )
- return;
- HWND hWndOwn = m_hWnd;
- _ItemFocusDelay();
- if( ! ::IsWindow( hWndOwn ) )
- return;
- _CoolTipHide( false );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtPopupBaseWnd::_StartAnimation();
- if( ! ::IsWindow( hWndOwn ) )
- return;
- GetSite().SetAnimated(
- m_bAnimFinished ? NULL : this
- );
- }
- BEGIN_MESSAGE_MAP(CExtPopupBaseWnd, __BaseClassOfCExtPopupBaseWnd)
- //{{AFX_MSG_MAP(CExtPopupBaseWnd)
- ON_WM_MOUSEACTIVATE()
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_NCPAINT()
- ON_WM_NCCALCSIZE()
- ON_WM_SIZE()
- ON_WM_ACTIVATEAPP()
- ON_WM_CANCELMODE()
- ON_WM_SETCURSOR()
- ON_WM_TIMER()
- ON_MESSAGE(WM_SETFONT, OnSetFont)
- ON_MESSAGE(WM_GETFONT, OnGetFont)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- LRESULT CExtPopupBaseWnd::OnSetFont( WPARAM wParam, LPARAM lParam )
- {
- ASSERT_VALID( this );
- HFONT hFont = (HFONT) wParam;
- BOOL bRedraw = (BOOL) lParam;
- m_hFont = hFont;
- if( bRedraw )
- Invalidate();
- return 0L;
- }
-
- LRESULT CExtPopupBaseWnd::OnGetFont( WPARAM, LPARAM )
- {
- ASSERT_VALID( this );
- return (LRESULT) m_hFont;
- }
- LRESULT CExtPopupBaseWnd::WindowProc(
- UINT message,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- if( message == WM_PRINT || message == WM_PRINTCLIENT )
- {
- HDC hDC = (HDC)wParam;
- if( hDC == NULL )
- return 0;
- m_bPrintState = true;
- CDC * pDC = CDC::FromHandle( hDC );
- _DoPaint( *pDC );
- m_bPrintState = false;
- return 0;
- }
- LRESULT lResult = __BaseClassOfCExtPopupBaseWnd :: WindowProc( message, wParam, lParam );
- return lResult;
- }
- void CExtPopupBaseWnd::OnPaint()
- {
- ASSERT_VALID( this );
- CPaintDC dc( this );
- if( !(::IsWindow(GetSafeHwnd())) )
- return;
- if( !(::IsWindowVisible(GetSafeHwnd())) )
- return;
- CExtPaintManager::stat_ExcludeChildAreas(
- dc.GetSafeHdc(),
- m_hWnd
- );
- if( ! m_bAnimFinished )
- _DrawAnimatedState( dc );
- else
- _DoPaint( dc );
- }
- void CExtPopupBaseWnd::_DrawAnimatedState( CDC & dc )
- {
- ASSERT_VALID( this );
- if( !(::IsWindow(GetSafeHwnd())) )
- return;
- CRect rcClient;
- GetClientRect( &rcClient );
- int cx = rcClient.Width();
- int cy = rcClient.Height();
- CDC * pPaintDC = &dc;
- CPalette * pOldPalette = NULL;
- if( (::GetDeviceCaps(pPaintDC->m_hDC,RASTERCAPS) & RC_PALETTE) != 0 )
- {
- pOldPalette =
- pPaintDC->SelectPalette( & PmBridge_GetPM()->m_PaletteWide, FALSE );
- pPaintDC->RealizePalette();
- }
- CDC dcmm;
- VERIFY( dcmm.CreateCompatibleDC(pPaintDC) );
- bool bFail = false;
- if( m_bmpScreenDst.GetSafeHandle() == NULL )
- {
- ASSERT( m_bmpScreenSrc.GetSafeHandle() == NULL );
- ASSERT( m_bmpScreenTmp.GetSafeHandle() == NULL );
-
- int nBitsPerPixel = CExtPaintManager::stat_GetBPP();
- CBitmap * pBmpOld = NULL;
- if( ( m_AnimationType == __AT_FADE
- && nBitsPerPixel > 8
- )
- || m_AnimationType == __AT_CONTENT_EXPAND
- || m_AnimationType == __AT_CONTENT_DISPLAY
- || m_AnimationType == __AT_ROLL
- || m_AnimationType == __AT_SLIDE
- || m_AnimationType == __AT_ROLL_AND_STRETCH
- || m_AnimationType == __AT_SLIDE_AND_STRETCH
- || m_AnimationType == __AT_NOISE
- || m_AnimationType == __AT_BOXES
- || m_AnimationType == __AT_CIRCLES
- || m_AnimationType == __AT_HOLES
- )
- {
- BITMAPINFOHEADER bih;
- bih.biSize = sizeof(BITMAPINFOHEADER);
- bih.biWidth = cx;
- bih.biHeight = cy;
- bih.biPlanes = 1;
- bih.biBitCount = 32;
- bih.biCompression = BI_RGB;
- bih.biSizeImage = cx * cy;
- bih.biXPelsPerMeter = 0;
- bih.biYPelsPerMeter = 0;
- bih.biClrUsed = 0;
- bih.biClrImportant = 0;
- HBITMAP hDIB =
- ::CreateDIBSection(
- dcmm.GetSafeHdc(),
- (LPBITMAPINFO)&bih,
- DIB_RGB_COLORS,
- (void **)&m_clrFadeBitsSrc,
- NULL,
- NULL
- );
- if( hDIB != NULL && m_clrFadeBitsSrc != NULL )
- {
- m_bmpScreenSrc.Attach( hDIB );
- hDIB =
- ::CreateDIBSection(
- dcmm.GetSafeHdc(),
- (LPBITMAPINFO)&bih,
- DIB_RGB_COLORS,
- (void **)&m_clrFadeBitsDst,
- NULL,
- NULL
- );
- if( hDIB != NULL && m_clrFadeBitsDst != NULL )
- {
- m_bmpScreenDst.Attach( hDIB );
- hDIB =
- ::CreateDIBSection(
- dcmm.GetSafeHdc(),
- (LPBITMAPINFO)&bih,
- DIB_RGB_COLORS,
- (void **)&m_clrFadeBitsTmp,
- NULL,
- NULL
- );
- if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
- {
- m_bmpScreenTmp.Attach( hDIB );
- pBmpOld =
- dcmm.SelectObject( &m_bmpScreenSrc );
- bool bDefaultCapture = true;
- if( g_PaintManager.m_bIsWinVistaOrLater
- && g_PaintManager.m_DWM.IsCompositionEnabled()
- && m_bmpScreenSrcAlt.GetSafeHandle() != NULL
- )
- {
- CDC dcX;
- if( dcX.CreateCompatibleDC( NULL ) )
- {
- CBitmap * pBmpOldX = dcX.SelectObject( &m_bmpScreenSrcAlt );
- dcmm.BitBlt( 0, 0, cx, cy, &dcX, 0, 0, SRCCOPY );
- dcX.SelectObject( pBmpOldX );
- dcX.DeleteDC();
- bDefaultCapture = false;
- }
- }
- if( bDefaultCapture )
- dcmm.BitBlt(
- 0, 0, cx, cy, pPaintDC,
- rcClient.left,
- rcClient.top,
- SRCCOPY
- );
- UINT nSizeInBytes =
- sizeof(COLORREF) * cx * cy;
- __EXT_MFC_MEMCPY(
- m_clrFadeBitsDst,
- nSizeInBytes,
- m_clrFadeBitsSrc,
- nSizeInBytes
- );
- dcmm.SelectObject( &m_bmpScreenDst );
- } // if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
- else
- {
- m_bmpScreenSrc.DeleteObject();
- m_bmpScreenDst.DeleteObject();
- //return;
- bFail = true;
- } // else from if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
- } // if( hDIB != NULL && m_clrFadeBitsDst != NULL )
- else
- {
- m_bmpScreenSrc.DeleteObject();
- //return;
- bFail = true;
- } // else from if( hDIB != NULL && m_clrFadeBitsDst != NULL )
- } // if( hDIB != NULL && m_clrFadeBitsSrc != NULL )
- }
- else
- {
- m_bmpScreenDst.CreateCompatibleBitmap(
- pPaintDC,
- cx,
- cy
- );
- pBmpOld =
- dcmm.SelectObject( &m_bmpScreenDst );
- }
- if( ! bFail )
- _DoPaint( dcmm, false );
- dcmm.SetViewportOrg( CPoint(0,0) );
- dcmm.SelectObject( pBmpOld );
- } // if( m_bmpScreenDst.GetSafeHandle() == NULL )
- CBitmap * pBmpOld = NULL;
- if( ! bFail )
- {
- COLORREF * src = m_clrFadeBitsSrc;
- COLORREF * dst = m_clrFadeBitsDst;
- COLORREF * tmp = m_clrFadeBitsTmp;
- switch( m_AnimationType )
- {
- case __AT_BOXES:
- case __AT_CIRCLES:
- case __AT_HOLES:
- if( tmp!= NULL && src!=NULL && dst != NULL )
- {
- ASSERT(
- m_nAnimPercent >= 0 && m_nAnimPercent <= 100
- &&
- m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
- &&
- m_nAnimPercentOld <= m_nAnimPercent
- );
- ASSERT( __BOX_ANIM_METRIC > 0 ); // self assert
- if( m_nAnimPercentOld != m_nAnimPercent )
- {
- pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
- if( m_AnimationType == __AT_BOXES )
- { // do boxes animation
- for( int y=0; y<cy; y++ )
- {
- int _y0 = y % __BOX_ANIM_METRIC;
- int _yPercent = 100 -
- (_y0 * 100) / __BOX_ANIM_METRIC;
- if( _yPercent < m_nAnimPercent )
- {
- UINT nSizeInBytes =
- cx * sizeof(COLORREF);
- __EXT_MFC_MEMCPY(
- tmp,
- nSizeInBytes,
- src,
- nSizeInBytes
- );
- tmp += cx;
- src += cx;
- dst += cx;
- continue;
- }
- for( int x=0; x<cx; x++ )
- {
- int _x0 = x % __BOX_ANIM_METRIC;
- int _xPercent =
- (_x0 * 100) / __BOX_ANIM_METRIC;
- if( _xPercent < m_nAnimPercent )
- *tmp = *dst;
- else
- *tmp = *src;
- tmp++; src++; dst++;
- }
- } // for( int y=0; y<cy; y++ )
- } // do boxes animation
- else
- { // do circles/holes animation
- double radius = 0;
- if( m_AnimationType == __AT_HOLES )
- radius =
- ((((double)(__BOX_ANIM_METRIC)) / 2) * (100-m_nAnimPercent))
- / 100;
- else
- radius =
- ((((double)(__BOX_ANIM_METRIC)) / 2) * m_nAnimPercent)
- / 100;
- if( radius > 0 )
- {
- for( int y=0; y<cy; y++ )
- {
- int _y0 = y % __BOX_ANIM_METRIC;
- int _y1 = y - _y0;
- //int _y2 = _y1 + __BOX_ANIM_METRIC;
- int _yCenter = _y1 + __BOX_ANIM_METRIC/2;
- int _yDist = abs( y - _yCenter );
- double _yDist2 = (double)_yDist*_yDist;
- for( int x=0; x<cx; x++ )
- {
- int _x0 = x % __BOX_ANIM_METRIC;
- int _x1 = x - _x0;
- //int _x2 = _x1 + __BOX_ANIM_METRIC;
- int _xCenter = _x1 + __BOX_ANIM_METRIC/2;
- int _xDist = abs( x - _xCenter );
- double _xDist2 = (double)_xDist*_xDist;
- double nDispance =
- ::sqrt(_yDist2+_xDist2);
- if( m_AnimationType == __AT_HOLES )
- { // holes
- if( nDispance >= radius )
- *tmp = *dst;
- else
- *tmp = *src;
- } // holes
- else
- { // circles
- if( nDispance < radius )
- *tmp = *dst;
- else
- *tmp = *src;
- } // circles
- tmp++; src++; dst++;
- }
- } // for( int y=0; y<cy; y++ )
- } // if( radius > 0 )
- } // do circles/holes animation
- int nMenuShadowSize = OnQueryMenuShadowSize();
- if( m_bCombineWithEA )
- { // paint combined area AS IS
- ASSERT( !m_rcExcludeArea.IsRectEmpty() );
- CRect rcExcludeArea( m_rcExcludeArea );
- ScreenToClient( &rcExcludeArea );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- pPaintDC->BitBlt(
- rcExcludeArea.left, rcExcludeArea.top,
- rcExcludeArea.Width(), rcExcludeArea.Height(),
- &dcmm,
- rcExcludeArea.left, rcExcludeArea.top,
- SRCCOPY
- );
- dcmm.SelectObject( pBmpOld );
- pBmpOld = NULL;
- if( m_eCombineAlign != __CMBA_NONE )
- {
- rcExcludeArea.InflateRect(
- (m_eCombineAlign == __CMBA_RIGHT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_BOTTOM) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_LEFT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_TOP) ?
- 0 : nMenuShadowSize
- );
- } // if( m_eCombineAlign != __CMBA_NONE )
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- } // paint combined area AS IS
- if( nMenuShadowSize > 0 )
- {
- CRect rcExcludeArea( rcClient );
- rcExcludeArea.left =
- rcExcludeArea.right
- - nMenuShadowSize;
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- rcExcludeArea = rcClient ;
- rcExcludeArea.top =
- rcExcludeArea.bottom
- - nMenuShadowSize;
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- }
-
- pPaintDC->BitBlt(
- rcClient.left, rcClient.top, cx, cy,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- if( nMenuShadowSize > 0 || m_bCombineWithEA )
- pPaintDC->SelectClipRgn( NULL );
- } // if( m_nAnimPercentOld != m_nAnimPercent )
- }
- break; // cases __AT_BOXES,__AT_CIRCLES,__AT_HOLES
- case __AT_NOISE:
- if( tmp!= NULL && src!=NULL && dst != NULL )
- {
- ASSERT(
- m_nAnimPercent >= 0 && m_nAnimPercent <= 100
- &&
- m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
- &&
- m_nAnimPercentOld <= m_nAnimPercent
- );
- if( m_nAnimPercentOld != m_nAnimPercent )
- {
- int nDiff =
- m_nAnimPercent - m_nAnimPercentOld;
- ASSERT( nDiff > 0 );
- int nRandHalf = nDiff / 2 + 1;
- ASSERT( nRandHalf > 0 );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
- for( int pixel = 0; pixel < cx * cy; pixel++ )
- {
- int nRandValue =
- rand() % nDiff;
- if( nRandValue > nRandHalf )
- *tmp = *dst;
- // else
- // *tmp = *src;
- tmp++; src++; dst++;
- } // for( int pixel = 0; pixel < cx * cy; pixel++ )
- int nMenuShadowSize = OnQueryMenuShadowSize();
- if( m_bCombineWithEA )
- { // paint combined area AS IS
- ASSERT( !m_rcExcludeArea.IsRectEmpty() );
- CRect rcExcludeArea( m_rcExcludeArea );
- ScreenToClient( &rcExcludeArea );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- pPaintDC->BitBlt(
- rcExcludeArea.left, rcExcludeArea.top,
- rcExcludeArea.Width(), rcExcludeArea.Height(),
- &dcmm,
- rcExcludeArea.left, rcExcludeArea.top,
- SRCCOPY
- );
- dcmm.SelectObject( pBmpOld );
- pBmpOld = NULL;
- if( m_eCombineAlign != __CMBA_NONE )
- {
- rcExcludeArea.InflateRect(
- (m_eCombineAlign == __CMBA_RIGHT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_BOTTOM) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_LEFT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_TOP) ?
- 0 : nMenuShadowSize
- );
- } // if( m_eCombineAlign != __CMBA_NONE )
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- } // paint combined area AS IS
- if( nMenuShadowSize > 0 )
- {
- CRect rcExcludeArea( rcClient );
- rcExcludeArea.left =
- rcExcludeArea.right
- - nMenuShadowSize;
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- rcExcludeArea = rcClient ;
- rcExcludeArea.top =
- rcExcludeArea.bottom
- - nMenuShadowSize;
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- }
-
- pPaintDC->BitBlt(
- rcClient.left, rcClient.top, cx, cy,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- if( nMenuShadowSize > 0 || m_bCombineWithEA )
- pPaintDC->SelectClipRgn( NULL );
- } // if( m_nAnimPercentOld != m_nAnimPercent )
- }
- break; // case __AT_NOISE
- case __AT_SLIDE:
- case __AT_ROLL:
- case __AT_ROLL_AND_STRETCH:
- case __AT_SLIDE_AND_STRETCH:
- if( tmp!= NULL && src!=NULL && dst != NULL )
- {
- ASSERT(
- m_nAnimPercent >= 0 && m_nAnimPercent <= 100
- &&
- m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
- &&
- m_nAnimPercentOld <= m_nAnimPercent
- );
- CRect _rcClient;
- _GetClientRect( &_rcClient );
- if( m_bCombineWithEA )
- { // paint combined area AS IS
- ASSERT( !m_rcExcludeArea.IsRectEmpty() );
- CRect rcExcludeArea( m_rcExcludeArea );
- ScreenToClient( &rcExcludeArea );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- pPaintDC->BitBlt(
- rcExcludeArea.left, rcExcludeArea.top,
- rcExcludeArea.Width(), rcExcludeArea.Height(),
- &dcmm,
- rcExcludeArea.left, rcExcludeArea.top,
- SRCCOPY
- );
- dcmm.SelectObject( pBmpOld );
- pBmpOld = NULL;
- if( m_eCombineAlign != __CMBA_NONE )
- {
- int nMenuShadowSize = OnQueryMenuShadowSize();
- rcExcludeArea.InflateRect(
- (m_eCombineAlign == __CMBA_RIGHT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_BOTTOM) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_LEFT) ?
- 0 : nMenuShadowSize,
- (m_eCombineAlign == __CMBA_TOP) ?
- 0 : nMenuShadowSize
- );
- } // if( m_eCombineAlign != __CMBA_NONE )
- pPaintDC->ExcludeClipRect(
- &rcExcludeArea
- );
- } // paint combined area AS IS
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- int cx =
- _rcClient.Width();
- int cy =
- _rcClient.Height();
- if( m_AnimationType == __AT_ROLL
- ||
- m_AnimationType == __AT_SLIDE
- )
- { // non-stratchable variants
- int _cx = 0;
- if( m_AnimationType == __AT_ROLL )
- _cx = (cx * (100-m_nAnimPercent)) / 100;
- int _cy =
- (cy * (100-m_nAnimPercent)) / 100;
- if( m_eCombineAlign == __CMBA_RIGHT )
- {
- CRgn rgnClip;
- if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
- pPaintDC->SelectClipRgn( &rgnClip );
- pPaintDC->BitBlt(
- _rcClient.left+_cx, _rcClient.top-_cy, cx, cy,
- &dcmm,
- _rcClient.left, _rcClient.top,
- SRCCOPY
- );
- pPaintDC->SelectClipRgn( NULL );
- } // if m_eCombineAlign is __CMBA_RIGHT
- else if( m_eCombineAlign == __CMBA_BOTTOM )
- {
- CRgn rgnClip;
- if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
- pPaintDC->SelectClipRgn( &rgnClip );
- pPaintDC->BitBlt(
- _rcClient.left-_cx, _rcClient.top+_cy, cx, cy,
- &dcmm,
- _rcClient.left, _rcClient.top,
- SRCCOPY
- );
- pPaintDC->SelectClipRgn( NULL );
- } // if m_eCombineAlign is __CMBA_BOTTOM
- else
- { // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
- pPaintDC->BitBlt(
- _rcClient.left-_cx, _rcClient.top-_cy, cx, cy,
- &dcmm,
- _rcClient.left, _rcClient.top,
- SRCCOPY
- );
- } // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
- } // non-stratchable variants
- else
- { // stratchable variants
- int _cx = cx;
- if( m_AnimationType == __AT_ROLL_AND_STRETCH )
- _cx = (cx * m_nAnimPercent) / 100;
- int _cy =
- (cy * m_nAnimPercent) / 100;
- int nOldStretchBltMode =
- pPaintDC->SetStretchBltMode(
- g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
- );
- if( m_eCombineAlign == __CMBA_RIGHT
- && m_AnimationType == __AT_ROLL_AND_STRETCH
- )
- {
- CRgn rgnClip;
- if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
- pPaintDC->SelectClipRgn( &rgnClip );
- pPaintDC->StretchBlt(
- _rcClient.left+cx-_cx, _rcClient.top, _cx, _cy,
- &dcmm,
- _rcClient.left, _rcClient.top, cx, cy,
- SRCCOPY
- );
- pPaintDC->SelectClipRgn( NULL );
- } // if m_eCombineAlign is __CMBA_RIGHT with __AT_ROLL_AND_STRETCH animation
- else if( m_eCombineAlign == __CMBA_BOTTOM )
- {
- CRgn rgnClip;
- if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
- pPaintDC->SelectClipRgn( &rgnClip );
- pPaintDC->StretchBlt(
- _rcClient.left-cx+_cx, _rcClient.top+cy-_cy, _cx, _cy,
- &dcmm,
- _rcClient.left, _rcClient.top, cx, cy,
- SRCCOPY
- );
- pPaintDC->SelectClipRgn( NULL );
- } // if m_eCombineAlign is __CMBA_BOTTOM
- else
- { // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
- pPaintDC->StretchBlt(
- _rcClient.left, _rcClient.top, _cx, _cy,
- &dcmm,
- _rcClient.left, _rcClient.top, cx, cy,
- SRCCOPY
- );
- } // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
- pPaintDC->SetStretchBltMode( nOldStretchBltMode );
- } // stratchable variants
- if( m_bCombineWithEA )
- pPaintDC->SelectClipRgn( NULL );
- }
- break; // cases __AT_ROLL, __AT_SLIDE, __AT_ROLL_AND_STRETCH, __AT_ROLL_AND_STRETCH
- case __AT_CONTENT_EXPAND:
- if( tmp!= NULL
- && src!=NULL
- && dst != NULL
- && IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) )
- )
- {
- CExtPopupMenuWnd * pThisPopup = STATIC_DOWNCAST( CExtPopupMenuWnd, this );
- ASSERT(
- m_nAnimPercent >= 0 && m_nAnimPercent <= 100
- &&
- m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
- &&
- m_nAnimPercentOld <= m_nAnimPercent
- );
- CRect _rcClient;
- _GetClientRect( &_rcClient );
- if( m_bCombineWithEA )
- { // paint combined area AS IS
- ASSERT( !m_rcExcludeArea.IsRectEmpty() );
- CRect rcExcludeArea( m_rcExcludeArea );
- ScreenToClient( &rcExcludeArea );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- pPaintDC->BitBlt(
- rcExcludeArea.left, rcExcludeArea.top,
- rcExcludeArea.Width(), rcExcludeArea.Height(),
- &dcmm,
- rcExcludeArea.left, rcExcludeArea.top,
- SRCCOPY
- );
- dcmm.SelectObject( pBmpOld );
- pBmpOld = NULL;
- } // paint combined area AS IS
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- int cx =
- _rcClient.Width();
- int cy =
- _rcClient.Height();
- int _cx = cx;
- int _cy =
- (cy * m_nAnimPercent) / 100;
- CExtPopupMenuWnd::visible_items_t v;
- pThisPopup->_GetVisibleItems(
- dcmm.GetSafeHdc(), // dc.GetSafeHdc()
- v
- );
- if( v.GetSize() == 0 )
- { // if menu is empty
- int nOldStretchBltMode =
- pPaintDC->SetStretchBltMode(
- g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
- );
- pPaintDC->StretchBlt(
- _rcClient.left, _rcClient.top, _cx, _cy,
- &dcmm,
- _rcClient.left, _rcClient.top, cx, cy,
- SRCCOPY
- );
- pPaintDC->SetStretchBltMode( nOldStretchBltMode );
- } // if menu is empty
- else
- { // if menu is NOT empty
- int y_pos_src = _rcClient.top;
- int y_pos_dst = _rcClient.top;
- INT vis_iter = 0;
- int nItemIndex = 0;
- int nItemCount = int(v.GetSize());
- ASSERT( nItemCount > 0 );
- CExtPopupMenuWnd::expand_effect_rects_container_t vRects;
-
- for( ; vis_iter < v.GetSize(); ++vis_iter, ++nItemIndex )
- { // calc rects for visible items
- CExtPopupMenuWnd::VisibleItemDefinition_t & vi = v[vis_iter];
- CExtPopupMenuWnd::MENUITEMDATA & mi =
- pThisPopup->ItemGetInfo( vi.m_nIndex );
- ASSERT(
- vi.m_nIndex >= 0
- && vi.m_nIndex < pThisPopup->ItemGetCount() // m_items_all.GetSize()
- );
- ASSERT( mi.IsDisplayed() );
- ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
- CRect rcItemSrc;
- pThisPopup->_GetItemRect( vi.m_nIndex, rcItemSrc, false );
- rcItemSrc.left = _rcClient.left;
- rcItemSrc.right = _rcClient.right;
- if( nItemIndex == 0 )
- rcItemSrc.top = _rcClient.top;
- else if( nItemIndex == (nItemCount-1) )
- rcItemSrc.bottom = _rcClient.bottom;
- int y_pos_src_next =
- y_pos_src + rcItemSrc.Height();
- CRect rcItemDst( rcItemSrc );
- rcItemDst.OffsetRect(
- 0,
- y_pos_dst - rcItemDst.top
- );
- if( vi.m_bRarelyUsed )
- rcItemDst.bottom =
- rcItemDst.top
- +
- (rcItemDst.Height() * m_nAnimPercent)
- / 100;
- int y_pos_dst_next =
- y_pos_dst + rcItemDst.Height();
-
- CExtPopupMenuWnd::ExpandEffectRects_t _eert(
- rcItemSrc,
- rcItemDst
- );
- vRects.Add( _eert );
- y_pos_dst = y_pos_dst_next;
- y_pos_src = y_pos_src_next;
- } // calc rects for visible items
- // y_pos_dst is now equal to size of
- // all compressed items
- ASSERT( y_pos_dst <= y_pos_src );
- if( m_bCombineWithEA
- && m_eCombineAlign == __CMBA_BOTTOM
- && y_pos_dst != y_pos_src
- )
- { // expand from bottom to top
- INT iter_rects = 0;
- int nDstOffset =
- y_pos_src - y_pos_dst;
- for( ; iter_rects < vRects.GetSize(); ++iter_rects )
- { // adjust destination rects
- CExtPopupMenuWnd::ExpandEffectRects_t & eerc =
- vRects[ iter_rects ];
- eerc.m_rcDst.OffsetRect(
- 0,
- nDstOffset
- );
- } // adjust destination rects
- } // expand from bottom to top
- INT iter_rects = 0;
- for( ; iter_rects < vRects.GetSize(); ++iter_rects )
- { // paint visible items
- CExtPopupMenuWnd::ExpandEffectRects_t & eerc =
- vRects[ iter_rects ];
- if( eerc.m_rcDst.IsRectEmpty() )
- continue;
- if( CExtPopupMenuWnd::g_bUseStretchOnExpandAnimation )
- {
- int nOldStretchBltMode =
- pPaintDC->SetStretchBltMode(
- g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
- );
- // something better then Office XP
- pPaintDC->StretchBlt(
- eerc.m_rcDst.left, eerc.m_rcDst.top,
- eerc.m_rcDst.Width(), eerc.m_rcDst.Height(),
- &dcmm,
- eerc.m_rcSrc.left, eerc.m_rcSrc.top,
- eerc.m_rcSrc.Width(), eerc.m_rcSrc.Height(),
- SRCCOPY
- );
- pPaintDC->SetStretchBltMode( nOldStretchBltMode );
- } // if( CExtPopupMenuWnd::g_bUseStretchOnExpandAnimation )
- else
- // somthing really like Office XP
- pPaintDC->BitBlt(
- eerc.m_rcDst.left, eerc.m_rcDst.top,
- eerc.m_rcDst.Width(), eerc.m_rcDst.Height(),
- &dcmm,
- eerc.m_rcSrc.left, eerc.m_rcSrc.top,
- SRCCOPY
- );
- } // paint visible items
- } // if menu is NOT empty
- }
- break; // case __AT_CONTENT_EXPAND
- case __AT_CONTENT_DISPLAY:
- if( tmp!= NULL && src!=NULL && dst != NULL )
- {
- pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
- pPaintDC->BitBlt(
- rcClient.left, rcClient.top, cx, cy,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- }
- break; // case __AT_CONTENT_DISPLAY
- case __AT_FADE:
- if( tmp!= NULL && src!=NULL && dst != NULL )
- {
- ASSERT(
- m_nAnimPercent >= 0 && m_nAnimPercent <= 100
- &&
- m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
- &&
- m_nAnimPercentOld <= m_nAnimPercent
- );
- pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
- for( int pixel = 0; pixel < cx * cy; pixel++ )
- {
- COLORREF c0 = *dst++;
- COLORREF c1 = *src++;
- *tmp++ =
- RGB(
- (m_nAnimPercent*long(GetRValue(c0)) + (100L-m_nAnimPercent)*long(GetRValue(c1)) ) / 100L,
- (m_nAnimPercent*long(GetGValue(c0)) + (100L-m_nAnimPercent)*long(GetGValue(c1)) ) / 100L,
- (m_nAnimPercent*long(GetBValue(c0)) + (100L-m_nAnimPercent)*long(GetBValue(c1)) ) / 100L
- );
- } // for( int pixel = 0; pixel < cx * cy; pixel++ )
- pPaintDC->BitBlt(
- rcClient.left, rcClient.top, cx, cy,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- );
- }
- break; // case __AT_FADE
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break; // default
- #endif // _DEBUG
- } // switch( m_AnimationType )
- } // if( ! bFail )
- if( pBmpOld != NULL )
- dcmm.SelectObject( pBmpOld );
- if( pOldPalette != NULL )
- pPaintDC->SelectPalette( pOldPalette, FALSE );
- }
- void CExtPopupBaseWnd::_DoPaint( CDC & dcPaint, bool bUseBackBuffer /*= true*/ )
- {
- ASSERT_VALID( this );
- dcPaint;
- bUseBackBuffer;
- }
- void CExtPopupBaseWnd::_DelayPaint()
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return;
- PostMessage( WM_TIMER, ID_TIMER_DELAY_PAINT );
- }
- void CExtPopupBaseWnd::OnTimer(__EXT_MFC_UINT_PTR nIDEvent)
- {
- ASSERT_VALID( this );
- switch( nIDEvent )
- {
- case ID_TIMER_LIFE_STEP:
- return;
- case ID_TIMER_DELAY_PAINT:
- {
- KillTimer( ID_TIMER_DELAY_PAINT );
- CClientDC dc( this );
- _DoPaint( dc );
- }
- return;
- case ID_TIMER_DELAY_SHOW:
- {
- VERIFY( KillTimer( ID_TIMER_DELAY_SHOW ) );
- ShowWindow( SW_SHOWNA );
- Invalidate( FALSE );
- UpdateWindow();
- return;
- }
- // case ID_TIMER_DELAY_SHOW
- case ID_TIMER_ANIMATION:
- if( ! m_bAnimFinished )
- {
- clock_t nCurrAnimTime = clock();
- int nDuration =
- nCurrAnimTime - g_nLastAnimTime;
- int nSteps = (int)
- (0.5 + (float) nDuration / ID_PERIOD_ANIMATION);
- switch( m_AnimationType )
- {
- case __AT_CONTENT_DISPLAY:
- m_bAnimFinished = true;
- break;
- case __AT_FADE:
- case __AT_CONTENT_EXPAND:
- case __AT_ROLL:
- case __AT_SLIDE:
- case __AT_ROLL_AND_STRETCH:
- case __AT_SLIDE_AND_STRETCH:
- case __AT_NOISE:
- case __AT_BOXES:
- case __AT_CIRCLES:
- case __AT_HOLES:
- m_nAnimPercentOld = m_nAnimPercent;
- m_nAnimPercent += g_nAnimStepMetric;
- if( m_nAnimPercent >
- 100 + nSteps * g_nAnimStepMetric
- )
- m_nAnimPercent = 101;
- if( m_nAnimPercent > 100 )
- m_bAnimFinished = true;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( m_AnimationType )
- if( m_bAnimFinished )
- {
- if( !_FindCustomizeMode() )
- {
- g_SoundPlayer->PlaySound(
- m_ePlaySoundOnAnimationFinished
- );
- m_ePlaySoundOnAnimationFinished =
- CExtSoundPlayer::__NO_SOUND;
- } // if( !_FindCustomizeMode() )
- KillTimer(ID_TIMER_ANIMATION);
- m_AnimationType = g_DefAnimationType;
- } // if( m_bAnimFinished )
- if( GetSafeHwnd() != NULL )
- {
- if( m_bAnimFinished )
- _EndAnimation();
- else
- {
- Invalidate( FALSE );
- UpdateWindow();
- }
- g_nLastAnimTime = nCurrAnimTime;
- }
- } // if( ! m_bAnimFinished )
-
- if( m_bAnimFinished )
- if( IsKindOf(RUNTIME_CLASS(CExtPopupMenuWnd)) )
- ((CExtPopupMenuWnd *)this)->
- GetSite().SetAnimated( NULL );
- return;
- // case ID_TIMER_ANIMATION
- default:
- __BaseClassOfCExtPopupBaseWnd::OnTimer(nIDEvent);
- break; // default
- } // switch( nIDEvent )
- }
- int CExtPopupBaseWnd::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
- {
- ASSERT_VALID( this );
- pDesktopWnd;
- nHitTest;
- message;
- if( _FindCustomizeMode() )
- {
- if( IsKindOf(RUNTIME_CLASS(CExtPopupMenuWnd)) )
- ((CExtPopupMenuWnd*)this)->_DoResetChainPositions();
- else
- SetWindowPos(
- &CWnd::wndTopMost,
- -1, -1, -1, -1,
- SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
- );
- return MA_NOACTIVATE;
- }
- HWND hWndInPlace = ::GetWindow( m_hWnd, GW_CHILD );
- if( hWndInPlace != NULL )
- {
- CPoint ptScreenClick;
- if( ! ::GetCursorPos(&ptScreenClick) )
- return MA_NOACTIVATEANDEAT;
- HWND hWndFromPoint = ::WindowFromPoint( ptScreenClick );
- if( hWndFromPoint != NULL
- && (::__EXT_MFC_GetWindowLong(hWndFromPoint,GWL_STYLE)&WS_CHILD) != 0
- && ::GetParent(hWndFromPoint) == m_hWnd
- )
- return MA_ACTIVATE;
- } // if( hWndInPlace != NULL )
- return MA_NOACTIVATEANDEAT;
- //return CExtPopupBaseWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
- }
- void CExtPopupMenuWnd::_DoShowChain(
- int nCmdShow // = SW_SHOWNA
- )
- {
- ASSERT_VALID( this );
- if( m_hWnd == NULL || (! ::IsWindow(m_hWnd) ) )
- return;
- ShowWindow( nCmdShow );
- if( m_nCurIndex < 0 )
- return;
- MENUITEMDATA & mi = ItemGetInfo( m_nCurIndex );
- if( ! mi.IsPopup() )
- return;
- mi.GetPopup()->_DoShowChain( nCmdShow );
- }
- void CExtPopupMenuWnd::_DoResetChainPositions()
- {
- ASSERT_VALID( this );
- CExtPopupMenuWnd * pChild = NULL;
- if( m_nCurIndex >= 0 )
- {
- MENUITEMDATA & mi = ItemGetInfo( m_nCurIndex );
- if( mi.IsPopup() )
- {
- pChild = mi.GetPopup();
- if( pChild->GetSafeHwnd() == NULL
- || (! pChild->IsWindowVisible() )
- )
- pChild = NULL;
- } // if( mi.IsPopup() )
- } // if( m_nCurIndex >= 0 )
- if( pChild != NULL )
- pChild->_DoResetChainPositions();
- _DoResetChainPositionsImpl( NULL );
- }
- void CExtPopupMenuWnd::_DoResetChainPositionsImpl(
- CExtPopupMenuWnd * pPrev
- )
- {
- SetWindowPos(
- ( pPrev == NULL ) ? (&CWnd::wndTopMost) : pPrev,
- 0, 0, 0, 0,
- SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
- |SWP_NOREDRAW
- );
- { // BLOCK : DC painting
- CClientDC dc( this );
- _DoPaint( dc );
- } // BLOCK : DC painting
- if( m_pWndParentMenu != NULL )
- m_pWndParentMenu->_DoResetChainPositionsImpl( this );
- }
- BOOL CExtPopupBaseWnd::OnEraseBkgnd(CDC* pDC)
- {
- ASSERT_VALID( this );
- pDC;
- return TRUE;
- }
- void CExtPopupBaseWnd::OnNcPaint()
- {
- ASSERT_VALID( this );
- }
- void CExtPopupBaseWnd::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
- {
- ASSERT_VALID( this );
- bCalcValidRects;
- lpncsp;
- /// __BaseClassOfCExtPopupBaseWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
- }
- void CExtPopupBaseWnd::OnSize(UINT nType, int cx, int cy)
- {
- ASSERT_VALID( this );
- __BaseClassOfCExtPopupBaseWnd::OnSize(nType, cx, cy);
- Invalidate(FALSE);
- }
- bool CExtPopupBaseWnd::OnQueryLayoutRTL() const
- {
- ASSERT_VALID( this );
- bool bRTL =
- ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 )
- ? true : false;
- return bRTL;
- }
- BOOL CExtPopupBaseWnd::DestroyWindow()
- {
- __PROF_UIS_MANAGE_STATE;
- if( m_ctrlShadow.GetSafeHwnd() )
- m_ctrlShadow.DestroyWindow();
- HWND hWndOwn = GetSafeHwnd();
- if( hWndOwn == NULL || (! ::IsWindow( hWndOwn ) ) )
- return TRUE;
- return ::DestroyWindow( hWndOwn );
- }
- void CExtPopupBaseWnd::PostNcDestroy()
- {
- ASSERT_VALID( this );
- }
- void CExtPopupMenuWnd::PostNcDestroy()
- {
- ASSERT_VALID( this );
- if( _FindCustomizeMode() )
- return;
- if( m_bTopLevel
- && ( ! _IsFadeOutAnimation() )
- )
- {
- CExtPopupMenuSite & _site = GetSite();
- DWORD dwTrackFlags = TrackFlagsGet();
- ASSERT( m_hWndCmdReceiver != NULL );
- if( ::IsWindow(m_hWndCmdReceiver) )
- ::SendMessage(
- m_hWndCmdReceiver,
- g_nMsgNotifyMenuClosed,
- 0,
- LPARAM( this )
- );
- if( m_hWndNotifyMenuClosed != NULL
- && ::IsWindow( m_hWndNotifyMenuClosed )
- )
- ::SendMessage(
- m_hWndNotifyMenuClosed,
- g_nMsgNotifyMenuClosed,
- 0,
- LPARAM( this )
- );
- if( ( ! _site.IsEmpty() )
- && ( ! _site.IsShutdownMode() )
- && (dwTrackFlags&TPMX_NO_SITE) == 0
- )
- {
- _site.DoneInstance();
- ASSERT( _site.IsEmpty() );
- ASSERT( ! _site.IsShutdownMode() );
- }
- } // if( m_bTopLevel )
- }
- void CExtPopupMenuWnd::_DeleteFadeOutMenu()
- {
- ASSERT_VALID( this );
- delete this;
- }
- bool CExtPopupBaseWnd::_FindHelpMode() const
- {
- // if( ::AfxGetApp()->m_bHelpMode )
- // return true;
- return false;
- }
- bool CExtPopupMenuWnd::_FindHelpMode() const
- {
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_HELP_CTX_MODE) != 0 )
- return true;
- if( m_pWndParentMenu != NULL )
- return m_pWndParentMenu->_FindHelpMode();
- return CExtPopupBaseWnd::_FindHelpMode();
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * CExtPopupMenuWnd::_FindCustomizeSite() const
- {
- if( m_pCustomizeSite != NULL )
- return (CExtCustomizeSite *)m_pCustomizeSite;
- if( m_pWndParentMenu != NULL )
- return m_pWndParentMenu->_FindCustomizeSite();
- return NULL;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtPopupBaseWnd::_FindCustomizeMode() const
- {
- return false;
- }
- INT CExtPopupMenuWnd::_FindChildPopup( const CExtPopupMenuWnd * pPopup ) const
- {
- ASSERT_VALID( this );
- if( pPopup == NULL )
- return -1;
- ASSERT_VALID( pPopup );
- INT nIndex, nCount = ItemGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- const MENUITEMDATA & _mii = ItemGetInfo( nIndex );
- if(! _mii.IsPopup() )
- continue;
- const CExtPopupMenuWnd * pChildPopup = _mii.GetPopup();
- if( LPVOID(pChildPopup) == LPVOID(pPopup) )
- return nIndex;
- }
- return -1;
- }
- bool CExtPopupMenuWnd::_FindCustomizeMode() const
- {
- DWORD dwTrackFlags = TrackFlagsGet();
- if( (dwTrackFlags&TPMX_CUSTOMIZE_MODE) != 0 )
- return true;
- if( m_pWndParentMenu != NULL )
- return m_pWndParentMenu->_FindCustomizeMode();
- return false;
- }
- BOOL CExtPopupBaseWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- ASSERT_VALID( this );
- if( _FindHelpMode() )
- {
- SetCursor( afxData.hcurHelp );
- return TRUE;
- }
- return __BaseClassOfCExtPopupBaseWnd::OnSetCursor(pWnd, nHitTest, message);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupMenuTipWnd
- IMPLEMENT_DYNCREATE(CExtPopupMenuTipWnd, CExtPopupBaseWnd)
- bool CExtPopupMenuTipWnd::g_bEnableAdvTips = true;
- CExtPopupMenuTipWnd::CExtPopupMenuTipWnd()
- : m_bFlipHorz( false )
- , m_bFlipVert( false )
- , m_sizeClassicMargins( 3, 2 )
- , m_sizeRounders( 12, 10 )
- , m_sizeLeader( 25, 25 )
- , m_nIconMarginDX( 5 )
- , m_nBalloonDistance( 12 )
- , m_nClassicDistance( 13 )
- , m_eTS( CExtPopupMenuTipWnd::__ETS_BALLOON )
- , m_nSizeShadow( -1 )
- , m_ttLA( 0 )
- , m_bPassiveMode( false )
- , m_bDelayedLayeredBehavior( false )
- , m_ptGuideLines( -32767, -32767 )
- , m_nTransparencyKey( BYTE(0x0FF) )
- , m_rcAlignment( 0, 0, 0, 0 )
- , m_nPeriodDelayShowQuick( ID_PERIOD_DELAY_SHOW_QUICK )
- , m_nPeriodDelayShowNormal( ID_PERIOD_DELAY_SHOW_NORMAL )
- , m_hWndLastParent( NULL )
- , m_bNoHideDetection( false )
- {
- m_AnimationType = __AT_NONE;
- m_bAnimFinished = true;
- // HICON hIcon =
- // ::LoadIcon(
- // NULL,
- // IDI_INFORMATION
- // );
- // if( hIcon != NULL )
- // {
- // m_sizeRenderingIcon.cx = 16;
- // m_sizeRenderingIcon.cy = 16;
- // m_icon.m_bmpNormal.AssignFromHICON( hIcon );
- // ::DestroyIcon( hIcon );
- // CExtBitmap::Filter _f( CExtBitmap::Filter::hermite );
- // m_icon.m_bmpNormal.Scale( 14, 14, _f );
- // }
- BYTE arrIconInformation[]=
- {
- 0x42,0x4D,0x36,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,
- 0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,0x14,0x00,0x51,0x26,0x12,0x1B,0x56,0x2A,0x15,0x52,0x55,0x2A,
- 0x15,0x0F,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,
- 0x14,0x00,0x51,0x26,0x11,0x36,0x9A,0x6B,0x45,0xD1,0x75,0x47,0x29,0xCF,0x50,0x26,0x12,0x19,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,0x14,0x00,0x50,0x25,0x11,0x00,0x4C,0x21,0x0C,0x34,0x91,0x66,0x45,0xE4,0xE8,0xBC,
- 0x8E,0xFF,0x78,0x4A,0x2C,0xCD,0x4E,0x23,0x10,0x1F,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x53,0x27,0x13,0x00,0x4F,0x23,0x0F,0x17,0x58,0x2C,
- 0x16,0x66,0x69,0x3F,0x27,0x9C,0x7B,0x54,0x3A,0xE0,0xC8,0xA4,0x81,0xFF,0xEB,0xC3,0x99,0xFF,0x86,0x5B,0x3D,0xF1,0x50,0x24,
- 0x0F,0xB1,0x4F,0x24,0x10,0x65,0x54,0x29,0x14,0x18,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
- 0x15,0x00,0x50,0x24,0x10,0x00,0x5D,0x32,0x1A,0x44,0x8B,0x65,0x4A,0xC8,0xAF,0x8F,0x71,0xFF,0xC7,0xA7,0x87,0xFF,0xD7,0xB8,
- 0x97,0xFF,0xE8,0xC8,0xA5,0xFF,0xF4,0xD0,0xAA,0xFF,0xCF,0xAC,0x8A,0xFF,0xAA,0x85,0x64,0xFF,0x7A,0x51,0x34,0xFB,0x53,0x27,
- 0x11,0xBA,0x53,0x28,0x13,0x3B,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x50,0x24,0x10,0x00,0x70,0x46,0x2D,0x51,0xB2,0x94,
- 0x79,0xF1,0xD8,0xBD,0xA2,0xFF,0xED,0xD1,0xB3,0xFF,0xE8,0xC0,0x9E,0xFF,0xDD,0xA3,0x7A,0xFF,0xEF,0xB4,0x8A,0xFF,0xED,0xB2,
- 0x87,0xFF,0xE9,0xBD,0x97,0xFF,0xEA,0xCA,0xA7,0xFF,0xD3,0xB2,0x91,0xFF,0x9D,0x76,0x56,0xFF,0x58,0x2C,0x15,0xD2,0x52,0x27,
- 0x13,0x36,0x55,0x2A,0x15,0x00,0x63,0x39,0x22,0x25,0xB9,0x9F,0x86,0xEB,0xDF,0xC7,0xB0,0xFF,0xFB,0xDF,0xC2,0xFF,0xFF,0xE6,
- 0xC8,0xFF,0xF3,0xD7,0xB9,0xFF,0xAD,0x64,0x3C,0xFF,0x9F,0x33,0x0D,0xFF,0xB3,0x65,0x3A,0xFF,0xF1,0xD0,0xAD,0xFF,0xFF,0xE1,
- 0xBE,0xFF,0xF6,0xD3,0xB2,0xFF,0xDB,0xBE,0x9E,0xFF,0x9B,0x75,0x56,0xFF,0x52,0x26,0x10,0xAB,0x54,0x2A,0x15,0x0E,0xA2,0x83,
- 0x6A,0x9C,0xDD,0xCA,0xB6,0xFF,0xFB,0xE3,0xCB,0xFF,0xFF,0xE7,0xCD,0xFF,0xFF,0xE4,0xCA,0xFF,0xFF,0xF1,0xD6,0xFF,0xBF,0x8A,
- 0x67,0xFF,0x84,0x19,0x00,0xFF,0xC3,0x88,0x63,0xFF,0xFF,0xEE,0xD1,0xFF,0xFF,0xE0,0xC0,0xFF,0xFF,0xE1,0xC1,0xFF,0xF6,0xD7,
- 0xB8,0xFF,0xD7,0xBA,0x9C,0xFF,0x73,0x49,0x30,0xEE,0x50,0x25,0x10,0x42,0xCC,0xB8,0xA5,0xE7,0xEF,0xDD,0xCB,0xFF,0xFF,0xEC,
- 0xD7,0xFF,0xFF,0xE9,0xD3,0xFF,0xFF,0xE8,0xD1,0xFF,0xFF,0xF2,0xDC,0xFF,0xBD,0x88,0x67,0xFF,0x88,0x1D,0x00,0xFF,0xC3,0x89,
- 0x66,0xFF,0xFF,0xEE,0xD5,0xFF,0xFF,0xE4,0xC8,0xFF,0xFF,0xE3,0xC7,0xFF,0xFF,0xE4,0xC7,0xFF,0xEF,0xD6,0xBA,0xFF,0xA1,0x7E,
- 0x64,0xFD,0x4E,0x22,0x0D,0x5D,0xD3,0xC6,0xB9,0xF0,0xF8,0xE7,0xD8,0xFF,0xFF,0xEF,0xDE,0xFF,0xFF,0xED,0xDB,0xFF,0xFF,0xEC,
- 0xD8,0xFF,0xFF,0xFA,0xE8,0xFF,0xC1,0x8F,0x71,0xFF,0x88,0x1C,0x00,0xFF,0xC3,0x8A,0x69,0xFF,0xFF,0xF2,0xDC,0xFF,0xFF,0xE7,
- 0xCF,0xFF,0xFF,0xE7,0xCE,0xFF,0xFF,0xE8,0xCF,0xFF,0xF8,0xE1,0xC9,0xFF,0xAD,0x8F,0x78,0xFE,0x4D,0x21,0x0C,0x5E,0xD5,0xCB,
- 0xC1,0xF1,0xF9,0xED,0xE1,0xFF,0xFF,0xF3,0xE6,0xFF,0xFF,0xF1,0xE3,0xFF,0xFF,0xF3,0xE4,0xFF,0xEE,0xDD,0xCB,0xFF,0xA3,0x59,
- 0x34,0xFF,0x81,0x13,0x00,0xFF,0xBC,0x86,0x66,0xFF,0xFF,0xF7,0xE6,0xFF,0xFF,0xEB,0xD7,0xFF,0xFF,0xEA,0xD5,0xFF,0xFF,0xED,
- 0xD7,0xFF,0xFA,0xE9,0xD3,0xFF,0xAF,0x93,0x7D,0xF9,0x4D,0x21,0x0C,0x50,0xDB,0xCF,0xC2,0xD5,0xF4,0xEE,0xE7,0xFF,0xFF,0xF9,
- 0xF0,0xFF,0xFF,0xF4,0xEA,0xFF,0xFF,0xF9,0xEF,0xFF,0xDC,0xC4,0xB3,0xFF,0xB5,0x89,0x74,0xFF,0xAE,0x84,0x70,0xFF,0xD1,0xB5,
- 0xA2,0xFF,0xFF,0xF6,0xE7,0xFF,0xFF,0xEF,0xDF,0xFF,0xFF,0xED,0xDC,0xFF,0xFF,0xF6,0xE5,0xFF,0xFB,0xEE,0xDC,0xFF,0x9F,0x7F,
- 0x69,0xD3,0x4D,0x21,0x0B,0x1C,0xE3,0xCF,0xBB,0x6A,0xE8,0xE5,0xE2,0xFF,0xFE,0xFC,0xF8,0xFF,0xFF,0xFA,0xF5,0xFF,0xFF,0xF7,
- 0xEF,0xFF,0xFF,0xFE,0xF8,0xFF,0xF7,0xE5,0xD8,0xFF,0xF3,0xCC,0xB3,0xFF,0xFF,0xF0,0xE3,0xFF,0xFF,0xF5,0xEA,0xFF,0xFF,0xF2,
- 0xE6,0xFF,0xFF,0xF8,0xEF,0xFF,0xFF,0xFA,0xF1,0xFF,0xE7,0xD7,0xC7,0xFF,0x6A,0x41,0x2B,0x67,0x50,0x25,0x10,0x00,0xEC,0xD2,
- 0xB8,0x04,0xE7,0xDB,0xCF,0xB0,0xEF,0xEE,0xEC,0xFF,0xFE,0xFE,0xFD,0xFF,0xFF,0xFE,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0x9C,0x61,
- 0x43,0xFF,0x8F,0x21,0x00,0xFF,0xC7,0x99,0x80,0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFC,0xF8,0xFF,0xFF,0xFF,0xFC,0xFF,0xFA,0xF2,
- 0xE8,0xFF,0x97,0x77,0x62,0x91,0x4D,0x20,0x0B,0x04,0x55,0x2A,0x15,0x00,0xED,0xD3,0xBA,0x00,0xED,0xD4,0xBC,0x0C,0xE7,0xDD,
- 0xD2,0x9B,0xF2,0xF1,0xF0,0xFF,0xFB,0xFC,0xFD,0xFF,0xFE,0xFF,0xFF,0xFF,0xC6,0xB2,0xA8,0xFF,0x8A,0x5C,0x4F,0xFF,0xDF,0xD2,
- 0xCB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xE5,0xDD,0xF1,0x95,0x76,0x64,0x76,0x51,0x24,0x0F,0x03,0x54,0x29,
- 0x14,0x00,0x55,0x2A,0x15,0x00,0xED,0xD3,0xBA,0x00,0xED,0xD4,0xBD,0x00,0xEA,0xD8,0xC6,0x00,0xCB,0xB6,0xA8,0x3D,0xE1,0xD9,
- 0xD1,0xA1,0xF1,0xEE,0xEB,0xE1,0xFA,0xFC,0xFD,0xEE,0xFB,0xFF,0xFF,0xEE,0xFA,0xFA,0xFA,0xEE,0xED,0xE5,0xDD,0xD1,0xAE,0x97,
- 0x89,0x88,0x68,0x40,0x2C,0x26,0x4C,0x20,0x0A,0x00,0x54,0x29,0x14,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x00
- };
- m_sizeRenderingIcon.cx = 16;
- m_sizeRenderingIcon.cy = 16;
- VERIFY(
- m_icon.m_bmpNormal.LoadBMP_Buffer(
- arrIconInformation,
- sizeof(arrIconInformation) / sizeof(arrIconInformation[0])
- )
- );
- g_listAllTips.AddTail( this );
- }
- CExtPopupMenuTipWnd::~CExtPopupMenuTipWnd()
- {
- POSITION pos = g_listAllTips.Find( this );
- if( pos != NULL )
- g_listAllTips.RemoveAt( pos );
- }
- BEGIN_MESSAGE_MAP(CExtPopupMenuTipWnd, CExtPopupBaseWnd)
- //{{AFX_MSG_MAP(CExtPopupMenuTipWnd)
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- ON_WM_ACTIVATEAPP()
- END_MESSAGE_MAP()
- HRGN CExtPopupMenuTipWnd::CalcRegion(
- CDC & dc,
- CSize * pSize // = NULL
- )
- {
- __PROF_UIS_MANAGE_STATE;
- // ASSERT_VALID( this );
- HRGN hRegion = NULL;
- m_bFlipHorz = false;
- m_bFlipVert = false;
- CWnd * pWndSearchMon = GetParent();
- ASSERT_VALID( pWndSearchMon );
- ASSERT( pWndSearchMon->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( pWndSearchMon->GetSafeHwnd() ) );
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, pWndSearchMon );
- CRect rcDesktop =
- g_bUseDesktopWorkArea
- ? _mp.m_rcWorkArea
- : _mp.m_rcMonitor
- ;
- CExtPaintManager * pPM = PmBridge_GetPM();
- ASSERT_VALID( pPM );
- CRect rcTextMeasure( 0, 0, 0, 0 );
- CFont * pAdvTipFont = &m_fontAdvTip;
- if( pAdvTipFont->GetSafeHandle() == NULL )
- pAdvTipFont = pPM->AdvTip_GetFont( this );
- if( pAdvTipFont->GetSafeHandle() == NULL )
- pAdvTipFont = &(pPM->m_FontNormal);
- CFont * pOldFont = dc.SelectObject( pAdvTipFont );
- if( ! m_sText.IsEmpty() )
- dc.DrawText(
- m_sText,
- m_sText.GetLength(),
- &rcTextMeasure,
- DT_LEFT|DT_CALCRECT
- );
- dc.SelectObject( pOldFont );
- CRect rcWnd = rcTextMeasure;
- e_tip_style_t eTS = GetTipStyle();
- switch( eTS )
- {
- case __ETS_BALLOON:
- case __ETS_BALLOON_NO_ICON:
- {
- rcWnd.InflateRect( m_sizeRounders );
- if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
- {
- rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- if( rcWnd.Height() < m_sizeRenderingIcon.cy )
- rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
- }
- POINT ptLeader[3];
- ptLeader[0].x = rcWnd.Width() - m_sizeRounders.cx;
- ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
- ptLeader[1].x = ptLeader[0].x;
- ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
- ptLeader[2].x = ptLeader[0].x - m_sizeLeader.cx;
- ptLeader[2].y = rcWnd.Height() - m_sizeRounders.cy;
- CRect rcRoundRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
- CRect rcRectRgn( 0, 0, rcWnd.Width(), rcWnd.Height() + m_sizeLeader.cy );
- if( ( m_ptTrack.x - rcWnd.Width() ) < rcDesktop.left )
- {
- m_bFlipHorz = true;
- ptLeader[0].x = m_sizeRounders.cx;
- ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
- ptLeader[1].x = ptLeader[0].x;
- ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
- ptLeader[2].x = ptLeader[0].x + m_sizeLeader.cx;
- ptLeader[2].y = ptLeader[0].y;
- }
- if( ( m_ptTrack.y - rcWnd.Height() - m_sizeRounders.cy * 2 ) < rcDesktop.top )
- {
- m_bFlipVert = true;
- ptLeader[0].y -= rcWnd.Height() - m_sizeRounders.cy * 2;
- ptLeader[1].y = ptLeader[0].y - m_sizeLeader.cy;
- ptLeader[2].y -= ptLeader[0].y;
- }
- CRgn rgnLeader, rgnCaption;
- rgnCaption.CreateRoundRectRgn(
- rcRoundRectRgn.left,
- rcRoundRectRgn.top,
- rcRoundRectRgn.right,
- rcRoundRectRgn.bottom,
- m_sizeRounders.cx,
- m_sizeRounders.cy
- );
- rgnLeader.CreatePolygonRgn(
- ptLeader,
- 3,
- ALTERNATE
- );
- hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
- if( hRegion == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- ::CombineRgn(
- hRegion,
- rgnCaption. operator HRGN (),
- rgnLeader. operator HRGN (),
- RGN_OR
- );
- if( m_bFlipVert )
- ::OffsetRgn(
- hRegion,
- 0,
- m_sizeLeader.cy
- );
- if( pSize != NULL )
- {
- pSize->cx = rcWnd.Width();
- pSize->cy = rcWnd.Height() + m_sizeLeader.cy;
- }
- } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
- break;
- case __ETS_RECTANGLE:
- case __ETS_RECTANGLE_NO_ICON:
- case __ETS_INV_RECTANGLE:
- case __ETS_INV_RECTANGLE_NO_ICON:
- {
- if( eTS != __ETS_RECTANGLE_NO_ICON
- && eTS != __ETS_INV_RECTANGLE_NO_ICON
- && (! m_icon.IsEmpty() ) )
- {
- rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- if( rcWnd.Height() < m_sizeRenderingIcon.cy )
- rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
- }
- rcWnd.InflateRect( m_sizeClassicMargins );
- int nSizeShadow = CalcShadowSize();
- ASSERT( nSizeShadow >= 0 );
- rcWnd.InflateRect( 0, 0, nSizeShadow, nSizeShadow );
- CRect rcRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
- hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
- if( hRegion != NULL )
- PmBridge_GetPM()->AdvTip_CalcRgn(
- hRegion,
- rcRectRgn,
- m_ctrlShadow.IsAvailable()
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- && ( ! IsKindOf( RUNTIME_CLASS( CExtPopupKeyTipWnd ) ) )
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- ,
- nSizeShadow,
- this
- );
- if( hRegion == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- if( ( m_ptTrack.x + rcWnd.Width() ) > rcDesktop.right )
- m_bFlipHorz = true;
- if( ( m_ptTrack.y + rcWnd.Height() ) > rcDesktop.bottom )
- m_bFlipVert = true;
- if( pSize != NULL )
- {
- pSize->cx = rcWnd.Width();
- pSize->cy = rcWnd.Height();
- }
- } // rectangle cases
- break;
- default:
- ASSERT( FALSE );
- return NULL;
- } // switch( eTS )
- return hRegion;
- }
- void CExtPopupMenuTipWnd::_EndAnimation()
- {
- //ASSERT_VALID( this );
- if( ( m_eTS == __ETS_RECTANGLE
- || m_eTS == __ETS_RECTANGLE_NO_ICON
- || m_eTS == __ETS_INV_RECTANGLE
- || m_eTS == __ETS_INV_RECTANGLE_NO_ICON
- )
- && m_ctrlShadow.IsAvailable()
- && m_ctrlShadow.GetSafeHwnd() == NULL
- )
- {
- INT nSizeShadow = m_nSizeShadow;
- if( nSizeShadow < 0 )
- nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
- if( nSizeShadow > 0 )
- m_ctrlShadow.Create( m_hWnd, nSizeShadow );
- }
- }
- void CExtPopupMenuTipWnd::_DoPaint(
- CDC & dcPaint,
- bool bUseBackBuffer //= true
- )
- {
- //ASSERT_VALID( this );
- bUseBackBuffer;
- CDC & dc = dcPaint;
- CRect rcLayout;
- GetClientRect( &rcLayout );
- HRGN hRegion = CreateRectRgnIndirect( &rcLayout );
- GetWindowRgn( hRegion );
- CRgn * pRegion = CRgn::FromHandle( hRegion );
- CExtPaintManager * pPM = PmBridge_GetPM();
- ASSERT_VALID( pPM );
- CFont * pAdvTipFont = &m_fontAdvTip;
- if( pAdvTipFont->GetSafeHandle() == NULL )
- pAdvTipFont = pPM->AdvTip_GetFont( this );
- if( pAdvTipFont->GetSafeHandle() == NULL )
- pAdvTipFont = &(pPM->m_FontNormal);
- COLORREF clrAdvTipText = pPM->AdvTip_GetTextColor( this );
- if( clrAdvTipText == COLORREF(-1L) )
- clrAdvTipText = pPM->GetColor( COLOR_INFOTEXT, this );
- e_tip_style_t eTS = GetTipStyle();
- switch( eTS )
- {
- case __ETS_BALLOON:
- case __ETS_BALLOON_NO_ICON:
- {
- CBrush brushWindow;
- brushWindow.CreateSolidBrush(
- //pPM->GetColor( COLOR_INFOBK, this )
- ::GetSysColor( COLOR_INFOBK )
- );
- CBrush brushFrame;
- brushFrame.CreateSolidBrush(
- //pPM->GetColor( COLOR_3DDKSHADOW, this )
- ::GetSysColor( COLOR_3DDKSHADOW )
- );
- CBrush brushInnerFrame;
- brushInnerFrame.CreateSolidBrush(
- //pPM->GetColor( COLOR_3DFACE, this)
- ::GetSysColor( COLOR_3DFACE )
- );
- // frame
- dc.FillRgn( pRegion, &brushWindow );
- dc.FrameRgn( pRegion, &brushInnerFrame, 3, 3 );
- dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
- // adjust icon's area
- rcLayout.DeflateRect( m_sizeRounders.cx, m_sizeRounders.cy, 0, 0 );
- if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
- rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- CFont * pOldFont = dc.SelectObject( pAdvTipFont );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- int nIconVertPos = m_sizeRounders.cy;
- if( m_bFlipVert )
- {
- rcLayout.OffsetRect( 0, m_sizeLeader.cy );
- nIconVertPos += m_sizeLeader.cy;
- }
- COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
- dc.DrawText(
- m_sText,
- m_sText.GetLength(),
- &rcLayout,
- DT_TOP|DT_LEFT
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldTextColor );
- dc.SelectObject( pOldFont );
- // icon
- if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
- {
- // ICON 2.53
- // HICON hIcon = m_icon.GetIcon();
- // if( hIcon != NULL )
- // ::DrawIconEx(
- // dc.GetSafeHdc(),
- // m_sizeRounders.cx,
- // nIconVertPos,
- // hIcon,
- // m_sizeRenderingIcon.cx,
- // m_sizeRenderingIcon.cy,
- // 0,
- // NULL,
- // DI_NORMAL
- // );
- m_icon.Paint(
- pPM,
- dc.GetSafeHdc(),
- m_sizeRounders.cx,
- nIconVertPos,
- m_sizeRenderingIcon.cx,
- m_sizeRenderingIcon.cy
- );
- }
- } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
- break;
- case __ETS_RECTANGLE:
- case __ETS_RECTANGLE_NO_ICON:
- case __ETS_INV_RECTANGLE:
- case __ETS_INV_RECTANGLE_NO_ICON:
- {
- int nSizeShadow = CalcShadowSize();
- ASSERT( nSizeShadow >= 0 );
- if( nSizeShadow > 0 )
- {
- rcLayout.DeflateRect( 0, 0, nSizeShadow, nSizeShadow );
- m_shadow.Paint(
- pPM,
- dc,
- rcLayout,
- CRect( 0, 0, 0, 0 ),
- CRect( 0, 0, 0, 0 ),
- nSizeShadow,
- 70,
- 95
- );
- }
- bool bAdvTipWithShadow =
- ( m_nSizeShadow > 0
- || ( m_ctrlShadow.GetSafeHwnd() != NULL
- && ( m_ctrlShadow.GetStyle() & WS_VISIBLE ) != 0
- )
- ) ? true : false;
- if( ! pPM->AdvTip_PaintBackground(
- dc,
- rcLayout,
- bAdvTipWithShadow,
- this
- )
- )
- {
- // frame
- //dc.FillRgn( pRegion, &brushWindow );
- //dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
- dc.FillSolidRect(
- &rcLayout,
- ::GetSysColor( COLOR_INFOBK )
- );
- dc.Draw3dRect(
- &rcLayout,
- pPM->GetColor( COLOR_3DDKSHADOW, this ),
- pPM->GetColor( COLOR_3DDKSHADOW, this )
- );
- }
- // adjust icon's area
- rcLayout.DeflateRect( m_sizeClassicMargins );
- if( eTS != __ETS_RECTANGLE_NO_ICON
- && eTS != __ETS_INV_RECTANGLE_NO_ICON
- && (! m_icon.IsEmpty() )
- )
- rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
-
- CFont * pOldFont = dc.SelectObject( pAdvTipFont );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
- dc.DrawText(
- m_sText,
- m_sText.GetLength(),
- &rcLayout,
- DT_TOP|DT_LEFT|DT_VCENTER
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldTextColor );
- dc.SelectObject( pOldFont );
- // icon
- if( eTS != __ETS_RECTANGLE_NO_ICON
- && eTS != __ETS_INV_RECTANGLE_NO_ICON
- && (! m_icon.IsEmpty() )
- )
- {
- int nIconHorzPos =
- rcLayout.left
- - m_sizeRenderingIcon.cx
- - m_nIconMarginDX
- ;
- int nIconVertPos =
- rcLayout.top
- + ( rcLayout.Height() - m_sizeRenderingIcon.cy ) / 2
- ;
- // ICON 2.53
- // HICON hIcon = m_icon.GetIcon();
- // if( hIcon != NULL )
- // ::DrawIconEx(
- // dc.GetSafeHdc(),
- // nIconHorzPos,
- // nIconVertPos,
- // hIcon,
- // m_sizeRenderingIcon.cx,
- // m_sizeRenderingIcon.cy,
- // 0,
- // NULL,
- // DI_NORMAL
- // );
- m_icon.Paint(
- pPM,
- dc.GetSafeHdc(),
- nIconHorzPos,
- nIconVertPos,
- m_sizeRenderingIcon.cx,
- m_sizeRenderingIcon.cy
- );
- }
- } // rectangle cases
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( eTS )
- ::DeleteObject( hRegion );
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuTipWnd::GetText() const
- {
- return LPCTSTR(m_sText);
- }
- void CExtPopupMenuTipWnd::SetText(
- __EXT_MFC_SAFE_LPCTSTR lpszText
- )
- {
- //ASSERT_VALID( this );
- m_sText = ( lpszText == NULL ) ? _T("") : lpszText;
- m_sText.TrimLeft();
- m_sText.TrimRight();
- }
- void CExtPopupMenuTipWnd::SetIcon(
- HICON hIcon,
- bool bCloneIcon // = false
- )
- {
- //ASSERT_VALID( this );
- if( ! m_icon.IsEmpty() )
- m_icon.Empty();
- if( hIcon == NULL )
- return;
- m_icon.AssignFromHICON( hIcon, bCloneIcon );
- m_sizeRenderingIcon = m_icon.GetSize();
- if( m_hWnd != NULL && ::IsWindow( m_hWnd ) )
- RedrawWindow();
- }
- void CExtPopupMenuTipWnd::SetIcon(
- CExtCmdIcon & _icon
- )
- {
- //ASSERT_VALID( this );
- m_icon = _icon;
- m_sizeRenderingIcon = m_icon.GetSize();
- if( m_hWnd != NULL && ::IsWindow( m_hWnd ) )
- RedrawWindow();
- }
- CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuTipWnd::GetTipStyle() const
- {
- //ASSERT_VALID( this );
- return m_eTS;
- }
- void CExtPopupMenuTipWnd::SetTipStyle( CExtPopupMenuTipWnd::e_tip_style_t eTS )
- {
- //ASSERT_VALID( this );
- m_eTS = eTS;
- }
- int CExtPopupMenuTipWnd::GetShadowSize() const
- {
- //ASSERT_VALID( this );
- return m_nSizeShadow;
- }
- void CExtPopupMenuTipWnd::SetShadowSize( int nSizeShadow )
- {
- //ASSERT_VALID( this );
- if( m_nSizeShadow == nSizeShadow )
- return;
- m_shadow.Destroy();
- m_nSizeShadow = nSizeShadow;
- }
- int CExtPopupMenuTipWnd::CalcShadowSize() const
- {
- //ASSERT_VALID( this );
- if( m_ctrlShadow.IsAvailable() )
- return 0;
- if( m_nSizeShadow >= 0 )
- return m_nSizeShadow;
- int nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
- if( nSizeShadow < 0 )
- return 0;
- return nSizeShadow;
- }
- CTypedPtrList < CPtrList, CExtPopupMenuTipWnd * > CExtPopupMenuTipWnd::g_listAllTips;
- void CExtPopupMenuTipWnd::UpdateDelayedLayeredBehaviorAll(
- CRuntimeClass * pRTC // = NULL
- )
- {
- POSITION pos = g_listAllTips.GetHeadPosition();
- for( ; pos != NULL; )
- {
- CExtPopupMenuTipWnd * pWndPopupMenuTip = g_listAllTips.GetNext( pos );
- ASSERT_VALID( pWndPopupMenuTip );
- if( pRTC != NULL )
- {
- if( ! pWndPopupMenuTip->IsKindOf( pRTC ) )
- continue;
- }
- pWndPopupMenuTip->UpdateDelayedLayeredBehavior();
- }
- }
- void CExtPopupMenuTipWnd::UpdateDelayedLayeredBehavior()
- {
- __PROF_UIS_MANAGE_STATE;
- //ASSERT_VALID( this );
- if( ( ! m_bDelayedLayeredBehavior )
- || ( ! g_PaintManager.m_bIsWin2000orLater )
- || GetSafeHwnd() == NULL
- )
- return;
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
- }
- bool CExtPopupMenuTipWnd::Show(
- CWnd * pWndParent,
- const RECT & rcExcludeArea,
- bool bNoDelay,
- HDWP & hPassiveModeDWP
- )
- {
- __PROF_UIS_MANAGE_STATE;
- //ASSERT_VALID( this );
- ASSERT_VALID( pWndParent );
- ASSERT( pWndParent->GetSafeHwnd() != NULL );
- if( ! g_bEnableAdvTips )
- {
- Hide();
- return true;
- }
- e_tip_style_t eTS = GetTipStyle();
- if( eTS == __ETS_NONE )
- {
- Hide();
- return true;
- }
- bool bQuickDelay = false;
- if( GetSafeHwnd() != NULL )
- {
- if( m_rcExcludeArea == rcExcludeArea )
- return true;
- if( ( ! bNoDelay )
- && (GetStyle()&WS_VISIBLE) != 0
- )
- bQuickDelay = true;
- Hide();
- if( ( ! bNoDelay ) && ( ! bQuickDelay ) )
- {
- long ttLA = (long)::time( NULL );
- long ttDist = ttLA - m_ttLA;
- if( ttDist <= 1 )
- {
- bQuickDelay = true;
- m_ttLA = ttLA;
- } // if( ttDist <= 1 )
- } // if( ( ! bNoDelay ) && ( ! bQuickDelay ) )
- } // if( GetSafeHwnd() != NULL )
- HCURSOR hCursor = ::LoadCursor( NULL, IDC_ARROW );
- ASSERT( hCursor != NULL );
- if( GetSafeHwnd() != NULL
- && GetParent() != pWndParent
- )
- {
- Hide();
- DestroyWindow();
- }
- if( GetSafeHwnd() == NULL )
- {
- CExtSafeString strClassName = ::AfxRegisterWndClass ( __TIP_WNDCLASS_STYLES__, hCursor, NULL, NULL );
- bool bLayered = false, bForceLayered = false;
- if( m_bPassiveMode
- && ( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
- || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
- )
- )
- bLayered = true;
- if( (! bLayered)
- && g_PaintManager.m_bIsWin2000orLater
- && g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL
- && ( m_AnimationType == __AT_NONE || m_AnimationType == __AT_CONTENT_DISPLAY )
- )
- bForceLayered = true;
- BOOL bCreateResult =
- CWnd::CreateEx(
- WS_EX_TOPMOST // | WS_EX_TRANSPARENT
- | ( g_PaintManager.m_bIsWin2000orLater ? (WS_EX_NOINHERITLAYOUT) : 0 )
- | ( ( bLayered || bForceLayered ) ? (__EXT_MFC_WS_EX_LAYERED) : 0 )
- ,
- strClassName,
- NULL,
- WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
- 0, 0, 0, 0,
- pWndParent->GetSafeHwnd(),
- NULL,
- NULL
- );
- ASSERT( bCreateResult );
- if( ! bCreateResult )
- return false;
- if( bForceLayered && (!bLayered) )
- {
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
- ShowWindow( SW_SHOWNOACTIVATE );
- Invalidate( FALSE );
- UpdateWindow();
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 255, __EXT_MFC_LWA_ALPHA );
- }
- if( m_bPassiveMode
- && ( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
- || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
- )
- )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 0, __EXT_MFC_LWA_ALPHA );
- }
- } // if( GetSafeHwnd() == NULL )
- #ifdef _DEBUG
- else
- {
- ASSERT_VALID( pWndParent );
- ASSERT( ::IsWindow( pWndParent->GetSafeHwnd() ) );
- } // else from if( GetSafeHwnd() == NULL )
- #endif // _DEBUG
- m_rcExcludeArea = rcExcludeArea;
- m_rcExcludeArea.NormalizeRect();
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, m_rcExcludeArea.CenterPoint() );
- CRect rcDesktop =
- g_bUseDesktopWorkArea
- ? _mp.m_rcWorkArea
- : _mp.m_rcMonitor
- ;
- CPoint ptTipTarget( m_rcExcludeArea.TopLeft() );
- CPoint ptWndPos( 0, 0 );
- CSize _sizeWindow( 0, 0 );
- bool bIR = true;
- switch( eTS )
- {
- case __ETS_BALLOON:
- case __ETS_BALLOON_NO_ICON:
- {
- ptTipTarget +=
- CSize( m_nBalloonDistance/2, m_nBalloonDistance/2 );
- m_ptTrack = m_ptTrackOriginal = ptTipTarget;
- CDC * pDC = GetDC();
- ASSERT_VALID( pDC );
- HRGN hRegion = CalcRegion( *pDC, &_sizeWindow );
- ASSERT( hRegion != NULL );
- ReleaseDC(pDC);
- VERIFY(
- ::SetWindowRgn(
- m_hWnd,
- hRegion,
- TRUE
- )
- );
- if( m_bFlipHorz )
- m_ptTrack.x +=
- m_rcExcludeArea.Width() - m_nBalloonDistance
- + _sizeWindow.cx - m_sizeRounders.cx * 2
- ;
- if( m_bFlipVert )
- m_ptTrack.y +=
- m_rcExcludeArea.Height() - m_nBalloonDistance
- + _sizeWindow.cy - m_sizeRounders.cx * 2
- ;
- ptWndPos.x = m_ptTrack.x - _sizeWindow.cx + m_sizeRounders.cx;
- ptWndPos.y = m_ptTrack.y - _sizeWindow.cy + m_sizeRounders.cy;
- SetWindowPos(
- &CWnd::wndTopMost,
- ptWndPos.x,
- ptWndPos.y,
- _sizeWindow.cx,
- _sizeWindow.cy,
- SWP_HIDEWINDOW|SWP_NOSENDCHANGING
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE //|SWP_NOCOPYBITS
- );
- } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
- break;
- case __ETS_RECTANGLE:
- case __ETS_RECTANGLE_NO_ICON:
- bIR = false; // continue cases
- case __ETS_INV_RECTANGLE:
- case __ETS_INV_RECTANGLE_NO_ICON:
- {
- CDC * pDC = GetDC();
- ASSERT_VALID( pDC );
- HRGN hRegion = CalcRegion( *pDC, &_sizeWindow );
- ASSERT( hRegion != NULL );
- ReleaseDC(pDC);
- ptTipTarget.x = m_rcExcludeArea.CenterPoint().x;
- if( m_bFlipHorz )
- ptTipTarget.x -=
- m_rcExcludeArea.Width()
- + _sizeWindow.cx
- ;
- if( bIR )
- ptTipTarget.y =
- m_rcExcludeArea.top
- - _sizeWindow.cy
- - 3
- ;
- else
- {
- bool bResetY = true;
- POINT ptCursor = { 0, 0 };
- if( ::GetCursorPos( &ptCursor )
- && m_rcExcludeArea.PtInRect(ptCursor)
- )
- {
- CExtCmdIcon _icon;
- _icon.AssignFromHICON( (HICON)hCursor, false, true );
- if( ! _icon.IsEmpty() )
- {
- ptTipTarget.x = ptCursor.x;
- if( m_bFlipHorz )
- ptTipTarget.x -=
- _sizeWindow.cx
- ;
- CSize _sizeIcon = _icon.GetSize();
- if( ! g_PaintManager.m_bIsWinXPorLater )
- {
- if( _sizeIcon.cx > 16 )
- _sizeIcon.cx = 16;
- if( _sizeIcon.cy > 16 )
- _sizeIcon.cy = 16;
- }
- ptTipTarget.y =
- ptCursor.y
- + _sizeIcon.cy
- ;
- if( ptTipTarget.y < m_rcExcludeArea.bottom )
- ptTipTarget.y = m_rcExcludeArea.bottom;
- bResetY = false;
- }
- }
- if( bResetY )
- ptTipTarget.y =
- m_rcExcludeArea.bottom
- + m_nClassicDistance
- ;
- }
- m_ptTrack = m_ptTrackOriginal = ptTipTarget;
- VERIFY(
- ::SetWindowRgn(
- m_hWnd,
- hRegion,
- TRUE
- )
- );
- if( m_bFlipVert )
- {
- if( bIR )
- m_ptTrack.y =
- m_rcExcludeArea.bottom
- + m_nClassicDistance
- ;
- else
- m_ptTrack.y =
- m_rcExcludeArea.top
- - m_nClassicDistance
- ;
- }
- if( (m_ptTrack.x + _sizeWindow.cx) > rcDesktop.right )
- m_ptTrack.x = rcDesktop.right - _sizeWindow.cx;
- if( m_ptTrack.x < rcDesktop.left )
- m_ptTrack.x = rcDesktop.left;
- if( (m_ptTrack.y + _sizeWindow.cy) > rcDesktop.bottom )
- m_ptTrack.y = rcDesktop.bottom - _sizeWindow.cy;
- if( m_ptTrack.y < rcDesktop.top )
- m_ptTrack.y = rcDesktop.top;
- ptWndPos = m_ptTrack;
- SetWindowPos(
- &CWnd::wndTopMost,
- ptWndPos.x,
- ptWndPos.y,
- _sizeWindow.cx,
- _sizeWindow.cy,
- SWP_HIDEWINDOW|SWP_NOSENDCHANGING
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE //|SWP_NOCOPYBITS
- );
- } // rectangle cases
- break;
- default:
- ASSERT( FALSE );
- return NULL;
- } // switch( eTS )
- if( hCursor != NULL )
- ::DestroyCursor( hCursor );
- if( m_ptGuideLines.x != -32767 && m_ptGuideLines.y != -32767 )
- {
- CRect rcWnd(
- CPoint(
- m_ptGuideLines.x - _sizeWindow.cx / 2,
- m_ptGuideLines.y - _sizeWindow.cy / 2
- ),
- _sizeWindow
- );
- MoveWindow( &rcWnd );
- }
- else
- {
- CRect rcWnd( ptWndPos, _sizeWindow );
- if( ! m_rcAlignment.IsRectEmpty() )
- {
- rcWnd.OffsetRect(
- m_rcAlignment.left - rcWnd.left,
- m_rcAlignment.bottom - rcWnd.top
- );
- m_rcAlignment.SetRect( 0, 0, 0, 0 );
- }
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, m_rcExcludeArea );
- CRect rcDesktop = g_bUseDesktopWorkArea
- ? _mp.m_rcWorkArea
- : _mp.m_rcMonitor
- ;
- if( rcWnd.right > rcDesktop.right )
- rcWnd.OffsetRect(
- - ( rcWnd.right - rcDesktop.right ),
- 0
- );
- if( rcWnd.left < rcDesktop.left )
- rcWnd.OffsetRect( rcDesktop.left - rcWnd.left, 0 );
- if( rcWnd.bottom > rcDesktop.bottom )
- rcWnd.OffsetRect(
- 0,
- - ( rcWnd.bottom - rcDesktop.bottom )
- );
- if( rcWnd.top < rcDesktop.top )
- rcWnd.OffsetRect( 0, rcDesktop.top - rcWnd.top );
- MoveWindow( &rcWnd );
- }
- if( ! m_bPassiveMode )
- {
- if( bNoDelay )
- SendMessage( WM_TIMER, ID_TIMER_DELAY_SHOW );
- else
- SetTimer( ID_TIMER_DELAY_SHOW, bQuickDelay ? m_nPeriodDelayShowQuick : m_nPeriodDelayShowNormal, NULL );
- SetTimer( ID_TIMER_DELAY_KILL, ID_PERIOD_DELAY_KILL, NULL );
- SetTimer( ID_TIMER_LIFE_STEP, ID_PERIOD_LIFE_STEP, NULL );
- } // if( ! m_bPassiveMode )
- else
- {
- EnableWindow( FALSE );
- if( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
- || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
- )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- if( hPassiveModeDWP != NULL && g_PaintManager.m_bIsWinVistaOrLater )
- {
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
- hPassiveModeDWP =
- ::DeferWindowPos(
- hPassiveModeDWP, m_hWnd, NULL, 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- //|SWP_NOREDRAW
- |SWP_SHOWWINDOW
- );
- } // if( hPassiveModeDWP != NULL && g_PaintManager.m_bIsWinVistaOrLater )
- if( hPassiveModeDWP == NULL
- || m_bDelayedLayeredBehavior
- || ( ! g_PaintManager.m_bIsWinVistaOrLater )
- )
- {
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
- ShowWindow( SW_SHOWNOACTIVATE );
- if( ! m_bDelayedLayeredBehavior )
- {
- Invalidate( FALSE );
- UpdateWindow();
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
- }
- } // if( hPassiveModeDWP == NULL || ...
- }
- //ModifyStyleEx( 0, WS_EX_TRANSPARENT );
- } // else from if( ! m_bPassiveMode )
- m_hWndLastParent = pWndParent->GetSafeHwnd();
- return true;
- }
- void CExtPopupMenuTipWnd::Hide()
- {
- //ASSERT_VALID( this );
- if( GetSafeHwnd() != NULL )
- {
- KillTimer( ID_TIMER_DELAY_SHOW );
- KillTimer( ID_TIMER_DELAY_KILL );
- KillTimer( ID_TIMER_LIFE_STEP );
- KillTimer( ID_TIMER_ANIMATION );
- SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_HIDEWINDOW|SWP_NOSENDCHANGING
- |SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE //|SWP_NOCOPYBITS
- );
- // CWnd * pWnd = GetParent();
- // CExtPopupMenuWnd * pPopup =
- // DYNAMIC_DOWNCAST(
- // CExtPopupMenuWnd,
- // pWnd
- // );
- // for( ; pPopup != NULL; pPopup = pPopup->GetParentMenuWnd() )
- // pPopup->_DelayPaint();
- }
- m_hWndLastParent = NULL;
- m_rcExcludeArea.SetRectEmpty();
- m_shadow.Destroy();
- if( m_ctrlShadow.GetSafeHwnd() != NULL )
- m_ctrlShadow.DestroyWindow();
- }
- void CExtPopupMenuTipWnd::OnTimer( __EXT_MFC_UINT_PTR nIDEvent )
- {
- //ASSERT_VALID( this );
- switch( nIDEvent )
- {
- case ID_TIMER_LIFE_STEP:
- if( CExtPopupMenuWnd::IsKeyPressed(VK_LBUTTON)
- || CExtPopupMenuWnd::IsKeyPressed(VK_MBUTTON)
- || CExtPopupMenuWnd::IsKeyPressed(VK_RBUTTON)
- )
- {
- HWND hWndCapture = ::GetCapture();
- if( hWndCapture != NULL && ::IsWindow( hWndCapture ) )
- {
- CWnd * pWndCapture = CWnd::FromHandlePermanent( hWndCapture );
- if( pWndCapture != NULL
- && pWndCapture->IsKindOf( RUNTIME_CLASS(CExtScrollBar) )
- && ((CExtScrollBar*)pWndCapture)->m_bCompleteRepaint
- )
- return;
- }
- Hide();
- }
- else if(
- CExtPopupMenuWnd::IsKeyPressed(VK_MENU)
- || CExtControlBar::_DraggingGetBar() != NULL
- )
- Hide();
- else if( CExtPopupMenuWnd::IsMenuTracking() )
- {
- CWnd * pWndParent = GetParent();
- if( pWndParent == NULL
- || (! pWndParent->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- )
- Hide();
- }
- return;
- case ID_TIMER_DELAY_SHOW:
- KillTimer( ID_TIMER_DELAY_SHOW );
- if( m_AnimationType != __AT_NONE )
- {
- SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_SHOWWINDOW|SWP_NOSENDCHANGING|SWP_NOREDRAW
- |SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE //|SWP_NOCOPYBITS
- );
- // if( g_DefAnimationType != CExtPopupMenuWnd::__AT_NONE )
- _StartAnimation();
- return;
- }
- if( g_PaintManager.m_bIsWin2000orLater && m_nTransparencyKey != BYTE(0x0FF) )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
- }
- SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_SHOWWINDOW|SWP_NOSENDCHANGING
- |SWP_NOSIZE|SWP_NOMOVE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE //|SWP_NOCOPYBITS
- );
- Invalidate( FALSE );
- UpdateWindow();
- if( g_PaintManager.m_bIsWin2000orLater && m_nTransparencyKey != BYTE(0x0FF) )
- {
- ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
- g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
- Invalidate( FALSE );
- UpdateWindow();
- }
- if( ( m_eTS == __ETS_RECTANGLE
- || m_eTS == __ETS_RECTANGLE_NO_ICON
- || m_eTS == __ETS_INV_RECTANGLE
- || m_eTS == __ETS_INV_RECTANGLE_NO_ICON
- )
- && m_ctrlShadow.IsAvailable()
- )
- {
- INT nSizeShadow = m_nSizeShadow;
- if( nSizeShadow < 0 )
- nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
- if( nSizeShadow > 0 )
- m_ctrlShadow.Create( m_hWnd, nSizeShadow );
- }
- return;
- case ID_TIMER_DELAY_KILL:
- if( m_bNoHideDetection )
- return;
- POINT ptCursor = { 0, 0 };
- if( ::GetCursorPos( &ptCursor )
- && m_rcExcludeArea.PtInRect(ptCursor)
- )
- return;
- Hide();
- return;
- } // switch( nIDEvent )
- CExtPopupBaseWnd::OnTimer( nIDEvent );
- }
- #if _MFC_VER < 0x700
- void CExtPopupMenuTipWnd::OnActivateApp(BOOL bActive, HTASK hTask)
- #else
- void CExtPopupMenuTipWnd::OnActivateApp(BOOL bActive, DWORD hTask)
- #endif
- {
- //ASSERT_VALID( this );
- bActive;
- hTask;
- Hide();
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupKeyTipWnd
- IMPLEMENT_DYNCREATE( CExtPopupKeyTipWnd, CExtPopupMenuTipWnd );
- CExtPopupKeyTipWnd::CExtPopupKeyTipWnd()
- {
- m_bPassiveMode = true;
- SetShadowSize( 0 );
- SetTipStyle( __ETS_RECTANGLE_NO_ICON );
- }
- CExtPopupKeyTipWnd::~CExtPopupKeyTipWnd()
- {
- }
- BEGIN_MESSAGE_MAP(CExtPopupKeyTipWnd,CExtPopupMenuTipWnd)
- //{{AFX_MSG_MAP(CExtPopupKeyTipWnd)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- bool CExtPopupKeyTipWnd::Create(
- CWnd * pWndKeyTipParent,
- CPoint ptGuideLines,
- __EXT_MFC_SAFE_LPCTSTR strKeyTipText,
- bool bEnabled,
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- ASSERT( strKeyTipText != NULL && _tcslen( strKeyTipText ) > 0 );
- ASSERT_VALID( pWndKeyTipParent );
- ASSERT( pWndKeyTipParent->GetSafeHwnd() != NULL );
- SetText( strKeyTipText );
- m_ptGuideLines = ptGuideLines;
- CRect rcKeyTipExcludeArea( ptGuideLines, ptGuideLines );
- rcKeyTipExcludeArea.InflateRect( 1, 1 );
- m_nTransparencyKey = BYTE(0x0FF);
- m_bDelayedLayeredBehavior = true;
- if( ( ! bEnabled ) && g_PaintManager.m_bIsWin2000orLater )
- m_nTransparencyKey = BYTE(0x080);
- if( ! Show( pWndKeyTipParent, rcKeyTipExcludeArea, true, hPassiveModeDWP ) )
- {
- return false;
- }
- return true;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtPopupScreenTipWnd
- IMPLEMENT_DYNCREATE( CExtPopupScreenTipWnd, CExtPopupMenuTipWnd );
- CExtPopupScreenTipWnd::CExtPopupScreenTipWnd()
- {
- m_AnimationType = g_PaintManager.m_bIsWin2000orLater ? __AT_NONE : __AT_FADE;
- m_nPeriodDelayShowQuick = ID_PERIOD_DELAY_SHOW_NORMAL;
- m_nPeriodDelayShowNormal = ID_PERIOD_DELAY_SHOW_RIBBON;
- m_sizeClassicMargins.cx = m_sizeClassicMargins.cy = 0;
- SetTipStyle( __ETS_RECTANGLE_NO_ICON );
- }
- CExtPopupScreenTipWnd::~CExtPopupScreenTipWnd()
- {
- }
- BEGIN_MESSAGE_MAP(CExtPopupScreenTipWnd,CExtPopupMenuTipWnd)
- //{{AFX_MSG_MAP(CExtPopupScreenTipWnd)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- HRGN CExtPopupScreenTipWnd::CalcRegion(
- CDC & dc,
- CSize * pSize // = NULL
- )
- {
- __PROF_UIS_MANAGE_STATE;
- // ASSERT_VALID( this );
- if( m_cmdScreenTip.IsEmpty() )
- return CExtPopupMenuTipWnd::CalcRegion( dc, pSize );
- HRGN hRegion = NULL;
- m_bFlipHorz = false;
- m_bFlipVert = false;
- CWnd * pWndSearchMon = GetParent();
- ASSERT_VALID( pWndSearchMon );
- ASSERT( pWndSearchMon->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow( pWndSearchMon->GetSafeHwnd() ) );
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, pWndSearchMon );
- CRect rcDesktop =
- g_bUseDesktopWorkArea
- ? _mp.m_rcWorkArea
- : _mp.m_rcMonitor
- ;
- CExtPaintManager * pPM = PmBridge_GetPM();
- ASSERT_VALID( pPM );
- CRect rcWnd( CPoint(0,0), pPM->ScreenTip_Measure( dc, m_cmdScreenTip, this ) );
- e_tip_style_t eTS = GetTipStyle();
- switch( eTS )
- {
- case __ETS_BALLOON:
- case __ETS_BALLOON_NO_ICON:
- {
- rcWnd.InflateRect( m_sizeRounders );
- if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
- {
- rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- if( rcWnd.Height() < m_sizeRenderingIcon.cy )
- rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
- }
- POINT ptLeader[3];
- ptLeader[0].x = rcWnd.Width() - m_sizeRounders.cx;
- ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
- ptLeader[1].x = ptLeader[0].x;
- ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
- ptLeader[2].x = ptLeader[0].x - m_sizeLeader.cx;
- ptLeader[2].y = rcWnd.Height() - m_sizeRounders.cy;
- CRect rcRoundRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
- CRect rcRectRgn( 0, 0, rcWnd.Width(), rcWnd.Height() + m_sizeLeader.cy );
- if( ( m_ptTrack.x - rcWnd.Width() ) < rcDesktop.left )
- {
- m_bFlipHorz = true;
- ptLeader[0].x = m_sizeRounders.cx;
- ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
- ptLeader[1].x = ptLeader[0].x;
- ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
- ptLeader[2].x = ptLeader[0].x + m_sizeLeader.cx;
- ptLeader[2].y = ptLeader[0].y;
- }
- if( ( m_ptTrack.y - rcWnd.Height() - m_sizeRounders.cy * 2 ) < rcDesktop.top )
- {
- m_bFlipVert = true;
- ptLeader[0].y -= rcWnd.Height() - m_sizeRounders.cy * 2;
- ptLeader[1].y = ptLeader[0].y - m_sizeLeader.cy;
- ptLeader[2].y -= ptLeader[0].y;
- }
- CRgn rgnLeader, rgnCaption;
- rgnCaption.CreateRoundRectRgn(
- rcRoundRectRgn.left,
- rcRoundRectRgn.top,
- rcRoundRectRgn.right,
- rcRoundRectRgn.bottom,
- m_sizeRounders.cx,
- m_sizeRounders.cy
- );
- rgnLeader.CreatePolygonRgn(
- ptLeader,
- 3,
- ALTERNATE
- );
- hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
- if( hRegion == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- ::CombineRgn(
- hRegion,
- rgnCaption. operator HRGN (),
- rgnLeader. operator HRGN (),
- RGN_OR
- );
- if( m_bFlipVert )
- ::OffsetRgn(
- hRegion,
- 0,
- m_sizeLeader.cy
- );
- if( pSize != NULL )
- {
- pSize->cx = rcWnd.Width();
- pSize->cy = rcWnd.Height() + m_sizeLeader.cy;
- }
- } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
- break;
- case __ETS_RECTANGLE:
- case __ETS_RECTANGLE_NO_ICON:
- case __ETS_INV_RECTANGLE:
- case __ETS_INV_RECTANGLE_NO_ICON:
- {
- if( eTS != __ETS_RECTANGLE_NO_ICON
- && eTS != __ETS_INV_RECTANGLE_NO_ICON
- && (! m_icon.IsEmpty() ) )
- {
- rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
- if( rcWnd.Height() < m_sizeRenderingIcon.cy )
- rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
- }
- rcWnd.InflateRect( m_sizeClassicMargins );
- int nSizeShadow = CalcShadowSize();
- ASSERT( nSizeShadow >= 0 );
- rcWnd.InflateRect( 0, 0, nSizeShadow, nSizeShadow );
- CRect rcRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
- hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
- if( hRegion != NULL )
- PmBridge_GetPM()->AdvTip_CalcRgn(
- hRegion,