ExtPopupMenuWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:735k
源码类别:

界面编程

开发平台:

Visual C++

  1. m_sizeItem.cx += __DROPDOWN_ARROW_GAP * 2 + __EXT_MENU_GAP + 3;
  2. if( ! bForceNoText )
  3. m_sizeItem.cx += __EXT_MENU_GAP;
  4. }
  5. //m_sizeItem.cx += __EXT_MENU_TOOLBTN_GAP * 2;
  6. m_sizeItem.cx += __EXT_MENU_TOOLBTN_GAP;
  7. // if( bForceNoText )
  8. // {
  9. // m_sizeItem.cx += 3;
  10. // m_sizeItem.cy += 3;
  11. // }
  12. } // if( IsToolButton() )
  13. else
  14. {
  15. m_sizeItem.cx +=
  16. m_nIconAreaWidth // sizeIcon.cx
  17. + __EXT_MENU_POPUP_ARROW_AREA_DX;
  18. } // else from if( IsToolButton() )
  19. if( IsToolButton() )
  20. {
  21. CExtPopupMenuWnd * pOwner = GetOwner();
  22. ASSERT_VALID( pOwner );
  23. CSize _size = pPM->Toolbar_GetMinButtonSize( pOwner );
  24. ASSERT( _size.cx >= 0 && _size.cy >= 0 );
  25. // if( m_sizeItem.cx < _size.cx )
  26. // m_sizeItem.cx = _size.cx;
  27. if( m_sizeItem.cy < _size.cy )
  28. m_sizeItem.cy = _size.cy;
  29. if( pPM->OnQueryPaintManagerName() == CExtPaintManager::ProfSkinPainter )
  30. {
  31. m_sizeItem.cx += _size.cx;
  32. }
  33. else
  34. {
  35. if( m_sizeItem.cx < _size.cx )
  36. m_sizeItem.cx = _size.cx;
  37. }
  38. } // if( IsToolButton() )
  39. }
  40. bool CExtPopupMenuWnd::MENUITEMDATA::UpdateFromMenu(
  41. HWND hWndCmdProfileInfo,
  42. CMenu * pTrackMenu,
  43. int nItemIndex,
  44. bool bNoRefToCmdMngr // = false
  45. )
  46. {
  47. ASSERT( pTrackMenu != NULL );
  48. ASSERT( pTrackMenu->GetSafeHmenu() != NULL );
  49. #ifdef _DEBUG
  50. int nMenuItemCount = pTrackMenu->GetMenuItemCount();
  51. ASSERT( nMenuItemCount > 0 );
  52. ASSERT( nItemIndex >= 0 && nItemIndex<nMenuItemCount );
  53. #endif // _DEBUG
  54. MENUITEMINFO _mii;
  55. ::memset( &_mii, 0, sizeof(MENUITEMINFO) );
  56. _mii.cbSize = sizeof(MENUITEMINFO);
  57. _mii.fMask = MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE;
  58. _mii.cch = __MAX_UI_ITEM_TEXT;
  59. CExtSafeString _sItemText;
  60. _mii.dwTypeData =
  61. _sItemText.GetBuffer(__MAX_UI_ITEM_TEXT);
  62. ASSERT( _mii.dwTypeData != NULL );
  63. if( _mii.dwTypeData == NULL )
  64. {
  65. ASSERT( FALSE );
  66. return false;
  67. }
  68. if( ! pTrackMenu->GetMenuItemInfo(
  69. nItemIndex,
  70. &_mii,
  71. TRUE
  72. )
  73. )
  74. {
  75. _sItemText.ReleaseBuffer();
  76. ASSERT( FALSE );
  77. return false;
  78. }
  79. _sItemText.ReleaseBuffer();
  80. m_nItemIndex = nItemIndex;
  81. if( (_mii.fType&MFT_SEPARATOR) != 0 )
  82. {
  83. m_sItemText.Empty();
  84. m_nCmdID = TYPE_SEPARATOR;
  85. MeasureItem( NULL );
  86. return true;
  87. }
  88. SetBold( ( (_mii.fState&MFS_DEFAULT) != 0 ) ? true : false );
  89. if( _mii.hSubMenu != NULL )
  90. {
  91. if( ! ConstructPopup() )
  92. {
  93. ASSERT( FALSE );
  94. return false;
  95. }
  96. m_nCmdID = (UINT)TYPE_POPUP;
  97. SetPopupText( _sItemText );
  98. MeasureItem( NULL );
  99. return true;
  100. }
  101. // m_sItemText.Empty();
  102. if( ! CExtCmdManager::IsCommand(_mii.wID) )
  103. {
  104. ASSERT( FALSE );
  105. return false;
  106. }
  107. m_nCmdID = _mii.wID;
  108. if( bNoRefToCmdMngr )
  109. {
  110. // use text as is
  111. SetNoCmdUI( true );
  112. Enable( ( (_mii.fState&MFS_DISABLED) != 0 ) ? false : true );
  113. Check( ( (_mii.fState&MFS_CHECKED) != 0 ) ? true : false );
  114. } // if( bNoRefToCmdMngr )
  115. else
  116. {
  117. CExtCmdItem * pCmdItem =
  118. g_CmdManager->CmdGetPtr(
  119. g_CmdManager->ProfileNameFromWnd( hWndCmdProfileInfo ),
  120. m_nCmdID
  121. );
  122. ASSERT( pCmdItem != NULL );
  123. if( pCmdItem == NULL )
  124. return false;
  125. // if( _sItemText.IsEmpty() )
  126. // _sItemText = pCmdItem->m_sMenuText;
  127. // if( _sItemText.IsEmpty() )
  128. // _sItemText = pCmdItem->m_sToolbarText;
  129. if( ! pCmdItem->m_sMenuText.IsEmpty() )
  130. _sItemText = pCmdItem->m_sMenuText;
  131. else if( ! pCmdItem->m_sToolbarText.IsEmpty() )
  132. _sItemText = pCmdItem->m_sToolbarText;
  133. SetAccelText( pCmdItem->m_sAccelText );
  134. } // else from if( bNoRefToCmdMngr )
  135. SetPopupText( _sItemText );
  136. MeasureItem( NULL );
  137. return true;
  138. }
  139. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  140. #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  141. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbVerifyTextInput(
  142. CInPlaceEditWnd & wndEdit,
  143. CExtCustomizeCmdTreeNode * pNode,
  144. __EXT_MFC_SAFE_LPCTSTR sTextOld,
  145. __EXT_MFC_SAFE_LPCTSTR sTextNew
  146. )
  147. {
  148. ASSERT_VALID( pNode );
  149. ASSERT( sTextOld != NULL );
  150. ASSERT( sTextNew != NULL );
  151. ASSERT(
  152. wndEdit.GetSafeHwnd() != NULL
  153. && ::IsWindow( wndEdit.GetSafeHwnd() )
  154. );
  155. CExtCustomizeSite * pSite =
  156. CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
  157. if( pSite == NULL )
  158. return true;
  159. return
  160. pSite->OnTextFieldVerify(
  161. NULL,
  162. pNode,
  163. sTextOld,
  164. sTextNew
  165. );
  166. }
  167. void CExtPopupMenuWnd::MENUITEMDATA::stat_CbPutTextInputResult(
  168. CInPlaceEditWnd & wndEdit,
  169. CExtCustomizeCmdTreeNode * pNode,
  170. __EXT_MFC_SAFE_LPCTSTR sTextNew
  171. )
  172. {
  173. ASSERT_VALID( pNode );
  174. ASSERT( sTextNew != NULL );
  175. ASSERT(
  176. wndEdit.GetSafeHwnd() != NULL
  177. && ::IsWindow( wndEdit.GetSafeHwnd() )
  178. );
  179. CExtCustomizeSite * pSite =
  180. CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
  181. if( pSite == NULL )
  182. return;
  183. pSite->OnTextFieldInplaceTextSet(
  184. NULL,
  185. pNode,
  186. pNode->m_sDefInplaceEditBuffer,
  187. sTextNew
  188. );
  189. }
  190. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInplaceEditWndProc(
  191. LRESULT & lResult,
  192. UINT message,
  193. WPARAM wParam,
  194. LPARAM lParam,
  195. CEdit & wndEdit,
  196. CExtCustomizeCmdTreeNode * pNode
  197. )
  198. {
  199. if( message == CExtCustomizeSite::g_nMsgQueryCustomizeSite )
  200. return false;
  201. if( (wndEdit.GetStyle() & WS_VISIBLE) == 0 )
  202. return false;
  203. ASSERT_VALID( pNode );
  204. ASSERT(
  205. wndEdit.GetSafeHwnd() != NULL
  206. && ::IsWindow( wndEdit.GetSafeHwnd() )
  207. );
  208. CExtCustomizeSite * pSite =
  209. CExtCustomizeSite::GetCustomizeSite( wndEdit.GetSafeHwnd() );
  210. if( pSite == NULL )
  211. return false;
  212. return
  213. pSite->OnTextFieldWndProcHook(
  214. lResult,
  215. message,
  216. wParam,
  217. lParam,
  218. wndEdit,
  219. NULL,
  220. pNode
  221. );
  222. }
  223. #ifndef __EXT_MFC_NO_BUILTIN_DATEFIELD
  224. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInitDatePickerContent(
  225. CExtDatePickerWnd & wndDatePicker,
  226. CExtCustomizeCmdTreeNode * pNode
  227. )
  228. {
  229. ASSERT_VALID( pNode );
  230. ASSERT(
  231. wndDatePicker.GetSafeHwnd() != NULL
  232. && ::IsWindow( wndDatePicker.GetSafeHwnd() )
  233. );
  234. CExtCustomizeSite * pSite =
  235. CExtCustomizeSite::GetCustomizeSite( wndDatePicker.GetSafeHwnd() );
  236. if( pSite == NULL )
  237. return false;
  238. return
  239. pSite->OnPopupDatePickerInitContent(
  240. NULL,
  241. pNode,
  242. wndDatePicker
  243. );
  244. }
  245. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbDatePickerSelection(
  246. LPVOID pSelectionNotification,
  247. CExtCustomizeCmdTreeNode * pNode
  248. )
  249. {
  250. ASSERT_VALID( pNode );
  251. const CExtDatePickerWnd::SELECTION_NOTIFICATION * pSN =
  252. CExtDatePickerWnd::SELECTION_NOTIFICATION::
  253. FromWPARAM( (WPARAM)pSelectionNotification );
  254. ASSERT( pSN != NULL );
  255. if( pSN == NULL )
  256. return false;
  257. CExtCustomizeSite * pSite =
  258. CExtCustomizeSite::GetCustomizeSite( pSN->m_hWndDatePicker ); 
  259. if( pSite == NULL )
  260. return false;
  261. return
  262. pSite->OnPopupDatePickerSelChange(
  263. NULL,
  264. pNode,
  265. pSelectionNotification
  266. );
  267. }
  268. #endif // __EXT_MFC_NO_BUILTIN_DATEFIELD
  269. #ifndef __EXT_MFC_NO_UNDO_REDO_POPUP
  270. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbFormatCaption(
  271. CExtSafeString & strCaption,
  272. CExtPopupUndoRedoMenuWnd * pUndoRedoPopupMenuWnd,
  273. CExtCustomizeCmdTreeNode * pNode
  274. )
  275. {
  276. ASSERT_VALID( pNode );
  277. if( pUndoRedoPopupMenuWnd == NULL )
  278. {
  279. ASSERT( FALSE );
  280. return false;
  281. }
  282. ASSERT_VALID( pUndoRedoPopupMenuWnd );
  283. CExtCustomizeSite * pSite =
  284. CExtCustomizeSite::GetCustomizeSite( pUndoRedoPopupMenuWnd->m_hWnd ); 
  285. if( pSite == NULL )
  286. return false;
  287. return
  288. pSite->OnPopupUndoRedoFormatCaption(
  289. NULL,
  290. pNode,
  291. pUndoRedoPopupMenuWnd,
  292. strCaption
  293. );
  294. }
  295. #endif // __EXT_MFC_NO_UNDO_REDO_POPUP
  296. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbInitListBoxContent(
  297. CExtPopupInplaceListBox & wndListBox,
  298. CExtCustomizeCmdTreeNode * pNode
  299. )
  300. {
  301. ASSERT_VALID( pNode );
  302. ASSERT(
  303. wndListBox.GetSafeHwnd() != NULL
  304. && ::IsWindow( wndListBox.GetSafeHwnd() )
  305. );
  306. CExtCustomizeSite * pSite =
  307. CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
  308. if( pSite == NULL )
  309. return false;
  310. return
  311. pSite->OnPopupListBoxInitContent(
  312. NULL,
  313. pNode,
  314. wndListBox
  315. );
  316. }
  317. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxSelection(
  318. CExtPopupInplaceListBox & wndListBox,
  319. CExtCustomizeCmdTreeNode * pNode,
  320. int eSAT // CExtPopupInplaceListBox::e_sel_action_t
  321. )
  322. {
  323. ASSERT_VALID( pNode );
  324. ASSERT(
  325. wndListBox.GetSafeHwnd() != NULL
  326. && ::IsWindow( wndListBox.GetSafeHwnd() )
  327. );
  328. CExtCustomizeSite * pSite =
  329. CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
  330. if( pSite == NULL )
  331. return false;
  332. switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
  333. {
  334. case CExtPopupInplaceListBox::__SAT_SELCHANGE:
  335. return
  336. pSite->OnPopupListBoxSelChange(
  337. NULL,
  338. pNode,
  339. wndListBox
  340. );
  341. case CExtPopupInplaceListBox::__SAT_SELENDOK:
  342. return
  343. pSite->OnPopupListBoxSelEndOK(
  344. NULL,
  345. pNode,
  346. wndListBox
  347. );
  348. case CExtPopupInplaceListBox::__SAT_SELENDCANCEL:
  349. return
  350. pSite->OnPopupListBoxSelEndCancel(
  351. NULL,
  352. pNode,
  353. wndListBox
  354. );
  355. case CExtPopupInplaceListBox::__SAT_CLOSE:
  356. return
  357. pSite->OnPopupListBoxClose(
  358. NULL,
  359. pNode,
  360. wndListBox
  361. );
  362. #ifdef _DEBUG
  363. default:
  364. ASSERT( FALSE );
  365. break;
  366. #endif // _DEBUG
  367. } // switch( ((CExtPopupInplaceListBox::e_sel_action_t)eSAT) )
  368. return false;
  369. }
  370. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxItemDraw(
  371. CExtPopupInplaceListBox & wndListBox,
  372. CExtCustomizeCmdTreeNode * pNode,
  373. LPDRAWITEMSTRUCT pDIS
  374. )
  375. {
  376. ASSERT_VALID( pNode );
  377. ASSERT( pDIS != NULL && pDIS->hDC != NULL );
  378. ASSERT(
  379. wndListBox.GetSafeHwnd() != NULL
  380. && ::IsWindow( wndListBox.GetSafeHwnd() )
  381. );
  382. CExtCustomizeSite * pSite =
  383. CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
  384. if( pSite == NULL )
  385. return false;
  386. if( pSite->OnPopupListBoxItemDraw(
  387. NULL,
  388. pNode,
  389. wndListBox,
  390. pDIS
  391. )
  392. )
  393. return true;
  394. INT nIndex = INT( pDIS->itemID );
  395. if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
  396. return false;
  397. if( nIndex < 0 || nIndex >= wndListBox.GetCount() )
  398. return true;
  399. CExtPopupMenuWnd * pPopup =
  400. STATIC_DOWNCAST( CExtPopupMenuWnd, wndListBox.GetParent() );
  401. CExtPaintManager * pPM = pPopup->PmBridge_GetPM();
  402. bool bEnabled = wndListBox.LbItemIsEnabled( nIndex );
  403. bool bSelected = ( pDIS->itemState & ODS_SELECTED ) != 0 ? true : false;
  404. COLORREF clrText = wndListBox.LbItemTextColorGet( nIndex );
  405. COLORREF clrBack = wndListBox.LbItemBackColorGet( nIndex );
  406. CDC dc;
  407. dc.Attach( pDIS->hDC );
  408. if( pDIS->itemAction & (ODA_DRAWENTIRE | ODA_SELECT) )
  409. {
  410. CRect rcErase( pDIS->rcItem );
  411. if( nIndex == (wndListBox.GetCount()-1) )
  412. {
  413. CRect rcClient;
  414. wndListBox.GetClientRect( &rcClient );
  415. if( rcErase.bottom < rcClient.bottom )
  416. rcErase.bottom = rcClient.bottom;
  417. }
  418. dc.FillSolidRect( 
  419. rcErase, 
  420. pPM->GetColor( COLOR_WINDOW )
  421. );
  422. dc.FillSolidRect(
  423. &pDIS->rcItem,
  424. (clrBack != COLORREF(-1L) && (!bSelected))
  425. ? clrBack
  426. : pPM->GetColor(
  427. ( bSelected && bEnabled )
  428. ? COLOR_HIGHLIGHT
  429. : COLOR_WINDOW,
  430. &wndListBox
  431. )
  432. );
  433. }
  434. if( nIndex >= 0 )
  435. {
  436. CString sText;
  437. wndListBox.GetText( (INT)pDIS->itemID, sText );
  438. if( ! sText.IsEmpty() )
  439. {
  440. COLORREF clrTextOld =
  441. dc.SetTextColor(
  442. (clrText != COLORREF(-1L) && (!bSelected))
  443. ? clrText
  444. : pPM->GetColor(
  445. ( bSelected && bEnabled )
  446. ? COLOR_HIGHLIGHTTEXT 
  447. : bEnabled
  448. ? COLOR_BTNTEXT 
  449. : CExtPaintManager::CLR_TEXT_DISABLED,
  450. &wndListBox
  451. )
  452. );
  453. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  454. CRect rcText( pDIS->rcItem );
  455. rcText.DeflateRect(
  456. pSite->OnPopupListBoxCalcItemExtraSizes(
  457. NULL,
  458. pNode
  459. )
  460. );
  461. dc.DrawText(
  462. sText,
  463. &rcText,
  464. DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX
  465. );
  466. dc.SetBkMode( nOldBkMode );
  467. dc.SetTextColor( clrTextOld );
  468. } // if( ! sText.IsEmpty() )
  469. } // if( nIndex >= 0 )
  470. if( bSelected && bEnabled )
  471. {
  472. COLORREF clrTextOld = 
  473. dc.SetTextColor( RGB(255,255,255) );
  474. COLORREF clrBkOld =
  475. dc.SetBkColor( RGB(0,0,0) );
  476. dc.DrawFocusRect( &pDIS->rcItem );
  477. dc.SetBkColor( clrBkOld );
  478. dc.SetTextColor( clrTextOld );
  479. }
  480. dc.Detach();
  481. return true;
  482. }
  483. bool CExtPopupMenuWnd::MENUITEMDATA::stat_CbListBoxItemMeasure(
  484. CExtPopupInplaceListBox & wndListBox,
  485. CExtCustomizeCmdTreeNode * pNode,
  486. LPMEASUREITEMSTRUCT pMIS
  487. )
  488. {
  489. ASSERT_VALID( pNode );
  490. ASSERT( pMIS != NULL );
  491. ASSERT(
  492. wndListBox.GetSafeHwnd() != NULL
  493. && ::IsWindow( wndListBox.GetSafeHwnd() )
  494. );
  495. CExtCustomizeSite * pSite =
  496. CExtCustomizeSite::GetCustomizeSite( wndListBox.GetSafeHwnd() );
  497. if( pSite == NULL )
  498. return false;
  499. if( pSite->OnPopupListBoxItemMeasure(
  500. NULL,
  501. pNode,
  502. wndListBox,
  503. pMIS
  504. )
  505. )
  506. return true;
  507. if( (wndListBox.GetStyle() & LBS_HASSTRINGS) == 0 )
  508. return false;
  509. pMIS->itemWidth = pMIS->itemHeight = 10;
  510. if( ((INT)pMIS->itemID) < 0 || ((INT)pMIS->itemID) >= wndListBox.GetCount() )
  511. return true;
  512. CExtSafeString sMeasure;
  513. wndListBox.GetText( (INT)pMIS->itemID, *((CString*)&sMeasure) );
  514. if( sMeasure.IsEmpty() )
  515. return true;
  516. CExtPopupMenuWnd * pPopup =
  517. STATIC_DOWNCAST( CExtPopupMenuWnd, wndListBox.GetParent() );
  518. CExtPaintManager * pPM = pPopup->PmBridge_GetPM();
  519. CWindowDC dc( NULL );
  520. CRect rcMeasure =
  521. CExtPaintManager::stat_CalcTextDimension(
  522. dc,
  523. pPM->m_FontNormal,
  524. sMeasure
  525. );
  526. rcMeasure.InflateRect(
  527. pSite->OnPopupListBoxCalcItemExtraSizes(
  528. NULL,
  529. pNode
  530. )
  531. );
  532. pMIS->itemWidth = rcMeasure.Width();
  533. pMIS->itemHeight = rcMeasure.Height();
  534. return true;
  535. }
  536. #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  537. bool CExtPopupMenuWnd::MENUITEMDATA::UpdateFromCmdTree(
  538. HWND hWndCmdRecv,
  539. CExtCustomizeCmdTreeNode * pNode,
  540. int nItemIndex,
  541. CExtPopupMenuWnd * pPopupParent // = NULL
  542. )
  543. {
  544. ASSERT_VALID( pNode );
  545. m_nItemIndex = nItemIndex;
  546. if( pNode->PreConstructMenuItem(
  547. this,
  548. hWndCmdRecv,
  549. nItemIndex,
  550. pPopupParent
  551. )
  552. )
  553. return true;
  554. if( pNode->GetFlags()&__ECTN_BOLD_IN_MENU )
  555. m_bBold = true;
  556. if( pNode->GetFlags()&__ECTN_BIG_ACCENT_IN_MENU )
  557. m_bBigAccent = true;
  558. m_sExtendedText = pNode->GetTextMenuExtended();
  559. LPCTSTR sCaptionText = LPCTSTR( pNode->GetTextMenuCaption() );
  560. CExtCustomizeSite * pSite = NULL;
  561. #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  562. if( (pNode->GetFlags() & __ECTN_TBB_TEXT_FIELD) != 0 )
  563. {
  564. ASSERT( m_hWndSpecCmdReceiver != NULL );
  565. ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
  566. pSite =
  567. CExtCustomizeSite::GetCustomizeSite(
  568. m_hWndSpecCmdReceiver
  569. );
  570. // if( pSite == NULL )
  571. // {
  572. // ASSERT( FALSE );
  573. // return false;
  574. // }
  575. bool bComboField =
  576. ( (pNode->GetFlags() & __ECTN_TBB_COMBO) != 0 )
  577. ? true : false;
  578. bool bDateField =
  579. ( (pNode->GetFlags() & __ECTN_TBB_DATE) != 0 )
  580. ? true : false;
  581. m_nCmdID =
  582. ( bComboField || bDateField )
  583. ? ((UINT)TYPE_POPUP)
  584. : pNode->GetCmdID( false )
  585. ;
  586. m_pCmdNode = pNode;
  587. if( bComboField )
  588. {
  589. // construct a popup
  590. //ASSERT( m_iconPopup.IsEmpty() );
  591. //ASSERT( m_pWndChild == NULL );
  592. if( ! m_iconPopup.IsEmpty() )
  593. m_iconPopup.Empty();
  594. if( m_pWndChild != NULL )
  595. {
  596. m_pWndChild->m_pWndParentMenu = NULL;
  597. delete m_pWndChild;
  598. m_pWndChild = NULL;
  599. }
  600. CExtPopupControlMenuWnd * pExtCrtPopup = NULL;
  601. if( pSite != NULL )
  602. pExtCrtPopup = 
  603. pSite->OnTextFieldCreateDropPopup(
  604. NULL,
  605. pNode,
  606. m_hWndSpecCmdReceiver,
  607. false
  608. );
  609. if( pExtCrtPopup != NULL )
  610. {
  611. m_pWndChild = pExtCrtPopup;
  612. if( pPopupParent != NULL )
  613. m_pWndChild->m_pWndParentMenu = pPopupParent;
  614. if( sCaptionText != NULL )
  615. pExtCrtPopup->MenuCaptionTextSet( sCaptionText );
  616. } // if( pExtCrtPopup != NULL )
  617. else
  618. {
  619. CExtPopupListBoxMenuWnd * pPopup =
  620. STATIC_DOWNCAST(
  621. CExtPopupListBoxMenuWnd,
  622. CExtPopupMenuWnd::InstantiatePopupMenu(
  623. hWndCmdRecv,
  624. RUNTIME_CLASS(CExtPopupListBoxMenuWnd),
  625. pNode // this
  626. )
  627. );
  628. if( sCaptionText != NULL )
  629. pPopup->MenuCaptionTextSet( sCaptionText );
  630. if( pPopupParent != NULL )
  631. pPopup->m_pWndParentMenu = pPopupParent;
  632. pPopup->m_lParamListCookie = pNode->GetLParam();
  633. pPopup->m_pCbListBoxSelection = 
  634. (CExtPopupInplaceListBox::pCbListBoxSelection)
  635. stat_CbListBoxSelection;
  636. pPopup->m_pSelectionCookie = (LPVOID)pNode;
  637. pPopup->m_pCbInitListBoxContent =
  638. (CExtPopupInplaceListBox::pCbInitListBoxContent)
  639. stat_CbInitListBoxContent;
  640. pPopup->m_pInitListBoxCookie = (LPVOID)pNode;
  641. pPopup->m_pCbListBoxItemDraw =
  642. (CExtPopupInplaceListBox::pCbListBoxItemDraw)
  643. stat_CbListBoxItemDraw;
  644. pPopup->m_pCbListBoxItemMeasure =
  645. (CExtPopupInplaceListBox::pCbListBoxItemMeasure)
  646. stat_CbListBoxItemMeasure;
  647. pPopup->m_pListBoxItemCookie = (LPVOID)pNode;
  648. CSize sizeMeasure( 0, 0 );
  649. if( pSite != NULL )
  650. {
  651. pSite->OnPopupListBoxGetStyles(
  652. NULL,
  653. pNode,
  654. pPopup->m_dwListBoxStyles
  655. );
  656. sizeMeasure =
  657. pSite->OnPopupListBoxMeasureTrackSize(
  658. NULL,
  659. pNode
  660. );
  661. } // if( pSite != NULL )
  662. if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
  663. {
  664. pPopup->m_sizeChildControl.cx = pNode->TextFieldWidthGet();
  665. pPopup->m_sizeChildControl.cy = pNode->DropDownHeightMaxGet();
  666. } // if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
  667. else
  668. pPopup->m_sizeChildControl = sizeMeasure;
  669. m_pWndChild = pPopup;
  670. } // else from if( pExtCrtPopup != NULL )
  671. m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
  672. //
  673. m_sItemText = _T("");
  674. m_sAccelText = _T("");
  675. SetPopupText( pNode->GetTextInMenu( NULL ) );
  676. } // if( bComboField )
  677. #ifndef __EXT_MFC_NO_BUILTIN_DATEFIELD
  678. else if( bDateField )
  679. {
  680. // construct a popup
  681. ASSERT( m_iconPopup.IsEmpty() );
  682. ASSERT( m_pWndChild == NULL );
  683. CExtPopupControlMenuWnd * pExtCrtPopup =
  684. pSite->OnTextFieldCreateDropPopup(
  685. NULL,
  686. pNode,
  687. m_hWndSpecCmdReceiver,
  688. false
  689. );
  690. if( pExtCrtPopup != NULL )
  691. {
  692. m_pWndChild = pExtCrtPopup;
  693. if( sCaptionText != NULL )
  694. pExtCrtPopup->MenuCaptionTextSet( sCaptionText );
  695. } // if( pExtCrtPopup != NULL )
  696. else
  697. {
  698. CSize szCalendarDimensions = CSize(1,1);
  699. DWORD dwDatePickerWindowStyle = WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN;
  700. DWORD dwDatePickerStyle = __EDPWS_DEFAULT;
  701. pSite->OnPopupDatePickerGetStyles(
  702. NULL,
  703. pNode,
  704. szCalendarDimensions,
  705. dwDatePickerStyle
  706. );
  707. CExtPopupDatePickerMenuWnd * pPopup =
  708. STATIC_DOWNCAST(
  709. CExtPopupDatePickerMenuWnd,
  710. CExtPopupMenuWnd::InstantiatePopupMenu(
  711. m_hWndSpecCmdReceiver,
  712. RUNTIME_CLASS(CExtPopupDatePickerMenuWnd),
  713. pNode // this
  714. )
  715. );
  716. pPopup->Construct(
  717. pNode->GetLParam(),
  718. szCalendarDimensions,
  719. dwDatePickerWindowStyle,
  720. dwDatePickerStyle
  721. );
  722. if( sCaptionText != NULL )
  723. pPopup->MenuCaptionTextSet( sCaptionText );
  724. pPopup->m_pCbDatePickerSelection = 
  725. (CExtPopupInplaceDatePicker::pCbDatePickerSelection)
  726. stat_CbDatePickerSelection;
  727. pPopup->m_pDatePickerSelectionCookie = (LPVOID)pNode;
  728. pPopup->m_pCbInitDatePickerContent =
  729. (CExtPopupInplaceDatePicker::pCbInitDatePickerContent)
  730. stat_CbInitDatePickerContent;
  731. pPopup->m_pInitDatePickerCookie = (LPVOID)pNode;
  732. m_pWndChild = pPopup;
  733. } // else from if( pExtCrtPopup != NULL )
  734. m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
  735. m_sItemText = _T("");
  736. m_sAccelText = _T("");
  737. SetPopupText( pNode->GetTextInMenu( NULL ) );
  738. } // if( bDateField )
  739. #endif // __EXT_MFC_NO_BUILTIN_DATEFIELD
  740. else
  741. m_sItemText = pNode->GetTextInMenu( NULL );
  742. if( pSite != NULL )
  743. pSite->OnTextFieldInplaceTextGet(
  744. NULL,
  745. pNode,
  746. pNode->m_sDefInplaceEditBuffer
  747. );
  748. SetInplaceEdit(
  749. &pNode->m_sDefInplaceEditBuffer,
  750. (CExtPopupMenuWnd::pCbVerifyTextInput)stat_CbVerifyTextInput,
  751. (CExtPopupMenuWnd::pCbPutTextInputResult)stat_CbPutTextInputResult,
  752. (CExtPopupMenuWnd::pCbInplaceEditWndProc)stat_CbInplaceEditWndProc,
  753. (LPVOID)pNode,
  754. pNode->TextFieldWidthGet()
  755. );
  756. bool bTextFieldIsNotEditable =
  757. ( (pNode->GetFlags() & __ECTN_TBB_TF_NE) != 0 )
  758. ? true : false;
  759. AllowInplaceEditActivation( ! bTextFieldIsNotEditable );
  760. SetDisplayed( true );
  761. SetAccelText( _T("") );
  762. MeasureItem( NULL );
  763. return true;
  764. } // if( (pNode->GetFlags() & __ECTN_TBB_TEXT_FIELD) != 0 )
  765. #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  766. if( pNode->GetFlags() & __ECTN_TBB_COLOR )
  767. {
  768. ASSERT( m_iconPopup.IsEmpty() );
  769. ASSERT( m_pWndChild == NULL );
  770. CExtPopupColorMenuWnd * pColorPopup =
  771. STATIC_DOWNCAST(
  772. CExtPopupColorMenuWnd,
  773. CExtPopupMenuWnd::InstantiatePopupMenu(
  774. hWndCmdRecv,
  775. RUNTIME_CLASS(CExtPopupColorMenuWnd),
  776. pPopupParent // this
  777. )
  778. );
  779. if( sCaptionText != NULL )
  780. pColorPopup->MenuCaptionTextSet( sCaptionText );
  781.  m_pWndChild = pColorPopup;
  782. if( pPopupParent != NULL )
  783. m_pWndChild->m_pWndParentMenu = pPopupParent;
  784. ASSERT( m_hWndSpecCmdReceiver != NULL );
  785. ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
  786. m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
  787. m_nCmdID = (UINT)TYPE_POPUP;
  788. m_sItemText = pNode->GetTextInMenu( NULL );
  789. m_pCmdNode = pNode;
  790. ASSERT( m_pWndChild != NULL );
  791. m_pWndChild->m_pNode = pNode;
  792. pColorPopup->m_lParamCookie = pNode->GetLParam();
  793. pColorPopup->m_bEnableBtnColorDefault =
  794. ( (pNode->GetFlags() & __ECTN_TBB_MCB_DEFAULT) != 0 ) ? true : false;
  795. pColorPopup->m_bEnableBtnColorCustom =
  796. ( (pNode->GetFlags() & __ECTN_TBB_MCB_CUSTOM) != 0 ) ? true : false;
  797. if( pSite == NULL && m_hWndSpecCmdReceiver != NULL )
  798. pSite =
  799. CExtCustomizeSite::GetCustomizeSite(
  800. m_hWndSpecCmdReceiver
  801. );
  802. if( pSite == NULL )
  803. {
  804. ASSERT( FALSE );
  805. return false;
  806. }
  807. pSite->OnColorItemValueGet(
  808. NULL,
  809. pNode,
  810. pColorPopup->m_clrDefault,
  811. false
  812. );
  813. pSite->OnColorItemValueGet(
  814. NULL,
  815. pNode,
  816. pColorPopup->m_clrInitial,
  817. true
  818. );
  819. CExtSafeString sBtnText;
  820. if( pSite->OnColorItemGetBtnTextDefault(
  821. NULL,
  822. pNode,
  823. sBtnText
  824. )
  825. )
  826. pColorPopup->m_sBtnTextColorDefault = sBtnText;
  827. sBtnText.Empty();
  828. if( pSite->OnColorItemGetBtnTextCustom(
  829. NULL,
  830. pNode,
  831. sBtnText
  832. )
  833. )
  834. pColorPopup->m_sBtnTextColorCustom = sBtnText;
  835. pSite->OnColorItemGenerateIcon(
  836. NULL,
  837. pNode,
  838. pColorPopup->m_clrInitial,
  839. m_iconPopup
  840. );
  841. CExtCmdItem * pCmdItem =
  842. g_CmdManager->CmdGetPtr(
  843. g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
  844. pNode->GetCmdID()
  845. );
  846. if( pCmdItem != NULL )
  847. SetAccelText( pCmdItem->m_sAccelText );
  848. MeasureItem( NULL );
  849. return true;
  850. } // if( pNode->GetFlags() & __ECTN_TBB_COLOR )
  851. #ifndef __EXT_MFC_NO_UNDO_REDO_POPUP
  852. else if( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO )
  853. {
  854. ASSERT( m_iconPopup.IsEmpty() );
  855. ASSERT( m_pWndChild == NULL );
  856. CExtPopupUndoRedoMenuWnd * pPopup =
  857. STATIC_DOWNCAST(
  858. CExtPopupUndoRedoMenuWnd,
  859. CExtPopupMenuWnd::InstantiatePopupMenu(
  860. hWndCmdRecv,
  861. RUNTIME_CLASS(CExtPopupUndoRedoMenuWnd),
  862. m_pOwner
  863. )
  864. );
  865. if( sCaptionText != NULL )
  866. pPopup->MenuCaptionTextSet( sCaptionText );
  867. pPopup->m_lParamCookie = pNode->GetLParam();
  868. pPopup->m_pCbListBoxSelection = 
  869. (CExtPopupInplaceListBox::pCbListBoxSelection)
  870. stat_CbListBoxSelection;
  871. pPopup->m_pSelectionCookie = (LPVOID)pNode;
  872. pPopup->m_pCbInitListBoxContent =
  873. (CExtPopupInplaceListBox::pCbInitListBoxContent)
  874. stat_CbInitListBoxContent;
  875. pPopup->m_pInitListBoxCookie = (LPVOID)pNode;
  876. pPopup->m_pCbListBoxItemDraw =
  877. (CExtPopupInplaceListBox::pCbListBoxItemDraw)
  878. stat_CbListBoxItemDraw;
  879. pPopup->m_pCbListBoxItemMeasure =
  880. (CExtPopupInplaceListBox::pCbListBoxItemMeasure)
  881. stat_CbListBoxItemMeasure;
  882. pPopup->m_pListBoxItemCookie = (LPVOID)pNode;
  883. if( pSite == NULL )
  884. pSite = CExtCustomizeSite::GetCustomizeSite( m_hWndSpecCmdReceiver );
  885. if( pSite == NULL )
  886. {
  887. ASSERT( FALSE );
  888. return false;
  889. }
  890. pSite->OnPopupListBoxGetStyles(
  891. NULL,
  892. pNode,
  893. pPopup->m_dwListBoxStyles
  894. );
  895. pPopup->m_pCbFormatCaption =
  896. (CExtPopupUndoRedoMenuWnd::pCbFormatCaption)
  897. stat_CbFormatCaption;
  898. pPopup->m_pFormatCaptionCookie = (LPVOID)pNode;
  899. CSize sizeMeasure =
  900. pSite->OnPopupListBoxMeasureTrackSize(
  901. NULL,
  902. pNode
  903. );
  904. if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
  905. {
  906. pPopup->m_sizeChildControl.cx = pNode->TextFieldWidthGet();
  907. pPopup->m_sizeChildControl.cy = pNode->DropDownHeightMaxGet();
  908. } // if( sizeMeasure.cx == 0 && sizeMeasure.cy == 0 )
  909. else
  910. pPopup->m_sizeChildControl = sizeMeasure;
  911. m_pWndChild = pPopup;
  912. if( pPopupParent != NULL )
  913. m_pWndChild->m_pWndParentMenu = pPopupParent;
  914. ASSERT( m_hWndSpecCmdReceiver != NULL );
  915. ASSERT( ::IsWindow(m_hWndSpecCmdReceiver) );
  916. m_pWndChild->m_hWndCmdReceiver = m_hWndSpecCmdReceiver;
  917. SetPopupText( pNode->GetTextInMenu( NULL ) );
  918. // m_nCmdID = pNode->GetCmdID( true );
  919. m_nCmdID = (UINT)TYPE_POPUP;
  920. m_pCmdNode = pNode;
  921. ASSERT( m_pWndChild != NULL );
  922. m_pWndChild->m_pNode = pNode;
  923. CExtCmdItem * pCmdItem =
  924. g_CmdManager->CmdGetPtr(
  925. g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
  926. pNode->GetCmdID()
  927. );
  928. if( pCmdItem != NULL )
  929. SetAccelText( pCmdItem->m_sAccelText );
  930. MeasureItem( NULL );
  931. return true;
  932. } // else if( pNode->GetFlags() & __ECTN_TBB_UNDO_REDO )
  933. #endif // __EXT_MFC_NO_UNDO_REDO_POPUP
  934. if( (pNode->GetFlags() & __ECTN_AUTO_POPUP) != 0
  935. || pNode->GetNodeCount() > 0
  936. )
  937. {
  938. if( ! ConstructPopup() )
  939. {
  940. ASSERT( FALSE );
  941. return false;
  942. }
  943. if( sCaptionText != NULL && m_pWndChild != NULL )
  944. m_pWndChild->MenuCaptionTextSet( sCaptionText );
  945. m_nCmdID = (UINT)TYPE_POPUP;
  946. m_sItemText = pNode->GetTextInMenu( NULL );
  947. m_pCmdNode = pNode;
  948. ASSERT( m_pWndChild != NULL );
  949. m_pWndChild->m_pNode = pNode;
  950. MeasureItem( NULL );
  951. return true;
  952. }
  953. // m_sItemText.Empty();
  954. UINT nNodeCmdID = pNode->GetCmdID();
  955. if(  nNodeCmdID == ID_SEPARATOR )
  956. {
  957. SetSeparator( nItemIndex );
  958. return true;
  959. }
  960. else if( ! CExtCmdManager::IsCommand( nNodeCmdID ) )
  961. {
  962. ASSERT( FALSE );
  963. return false;
  964. }
  965. #if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  966. if( (pNode->GetFlags() & (__ECTN_TBB_COMBO|__ECTN_TBB_DATE|__ECTN_TBB_TEXT_FIELD) ) == 0 )
  967. #endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
  968. m_nCmdID = pNode->GetCmdID();
  969. CExtCmdItem * pCmdItem =
  970. g_CmdManager->CmdGetPtr(
  971. g_CmdManager->ProfileNameFromWnd( hWndCmdRecv ),
  972. pNode->GetCmdID()
  973. );
  974. // ASSERT( pCmdItem != NULL );
  975. // if( pCmdItem == NULL )
  976. // return false;
  977. m_sItemText = pNode->GetTextInMenu( pCmdItem );
  978. m_pCmdNode = pNode;
  979. if( pCmdItem != NULL )
  980. SetAccelText( pCmdItem->m_sAccelText );
  981. pNode->PostConstructMenuItem(
  982. this,
  983. hWndCmdRecv,
  984. nItemIndex,
  985. pPopupParent
  986. );
  987. MeasureItem( NULL );
  988. return true;
  989. }
  990. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  991. /////////////////////////////////////////////////////////////////////////////
  992. // CExtPopupBaseWnd
  993. IMPLEMENT_DYNCREATE( CExtPopupBaseWnd, __BaseClassOfCExtPopupBaseWnd )
  994. IMPLEMENT_CExtPmBridge_MEMBERS( CExtPopupBaseWnd );
  995. CExtPopupBaseWnd::CExtPopupBaseWnd()
  996. : m_bPrintState( false )
  997. , m_eCombineAlign( __CMBA_NONE )
  998. , m_hFont( NULL )
  999. {
  1000. m_clrFadeBitsSrc
  1001. = m_clrFadeBitsDst
  1002. = m_clrFadeBitsTmp
  1003. = NULL;
  1004. m_AnimationType = g_DefAnimationType;
  1005. _InitAnimation();
  1006. m_ePlaySoundOnAnimationFinished =
  1007. CExtSoundPlayer::__NO_SOUND;
  1008. m_sizeFullItems.cx = m_sizeFullItems.cy = 1;
  1009. m_bExcludeAreaSpec
  1010. = m_bCombineWithEA
  1011. = false;
  1012. m_rcExcludeArea.SetRectEmpty();
  1013. m_ptTrack.x = m_ptTrack.y
  1014. = m_ptTrackOriginal.x = m_ptTrackOriginal.y
  1015. = m_ptTrackInvoked.x = m_ptTrackInvoked.y
  1016. = m_ptTrackWatched.x = m_ptTrackWatched.y
  1017. = 0;
  1018. PmBridge_Install();
  1019. }
  1020. CExtPopupBaseWnd::~CExtPopupBaseWnd()
  1021. {
  1022. PmBridge_Uninstall();
  1023. }
  1024. void CExtPopupBaseWnd::_AdjustAnimation(
  1025. CExtPopupBaseWnd::e_animation_type_t & eAT
  1026. )
  1027. {
  1028. ASSERT_VALID( this );
  1029. eAT;
  1030. }
  1031. void CExtPopupMenuWnd::_AdjustAnimation(
  1032. CExtPopupBaseWnd::e_animation_type_t & eAT
  1033. )
  1034. {
  1035. ASSERT_VALID( this );
  1036. if( _IsRibbonMode() )
  1037. eAT = __AT_CONTENT_DISPLAY;
  1038. }
  1039. CExtSafeString CExtPopupBaseWnd::GetAnimaptionName( CExtPopupBaseWnd::e_animation_type_t eAT )
  1040. {
  1041. CExtSafeString strAT;
  1042. switch( eAT )
  1043. {
  1044. case __AT_NONE:
  1045. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_NONE ) )
  1046. strAT = _T("(none)");
  1047. break;
  1048. case __AT_RANDOM:
  1049. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_RANDOM ) )
  1050. strAT = _T("Random select");
  1051. break;
  1052. case __AT_ROLL:
  1053. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_ROLL ) )
  1054. strAT = _T("Roll");
  1055. break;
  1056. case __AT_SLIDE:
  1057. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_SLIDE ) )
  1058. strAT = _T("Slide");
  1059. break;
  1060. case __AT_FADE:
  1061. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_FADE ) )
  1062. strAT = _T("Fade");
  1063. break;
  1064. case __AT_ROLL_AND_STRETCH:
  1065. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_ROLL_AND_STRETCH ) )
  1066. strAT = _T("Roll and stretch");
  1067. break;
  1068. case __AT_SLIDE_AND_STRETCH:
  1069. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_SLIDE_AND_STRETCH ) )
  1070. strAT = _T("Slide and stretch");
  1071. break;
  1072. case __AT_NOISE:
  1073. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_NOISE ) )
  1074. strAT = _T("Noise");
  1075. break;
  1076. case __AT_BOXES:
  1077. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_BOXES ) )
  1078. strAT = _T("Boxes");
  1079. break;
  1080. case __AT_CIRCLES:
  1081. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_CIRCLES ) )
  1082. strAT = _T("Circles");
  1083. break;
  1084. case __AT_HOLES:
  1085. if( ! g_ResourceManager->LoadString( strAT, IDS_EXT_AT_HOLES ) )
  1086. strAT = _T("Holes");
  1087. break;
  1088. } // switch( eAT )
  1089. return strAT;
  1090. }
  1091. void CExtPopupBaseWnd::_InitAnimation()
  1092. {
  1093. ASSERT_VALID( this );
  1094. m_nAnimPercent = m_nAnimPercentOld = 0;
  1095. _AdjustAnimation( m_AnimationType );
  1096. if( ( m_AnimationType < 0
  1097. || m_AnimationType > __AT_MAX_VALID_VALUE
  1098. )
  1099. && m_AnimationType != __AT_CONTENT_DISPLAY
  1100. && m_AnimationType != __AT_CONTENT_EXPAND
  1101. )
  1102. m_AnimationType = __AT_NONE;
  1103. if( m_AnimationType == __AT_RANDOM )
  1104. {
  1105. int nRand = rand() % (__AT_MAX_VALID_VALUE+1);
  1106. ASSERT( nRand >= 0 && nRand <= __AT_MAX_VALID_VALUE );
  1107. if( nRand == __AT_NONE || nRand == __AT_RANDOM )
  1108. nRand = __AT_FADE; // most cool of all effects
  1109. m_AnimationType = (e_animation_type_t)nRand;
  1110. }
  1111. int nBitsPerPixel = CExtPaintManager::stat_GetBPP();
  1112. if( nBitsPerPixel <= 8
  1113. && m_AnimationType != __AT_CONTENT_EXPAND
  1114. && m_AnimationType != __AT_CONTENT_DISPLAY
  1115. )
  1116. {
  1117. m_AnimationType = __AT_NONE;
  1118. m_bAnimFinished = true;
  1119. }
  1120. else
  1121. {
  1122. m_bAnimFinished =
  1123. (m_AnimationType == __AT_NONE) ? true : false;
  1124. }
  1125. // ASSERT(
  1126. // m_bmpScreenDst.GetSafeHandle() == NULL
  1127. // && m_bmpScreenSrc.GetSafeHandle() == NULL
  1128. // && m_bmpScreenTmp.GetSafeHandle() == NULL
  1129. // && m_clrFadeBitsSrc == NULL
  1130. // && m_clrFadeBitsDst == NULL
  1131. // && m_clrFadeBitsTmp == NULL
  1132. // );
  1133. if( m_bmpScreenDst.GetSafeHandle() != NULL )
  1134. m_bmpScreenDst.DeleteObject();
  1135. if( m_bmpScreenSrc.GetSafeHandle() != NULL )
  1136. m_bmpScreenSrc.DeleteObject();
  1137. //  if( m_bmpScreenSrcAlt.GetSafeHandle() != NULL )
  1138. //  m_bmpScreenSrcAlt.DeleteObject();
  1139. if( m_bmpScreenTmp.GetSafeHandle() != NULL )
  1140. m_bmpScreenTmp.DeleteObject();
  1141. m_clrFadeBitsSrc = NULL;
  1142. m_clrFadeBitsDst = NULL;
  1143. m_clrFadeBitsTmp = NULL;
  1144. }
  1145. void CExtPopupBaseWnd::_StartAnimation()
  1146. {
  1147. ASSERT_VALID( this );
  1148. _InitAnimation();
  1149. if( m_AnimationType != __AT_NONE )
  1150. {
  1151. SetTimer( ID_TIMER_ANIMATION, ID_PERIOD_ANIMATION, NULL );
  1152. g_nLastAnimTime = clock();
  1153. }
  1154. }
  1155. void CExtPopupMenuWnd::_StartAnimation()
  1156. {
  1157. ASSERT_VALID( this );
  1158. if( _FindCustomizeMode() )
  1159. return;
  1160. HWND hWndOwn = m_hWnd;
  1161. _ItemFocusDelay();
  1162. if( ! ::IsWindow( hWndOwn ) )
  1163. return;
  1164. _CoolTipHide( false );
  1165. if( ! ::IsWindow( hWndOwn ) )
  1166. return;
  1167. CExtPopupBaseWnd::_StartAnimation();
  1168. if( ! ::IsWindow( hWndOwn ) )
  1169. return;
  1170. GetSite().SetAnimated(
  1171. m_bAnimFinished ? NULL : this
  1172. );
  1173. }
  1174. BEGIN_MESSAGE_MAP(CExtPopupBaseWnd, __BaseClassOfCExtPopupBaseWnd)
  1175. //{{AFX_MSG_MAP(CExtPopupBaseWnd)
  1176. ON_WM_MOUSEACTIVATE()
  1177. ON_WM_ERASEBKGND()
  1178. ON_WM_PAINT()
  1179. ON_WM_NCPAINT()
  1180. ON_WM_NCCALCSIZE()
  1181. ON_WM_SIZE()
  1182. ON_WM_ACTIVATEAPP()
  1183. ON_WM_CANCELMODE()
  1184. ON_WM_SETCURSOR()
  1185. ON_WM_TIMER()
  1186. ON_MESSAGE(WM_SETFONT, OnSetFont)
  1187. ON_MESSAGE(WM_GETFONT, OnGetFont)
  1188. //}}AFX_MSG_MAP
  1189. END_MESSAGE_MAP()
  1190.  
  1191. LRESULT CExtPopupBaseWnd::OnSetFont( WPARAM wParam, LPARAM lParam )
  1192. {
  1193. ASSERT_VALID( this );
  1194. HFONT hFont = (HFONT) wParam;
  1195. BOOL bRedraw = (BOOL) lParam;
  1196. m_hFont = hFont; 
  1197. if( bRedraw )
  1198. Invalidate();
  1199. return 0L;
  1200. }
  1201.   
  1202. LRESULT CExtPopupBaseWnd::OnGetFont( WPARAM, LPARAM )
  1203. {
  1204. ASSERT_VALID( this );
  1205.     return (LRESULT) m_hFont;
  1206. }
  1207. LRESULT CExtPopupBaseWnd::WindowProc(
  1208. UINT message,
  1209. WPARAM wParam,
  1210. LPARAM lParam
  1211. )
  1212. {
  1213. if( message == WM_PRINT || message == WM_PRINTCLIENT )
  1214. {
  1215. HDC hDC = (HDC)wParam;
  1216. if( hDC == NULL )
  1217. return 0;
  1218. m_bPrintState = true;
  1219. CDC * pDC = CDC::FromHandle( hDC );
  1220. _DoPaint( *pDC );
  1221. m_bPrintState = false;
  1222. return 0;
  1223. }
  1224. LRESULT lResult = __BaseClassOfCExtPopupBaseWnd :: WindowProc( message, wParam, lParam );
  1225. return lResult;
  1226. }
  1227. void CExtPopupBaseWnd::OnPaint() 
  1228. {
  1229. ASSERT_VALID( this );
  1230. CPaintDC dc( this );
  1231. if( !(::IsWindow(GetSafeHwnd())) )
  1232. return;
  1233. if( !(::IsWindowVisible(GetSafeHwnd())) )
  1234. return;
  1235. CExtPaintManager::stat_ExcludeChildAreas(
  1236. dc.GetSafeHdc(),
  1237. m_hWnd
  1238. );
  1239. if( ! m_bAnimFinished )
  1240. _DrawAnimatedState( dc );
  1241. else
  1242. _DoPaint( dc );
  1243. }
  1244. void CExtPopupBaseWnd::_DrawAnimatedState( CDC & dc )
  1245. {
  1246. ASSERT_VALID( this );
  1247. if( !(::IsWindow(GetSafeHwnd())) )
  1248. return;
  1249. CRect rcClient;
  1250. GetClientRect( &rcClient );
  1251. int cx = rcClient.Width();
  1252. int cy = rcClient.Height();
  1253. CDC * pPaintDC = &dc;
  1254. CPalette * pOldPalette = NULL;
  1255. if( (::GetDeviceCaps(pPaintDC->m_hDC,RASTERCAPS) & RC_PALETTE) != 0 )
  1256.     {
  1257.         pOldPalette =
  1258. pPaintDC->SelectPalette( & PmBridge_GetPM()->m_PaletteWide, FALSE );
  1259.         pPaintDC->RealizePalette();
  1260.     }
  1261. CDC dcmm;
  1262. VERIFY( dcmm.CreateCompatibleDC(pPaintDC) );
  1263. bool bFail = false;
  1264. if( m_bmpScreenDst.GetSafeHandle() == NULL )
  1265. {
  1266. ASSERT( m_bmpScreenSrc.GetSafeHandle() == NULL );
  1267. ASSERT( m_bmpScreenTmp.GetSafeHandle() == NULL );
  1268. int nBitsPerPixel = CExtPaintManager::stat_GetBPP();
  1269. CBitmap * pBmpOld = NULL;
  1270. if( ( m_AnimationType == __AT_FADE
  1271. && nBitsPerPixel > 8
  1272. )
  1273. || m_AnimationType == __AT_CONTENT_EXPAND
  1274. || m_AnimationType == __AT_CONTENT_DISPLAY
  1275. || m_AnimationType == __AT_ROLL
  1276. || m_AnimationType == __AT_SLIDE
  1277. || m_AnimationType == __AT_ROLL_AND_STRETCH
  1278. || m_AnimationType == __AT_SLIDE_AND_STRETCH
  1279. || m_AnimationType == __AT_NOISE
  1280. || m_AnimationType == __AT_BOXES
  1281. || m_AnimationType == __AT_CIRCLES
  1282. || m_AnimationType == __AT_HOLES
  1283. )
  1284. {
  1285. BITMAPINFOHEADER bih;
  1286. bih.biSize = sizeof(BITMAPINFOHEADER);
  1287. bih.biWidth = cx;
  1288. bih.biHeight = cy;
  1289. bih.biPlanes = 1;
  1290. bih.biBitCount = 32;
  1291. bih.biCompression = BI_RGB;
  1292. bih.biSizeImage = cx * cy;
  1293. bih.biXPelsPerMeter = 0;
  1294. bih.biYPelsPerMeter = 0;
  1295. bih.biClrUsed = 0;
  1296. bih.biClrImportant = 0;
  1297. HBITMAP hDIB =
  1298. ::CreateDIBSection(
  1299. dcmm.GetSafeHdc(),
  1300. (LPBITMAPINFO)&bih,
  1301. DIB_RGB_COLORS,
  1302. (void **)&m_clrFadeBitsSrc,
  1303. NULL,
  1304. NULL
  1305. );
  1306. if( hDIB != NULL && m_clrFadeBitsSrc != NULL )
  1307. {
  1308. m_bmpScreenSrc.Attach( hDIB );
  1309. hDIB =
  1310. ::CreateDIBSection(
  1311. dcmm.GetSafeHdc(),
  1312. (LPBITMAPINFO)&bih,
  1313. DIB_RGB_COLORS,
  1314. (void **)&m_clrFadeBitsDst,
  1315. NULL,
  1316. NULL
  1317. );
  1318. if( hDIB != NULL && m_clrFadeBitsDst != NULL )
  1319. {
  1320. m_bmpScreenDst.Attach( hDIB );
  1321. hDIB =
  1322. ::CreateDIBSection(
  1323. dcmm.GetSafeHdc(),
  1324. (LPBITMAPINFO)&bih,
  1325. DIB_RGB_COLORS,
  1326. (void **)&m_clrFadeBitsTmp,
  1327. NULL,
  1328. NULL
  1329. );
  1330. if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
  1331. {
  1332. m_bmpScreenTmp.Attach( hDIB );
  1333. pBmpOld =
  1334. dcmm.SelectObject( &m_bmpScreenSrc );
  1335. bool bDefaultCapture = true;
  1336. if( g_PaintManager.m_bIsWinVistaOrLater
  1337. && g_PaintManager.m_DWM.IsCompositionEnabled()
  1338. && m_bmpScreenSrcAlt.GetSafeHandle() != NULL
  1339. )
  1340. {
  1341. CDC dcX;
  1342. if( dcX.CreateCompatibleDC( NULL ) )
  1343. {
  1344. CBitmap * pBmpOldX = dcX.SelectObject( &m_bmpScreenSrcAlt );
  1345. dcmm.BitBlt( 0, 0, cx, cy, &dcX, 0, 0, SRCCOPY );
  1346. dcX.SelectObject( pBmpOldX );
  1347. dcX.DeleteDC();
  1348. bDefaultCapture = false;
  1349. }
  1350. }
  1351. if( bDefaultCapture )
  1352. dcmm.BitBlt(
  1353. 0, 0, cx, cy, pPaintDC,
  1354. rcClient.left,
  1355. rcClient.top,
  1356. SRCCOPY
  1357. );
  1358. UINT nSizeInBytes = 
  1359. sizeof(COLORREF) * cx * cy;
  1360. __EXT_MFC_MEMCPY(
  1361. m_clrFadeBitsDst,
  1362. nSizeInBytes,
  1363. m_clrFadeBitsSrc,
  1364. nSizeInBytes
  1365. );
  1366. dcmm.SelectObject( &m_bmpScreenDst );
  1367. } // if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
  1368. else
  1369. {
  1370. m_bmpScreenSrc.DeleteObject();
  1371. m_bmpScreenDst.DeleteObject();
  1372. //return;
  1373. bFail = true;
  1374. } // else from if( hDIB != NULL && m_clrFadeBitsTmp != NULL )
  1375. } // if( hDIB != NULL && m_clrFadeBitsDst != NULL )
  1376. else
  1377. {
  1378. m_bmpScreenSrc.DeleteObject();
  1379. //return;
  1380. bFail = true;
  1381. } // else from if( hDIB != NULL && m_clrFadeBitsDst != NULL )
  1382. } // if( hDIB != NULL && m_clrFadeBitsSrc != NULL )
  1383. }
  1384. else
  1385. {
  1386. m_bmpScreenDst.CreateCompatibleBitmap(
  1387. pPaintDC,
  1388. cx,
  1389. cy
  1390. );
  1391. pBmpOld =
  1392. dcmm.SelectObject( &m_bmpScreenDst );
  1393. }
  1394. if( ! bFail )
  1395. _DoPaint( dcmm, false );
  1396. dcmm.SetViewportOrg( CPoint(0,0) );
  1397. dcmm.SelectObject( pBmpOld );
  1398. } // if( m_bmpScreenDst.GetSafeHandle() == NULL )
  1399. CBitmap * pBmpOld = NULL;
  1400. if( ! bFail )
  1401. {
  1402. COLORREF * src = m_clrFadeBitsSrc;
  1403. COLORREF * dst = m_clrFadeBitsDst;
  1404. COLORREF * tmp = m_clrFadeBitsTmp;
  1405. switch( m_AnimationType )
  1406. {
  1407. case __AT_BOXES:
  1408. case __AT_CIRCLES:
  1409. case __AT_HOLES:
  1410. if( tmp!= NULL && src!=NULL && dst != NULL )
  1411. {
  1412. ASSERT(
  1413. m_nAnimPercent >= 0 && m_nAnimPercent <= 100
  1414. &&
  1415. m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
  1416. &&
  1417. m_nAnimPercentOld <= m_nAnimPercent
  1418. );
  1419. ASSERT( __BOX_ANIM_METRIC > 0 ); // self assert
  1420. if( m_nAnimPercentOld != m_nAnimPercent )
  1421. {
  1422. pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
  1423. if( m_AnimationType == __AT_BOXES )
  1424. { // do boxes animation
  1425. for( int y=0; y<cy; y++ )
  1426. {
  1427. int _y0 = y % __BOX_ANIM_METRIC;
  1428. int _yPercent = 100 -
  1429. (_y0 * 100) / __BOX_ANIM_METRIC;
  1430. if( _yPercent < m_nAnimPercent )
  1431. {
  1432. UINT nSizeInBytes = 
  1433. cx * sizeof(COLORREF);
  1434. __EXT_MFC_MEMCPY(
  1435. tmp,
  1436. nSizeInBytes,
  1437. src,
  1438. nSizeInBytes
  1439. );
  1440. tmp += cx;
  1441. src += cx;
  1442. dst += cx;
  1443. continue;
  1444. }
  1445. for( int x=0; x<cx; x++ )
  1446. {
  1447. int _x0 = x % __BOX_ANIM_METRIC;
  1448. int _xPercent =
  1449. (_x0 * 100) / __BOX_ANIM_METRIC;
  1450. if( _xPercent < m_nAnimPercent )
  1451. *tmp = *dst;
  1452. else
  1453. *tmp = *src;
  1454. tmp++; src++; dst++;
  1455. }
  1456. } // for( int y=0; y<cy; y++ )
  1457. } // do boxes animation
  1458. else
  1459. { // do circles/holes animation
  1460. double radius = 0;
  1461. if( m_AnimationType == __AT_HOLES )
  1462. radius = 
  1463. ((((double)(__BOX_ANIM_METRIC)) / 2) * (100-m_nAnimPercent))
  1464. / 100;
  1465. else
  1466. radius = 
  1467. ((((double)(__BOX_ANIM_METRIC)) / 2) * m_nAnimPercent)
  1468. / 100;
  1469. if( radius > 0 )
  1470. {
  1471. for( int y=0; y<cy; y++ )
  1472. {
  1473. int _y0 = y % __BOX_ANIM_METRIC;
  1474. int _y1 = y - _y0;
  1475. //int _y2 = _y1 + __BOX_ANIM_METRIC;
  1476. int _yCenter = _y1 + __BOX_ANIM_METRIC/2;
  1477. int _yDist = abs( y - _yCenter );
  1478. double _yDist2 = (double)_yDist*_yDist;
  1479. for( int x=0; x<cx; x++ )
  1480. {
  1481. int _x0 = x % __BOX_ANIM_METRIC;
  1482. int _x1 = x - _x0;
  1483. //int _x2 = _x1 + __BOX_ANIM_METRIC;
  1484. int _xCenter = _x1 + __BOX_ANIM_METRIC/2;
  1485. int _xDist = abs( x - _xCenter );
  1486. double _xDist2 = (double)_xDist*_xDist;
  1487. double nDispance =
  1488. ::sqrt(_yDist2+_xDist2);
  1489. if( m_AnimationType == __AT_HOLES )
  1490. { // holes
  1491. if( nDispance >= radius )
  1492. *tmp = *dst;
  1493. else
  1494. *tmp = *src;
  1495. } // holes
  1496. else
  1497. { // circles
  1498. if( nDispance < radius )
  1499. *tmp = *dst;
  1500. else
  1501. *tmp = *src;
  1502. } // circles
  1503. tmp++; src++; dst++;
  1504. }
  1505. } // for( int y=0; y<cy; y++ )
  1506. } // if( radius > 0 )
  1507. } // do circles/holes animation
  1508. int nMenuShadowSize = OnQueryMenuShadowSize();
  1509. if( m_bCombineWithEA )
  1510. { // paint combined area AS IS
  1511. ASSERT( !m_rcExcludeArea.IsRectEmpty() );
  1512. CRect rcExcludeArea( m_rcExcludeArea );
  1513. ScreenToClient( &rcExcludeArea );
  1514. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1515. pPaintDC->BitBlt(
  1516. rcExcludeArea.left, rcExcludeArea.top,
  1517. rcExcludeArea.Width(), rcExcludeArea.Height(), 
  1518. &dcmm,
  1519. rcExcludeArea.left, rcExcludeArea.top,
  1520. SRCCOPY
  1521. );
  1522. dcmm.SelectObject( pBmpOld );
  1523. pBmpOld = NULL;
  1524. if( m_eCombineAlign != __CMBA_NONE )
  1525. {
  1526. rcExcludeArea.InflateRect(
  1527. (m_eCombineAlign == __CMBA_RIGHT) ?
  1528. 0 : nMenuShadowSize,
  1529. (m_eCombineAlign == __CMBA_BOTTOM) ?
  1530. 0 : nMenuShadowSize,
  1531. (m_eCombineAlign == __CMBA_LEFT) ?
  1532. 0 : nMenuShadowSize,
  1533. (m_eCombineAlign == __CMBA_TOP) ?
  1534. 0 : nMenuShadowSize
  1535. );
  1536. } // if( m_eCombineAlign != __CMBA_NONE )
  1537. pPaintDC->ExcludeClipRect(
  1538. &rcExcludeArea
  1539. );
  1540. } // paint combined area AS IS
  1541. if( nMenuShadowSize > 0 )
  1542. {
  1543. CRect rcExcludeArea( rcClient );
  1544. rcExcludeArea.left =
  1545. rcExcludeArea.right
  1546. - nMenuShadowSize;
  1547. pPaintDC->ExcludeClipRect(
  1548. &rcExcludeArea
  1549. );
  1550. rcExcludeArea = rcClient ;
  1551. rcExcludeArea.top =
  1552. rcExcludeArea.bottom
  1553. - nMenuShadowSize;
  1554. pPaintDC->ExcludeClipRect(
  1555. &rcExcludeArea
  1556. );
  1557. }
  1558. pPaintDC->BitBlt(
  1559. rcClient.left, rcClient.top, cx, cy, 
  1560. &dcmm,
  1561. 0,
  1562. 0,
  1563. SRCCOPY
  1564. );
  1565. if( nMenuShadowSize > 0 || m_bCombineWithEA )
  1566. pPaintDC->SelectClipRgn( NULL );
  1567. } // if( m_nAnimPercentOld != m_nAnimPercent )
  1568. }
  1569. break; // cases __AT_BOXES,__AT_CIRCLES,__AT_HOLES
  1570. case __AT_NOISE:
  1571. if( tmp!= NULL && src!=NULL && dst != NULL )
  1572. {
  1573. ASSERT(
  1574. m_nAnimPercent >= 0 && m_nAnimPercent <= 100
  1575. &&
  1576. m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
  1577. &&
  1578. m_nAnimPercentOld <= m_nAnimPercent
  1579. );
  1580. if( m_nAnimPercentOld != m_nAnimPercent )
  1581. {
  1582. int nDiff =
  1583. m_nAnimPercent - m_nAnimPercentOld;
  1584. ASSERT( nDiff > 0 );
  1585. int nRandHalf = nDiff / 2 + 1;
  1586. ASSERT( nRandHalf > 0 );
  1587. pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
  1588. for( int pixel = 0; pixel < cx * cy; pixel++ )
  1589. {
  1590. int nRandValue = 
  1591. rand() % nDiff;
  1592. if( nRandValue > nRandHalf )
  1593. *tmp = *dst;
  1594. // else
  1595. // *tmp = *src;
  1596. tmp++; src++; dst++;
  1597. } // for( int pixel = 0; pixel < cx * cy; pixel++ )
  1598. int nMenuShadowSize = OnQueryMenuShadowSize();
  1599. if( m_bCombineWithEA )
  1600. { // paint combined area AS IS
  1601. ASSERT( !m_rcExcludeArea.IsRectEmpty() );
  1602. CRect rcExcludeArea( m_rcExcludeArea );
  1603. ScreenToClient( &rcExcludeArea );
  1604. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1605. pPaintDC->BitBlt(
  1606. rcExcludeArea.left, rcExcludeArea.top,
  1607. rcExcludeArea.Width(), rcExcludeArea.Height(), 
  1608. &dcmm,
  1609. rcExcludeArea.left, rcExcludeArea.top,
  1610. SRCCOPY
  1611. );
  1612. dcmm.SelectObject( pBmpOld );
  1613. pBmpOld = NULL;
  1614. if( m_eCombineAlign != __CMBA_NONE )
  1615. {
  1616. rcExcludeArea.InflateRect(
  1617. (m_eCombineAlign == __CMBA_RIGHT) ?
  1618. 0 : nMenuShadowSize,
  1619. (m_eCombineAlign == __CMBA_BOTTOM) ?
  1620. 0 : nMenuShadowSize,
  1621. (m_eCombineAlign == __CMBA_LEFT) ?
  1622. 0 : nMenuShadowSize,
  1623. (m_eCombineAlign == __CMBA_TOP) ?
  1624. 0 : nMenuShadowSize
  1625. );
  1626. } // if( m_eCombineAlign != __CMBA_NONE )
  1627. pPaintDC->ExcludeClipRect(
  1628. &rcExcludeArea
  1629. );
  1630. } // paint combined area AS IS
  1631. if( nMenuShadowSize > 0 )
  1632. {
  1633. CRect rcExcludeArea( rcClient );
  1634. rcExcludeArea.left =
  1635. rcExcludeArea.right
  1636. - nMenuShadowSize;
  1637. pPaintDC->ExcludeClipRect(
  1638. &rcExcludeArea
  1639. );
  1640. rcExcludeArea = rcClient ;
  1641. rcExcludeArea.top =
  1642. rcExcludeArea.bottom
  1643. - nMenuShadowSize;
  1644. pPaintDC->ExcludeClipRect(
  1645. &rcExcludeArea
  1646. );
  1647. }
  1648. pPaintDC->BitBlt(
  1649. rcClient.left, rcClient.top, cx, cy, 
  1650. &dcmm,
  1651. 0,
  1652. 0,
  1653. SRCCOPY
  1654. );
  1655. if( nMenuShadowSize > 0 || m_bCombineWithEA )
  1656. pPaintDC->SelectClipRgn( NULL );
  1657. } // if( m_nAnimPercentOld != m_nAnimPercent )
  1658. }
  1659. break; // case __AT_NOISE
  1660. case __AT_SLIDE:
  1661. case __AT_ROLL:
  1662. case __AT_ROLL_AND_STRETCH:
  1663. case __AT_SLIDE_AND_STRETCH:
  1664. if( tmp!= NULL && src!=NULL && dst != NULL )
  1665. {
  1666. ASSERT(
  1667. m_nAnimPercent >= 0 && m_nAnimPercent <= 100
  1668. &&
  1669. m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
  1670. &&
  1671. m_nAnimPercentOld <= m_nAnimPercent
  1672. );
  1673. CRect _rcClient;
  1674. _GetClientRect( &_rcClient );
  1675. if( m_bCombineWithEA )
  1676. { // paint combined area AS IS
  1677. ASSERT( !m_rcExcludeArea.IsRectEmpty() );
  1678. CRect rcExcludeArea( m_rcExcludeArea );
  1679. ScreenToClient( &rcExcludeArea );
  1680. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1681. pPaintDC->BitBlt(
  1682. rcExcludeArea.left, rcExcludeArea.top,
  1683. rcExcludeArea.Width(), rcExcludeArea.Height(), 
  1684. &dcmm,
  1685. rcExcludeArea.left, rcExcludeArea.top,
  1686. SRCCOPY
  1687. );
  1688. dcmm.SelectObject( pBmpOld );
  1689. pBmpOld = NULL;
  1690. if( m_eCombineAlign != __CMBA_NONE )
  1691. {
  1692. int nMenuShadowSize = OnQueryMenuShadowSize();
  1693. rcExcludeArea.InflateRect(
  1694. (m_eCombineAlign == __CMBA_RIGHT) ?
  1695. 0 : nMenuShadowSize,
  1696. (m_eCombineAlign == __CMBA_BOTTOM) ?
  1697. 0 : nMenuShadowSize,
  1698. (m_eCombineAlign == __CMBA_LEFT) ?
  1699. 0 : nMenuShadowSize,
  1700. (m_eCombineAlign == __CMBA_TOP) ?
  1701. 0 : nMenuShadowSize
  1702. );
  1703. } // if( m_eCombineAlign != __CMBA_NONE )
  1704. pPaintDC->ExcludeClipRect(
  1705. &rcExcludeArea
  1706. );
  1707. } // paint combined area AS IS
  1708. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1709. int cx =
  1710. _rcClient.Width();
  1711. int cy =
  1712. _rcClient.Height();
  1713. if( m_AnimationType == __AT_ROLL
  1714. ||
  1715. m_AnimationType == __AT_SLIDE
  1716. )
  1717. { // non-stratchable variants
  1718. int _cx = 0;
  1719. if( m_AnimationType == __AT_ROLL )
  1720. _cx = (cx * (100-m_nAnimPercent)) / 100;
  1721. int _cy =
  1722. (cy * (100-m_nAnimPercent)) / 100;
  1723. if( m_eCombineAlign == __CMBA_RIGHT )
  1724. {
  1725. CRgn rgnClip;
  1726. if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
  1727. pPaintDC->SelectClipRgn( &rgnClip );
  1728. pPaintDC->BitBlt(
  1729. _rcClient.left+_cx, _rcClient.top-_cy, cx, cy, 
  1730. &dcmm,
  1731. _rcClient.left, _rcClient.top,
  1732. SRCCOPY
  1733. );
  1734. pPaintDC->SelectClipRgn( NULL );
  1735. } // if m_eCombineAlign is __CMBA_RIGHT
  1736. else if( m_eCombineAlign == __CMBA_BOTTOM )
  1737. {
  1738. CRgn rgnClip;
  1739. if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
  1740. pPaintDC->SelectClipRgn( &rgnClip );
  1741. pPaintDC->BitBlt(
  1742. _rcClient.left-_cx, _rcClient.top+_cy, cx, cy,
  1743. &dcmm,
  1744. _rcClient.left, _rcClient.top,
  1745. SRCCOPY
  1746. );
  1747. pPaintDC->SelectClipRgn( NULL );
  1748. } // if m_eCombineAlign is __CMBA_BOTTOM
  1749. else
  1750. { // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
  1751. pPaintDC->BitBlt(
  1752. _rcClient.left-_cx, _rcClient.top-_cy, cx, cy,
  1753. &dcmm,
  1754. _rcClient.left, _rcClient.top,
  1755. SRCCOPY
  1756. );
  1757. } // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
  1758. } // non-stratchable variants
  1759. else
  1760. { // stratchable variants
  1761. int _cx = cx;
  1762. if( m_AnimationType == __AT_ROLL_AND_STRETCH )
  1763. _cx = (cx * m_nAnimPercent) / 100;
  1764. int _cy =
  1765. (cy * m_nAnimPercent) / 100;
  1766. int nOldStretchBltMode =
  1767. pPaintDC->SetStretchBltMode(
  1768. g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
  1769. );
  1770. if( m_eCombineAlign == __CMBA_RIGHT
  1771. && m_AnimationType == __AT_ROLL_AND_STRETCH
  1772. )
  1773. {
  1774. CRgn rgnClip;
  1775. if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
  1776. pPaintDC->SelectClipRgn( &rgnClip );
  1777. pPaintDC->StretchBlt(
  1778. _rcClient.left+cx-_cx, _rcClient.top, _cx, _cy,
  1779. &dcmm,
  1780. _rcClient.left, _rcClient.top, cx, cy, 
  1781. SRCCOPY
  1782. );
  1783. pPaintDC->SelectClipRgn( NULL );
  1784. } // if m_eCombineAlign is __CMBA_RIGHT with __AT_ROLL_AND_STRETCH animation
  1785. else if( m_eCombineAlign == __CMBA_BOTTOM )
  1786. {
  1787. CRgn rgnClip;
  1788. if( rgnClip.CreateRectRgnIndirect( &_rcClient ) )
  1789. pPaintDC->SelectClipRgn( &rgnClip );
  1790. pPaintDC->StretchBlt(
  1791. _rcClient.left-cx+_cx, _rcClient.top+cy-_cy, _cx, _cy,
  1792. &dcmm,
  1793. _rcClient.left, _rcClient.top, cx, cy, 
  1794. SRCCOPY
  1795. );
  1796. pPaintDC->SelectClipRgn( NULL );
  1797. } // if m_eCombineAlign is __CMBA_BOTTOM
  1798. else
  1799. { // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
  1800. pPaintDC->StretchBlt(
  1801. _rcClient.left, _rcClient.top, _cx, _cy,
  1802. &dcmm,
  1803. _rcClient.left, _rcClient.top, cx, cy, 
  1804. SRCCOPY
  1805. );
  1806. } // if m_eCombineAlign is __CMBA_TOP or __CMBA_LEFT
  1807. pPaintDC->SetStretchBltMode( nOldStretchBltMode );
  1808. } // stratchable variants
  1809. if( m_bCombineWithEA )
  1810. pPaintDC->SelectClipRgn( NULL );
  1811. }
  1812. break; // cases __AT_ROLL, __AT_SLIDE, __AT_ROLL_AND_STRETCH, __AT_ROLL_AND_STRETCH
  1813. case __AT_CONTENT_EXPAND:
  1814. if( tmp!= NULL
  1815. && src!=NULL
  1816. && dst != NULL
  1817. && IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) )
  1818. )
  1819. {
  1820. CExtPopupMenuWnd * pThisPopup = STATIC_DOWNCAST( CExtPopupMenuWnd, this );
  1821. ASSERT(
  1822. m_nAnimPercent >= 0 && m_nAnimPercent <= 100
  1823. &&
  1824. m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
  1825. &&
  1826. m_nAnimPercentOld <= m_nAnimPercent
  1827. );
  1828. CRect _rcClient;
  1829. _GetClientRect( &_rcClient );
  1830. if( m_bCombineWithEA )
  1831. { // paint combined area AS IS
  1832. ASSERT( !m_rcExcludeArea.IsRectEmpty() );
  1833. CRect rcExcludeArea( m_rcExcludeArea );
  1834. ScreenToClient( &rcExcludeArea );
  1835. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1836. pPaintDC->BitBlt(
  1837. rcExcludeArea.left, rcExcludeArea.top,
  1838. rcExcludeArea.Width(), rcExcludeArea.Height(), 
  1839. &dcmm,
  1840. rcExcludeArea.left, rcExcludeArea.top,
  1841. SRCCOPY
  1842. );
  1843. dcmm.SelectObject( pBmpOld );
  1844. pBmpOld = NULL;
  1845. } // paint combined area AS IS
  1846. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1847. int cx =
  1848. _rcClient.Width();
  1849. int cy =
  1850. _rcClient.Height();
  1851. int _cx = cx;
  1852. int _cy =
  1853. (cy * m_nAnimPercent) / 100;
  1854. CExtPopupMenuWnd::visible_items_t v;
  1855. pThisPopup->_GetVisibleItems(
  1856. dcmm.GetSafeHdc(), // dc.GetSafeHdc()
  1857. v
  1858. );
  1859. if( v.GetSize() == 0 )
  1860. { // if menu is empty
  1861. int nOldStretchBltMode =
  1862. pPaintDC->SetStretchBltMode(
  1863. g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
  1864. );
  1865. pPaintDC->StretchBlt(
  1866. _rcClient.left, _rcClient.top, _cx, _cy, 
  1867. &dcmm,
  1868. _rcClient.left, _rcClient.top, cx, cy,
  1869. SRCCOPY
  1870. );
  1871. pPaintDC->SetStretchBltMode( nOldStretchBltMode );
  1872. } // if menu is empty
  1873. else
  1874. { // if menu is NOT empty
  1875. int y_pos_src = _rcClient.top;
  1876. int y_pos_dst = _rcClient.top;
  1877. INT vis_iter = 0;
  1878. int nItemIndex = 0;
  1879. int nItemCount = int(v.GetSize());
  1880. ASSERT( nItemCount > 0 );
  1881. CExtPopupMenuWnd::expand_effect_rects_container_t vRects;
  1882. for( ; vis_iter < v.GetSize(); ++vis_iter, ++nItemIndex )
  1883. { // calc rects for visible items
  1884. CExtPopupMenuWnd::VisibleItemDefinition_t & vi = v[vis_iter];
  1885. CExtPopupMenuWnd::MENUITEMDATA & mi =
  1886. pThisPopup->ItemGetInfo( vi.m_nIndex );
  1887. ASSERT(
  1888. vi.m_nIndex >= 0
  1889. && vi.m_nIndex < pThisPopup->ItemGetCount() // m_items_all.GetSize()
  1890. );
  1891. ASSERT( mi.IsDisplayed() );
  1892. ASSERT( mi.GetCmdID() == vi.m_nHelperCmdID );
  1893. CRect rcItemSrc;
  1894. pThisPopup->_GetItemRect( vi.m_nIndex, rcItemSrc, false );
  1895. rcItemSrc.left = _rcClient.left;
  1896. rcItemSrc.right = _rcClient.right;
  1897. if( nItemIndex == 0 )
  1898. rcItemSrc.top = _rcClient.top;
  1899. else if( nItemIndex == (nItemCount-1) )
  1900. rcItemSrc.bottom = _rcClient.bottom;
  1901. int y_pos_src_next = 
  1902. y_pos_src + rcItemSrc.Height();
  1903. CRect rcItemDst( rcItemSrc );
  1904. rcItemDst.OffsetRect(
  1905. 0,
  1906. y_pos_dst - rcItemDst.top
  1907. );
  1908. if( vi.m_bRarelyUsed )
  1909. rcItemDst.bottom =
  1910. rcItemDst.top
  1911. +
  1912. (rcItemDst.Height() * m_nAnimPercent)
  1913. / 100;
  1914. int y_pos_dst_next = 
  1915. y_pos_dst + rcItemDst.Height();
  1916. CExtPopupMenuWnd::ExpandEffectRects_t _eert(
  1917. rcItemSrc,
  1918. rcItemDst
  1919. );
  1920. vRects.Add( _eert );
  1921. y_pos_dst = y_pos_dst_next;
  1922. y_pos_src = y_pos_src_next;
  1923. } // calc rects for visible items
  1924. // y_pos_dst is now equal to size of
  1925. // all compressed items
  1926. ASSERT( y_pos_dst <= y_pos_src );
  1927. if( m_bCombineWithEA
  1928. && m_eCombineAlign == __CMBA_BOTTOM
  1929. && y_pos_dst != y_pos_src
  1930. )
  1931. { // expand from bottom to top
  1932. INT iter_rects = 0;
  1933. int nDstOffset =
  1934. y_pos_src - y_pos_dst;
  1935. for( ; iter_rects < vRects.GetSize(); ++iter_rects )
  1936. { // adjust destination rects
  1937. CExtPopupMenuWnd::ExpandEffectRects_t & eerc =
  1938. vRects[ iter_rects ];
  1939. eerc.m_rcDst.OffsetRect(
  1940. 0,
  1941. nDstOffset
  1942. );
  1943. } // adjust destination rects
  1944. } // expand from bottom to top
  1945. INT iter_rects = 0;
  1946. for( ; iter_rects < vRects.GetSize(); ++iter_rects )
  1947. { // paint visible items
  1948. CExtPopupMenuWnd::ExpandEffectRects_t & eerc =
  1949. vRects[ iter_rects ];
  1950. if( eerc.m_rcDst.IsRectEmpty() )
  1951. continue;
  1952. if( CExtPopupMenuWnd::g_bUseStretchOnExpandAnimation )
  1953. {
  1954. int nOldStretchBltMode =
  1955. pPaintDC->SetStretchBltMode(
  1956. g_PaintManager.m_bIsWinNT ? HALFTONE : COLORONCOLOR
  1957. );
  1958. // something better then Office XP
  1959. pPaintDC->StretchBlt(
  1960. eerc.m_rcDst.left, eerc.m_rcDst.top,
  1961. eerc.m_rcDst.Width(), eerc.m_rcDst.Height(), 
  1962. &dcmm,
  1963. eerc.m_rcSrc.left, eerc.m_rcSrc.top,
  1964. eerc.m_rcSrc.Width(), eerc.m_rcSrc.Height(), 
  1965. SRCCOPY
  1966. );
  1967. pPaintDC->SetStretchBltMode( nOldStretchBltMode );
  1968. } // if( CExtPopupMenuWnd::g_bUseStretchOnExpandAnimation )
  1969. else
  1970. // somthing really like Office XP
  1971. pPaintDC->BitBlt(
  1972. eerc.m_rcDst.left, eerc.m_rcDst.top,
  1973. eerc.m_rcDst.Width(), eerc.m_rcDst.Height(), 
  1974. &dcmm,
  1975. eerc.m_rcSrc.left, eerc.m_rcSrc.top,
  1976. SRCCOPY
  1977. );
  1978. } // paint visible items
  1979. } // if menu is NOT empty
  1980. }
  1981. break; // case __AT_CONTENT_EXPAND
  1982. case __AT_CONTENT_DISPLAY:
  1983. if( tmp!= NULL && src!=NULL && dst != NULL )
  1984. {
  1985. pBmpOld = dcmm.SelectObject( &m_bmpScreenDst );
  1986. pPaintDC->BitBlt(
  1987. rcClient.left, rcClient.top, cx, cy, 
  1988. &dcmm,
  1989. 0,
  1990. 0,
  1991. SRCCOPY
  1992. );
  1993. }
  1994. break; // case __AT_CONTENT_DISPLAY
  1995. case __AT_FADE:
  1996. if( tmp!= NULL && src!=NULL && dst != NULL )
  1997. {
  1998. ASSERT(
  1999. m_nAnimPercent >= 0 && m_nAnimPercent <= 100
  2000. &&
  2001. m_nAnimPercentOld >= 0 && m_nAnimPercentOld <= 100
  2002. &&
  2003. m_nAnimPercentOld <= m_nAnimPercent
  2004. );
  2005. pBmpOld = dcmm.SelectObject( &m_bmpScreenTmp );
  2006. for( int pixel = 0; pixel < cx * cy; pixel++ )
  2007. {
  2008. COLORREF c0 = *dst++;
  2009. COLORREF c1 = *src++;
  2010. *tmp++ =
  2011. RGB(
  2012. (m_nAnimPercent*long(GetRValue(c0)) + (100L-m_nAnimPercent)*long(GetRValue(c1)) ) / 100L,
  2013. (m_nAnimPercent*long(GetGValue(c0)) + (100L-m_nAnimPercent)*long(GetGValue(c1)) ) / 100L,
  2014. (m_nAnimPercent*long(GetBValue(c0)) + (100L-m_nAnimPercent)*long(GetBValue(c1)) ) / 100L
  2015. );
  2016. } // for( int pixel = 0; pixel < cx * cy; pixel++ )
  2017. pPaintDC->BitBlt(
  2018. rcClient.left, rcClient.top, cx, cy, 
  2019. &dcmm,
  2020. 0,
  2021. 0,
  2022. SRCCOPY
  2023. );
  2024. }
  2025. break; // case __AT_FADE
  2026. #ifdef _DEBUG
  2027. default:
  2028. ASSERT( FALSE );
  2029. break; // default
  2030. #endif // _DEBUG
  2031. } // switch( m_AnimationType )
  2032. } // if( ! bFail )
  2033. if( pBmpOld != NULL )
  2034. dcmm.SelectObject( pBmpOld );
  2035. if( pOldPalette != NULL )
  2036. pPaintDC->SelectPalette( pOldPalette, FALSE );
  2037. }
  2038. void CExtPopupBaseWnd::_DoPaint( CDC & dcPaint, bool bUseBackBuffer /*= true*/ )
  2039. {
  2040. ASSERT_VALID( this );
  2041. dcPaint;
  2042. bUseBackBuffer;
  2043. }
  2044. void CExtPopupBaseWnd::_DelayPaint()
  2045. {
  2046. ASSERT_VALID( this );
  2047. if( GetSafeHwnd() == NULL )
  2048. return;
  2049. PostMessage( WM_TIMER, ID_TIMER_DELAY_PAINT );
  2050. }
  2051. void CExtPopupBaseWnd::OnTimer(__EXT_MFC_UINT_PTR nIDEvent) 
  2052. {
  2053. ASSERT_VALID( this );
  2054. switch( nIDEvent )
  2055. {
  2056. case ID_TIMER_LIFE_STEP:
  2057. return;
  2058. case ID_TIMER_DELAY_PAINT:
  2059. {
  2060. KillTimer( ID_TIMER_DELAY_PAINT );
  2061. CClientDC dc( this );
  2062. _DoPaint( dc );
  2063. }
  2064. return;
  2065. case ID_TIMER_DELAY_SHOW:
  2066. {
  2067. VERIFY( KillTimer( ID_TIMER_DELAY_SHOW ) );
  2068. ShowWindow( SW_SHOWNA );
  2069. Invalidate( FALSE );
  2070. UpdateWindow();
  2071. return;
  2072. }
  2073. // case ID_TIMER_DELAY_SHOW
  2074. case ID_TIMER_ANIMATION:
  2075. if( ! m_bAnimFinished )
  2076. {
  2077. clock_t nCurrAnimTime = clock();
  2078. int nDuration =
  2079. nCurrAnimTime - g_nLastAnimTime;
  2080. int nSteps = (int)
  2081. (0.5 + (float) nDuration / ID_PERIOD_ANIMATION);
  2082. switch( m_AnimationType )
  2083. {
  2084. case __AT_CONTENT_DISPLAY:
  2085. m_bAnimFinished = true;
  2086. break;
  2087. case __AT_FADE:
  2088. case __AT_CONTENT_EXPAND:
  2089. case __AT_ROLL:
  2090. case __AT_SLIDE:
  2091. case __AT_ROLL_AND_STRETCH:
  2092. case __AT_SLIDE_AND_STRETCH:
  2093. case __AT_NOISE:
  2094. case __AT_BOXES:
  2095. case __AT_CIRCLES:
  2096. case __AT_HOLES:
  2097. m_nAnimPercentOld = m_nAnimPercent;
  2098. m_nAnimPercent += g_nAnimStepMetric;
  2099. if( m_nAnimPercent >
  2100. 100 + nSteps * g_nAnimStepMetric
  2101. )
  2102. m_nAnimPercent = 101;
  2103. if( m_nAnimPercent > 100 )
  2104. m_bAnimFinished = true;
  2105. break;
  2106. #ifdef _DEBUG
  2107. default:
  2108. ASSERT( FALSE );
  2109. break;
  2110. #endif // _DEBUG
  2111. } // switch( m_AnimationType )
  2112. if( m_bAnimFinished )
  2113. {
  2114. if( !_FindCustomizeMode() )
  2115. {
  2116. g_SoundPlayer->PlaySound(
  2117. m_ePlaySoundOnAnimationFinished
  2118. );
  2119. m_ePlaySoundOnAnimationFinished =
  2120. CExtSoundPlayer::__NO_SOUND;
  2121. } // if( !_FindCustomizeMode() )
  2122. KillTimer(ID_TIMER_ANIMATION);
  2123. m_AnimationType = g_DefAnimationType;
  2124. } // if( m_bAnimFinished )
  2125. if( GetSafeHwnd() != NULL )
  2126. {
  2127. if( m_bAnimFinished )
  2128. _EndAnimation();
  2129. else
  2130. {
  2131. Invalidate( FALSE );
  2132. UpdateWindow();
  2133. }
  2134. g_nLastAnimTime = nCurrAnimTime;
  2135. }
  2136. } // if( ! m_bAnimFinished )
  2137. if( m_bAnimFinished )
  2138. if( IsKindOf(RUNTIME_CLASS(CExtPopupMenuWnd)) )
  2139. ((CExtPopupMenuWnd *)this)->
  2140. GetSite().SetAnimated( NULL );
  2141. return;
  2142. // case ID_TIMER_ANIMATION
  2143. default:
  2144. __BaseClassOfCExtPopupBaseWnd::OnTimer(nIDEvent);
  2145. break; // default
  2146. } // switch( nIDEvent )
  2147. }
  2148. int CExtPopupBaseWnd::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) 
  2149. {
  2150. ASSERT_VALID( this );
  2151. pDesktopWnd;
  2152. nHitTest;
  2153. message;
  2154. if( _FindCustomizeMode() )
  2155. {
  2156. if( IsKindOf(RUNTIME_CLASS(CExtPopupMenuWnd)) )
  2157. ((CExtPopupMenuWnd*)this)->_DoResetChainPositions();
  2158. else
  2159. SetWindowPos(
  2160. &CWnd::wndTopMost,
  2161. -1, -1, -1, -1,
  2162. SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
  2163. );
  2164. return MA_NOACTIVATE;
  2165. }
  2166. HWND hWndInPlace = ::GetWindow( m_hWnd, GW_CHILD );
  2167. if( hWndInPlace != NULL )
  2168. {
  2169. CPoint ptScreenClick;
  2170. if( ! ::GetCursorPos(&ptScreenClick) )
  2171. return MA_NOACTIVATEANDEAT;
  2172. HWND hWndFromPoint = ::WindowFromPoint( ptScreenClick );
  2173. if( hWndFromPoint != NULL
  2174. && (::__EXT_MFC_GetWindowLong(hWndFromPoint,GWL_STYLE)&WS_CHILD) != 0
  2175. && ::GetParent(hWndFromPoint) == m_hWnd
  2176. )
  2177. return MA_ACTIVATE;
  2178. } // if( hWndInPlace != NULL )
  2179. return MA_NOACTIVATEANDEAT;
  2180. //return CExtPopupBaseWnd::OnMouseActivate(pDesktopWnd, nHitTest, message);
  2181. }
  2182. void CExtPopupMenuWnd::_DoShowChain(
  2183. int nCmdShow // = SW_SHOWNA
  2184. )
  2185. {
  2186. ASSERT_VALID( this );
  2187. if( m_hWnd == NULL || (! ::IsWindow(m_hWnd) ) )
  2188. return;
  2189. ShowWindow( nCmdShow );
  2190. if( m_nCurIndex < 0 )
  2191. return;
  2192. MENUITEMDATA & mi = ItemGetInfo( m_nCurIndex );
  2193. if( ! mi.IsPopup() )
  2194. return;
  2195. mi.GetPopup()->_DoShowChain( nCmdShow );
  2196. }
  2197. void CExtPopupMenuWnd::_DoResetChainPositions()
  2198. {
  2199. ASSERT_VALID( this );
  2200. CExtPopupMenuWnd * pChild = NULL;
  2201. if( m_nCurIndex >= 0 )
  2202. {
  2203. MENUITEMDATA & mi = ItemGetInfo( m_nCurIndex );
  2204. if( mi.IsPopup() )
  2205. {
  2206. pChild = mi.GetPopup();
  2207. if( pChild->GetSafeHwnd() == NULL
  2208. || (! pChild->IsWindowVisible() )
  2209. )
  2210. pChild = NULL;
  2211. } // if( mi.IsPopup() )
  2212. } // if( m_nCurIndex >= 0 )
  2213. if( pChild != NULL )
  2214. pChild->_DoResetChainPositions();
  2215. _DoResetChainPositionsImpl( NULL );
  2216. }
  2217. void CExtPopupMenuWnd::_DoResetChainPositionsImpl(
  2218. CExtPopupMenuWnd * pPrev
  2219. )
  2220. {
  2221. SetWindowPos(
  2222. ( pPrev == NULL ) ? (&CWnd::wndTopMost) : pPrev,
  2223. 0, 0, 0, 0,
  2224. SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
  2225. |SWP_NOREDRAW
  2226. );
  2227. { // BLOCK : DC painting
  2228. CClientDC dc( this );
  2229. _DoPaint( dc );
  2230. } // BLOCK : DC painting
  2231. if( m_pWndParentMenu != NULL )
  2232. m_pWndParentMenu->_DoResetChainPositionsImpl( this );
  2233. }
  2234. BOOL CExtPopupBaseWnd::OnEraseBkgnd(CDC* pDC) 
  2235. {
  2236. ASSERT_VALID( this );
  2237. pDC;
  2238. return TRUE;
  2239. }
  2240. void CExtPopupBaseWnd::OnNcPaint() 
  2241. {
  2242. ASSERT_VALID( this );
  2243. }
  2244. void CExtPopupBaseWnd::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) 
  2245. {
  2246. ASSERT_VALID( this );
  2247. bCalcValidRects;
  2248. lpncsp;
  2249. /// __BaseClassOfCExtPopupBaseWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
  2250. }
  2251. void CExtPopupBaseWnd::OnSize(UINT nType, int cx, int cy) 
  2252. {
  2253. ASSERT_VALID( this );
  2254. __BaseClassOfCExtPopupBaseWnd::OnSize(nType, cx, cy);
  2255. Invalidate(FALSE);
  2256. }
  2257. bool CExtPopupBaseWnd::OnQueryLayoutRTL() const
  2258. {
  2259. ASSERT_VALID( this );
  2260. bool bRTL =
  2261. ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 )
  2262. ? true : false;
  2263. return bRTL;
  2264. }
  2265. BOOL CExtPopupBaseWnd::DestroyWindow()
  2266. {
  2267. __PROF_UIS_MANAGE_STATE;
  2268. if( m_ctrlShadow.GetSafeHwnd() )
  2269. m_ctrlShadow.DestroyWindow();
  2270. HWND hWndOwn = GetSafeHwnd();
  2271. if( hWndOwn == NULL || (! ::IsWindow( hWndOwn ) ) )
  2272. return TRUE;
  2273. return ::DestroyWindow( hWndOwn );
  2274. }
  2275. void CExtPopupBaseWnd::PostNcDestroy() 
  2276. {
  2277. ASSERT_VALID( this );
  2278. }
  2279. void CExtPopupMenuWnd::PostNcDestroy() 
  2280. {
  2281. ASSERT_VALID( this );
  2282. if( _FindCustomizeMode() )
  2283. return;
  2284. if( m_bTopLevel
  2285. && ( ! _IsFadeOutAnimation() )
  2286. )
  2287. {
  2288. CExtPopupMenuSite & _site = GetSite();
  2289. DWORD dwTrackFlags = TrackFlagsGet();
  2290. ASSERT( m_hWndCmdReceiver != NULL );
  2291. if( ::IsWindow(m_hWndCmdReceiver) )
  2292. ::SendMessage(
  2293. m_hWndCmdReceiver,
  2294. g_nMsgNotifyMenuClosed,
  2295. 0,
  2296. LPARAM( this )
  2297. );
  2298. if( m_hWndNotifyMenuClosed != NULL
  2299. && ::IsWindow( m_hWndNotifyMenuClosed )
  2300. )
  2301. ::SendMessage(
  2302. m_hWndNotifyMenuClosed,
  2303. g_nMsgNotifyMenuClosed,
  2304. 0,
  2305. LPARAM( this )
  2306. );
  2307. if( ( ! _site.IsEmpty() )
  2308. && ( ! _site.IsShutdownMode() )
  2309. && (dwTrackFlags&TPMX_NO_SITE) == 0
  2310. )
  2311. {
  2312. _site.DoneInstance();
  2313. ASSERT( _site.IsEmpty() );
  2314. ASSERT( ! _site.IsShutdownMode() );
  2315. }
  2316. } // if( m_bTopLevel )
  2317. }
  2318. void CExtPopupMenuWnd::_DeleteFadeOutMenu()
  2319. {
  2320. ASSERT_VALID( this );
  2321. delete this;
  2322. }
  2323. bool CExtPopupBaseWnd::_FindHelpMode() const
  2324. {
  2325. // if( ::AfxGetApp()->m_bHelpMode )
  2326. // return true;
  2327. return false;
  2328. }
  2329. bool CExtPopupMenuWnd::_FindHelpMode() const
  2330. {
  2331. DWORD dwTrackFlags = TrackFlagsGet();
  2332. if( (dwTrackFlags&TPMX_HELP_CTX_MODE) != 0 )
  2333. return true;
  2334. if( m_pWndParentMenu != NULL )
  2335. return m_pWndParentMenu->_FindHelpMode();
  2336. return CExtPopupBaseWnd::_FindHelpMode();
  2337. }
  2338. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  2339. CExtCustomizeSite * CExtPopupMenuWnd::_FindCustomizeSite() const
  2340. {
  2341. if( m_pCustomizeSite != NULL )
  2342. return (CExtCustomizeSite *)m_pCustomizeSite;
  2343. if( m_pWndParentMenu != NULL )
  2344. return m_pWndParentMenu->_FindCustomizeSite();
  2345. return NULL;
  2346. }
  2347. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  2348. bool CExtPopupBaseWnd::_FindCustomizeMode() const
  2349. {
  2350. return false;
  2351. }
  2352. INT CExtPopupMenuWnd::_FindChildPopup( const CExtPopupMenuWnd * pPopup ) const
  2353. {
  2354. ASSERT_VALID( this );
  2355. if( pPopup == NULL )
  2356. return -1;
  2357. ASSERT_VALID( pPopup );
  2358. INT nIndex, nCount = ItemGetCount();
  2359. for( nIndex = 0; nIndex < nCount; nIndex ++ )
  2360. {
  2361. const MENUITEMDATA & _mii = ItemGetInfo( nIndex );
  2362. if(! _mii.IsPopup() )
  2363. continue;
  2364. const CExtPopupMenuWnd * pChildPopup = _mii.GetPopup();
  2365. if( LPVOID(pChildPopup) == LPVOID(pPopup) )
  2366. return nIndex;
  2367. }
  2368. return -1;
  2369. }
  2370. bool CExtPopupMenuWnd::_FindCustomizeMode() const
  2371. {
  2372. DWORD dwTrackFlags = TrackFlagsGet();
  2373. if( (dwTrackFlags&TPMX_CUSTOMIZE_MODE) != 0 )
  2374. return true;
  2375. if( m_pWndParentMenu != NULL )
  2376. return m_pWndParentMenu->_FindCustomizeMode();
  2377. return false;
  2378. }
  2379. BOOL CExtPopupBaseWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
  2380. {
  2381. ASSERT_VALID( this );
  2382. if( _FindHelpMode() )
  2383. {
  2384. SetCursor( afxData.hcurHelp );
  2385. return TRUE;
  2386. }
  2387. return __BaseClassOfCExtPopupBaseWnd::OnSetCursor(pWnd, nHitTest, message);
  2388. }
  2389. /////////////////////////////////////////////////////////////////////////////
  2390. // CExtPopupMenuTipWnd
  2391. IMPLEMENT_DYNCREATE(CExtPopupMenuTipWnd, CExtPopupBaseWnd)
  2392. bool CExtPopupMenuTipWnd::g_bEnableAdvTips = true;
  2393. CExtPopupMenuTipWnd::CExtPopupMenuTipWnd()
  2394. : m_bFlipHorz( false )
  2395. , m_bFlipVert( false )
  2396. , m_sizeClassicMargins( 3, 2 )
  2397. , m_sizeRounders( 12, 10 )
  2398. , m_sizeLeader( 25, 25 )
  2399. , m_nIconMarginDX( 5 )
  2400. , m_nBalloonDistance( 12 )
  2401. , m_nClassicDistance( 13 )
  2402. , m_eTS( CExtPopupMenuTipWnd::__ETS_BALLOON )
  2403. , m_nSizeShadow( -1 )
  2404. , m_ttLA( 0 )
  2405. , m_bPassiveMode( false )
  2406. , m_bDelayedLayeredBehavior( false )
  2407. , m_ptGuideLines( -32767, -32767 )
  2408. , m_nTransparencyKey( BYTE(0x0FF) )
  2409. , m_rcAlignment( 0, 0, 0, 0 )
  2410. , m_nPeriodDelayShowQuick( ID_PERIOD_DELAY_SHOW_QUICK )
  2411. , m_nPeriodDelayShowNormal( ID_PERIOD_DELAY_SHOW_NORMAL )
  2412. , m_hWndLastParent( NULL )
  2413. , m_bNoHideDetection( false )
  2414. {
  2415. m_AnimationType = __AT_NONE;
  2416. m_bAnimFinished = true;
  2417. // HICON hIcon =
  2418. //  ::LoadIcon(
  2419. //  NULL,
  2420. //  IDI_INFORMATION
  2421. //  );
  2422. //  if( hIcon != NULL )
  2423. //  {
  2424. //  m_sizeRenderingIcon.cx = 16;
  2425. //  m_sizeRenderingIcon.cy = 16;
  2426. //  m_icon.m_bmpNormal.AssignFromHICON( hIcon );
  2427. //  ::DestroyIcon( hIcon );
  2428. //  CExtBitmap::Filter _f( CExtBitmap::Filter::hermite );
  2429. //  m_icon.m_bmpNormal.Scale( 14, 14, _f );
  2430. //  }
  2431. BYTE arrIconInformation[]=
  2432. {
  2433. 0x42,0x4D,0x36,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,
  2434. 0x00,0x00,0x01,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  2435. 0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2436. 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,0x14,0x00,0x51,0x26,0x12,0x1B,0x56,0x2A,0x15,0x52,0x55,0x2A,
  2437. 0x15,0x0F,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2438. 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,
  2439. 0x14,0x00,0x51,0x26,0x11,0x36,0x9A,0x6B,0x45,0xD1,0x75,0x47,0x29,0xCF,0x50,0x26,0x12,0x19,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2440. 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2441. 0x15,0x00,0x55,0x2A,0x15,0x00,0x54,0x29,0x14,0x00,0x50,0x25,0x11,0x00,0x4C,0x21,0x0C,0x34,0x91,0x66,0x45,0xE4,0xE8,0xBC,
  2442. 0x8E,0xFF,0x78,0x4A,0x2C,0xCD,0x4E,0x23,0x10,0x1F,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2443. 0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x53,0x27,0x13,0x00,0x4F,0x23,0x0F,0x17,0x58,0x2C,
  2444. 0x16,0x66,0x69,0x3F,0x27,0x9C,0x7B,0x54,0x3A,0xE0,0xC8,0xA4,0x81,0xFF,0xEB,0xC3,0x99,0xFF,0x86,0x5B,0x3D,0xF1,0x50,0x24,
  2445. 0x0F,0xB1,0x4F,0x24,0x10,0x65,0x54,0x29,0x14,0x18,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,
  2446. 0x15,0x00,0x50,0x24,0x10,0x00,0x5D,0x32,0x1A,0x44,0x8B,0x65,0x4A,0xC8,0xAF,0x8F,0x71,0xFF,0xC7,0xA7,0x87,0xFF,0xD7,0xB8,
  2447. 0x97,0xFF,0xE8,0xC8,0xA5,0xFF,0xF4,0xD0,0xAA,0xFF,0xCF,0xAC,0x8A,0xFF,0xAA,0x85,0x64,0xFF,0x7A,0x51,0x34,0xFB,0x53,0x27,
  2448. 0x11,0xBA,0x53,0x28,0x13,0x3B,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x50,0x24,0x10,0x00,0x70,0x46,0x2D,0x51,0xB2,0x94,
  2449. 0x79,0xF1,0xD8,0xBD,0xA2,0xFF,0xED,0xD1,0xB3,0xFF,0xE8,0xC0,0x9E,0xFF,0xDD,0xA3,0x7A,0xFF,0xEF,0xB4,0x8A,0xFF,0xED,0xB2,
  2450. 0x87,0xFF,0xE9,0xBD,0x97,0xFF,0xEA,0xCA,0xA7,0xFF,0xD3,0xB2,0x91,0xFF,0x9D,0x76,0x56,0xFF,0x58,0x2C,0x15,0xD2,0x52,0x27,
  2451. 0x13,0x36,0x55,0x2A,0x15,0x00,0x63,0x39,0x22,0x25,0xB9,0x9F,0x86,0xEB,0xDF,0xC7,0xB0,0xFF,0xFB,0xDF,0xC2,0xFF,0xFF,0xE6,
  2452. 0xC8,0xFF,0xF3,0xD7,0xB9,0xFF,0xAD,0x64,0x3C,0xFF,0x9F,0x33,0x0D,0xFF,0xB3,0x65,0x3A,0xFF,0xF1,0xD0,0xAD,0xFF,0xFF,0xE1,
  2453. 0xBE,0xFF,0xF6,0xD3,0xB2,0xFF,0xDB,0xBE,0x9E,0xFF,0x9B,0x75,0x56,0xFF,0x52,0x26,0x10,0xAB,0x54,0x2A,0x15,0x0E,0xA2,0x83,
  2454. 0x6A,0x9C,0xDD,0xCA,0xB6,0xFF,0xFB,0xE3,0xCB,0xFF,0xFF,0xE7,0xCD,0xFF,0xFF,0xE4,0xCA,0xFF,0xFF,0xF1,0xD6,0xFF,0xBF,0x8A,
  2455. 0x67,0xFF,0x84,0x19,0x00,0xFF,0xC3,0x88,0x63,0xFF,0xFF,0xEE,0xD1,0xFF,0xFF,0xE0,0xC0,0xFF,0xFF,0xE1,0xC1,0xFF,0xF6,0xD7,
  2456. 0xB8,0xFF,0xD7,0xBA,0x9C,0xFF,0x73,0x49,0x30,0xEE,0x50,0x25,0x10,0x42,0xCC,0xB8,0xA5,0xE7,0xEF,0xDD,0xCB,0xFF,0xFF,0xEC,
  2457. 0xD7,0xFF,0xFF,0xE9,0xD3,0xFF,0xFF,0xE8,0xD1,0xFF,0xFF,0xF2,0xDC,0xFF,0xBD,0x88,0x67,0xFF,0x88,0x1D,0x00,0xFF,0xC3,0x89,
  2458. 0x66,0xFF,0xFF,0xEE,0xD5,0xFF,0xFF,0xE4,0xC8,0xFF,0xFF,0xE3,0xC7,0xFF,0xFF,0xE4,0xC7,0xFF,0xEF,0xD6,0xBA,0xFF,0xA1,0x7E,
  2459. 0x64,0xFD,0x4E,0x22,0x0D,0x5D,0xD3,0xC6,0xB9,0xF0,0xF8,0xE7,0xD8,0xFF,0xFF,0xEF,0xDE,0xFF,0xFF,0xED,0xDB,0xFF,0xFF,0xEC,
  2460. 0xD8,0xFF,0xFF,0xFA,0xE8,0xFF,0xC1,0x8F,0x71,0xFF,0x88,0x1C,0x00,0xFF,0xC3,0x8A,0x69,0xFF,0xFF,0xF2,0xDC,0xFF,0xFF,0xE7,
  2461. 0xCF,0xFF,0xFF,0xE7,0xCE,0xFF,0xFF,0xE8,0xCF,0xFF,0xF8,0xE1,0xC9,0xFF,0xAD,0x8F,0x78,0xFE,0x4D,0x21,0x0C,0x5E,0xD5,0xCB,
  2462. 0xC1,0xF1,0xF9,0xED,0xE1,0xFF,0xFF,0xF3,0xE6,0xFF,0xFF,0xF1,0xE3,0xFF,0xFF,0xF3,0xE4,0xFF,0xEE,0xDD,0xCB,0xFF,0xA3,0x59,
  2463. 0x34,0xFF,0x81,0x13,0x00,0xFF,0xBC,0x86,0x66,0xFF,0xFF,0xF7,0xE6,0xFF,0xFF,0xEB,0xD7,0xFF,0xFF,0xEA,0xD5,0xFF,0xFF,0xED,
  2464. 0xD7,0xFF,0xFA,0xE9,0xD3,0xFF,0xAF,0x93,0x7D,0xF9,0x4D,0x21,0x0C,0x50,0xDB,0xCF,0xC2,0xD5,0xF4,0xEE,0xE7,0xFF,0xFF,0xF9,
  2465. 0xF0,0xFF,0xFF,0xF4,0xEA,0xFF,0xFF,0xF9,0xEF,0xFF,0xDC,0xC4,0xB3,0xFF,0xB5,0x89,0x74,0xFF,0xAE,0x84,0x70,0xFF,0xD1,0xB5,
  2466. 0xA2,0xFF,0xFF,0xF6,0xE7,0xFF,0xFF,0xEF,0xDF,0xFF,0xFF,0xED,0xDC,0xFF,0xFF,0xF6,0xE5,0xFF,0xFB,0xEE,0xDC,0xFF,0x9F,0x7F,
  2467. 0x69,0xD3,0x4D,0x21,0x0B,0x1C,0xE3,0xCF,0xBB,0x6A,0xE8,0xE5,0xE2,0xFF,0xFE,0xFC,0xF8,0xFF,0xFF,0xFA,0xF5,0xFF,0xFF,0xF7,
  2468. 0xEF,0xFF,0xFF,0xFE,0xF8,0xFF,0xF7,0xE5,0xD8,0xFF,0xF3,0xCC,0xB3,0xFF,0xFF,0xF0,0xE3,0xFF,0xFF,0xF5,0xEA,0xFF,0xFF,0xF2,
  2469. 0xE6,0xFF,0xFF,0xF8,0xEF,0xFF,0xFF,0xFA,0xF1,0xFF,0xE7,0xD7,0xC7,0xFF,0x6A,0x41,0x2B,0x67,0x50,0x25,0x10,0x00,0xEC,0xD2,
  2470. 0xB8,0x04,0xE7,0xDB,0xCF,0xB0,0xEF,0xEE,0xEC,0xFF,0xFE,0xFE,0xFD,0xFF,0xFF,0xFE,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0x9C,0x61,
  2471. 0x43,0xFF,0x8F,0x21,0x00,0xFF,0xC7,0x99,0x80,0xFF,0xFF,0xFF,0xFD,0xFF,0xFF,0xFC,0xF8,0xFF,0xFF,0xFF,0xFC,0xFF,0xFA,0xF2,
  2472. 0xE8,0xFF,0x97,0x77,0x62,0x91,0x4D,0x20,0x0B,0x04,0x55,0x2A,0x15,0x00,0xED,0xD3,0xBA,0x00,0xED,0xD4,0xBC,0x0C,0xE7,0xDD,
  2473. 0xD2,0x9B,0xF2,0xF1,0xF0,0xFF,0xFB,0xFC,0xFD,0xFF,0xFE,0xFF,0xFF,0xFF,0xC6,0xB2,0xA8,0xFF,0x8A,0x5C,0x4F,0xFF,0xDF,0xD2,
  2474. 0xCB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEE,0xE5,0xDD,0xF1,0x95,0x76,0x64,0x76,0x51,0x24,0x0F,0x03,0x54,0x29,
  2475. 0x14,0x00,0x55,0x2A,0x15,0x00,0xED,0xD3,0xBA,0x00,0xED,0xD4,0xBD,0x00,0xEA,0xD8,0xC6,0x00,0xCB,0xB6,0xA8,0x3D,0xE1,0xD9,
  2476. 0xD1,0xA1,0xF1,0xEE,0xEB,0xE1,0xFA,0xFC,0xFD,0xEE,0xFB,0xFF,0xFF,0xEE,0xFA,0xFA,0xFA,0xEE,0xED,0xE5,0xDD,0xD1,0xAE,0x97,
  2477. 0x89,0x88,0x68,0x40,0x2C,0x26,0x4C,0x20,0x0A,0x00,0x54,0x29,0x14,0x00,0x55,0x2A,0x15,0x00,0x55,0x2A,0x15,0x00,0x00
  2478. };
  2479. m_sizeRenderingIcon.cx = 16;
  2480. m_sizeRenderingIcon.cy = 16;
  2481. VERIFY(
  2482. m_icon.m_bmpNormal.LoadBMP_Buffer(
  2483. arrIconInformation,
  2484. sizeof(arrIconInformation) / sizeof(arrIconInformation[0])
  2485. )
  2486. );
  2487. g_listAllTips.AddTail( this );
  2488. }
  2489. CExtPopupMenuTipWnd::~CExtPopupMenuTipWnd()
  2490. {
  2491. POSITION pos = g_listAllTips.Find( this );
  2492. if( pos != NULL )
  2493. g_listAllTips.RemoveAt( pos );
  2494. }
  2495. BEGIN_MESSAGE_MAP(CExtPopupMenuTipWnd, CExtPopupBaseWnd)
  2496. //{{AFX_MSG_MAP(CExtPopupMenuTipWnd)
  2497. ON_WM_TIMER()
  2498. //}}AFX_MSG_MAP
  2499. ON_WM_ACTIVATEAPP()
  2500. END_MESSAGE_MAP()
  2501. HRGN CExtPopupMenuTipWnd::CalcRegion(
  2502. CDC & dc,
  2503. CSize * pSize // = NULL
  2504. )
  2505. {
  2506. __PROF_UIS_MANAGE_STATE;
  2507. // ASSERT_VALID( this );
  2508. HRGN hRegion = NULL;
  2509. m_bFlipHorz = false;
  2510. m_bFlipVert = false;
  2511. CWnd * pWndSearchMon = GetParent();
  2512. ASSERT_VALID( pWndSearchMon );
  2513. ASSERT( pWndSearchMon->GetSafeHwnd() != NULL );
  2514. ASSERT( ::IsWindow( pWndSearchMon->GetSafeHwnd() ) );
  2515. CExtPaintManager::monitor_parms_t _mp;
  2516. CExtPaintManager::stat_GetMonitorParms( _mp, pWndSearchMon );
  2517. CRect rcDesktop =
  2518. g_bUseDesktopWorkArea
  2519. ? _mp.m_rcWorkArea
  2520. : _mp.m_rcMonitor
  2521. ;
  2522. CExtPaintManager * pPM = PmBridge_GetPM();
  2523. ASSERT_VALID( pPM );
  2524. CRect rcTextMeasure( 0, 0, 0, 0 );
  2525. CFont * pAdvTipFont = &m_fontAdvTip;
  2526. if( pAdvTipFont->GetSafeHandle() == NULL )
  2527. pAdvTipFont = pPM->AdvTip_GetFont( this );
  2528. if( pAdvTipFont->GetSafeHandle() == NULL )
  2529. pAdvTipFont = &(pPM->m_FontNormal);
  2530. CFont * pOldFont = dc.SelectObject( pAdvTipFont );
  2531. if( ! m_sText.IsEmpty() )
  2532. dc.DrawText(
  2533. m_sText,
  2534. m_sText.GetLength(),
  2535. &rcTextMeasure,
  2536. DT_LEFT|DT_CALCRECT
  2537. );
  2538. dc.SelectObject( pOldFont );
  2539. CRect rcWnd = rcTextMeasure;
  2540. e_tip_style_t eTS = GetTipStyle();
  2541. switch( eTS )
  2542. {
  2543. case __ETS_BALLOON:
  2544. case __ETS_BALLOON_NO_ICON:
  2545. {
  2546. rcWnd.InflateRect( m_sizeRounders );
  2547. if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
  2548. {
  2549. rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  2550. if( rcWnd.Height() < m_sizeRenderingIcon.cy )
  2551. rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
  2552. }
  2553. POINT ptLeader[3];
  2554. ptLeader[0].x = rcWnd.Width() - m_sizeRounders.cx;
  2555. ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
  2556. ptLeader[1].x = ptLeader[0].x;
  2557. ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
  2558. ptLeader[2].x = ptLeader[0].x - m_sizeLeader.cx;
  2559. ptLeader[2].y = rcWnd.Height() - m_sizeRounders.cy;
  2560. CRect rcRoundRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
  2561. CRect rcRectRgn( 0, 0, rcWnd.Width(), rcWnd.Height() + m_sizeLeader.cy );
  2562. if( ( m_ptTrack.x - rcWnd.Width() ) < rcDesktop.left )
  2563. {
  2564. m_bFlipHorz = true;
  2565. ptLeader[0].x = m_sizeRounders.cx;
  2566. ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
  2567. ptLeader[1].x = ptLeader[0].x;
  2568. ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
  2569. ptLeader[2].x = ptLeader[0].x + m_sizeLeader.cx;
  2570. ptLeader[2].y = ptLeader[0].y;
  2571. }
  2572. if( ( m_ptTrack.y - rcWnd.Height() - m_sizeRounders.cy * 2 ) < rcDesktop.top )
  2573. {
  2574. m_bFlipVert = true;
  2575. ptLeader[0].y -= rcWnd.Height() - m_sizeRounders.cy * 2;
  2576. ptLeader[1].y = ptLeader[0].y - m_sizeLeader.cy;
  2577. ptLeader[2].y -= ptLeader[0].y;
  2578. }
  2579. CRgn rgnLeader, rgnCaption;
  2580. rgnCaption.CreateRoundRectRgn(
  2581. rcRoundRectRgn.left,
  2582. rcRoundRectRgn.top,
  2583. rcRoundRectRgn.right,
  2584. rcRoundRectRgn.bottom,
  2585. m_sizeRounders.cx,
  2586. m_sizeRounders.cy
  2587. );
  2588. rgnLeader.CreatePolygonRgn(
  2589. ptLeader,
  2590. 3,
  2591. ALTERNATE
  2592. );
  2593. hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
  2594. if( hRegion == NULL )
  2595. {
  2596. ASSERT( FALSE );
  2597. return NULL;
  2598. }
  2599. ::CombineRgn(
  2600. hRegion,
  2601. rgnCaption. operator HRGN (),
  2602. rgnLeader. operator HRGN (),
  2603. RGN_OR
  2604. );
  2605. if( m_bFlipVert )
  2606. ::OffsetRgn(
  2607. hRegion,
  2608. 0,
  2609. m_sizeLeader.cy
  2610. );
  2611. if( pSize != NULL )
  2612. {
  2613. pSize->cx = rcWnd.Width();
  2614. pSize->cy = rcWnd.Height() + m_sizeLeader.cy;
  2615. }
  2616. } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
  2617. break;
  2618. case __ETS_RECTANGLE:
  2619. case __ETS_RECTANGLE_NO_ICON:
  2620. case __ETS_INV_RECTANGLE:
  2621. case __ETS_INV_RECTANGLE_NO_ICON:
  2622. {
  2623. if( eTS != __ETS_RECTANGLE_NO_ICON
  2624. && eTS != __ETS_INV_RECTANGLE_NO_ICON
  2625. && (! m_icon.IsEmpty() ) )
  2626. {
  2627. rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  2628. if( rcWnd.Height() < m_sizeRenderingIcon.cy )
  2629. rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
  2630. }
  2631. rcWnd.InflateRect( m_sizeClassicMargins );
  2632. int nSizeShadow = CalcShadowSize();
  2633. ASSERT( nSizeShadow >= 0 );
  2634. rcWnd.InflateRect( 0, 0, nSizeShadow, nSizeShadow );
  2635. CRect rcRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
  2636. hRegion =  ::CreateRectRgnIndirect( &rcRectRgn );
  2637. if( hRegion != NULL )
  2638. PmBridge_GetPM()->AdvTip_CalcRgn(
  2639. hRegion,
  2640. rcRectRgn,
  2641. m_ctrlShadow.IsAvailable()
  2642. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  2643. && ( ! IsKindOf( RUNTIME_CLASS( CExtPopupKeyTipWnd ) ) )
  2644. #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
  2645. ,
  2646. nSizeShadow,
  2647. this
  2648. );
  2649. if( hRegion == NULL )
  2650. {
  2651. ASSERT( FALSE );
  2652. return NULL;
  2653. }
  2654. if( ( m_ptTrack.x + rcWnd.Width() ) > rcDesktop.right )
  2655. m_bFlipHorz = true;
  2656. if( ( m_ptTrack.y + rcWnd.Height() ) > rcDesktop.bottom )
  2657. m_bFlipVert = true;
  2658. if( pSize != NULL )
  2659. {
  2660. pSize->cx = rcWnd.Width();
  2661. pSize->cy = rcWnd.Height();
  2662. }
  2663. } // rectangle cases
  2664. break;
  2665. default:
  2666. ASSERT( FALSE );
  2667. return NULL;
  2668. } // switch( eTS )
  2669. return hRegion;
  2670. }
  2671. void CExtPopupMenuTipWnd::_EndAnimation()
  2672. {
  2673. //ASSERT_VALID( this );
  2674. if( ( m_eTS == __ETS_RECTANGLE
  2675. || m_eTS == __ETS_RECTANGLE_NO_ICON
  2676. || m_eTS == __ETS_INV_RECTANGLE
  2677. || m_eTS == __ETS_INV_RECTANGLE_NO_ICON
  2678. )
  2679. && m_ctrlShadow.IsAvailable()
  2680. && m_ctrlShadow.GetSafeHwnd() == NULL
  2681. )
  2682. {
  2683. INT nSizeShadow = m_nSizeShadow;
  2684. if( nSizeShadow < 0 )
  2685. nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
  2686. if( nSizeShadow > 0 )
  2687. m_ctrlShadow.Create( m_hWnd, nSizeShadow );
  2688. }
  2689. }
  2690. void CExtPopupMenuTipWnd::_DoPaint(
  2691. CDC & dcPaint,
  2692. bool bUseBackBuffer //= true
  2693. )
  2694. {
  2695. //ASSERT_VALID( this );
  2696. bUseBackBuffer;
  2697. CDC & dc = dcPaint;
  2698. CRect rcLayout;
  2699. GetClientRect( &rcLayout );
  2700. HRGN hRegion = CreateRectRgnIndirect( &rcLayout );
  2701. GetWindowRgn( hRegion );
  2702. CRgn * pRegion = CRgn::FromHandle( hRegion );
  2703. CExtPaintManager * pPM = PmBridge_GetPM();
  2704. ASSERT_VALID( pPM );
  2705. CFont * pAdvTipFont = &m_fontAdvTip;
  2706. if( pAdvTipFont->GetSafeHandle() == NULL )
  2707. pAdvTipFont = pPM->AdvTip_GetFont( this );
  2708. if( pAdvTipFont->GetSafeHandle() == NULL )
  2709. pAdvTipFont = &(pPM->m_FontNormal);
  2710. COLORREF clrAdvTipText = pPM->AdvTip_GetTextColor( this );
  2711. if( clrAdvTipText == COLORREF(-1L) )
  2712. clrAdvTipText = pPM->GetColor( COLOR_INFOTEXT, this );
  2713. e_tip_style_t eTS = GetTipStyle();
  2714. switch( eTS )
  2715. {
  2716. case __ETS_BALLOON:
  2717. case __ETS_BALLOON_NO_ICON:
  2718. {
  2719. CBrush brushWindow;
  2720. brushWindow.CreateSolidBrush(
  2721. //pPM->GetColor( COLOR_INFOBK, this )
  2722. ::GetSysColor( COLOR_INFOBK )
  2723. );
  2724. CBrush brushFrame;
  2725. brushFrame.CreateSolidBrush(
  2726. //pPM->GetColor( COLOR_3DDKSHADOW, this )
  2727. ::GetSysColor( COLOR_3DDKSHADOW )
  2728. );
  2729. CBrush brushInnerFrame;
  2730. brushInnerFrame.CreateSolidBrush(
  2731. //pPM->GetColor( COLOR_3DFACE, this)
  2732. ::GetSysColor( COLOR_3DFACE )
  2733. );
  2734. // frame
  2735. dc.FillRgn( pRegion, &brushWindow );
  2736. dc.FrameRgn( pRegion, &brushInnerFrame, 3, 3 );
  2737. dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
  2738. // adjust icon's area
  2739. rcLayout.DeflateRect( m_sizeRounders.cx, m_sizeRounders.cy, 0, 0 );
  2740. if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
  2741. rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  2742. CFont * pOldFont = dc.SelectObject( pAdvTipFont );
  2743. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  2744. int nIconVertPos = m_sizeRounders.cy;
  2745. if( m_bFlipVert )
  2746. {
  2747. rcLayout.OffsetRect( 0, m_sizeLeader.cy );
  2748. nIconVertPos += m_sizeLeader.cy;
  2749. }
  2750. COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
  2751. dc.DrawText(
  2752. m_sText,
  2753. m_sText.GetLength(),
  2754. &rcLayout,
  2755. DT_TOP|DT_LEFT
  2756. );
  2757. dc.SetBkMode( nOldBkMode );
  2758. dc.SetTextColor( clrOldTextColor );
  2759. dc.SelectObject( pOldFont );
  2760. // icon
  2761. if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
  2762. {
  2763. // ICON 2.53
  2764. //  HICON hIcon = m_icon.GetIcon();
  2765. //  if( hIcon != NULL )
  2766. //  ::DrawIconEx(
  2767. //  dc.GetSafeHdc(),
  2768. //  m_sizeRounders.cx,
  2769. //  nIconVertPos,
  2770. //  hIcon,
  2771. //  m_sizeRenderingIcon.cx,
  2772. //  m_sizeRenderingIcon.cy,
  2773. //  0,
  2774. //  NULL,
  2775. //  DI_NORMAL
  2776. //  );
  2777. m_icon.Paint(
  2778. pPM,
  2779. dc.GetSafeHdc(),
  2780.   m_sizeRounders.cx,
  2781.   nIconVertPos,
  2782.   m_sizeRenderingIcon.cx,
  2783.   m_sizeRenderingIcon.cy
  2784. );
  2785. }
  2786. } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
  2787. break;
  2788. case __ETS_RECTANGLE:
  2789. case __ETS_RECTANGLE_NO_ICON:
  2790. case __ETS_INV_RECTANGLE:
  2791. case __ETS_INV_RECTANGLE_NO_ICON:
  2792. {
  2793. int nSizeShadow = CalcShadowSize();
  2794. ASSERT( nSizeShadow >= 0 );
  2795. if( nSizeShadow > 0 )
  2796. {
  2797. rcLayout.DeflateRect( 0, 0, nSizeShadow, nSizeShadow );
  2798. m_shadow.Paint(
  2799. pPM,
  2800. dc,
  2801. rcLayout,
  2802. CRect( 0, 0, 0, 0 ),
  2803. CRect( 0, 0, 0, 0 ),
  2804. nSizeShadow,
  2805. 70,
  2806. 95
  2807. );
  2808. }
  2809. bool bAdvTipWithShadow =
  2810. ( m_nSizeShadow > 0
  2811. || ( m_ctrlShadow.GetSafeHwnd() != NULL
  2812. && ( m_ctrlShadow.GetStyle() & WS_VISIBLE ) != 0
  2813. )
  2814. ) ? true : false;
  2815. if( ! pPM->AdvTip_PaintBackground(
  2816. dc,
  2817. rcLayout,
  2818. bAdvTipWithShadow,
  2819. this
  2820. )
  2821. )
  2822. {
  2823. // frame
  2824. //dc.FillRgn( pRegion, &brushWindow );
  2825. //dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
  2826. dc.FillSolidRect(
  2827. &rcLayout,
  2828. ::GetSysColor( COLOR_INFOBK )
  2829. );
  2830. dc.Draw3dRect(
  2831. &rcLayout,
  2832. pPM->GetColor( COLOR_3DDKSHADOW, this ),
  2833. pPM->GetColor( COLOR_3DDKSHADOW, this )
  2834. );
  2835. }
  2836. // adjust icon's area
  2837. rcLayout.DeflateRect( m_sizeClassicMargins );
  2838. if( eTS != __ETS_RECTANGLE_NO_ICON
  2839. && eTS != __ETS_INV_RECTANGLE_NO_ICON
  2840. && (! m_icon.IsEmpty() )
  2841. )
  2842. rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  2843. CFont * pOldFont = dc.SelectObject( pAdvTipFont );
  2844. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  2845. COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
  2846. dc.DrawText(
  2847. m_sText,
  2848. m_sText.GetLength(),
  2849. &rcLayout,
  2850. DT_TOP|DT_LEFT|DT_VCENTER
  2851. );
  2852. dc.SetBkMode( nOldBkMode );
  2853. dc.SetTextColor( clrOldTextColor );
  2854. dc.SelectObject( pOldFont );
  2855. // icon
  2856. if( eTS != __ETS_RECTANGLE_NO_ICON
  2857. && eTS != __ETS_INV_RECTANGLE_NO_ICON
  2858. && (! m_icon.IsEmpty() )
  2859. )
  2860. {
  2861. int nIconHorzPos =
  2862. rcLayout.left
  2863. - m_sizeRenderingIcon.cx
  2864. - m_nIconMarginDX
  2865. ;
  2866. int nIconVertPos =
  2867. rcLayout.top
  2868. + ( rcLayout.Height() - m_sizeRenderingIcon.cy ) / 2
  2869. ;
  2870. // ICON 2.53
  2871. //  HICON hIcon = m_icon.GetIcon();
  2872. //  if( hIcon != NULL )
  2873. //  ::DrawIconEx(
  2874. //  dc.GetSafeHdc(),
  2875. //  nIconHorzPos,
  2876. //  nIconVertPos,
  2877. //  hIcon,
  2878. //  m_sizeRenderingIcon.cx,
  2879. //  m_sizeRenderingIcon.cy,
  2880. //  0,
  2881. //  NULL,
  2882. //  DI_NORMAL
  2883. //  );
  2884. m_icon.Paint(
  2885. pPM,
  2886. dc.GetSafeHdc(),
  2887. nIconHorzPos,
  2888. nIconVertPos,
  2889. m_sizeRenderingIcon.cx,
  2890. m_sizeRenderingIcon.cy
  2891. );
  2892. }
  2893. } // rectangle cases
  2894. break;
  2895. #ifdef _DEBUG
  2896. default:
  2897. ASSERT( FALSE );
  2898. break;
  2899. #endif // _DEBUG
  2900. } // switch( eTS )
  2901. ::DeleteObject( hRegion );
  2902. }
  2903. __EXT_MFC_SAFE_LPCTSTR CExtPopupMenuTipWnd::GetText() const
  2904. {
  2905. return LPCTSTR(m_sText);
  2906. }
  2907. void CExtPopupMenuTipWnd::SetText(
  2908. __EXT_MFC_SAFE_LPCTSTR lpszText
  2909. )
  2910. {
  2911. //ASSERT_VALID( this );
  2912. m_sText = ( lpszText == NULL ) ? _T("") : lpszText;
  2913. m_sText.TrimLeft();
  2914. m_sText.TrimRight();
  2915. }
  2916. void CExtPopupMenuTipWnd::SetIcon(
  2917. HICON hIcon,
  2918. bool bCloneIcon // = false
  2919. {
  2920. //ASSERT_VALID( this );
  2921. if( ! m_icon.IsEmpty() )
  2922. m_icon.Empty();
  2923. if( hIcon == NULL )
  2924. return;
  2925. m_icon.AssignFromHICON( hIcon, bCloneIcon );
  2926. m_sizeRenderingIcon = m_icon.GetSize();
  2927. if( m_hWnd != NULL && ::IsWindow( m_hWnd ) )
  2928. RedrawWindow();
  2929. }
  2930. void CExtPopupMenuTipWnd::SetIcon(
  2931. CExtCmdIcon & _icon
  2932. )
  2933. {
  2934. //ASSERT_VALID( this );
  2935. m_icon = _icon;
  2936. m_sizeRenderingIcon = m_icon.GetSize();
  2937. if( m_hWnd != NULL && ::IsWindow( m_hWnd ) )
  2938. RedrawWindow();
  2939. }
  2940. CExtPopupMenuTipWnd::e_tip_style_t CExtPopupMenuTipWnd::GetTipStyle() const
  2941. {
  2942. //ASSERT_VALID( this );
  2943. return m_eTS;
  2944. }
  2945. void CExtPopupMenuTipWnd::SetTipStyle( CExtPopupMenuTipWnd::e_tip_style_t eTS )
  2946. {
  2947. //ASSERT_VALID( this );
  2948. m_eTS = eTS;
  2949. }
  2950. int CExtPopupMenuTipWnd::GetShadowSize() const
  2951. {
  2952. //ASSERT_VALID( this );
  2953. return m_nSizeShadow;
  2954. }
  2955. void CExtPopupMenuTipWnd::SetShadowSize( int nSizeShadow )
  2956. {
  2957. //ASSERT_VALID( this );
  2958. if( m_nSizeShadow == nSizeShadow )
  2959. return;
  2960. m_shadow.Destroy();
  2961. m_nSizeShadow = nSizeShadow;
  2962. }
  2963. int CExtPopupMenuTipWnd::CalcShadowSize() const
  2964. {
  2965. //ASSERT_VALID( this );
  2966. if( m_ctrlShadow.IsAvailable() )
  2967. return 0;
  2968. if( m_nSizeShadow >= 0 )
  2969. return m_nSizeShadow;
  2970. int nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
  2971. if( nSizeShadow < 0 )
  2972. return 0;
  2973. return nSizeShadow;
  2974. }
  2975. CTypedPtrList < CPtrList, CExtPopupMenuTipWnd * > CExtPopupMenuTipWnd::g_listAllTips;
  2976. void CExtPopupMenuTipWnd::UpdateDelayedLayeredBehaviorAll(
  2977. CRuntimeClass * pRTC // = NULL
  2978. )
  2979. {
  2980. POSITION pos = g_listAllTips.GetHeadPosition();
  2981. for( ; pos != NULL; )
  2982. {
  2983. CExtPopupMenuTipWnd * pWndPopupMenuTip = g_listAllTips.GetNext( pos );
  2984. ASSERT_VALID( pWndPopupMenuTip );
  2985. if( pRTC != NULL )
  2986. {
  2987. if( ! pWndPopupMenuTip->IsKindOf( pRTC ) )
  2988. continue;
  2989. }
  2990. pWndPopupMenuTip->UpdateDelayedLayeredBehavior();
  2991. }
  2992. }
  2993. void CExtPopupMenuTipWnd::UpdateDelayedLayeredBehavior()
  2994. {
  2995. __PROF_UIS_MANAGE_STATE;
  2996. //ASSERT_VALID( this );
  2997. if( ( ! m_bDelayedLayeredBehavior )
  2998. || ( ! g_PaintManager.m_bIsWin2000orLater )
  2999. || GetSafeHwnd() == NULL
  3000. )
  3001. return;
  3002. ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
  3003. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
  3004. }
  3005. bool CExtPopupMenuTipWnd::Show(
  3006. CWnd * pWndParent,
  3007. const RECT & rcExcludeArea,
  3008. bool bNoDelay,
  3009. HDWP & hPassiveModeDWP
  3010. )
  3011. {
  3012. __PROF_UIS_MANAGE_STATE;
  3013. //ASSERT_VALID( this );
  3014. ASSERT_VALID( pWndParent );
  3015. ASSERT( pWndParent->GetSafeHwnd() != NULL );
  3016. if( ! g_bEnableAdvTips )
  3017. {
  3018. Hide();
  3019. return true;
  3020. }
  3021. e_tip_style_t eTS = GetTipStyle();
  3022. if( eTS == __ETS_NONE )
  3023. {
  3024. Hide();
  3025. return true;
  3026. }
  3027. bool bQuickDelay = false;
  3028. if( GetSafeHwnd() != NULL )
  3029. {
  3030. if( m_rcExcludeArea == rcExcludeArea )
  3031. return true;
  3032. if( ( ! bNoDelay )
  3033. && (GetStyle()&WS_VISIBLE) != 0
  3034. )
  3035. bQuickDelay = true;
  3036. Hide();
  3037. if( ( ! bNoDelay ) && ( ! bQuickDelay ) )
  3038. {
  3039. long ttLA = (long)::time( NULL );
  3040. long ttDist = ttLA - m_ttLA;
  3041. if( ttDist <= 1 )
  3042. {
  3043. bQuickDelay = true;
  3044. m_ttLA = ttLA;
  3045. } // if( ttDist <= 1 )
  3046. } // if( ( ! bNoDelay ) && ( ! bQuickDelay ) )
  3047. } // if( GetSafeHwnd() != NULL )
  3048. HCURSOR hCursor = ::LoadCursor( NULL, IDC_ARROW );
  3049. ASSERT( hCursor != NULL );
  3050. if( GetSafeHwnd() != NULL
  3051. && GetParent() != pWndParent
  3052. )
  3053. {
  3054. Hide();
  3055. DestroyWindow();
  3056. }
  3057. if( GetSafeHwnd() == NULL )
  3058. {
  3059. CExtSafeString strClassName = ::AfxRegisterWndClass ( __TIP_WNDCLASS_STYLES__, hCursor, NULL, NULL );
  3060. bool bLayered = false, bForceLayered = false;
  3061. if( m_bPassiveMode
  3062. && ( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
  3063. || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
  3064. )
  3065. )
  3066. bLayered = true;
  3067. if( (! bLayered)
  3068. && g_PaintManager.m_bIsWin2000orLater
  3069. && g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL
  3070. && ( m_AnimationType == __AT_NONE || m_AnimationType == __AT_CONTENT_DISPLAY )
  3071. )
  3072. bForceLayered = true;
  3073. BOOL bCreateResult =
  3074. CWnd::CreateEx(
  3075. WS_EX_TOPMOST // | WS_EX_TRANSPARENT
  3076. | ( g_PaintManager.m_bIsWin2000orLater ? (WS_EX_NOINHERITLAYOUT) : 0 )
  3077. | ( ( bLayered || bForceLayered ) ? (__EXT_MFC_WS_EX_LAYERED) : 0 )
  3078. ,
  3079. strClassName,
  3080. NULL,
  3081. WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
  3082. 0, 0, 0, 0,
  3083. pWndParent->GetSafeHwnd(),
  3084. NULL,
  3085. NULL
  3086. );
  3087. ASSERT( bCreateResult );
  3088. if( ! bCreateResult )
  3089. return false;
  3090. if( bForceLayered && (!bLayered) )
  3091. {
  3092. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
  3093. ShowWindow( SW_SHOWNOACTIVATE );
  3094. Invalidate( FALSE );
  3095. UpdateWindow();
  3096. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 255, __EXT_MFC_LWA_ALPHA );
  3097. }
  3098. if( m_bPassiveMode
  3099. && ( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
  3100. || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
  3101. )
  3102. )
  3103. {
  3104. ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
  3105. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 0, __EXT_MFC_LWA_ALPHA );
  3106. }
  3107. } // if( GetSafeHwnd() == NULL )
  3108. #ifdef _DEBUG
  3109. else
  3110. {
  3111. ASSERT_VALID( pWndParent );
  3112. ASSERT( ::IsWindow( pWndParent->GetSafeHwnd() ) );
  3113. } // else from if( GetSafeHwnd() == NULL )
  3114. #endif // _DEBUG
  3115. m_rcExcludeArea = rcExcludeArea;
  3116. m_rcExcludeArea.NormalizeRect();
  3117. CExtPaintManager::monitor_parms_t _mp;
  3118. CExtPaintManager::stat_GetMonitorParms( _mp, m_rcExcludeArea.CenterPoint() );
  3119. CRect rcDesktop =
  3120. g_bUseDesktopWorkArea
  3121. ? _mp.m_rcWorkArea
  3122. : _mp.m_rcMonitor
  3123. ;
  3124. CPoint ptTipTarget( m_rcExcludeArea.TopLeft() );
  3125. CPoint ptWndPos( 0, 0 );
  3126. CSize _sizeWindow( 0, 0 );
  3127. bool bIR = true;
  3128. switch( eTS )
  3129. {
  3130. case __ETS_BALLOON:
  3131. case __ETS_BALLOON_NO_ICON:
  3132. {
  3133. ptTipTarget +=
  3134. CSize( m_nBalloonDistance/2, m_nBalloonDistance/2 );
  3135. m_ptTrack = m_ptTrackOriginal = ptTipTarget;
  3136. CDC * pDC = GetDC();
  3137. ASSERT_VALID( pDC );
  3138. HRGN hRegion = CalcRegion( *pDC, &_sizeWindow );
  3139. ASSERT( hRegion != NULL );
  3140. ReleaseDC(pDC);
  3141. VERIFY(
  3142. ::SetWindowRgn(
  3143. m_hWnd,
  3144. hRegion,
  3145. TRUE
  3146. )
  3147. );
  3148. if( m_bFlipHorz )
  3149. m_ptTrack.x +=
  3150. m_rcExcludeArea.Width() - m_nBalloonDistance
  3151. + _sizeWindow.cx - m_sizeRounders.cx * 2
  3152. ;
  3153. if( m_bFlipVert )
  3154. m_ptTrack.y += 
  3155. m_rcExcludeArea.Height() - m_nBalloonDistance
  3156. + _sizeWindow.cy - m_sizeRounders.cx * 2
  3157. ;
  3158. ptWndPos.x = m_ptTrack.x - _sizeWindow.cx + m_sizeRounders.cx;
  3159. ptWndPos.y = m_ptTrack.y - _sizeWindow.cy + m_sizeRounders.cy;
  3160. SetWindowPos(
  3161. &CWnd::wndTopMost,
  3162. ptWndPos.x,
  3163. ptWndPos.y,
  3164. _sizeWindow.cx,
  3165. _sizeWindow.cy,
  3166. SWP_HIDEWINDOW|SWP_NOSENDCHANGING
  3167. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3168. |SWP_NOACTIVATE //|SWP_NOCOPYBITS
  3169. );
  3170. } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
  3171. break;
  3172. case __ETS_RECTANGLE:
  3173. case __ETS_RECTANGLE_NO_ICON:
  3174. bIR = false; // continue cases
  3175. case __ETS_INV_RECTANGLE:
  3176. case __ETS_INV_RECTANGLE_NO_ICON:
  3177. {
  3178. CDC * pDC = GetDC();
  3179. ASSERT_VALID( pDC );
  3180. HRGN hRegion = CalcRegion( *pDC, &_sizeWindow );
  3181. ASSERT( hRegion != NULL );
  3182. ReleaseDC(pDC);
  3183. ptTipTarget.x = m_rcExcludeArea.CenterPoint().x;
  3184. if( m_bFlipHorz )
  3185. ptTipTarget.x -=
  3186. m_rcExcludeArea.Width()
  3187. + _sizeWindow.cx
  3188. ;
  3189. if( bIR )
  3190. ptTipTarget.y =
  3191. m_rcExcludeArea.top
  3192. - _sizeWindow.cy
  3193. - 3
  3194. ;
  3195. else
  3196. {
  3197. bool bResetY = true;
  3198. POINT ptCursor = { 0, 0 };
  3199. if( ::GetCursorPos( &ptCursor )
  3200. && m_rcExcludeArea.PtInRect(ptCursor)
  3201. )
  3202. {
  3203. CExtCmdIcon _icon;
  3204. _icon.AssignFromHICON( (HICON)hCursor, false, true );
  3205. if( ! _icon.IsEmpty() )
  3206. {
  3207. ptTipTarget.x = ptCursor.x;
  3208. if( m_bFlipHorz )
  3209. ptTipTarget.x -=
  3210. _sizeWindow.cx
  3211. ;
  3212. CSize _sizeIcon = _icon.GetSize();
  3213. if( ! g_PaintManager.m_bIsWinXPorLater )
  3214. {
  3215. if( _sizeIcon.cx > 16 )
  3216. _sizeIcon.cx = 16;
  3217. if( _sizeIcon.cy > 16 )
  3218. _sizeIcon.cy = 16;
  3219. }
  3220. ptTipTarget.y =
  3221. ptCursor.y
  3222. + _sizeIcon.cy
  3223. ;
  3224. if( ptTipTarget.y < m_rcExcludeArea.bottom )
  3225. ptTipTarget.y = m_rcExcludeArea.bottom;
  3226. bResetY = false;
  3227. }
  3228. }
  3229. if( bResetY )
  3230. ptTipTarget.y =
  3231. m_rcExcludeArea.bottom
  3232. + m_nClassicDistance
  3233. ;
  3234. }
  3235. m_ptTrack = m_ptTrackOriginal = ptTipTarget;
  3236. VERIFY(
  3237. ::SetWindowRgn(
  3238. m_hWnd,
  3239. hRegion,
  3240. TRUE
  3241. )
  3242. );
  3243. if( m_bFlipVert )
  3244. {
  3245. if( bIR )
  3246. m_ptTrack.y =
  3247. m_rcExcludeArea.bottom
  3248. + m_nClassicDistance
  3249. ;
  3250. else
  3251. m_ptTrack.y =
  3252. m_rcExcludeArea.top
  3253. - m_nClassicDistance
  3254. ;
  3255. }
  3256. if( (m_ptTrack.x + _sizeWindow.cx) > rcDesktop.right )
  3257. m_ptTrack.x = rcDesktop.right - _sizeWindow.cx;
  3258. if( m_ptTrack.x < rcDesktop.left )
  3259. m_ptTrack.x = rcDesktop.left;
  3260. if( (m_ptTrack.y + _sizeWindow.cy) > rcDesktop.bottom )
  3261. m_ptTrack.y = rcDesktop.bottom - _sizeWindow.cy;
  3262. if( m_ptTrack.y < rcDesktop.top )
  3263. m_ptTrack.y = rcDesktop.top;
  3264. ptWndPos = m_ptTrack;
  3265. SetWindowPos(
  3266. &CWnd::wndTopMost,
  3267. ptWndPos.x,
  3268. ptWndPos.y,
  3269. _sizeWindow.cx,
  3270. _sizeWindow.cy,
  3271. SWP_HIDEWINDOW|SWP_NOSENDCHANGING
  3272. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3273. |SWP_NOACTIVATE //|SWP_NOCOPYBITS
  3274. );
  3275. } // rectangle cases
  3276. break;
  3277. default:
  3278. ASSERT( FALSE );
  3279. return NULL;
  3280. } // switch( eTS )
  3281. if( hCursor != NULL )
  3282. ::DestroyCursor( hCursor );
  3283. if( m_ptGuideLines.x != -32767 && m_ptGuideLines.y != -32767 )
  3284. {
  3285. CRect rcWnd(
  3286. CPoint(
  3287. m_ptGuideLines.x - _sizeWindow.cx / 2,
  3288. m_ptGuideLines.y - _sizeWindow.cy / 2
  3289. ),
  3290. _sizeWindow
  3291. );
  3292. MoveWindow( &rcWnd );
  3293. }
  3294. else
  3295. {
  3296. CRect rcWnd( ptWndPos, _sizeWindow );
  3297. if( ! m_rcAlignment.IsRectEmpty() )
  3298. {
  3299. rcWnd.OffsetRect(
  3300. m_rcAlignment.left - rcWnd.left,
  3301. m_rcAlignment.bottom - rcWnd.top
  3302. );
  3303. m_rcAlignment.SetRect( 0, 0, 0, 0 );
  3304. }
  3305. CExtPaintManager::monitor_parms_t _mp;
  3306. CExtPaintManager::stat_GetMonitorParms( _mp, m_rcExcludeArea );
  3307. CRect rcDesktop = g_bUseDesktopWorkArea
  3308. ? _mp.m_rcWorkArea
  3309. : _mp.m_rcMonitor
  3310. ;
  3311. if( rcWnd.right > rcDesktop.right )
  3312. rcWnd.OffsetRect(
  3313. - ( rcWnd.right - rcDesktop.right ),
  3314. 0
  3315. );
  3316. if( rcWnd.left < rcDesktop.left )
  3317. rcWnd.OffsetRect( rcDesktop.left - rcWnd.left, 0 );
  3318. if( rcWnd.bottom > rcDesktop.bottom )
  3319. rcWnd.OffsetRect(
  3320. 0,
  3321. - ( rcWnd.bottom - rcDesktop.bottom )
  3322. );
  3323. if( rcWnd.top < rcDesktop.top )
  3324. rcWnd.OffsetRect( 0, rcDesktop.top - rcWnd.top );
  3325. MoveWindow( &rcWnd );
  3326. }
  3327. if( ! m_bPassiveMode )
  3328. {
  3329. if( bNoDelay )
  3330. SendMessage( WM_TIMER, ID_TIMER_DELAY_SHOW );
  3331. else
  3332. SetTimer( ID_TIMER_DELAY_SHOW, bQuickDelay ? m_nPeriodDelayShowQuick : m_nPeriodDelayShowNormal, NULL );
  3333. SetTimer( ID_TIMER_DELAY_KILL, ID_PERIOD_DELAY_KILL, NULL );
  3334. SetTimer( ID_TIMER_LIFE_STEP, ID_PERIOD_LIFE_STEP, NULL );
  3335. } // if( ! m_bPassiveMode )
  3336. else
  3337. {
  3338. EnableWindow( FALSE );
  3339. if( ( g_PaintManager.m_bIsWin2000orLater && ( m_nTransparencyKey != BYTE(0x0FF) || m_bDelayedLayeredBehavior ) )
  3340. || ( g_PaintManager.m_bIsWinVistaOrLater && g_PaintManager.m_DWM.IsCompositionEnabled() )
  3341. )
  3342. {
  3343. ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
  3344. if( hPassiveModeDWP != NULL && g_PaintManager.m_bIsWinVistaOrLater )
  3345. {
  3346. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
  3347. hPassiveModeDWP =
  3348. ::DeferWindowPos(
  3349. hPassiveModeDWP, m_hWnd, NULL, 0, 0, 0, 0,
  3350. SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE
  3351. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3352. //|SWP_NOREDRAW
  3353. |SWP_SHOWWINDOW
  3354. );
  3355. } // if( hPassiveModeDWP != NULL && g_PaintManager.m_bIsWinVistaOrLater )
  3356. if( hPassiveModeDWP == NULL
  3357. || m_bDelayedLayeredBehavior
  3358. || ( ! g_PaintManager.m_bIsWinVistaOrLater )
  3359. )
  3360. {
  3361. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, 1, __EXT_MFC_LWA_ALPHA );
  3362. ShowWindow( SW_SHOWNOACTIVATE );
  3363. if( ! m_bDelayedLayeredBehavior )
  3364. {
  3365. Invalidate( FALSE );
  3366. UpdateWindow();
  3367. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd, 0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
  3368. }
  3369. } // if( hPassiveModeDWP == NULL || ...
  3370. }
  3371. //ModifyStyleEx( 0, WS_EX_TRANSPARENT );
  3372. } // else from if( ! m_bPassiveMode )
  3373. m_hWndLastParent = pWndParent->GetSafeHwnd();
  3374. return true;
  3375. }
  3376. void CExtPopupMenuTipWnd::Hide()
  3377. {
  3378. //ASSERT_VALID( this );
  3379. if( GetSafeHwnd() != NULL )
  3380. {
  3381. KillTimer( ID_TIMER_DELAY_SHOW );
  3382. KillTimer( ID_TIMER_DELAY_KILL );
  3383. KillTimer( ID_TIMER_LIFE_STEP );
  3384. KillTimer( ID_TIMER_ANIMATION );
  3385. SetWindowPos(
  3386. NULL, 0, 0, 0, 0,
  3387. SWP_HIDEWINDOW|SWP_NOSENDCHANGING
  3388. |SWP_NOSIZE|SWP_NOMOVE
  3389. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3390. |SWP_NOACTIVATE //|SWP_NOCOPYBITS
  3391. );
  3392. // CWnd * pWnd = GetParent();
  3393. // CExtPopupMenuWnd * pPopup =
  3394. // DYNAMIC_DOWNCAST(
  3395. // CExtPopupMenuWnd,
  3396. // pWnd
  3397. // );
  3398. // for( ; pPopup != NULL; pPopup = pPopup->GetParentMenuWnd() )
  3399. // pPopup->_DelayPaint();
  3400. }
  3401. m_hWndLastParent = NULL;
  3402. m_rcExcludeArea.SetRectEmpty();
  3403. m_shadow.Destroy();
  3404. if( m_ctrlShadow.GetSafeHwnd() != NULL )
  3405. m_ctrlShadow.DestroyWindow();
  3406. }
  3407. void CExtPopupMenuTipWnd::OnTimer( __EXT_MFC_UINT_PTR nIDEvent ) 
  3408. {
  3409. //ASSERT_VALID( this );
  3410. switch( nIDEvent )
  3411. {
  3412. case ID_TIMER_LIFE_STEP:
  3413. if( CExtPopupMenuWnd::IsKeyPressed(VK_LBUTTON)
  3414. || CExtPopupMenuWnd::IsKeyPressed(VK_MBUTTON)
  3415. || CExtPopupMenuWnd::IsKeyPressed(VK_RBUTTON)
  3416. )
  3417. {
  3418. HWND hWndCapture = ::GetCapture();
  3419. if( hWndCapture != NULL && ::IsWindow( hWndCapture ) )
  3420. {
  3421. CWnd * pWndCapture = CWnd::FromHandlePermanent( hWndCapture );
  3422. if( pWndCapture != NULL
  3423. && pWndCapture->IsKindOf( RUNTIME_CLASS(CExtScrollBar) )
  3424. && ((CExtScrollBar*)pWndCapture)->m_bCompleteRepaint
  3425. )
  3426. return;
  3427. }
  3428. Hide();
  3429. }
  3430. else if(
  3431. CExtPopupMenuWnd::IsKeyPressed(VK_MENU)
  3432. || CExtControlBar::_DraggingGetBar() != NULL
  3433. )
  3434. Hide();
  3435. else if( CExtPopupMenuWnd::IsMenuTracking() )
  3436. {
  3437. CWnd * pWndParent = GetParent();
  3438. if( pWndParent == NULL
  3439. || (! pWndParent->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
  3440. )
  3441. Hide();
  3442. }
  3443. return;
  3444. case ID_TIMER_DELAY_SHOW:
  3445. KillTimer( ID_TIMER_DELAY_SHOW );
  3446. if( m_AnimationType != __AT_NONE )
  3447. {
  3448. SetWindowPos(
  3449. NULL, 0, 0, 0, 0,
  3450. SWP_SHOWWINDOW|SWP_NOSENDCHANGING|SWP_NOREDRAW
  3451. |SWP_NOSIZE|SWP_NOMOVE
  3452. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3453. |SWP_NOACTIVATE //|SWP_NOCOPYBITS
  3454. );
  3455. // if( g_DefAnimationType != CExtPopupMenuWnd::__AT_NONE )
  3456. _StartAnimation();
  3457. return;
  3458. }
  3459. if( g_PaintManager.m_bIsWin2000orLater && m_nTransparencyKey != BYTE(0x0FF) )
  3460. {
  3461. ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
  3462. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd,  0, 1, __EXT_MFC_LWA_ALPHA );
  3463. }
  3464. SetWindowPos(
  3465. NULL, 0, 0, 0, 0,
  3466. SWP_SHOWWINDOW|SWP_NOSENDCHANGING
  3467. |SWP_NOSIZE|SWP_NOMOVE
  3468. |SWP_NOZORDER|SWP_NOOWNERZORDER
  3469. |SWP_NOACTIVATE //|SWP_NOCOPYBITS
  3470. );
  3471. Invalidate( FALSE );
  3472. UpdateWindow();
  3473. if( g_PaintManager.m_bIsWin2000orLater && m_nTransparencyKey != BYTE(0x0FF) )
  3474. {
  3475. ASSERT( g_PaintManager.m_pfnSetLayeredWindowAttributes != NULL );
  3476. g_PaintManager.m_pfnSetLayeredWindowAttributes( m_hWnd,  0, m_nTransparencyKey, __EXT_MFC_LWA_ALPHA );
  3477. Invalidate( FALSE );
  3478. UpdateWindow();
  3479. }
  3480. if( ( m_eTS == __ETS_RECTANGLE
  3481. || m_eTS == __ETS_RECTANGLE_NO_ICON
  3482. || m_eTS == __ETS_INV_RECTANGLE
  3483. || m_eTS == __ETS_INV_RECTANGLE_NO_ICON
  3484. )
  3485. && m_ctrlShadow.IsAvailable()
  3486. )
  3487. {
  3488. INT nSizeShadow = m_nSizeShadow;
  3489. if( nSizeShadow < 0 )
  3490. nSizeShadow = PmBridge_GetPM()->GetTipShadowSize();
  3491. if( nSizeShadow > 0 )
  3492. m_ctrlShadow.Create( m_hWnd, nSizeShadow );
  3493. }
  3494. return;
  3495. case ID_TIMER_DELAY_KILL:
  3496. if( m_bNoHideDetection )
  3497. return;
  3498. POINT ptCursor = { 0, 0 };
  3499. if( ::GetCursorPos( &ptCursor )
  3500. && m_rcExcludeArea.PtInRect(ptCursor)
  3501. )
  3502. return;
  3503. Hide();
  3504. return;
  3505. } // switch( nIDEvent )
  3506. CExtPopupBaseWnd::OnTimer( nIDEvent );
  3507. }
  3508. #if _MFC_VER < 0x700
  3509. void CExtPopupMenuTipWnd::OnActivateApp(BOOL bActive, HTASK hTask) 
  3510. #else
  3511. void CExtPopupMenuTipWnd::OnActivateApp(BOOL bActive, DWORD hTask) 
  3512. #endif
  3513. {
  3514. //ASSERT_VALID( this );
  3515. bActive;
  3516. hTask;
  3517. Hide();
  3518. }
  3519. #if (!defined __EXT_MFC_NO_CUSTOMIZE)
  3520. /////////////////////////////////////////////////////////////////////////////
  3521. // CExtPopupKeyTipWnd
  3522. IMPLEMENT_DYNCREATE( CExtPopupKeyTipWnd, CExtPopupMenuTipWnd );
  3523. CExtPopupKeyTipWnd::CExtPopupKeyTipWnd()
  3524. {
  3525. m_bPassiveMode = true;
  3526. SetShadowSize( 0 );
  3527. SetTipStyle( __ETS_RECTANGLE_NO_ICON );
  3528. }
  3529. CExtPopupKeyTipWnd::~CExtPopupKeyTipWnd()
  3530. {
  3531. }
  3532. BEGIN_MESSAGE_MAP(CExtPopupKeyTipWnd,CExtPopupMenuTipWnd)
  3533.     //{{AFX_MSG_MAP(CExtPopupKeyTipWnd)
  3534. //}}AFX_MSG_MAP
  3535. END_MESSAGE_MAP()
  3536. bool CExtPopupKeyTipWnd::Create(
  3537. CWnd * pWndKeyTipParent,
  3538. CPoint ptGuideLines,
  3539. __EXT_MFC_SAFE_LPCTSTR strKeyTipText,
  3540. bool bEnabled,
  3541. HDWP & hPassiveModeDWP
  3542. )
  3543. {
  3544. ASSERT_VALID( this );
  3545. ASSERT( strKeyTipText != NULL && _tcslen( strKeyTipText ) > 0 );
  3546. ASSERT_VALID( pWndKeyTipParent );
  3547. ASSERT( pWndKeyTipParent->GetSafeHwnd() != NULL );
  3548. SetText( strKeyTipText );
  3549. m_ptGuideLines = ptGuideLines;
  3550. CRect rcKeyTipExcludeArea( ptGuideLines, ptGuideLines );
  3551. rcKeyTipExcludeArea.InflateRect( 1, 1 );
  3552. m_nTransparencyKey = BYTE(0x0FF);
  3553. m_bDelayedLayeredBehavior = true;
  3554. if( ( ! bEnabled ) && g_PaintManager.m_bIsWin2000orLater )
  3555. m_nTransparencyKey = BYTE(0x080);
  3556. if( ! Show( pWndKeyTipParent, rcKeyTipExcludeArea, true, hPassiveModeDWP ) )
  3557. {
  3558. return false;
  3559. }
  3560. return true;
  3561. }
  3562. /////////////////////////////////////////////////////////////////////////////
  3563. // CExtPopupScreenTipWnd
  3564. IMPLEMENT_DYNCREATE( CExtPopupScreenTipWnd, CExtPopupMenuTipWnd );
  3565. CExtPopupScreenTipWnd::CExtPopupScreenTipWnd()
  3566. {
  3567. m_AnimationType = g_PaintManager.m_bIsWin2000orLater ? __AT_NONE : __AT_FADE;
  3568. m_nPeriodDelayShowQuick = ID_PERIOD_DELAY_SHOW_NORMAL;
  3569. m_nPeriodDelayShowNormal = ID_PERIOD_DELAY_SHOW_RIBBON;
  3570. m_sizeClassicMargins.cx = m_sizeClassicMargins.cy = 0;
  3571. SetTipStyle( __ETS_RECTANGLE_NO_ICON );
  3572. }
  3573. CExtPopupScreenTipWnd::~CExtPopupScreenTipWnd()
  3574. {
  3575. }
  3576. BEGIN_MESSAGE_MAP(CExtPopupScreenTipWnd,CExtPopupMenuTipWnd)
  3577.     //{{AFX_MSG_MAP(CExtPopupScreenTipWnd)
  3578. //}}AFX_MSG_MAP
  3579. END_MESSAGE_MAP()
  3580. HRGN CExtPopupScreenTipWnd::CalcRegion(
  3581. CDC & dc,
  3582. CSize * pSize // = NULL
  3583. )
  3584. {
  3585. __PROF_UIS_MANAGE_STATE;
  3586. // ASSERT_VALID( this );
  3587. if( m_cmdScreenTip.IsEmpty() )
  3588. return CExtPopupMenuTipWnd::CalcRegion( dc, pSize );
  3589. HRGN hRegion = NULL;
  3590. m_bFlipHorz = false;
  3591. m_bFlipVert = false;
  3592. CWnd * pWndSearchMon = GetParent();
  3593. ASSERT_VALID( pWndSearchMon );
  3594. ASSERT( pWndSearchMon->GetSafeHwnd() != NULL );
  3595. ASSERT( ::IsWindow( pWndSearchMon->GetSafeHwnd() ) );
  3596. CExtPaintManager::monitor_parms_t _mp;
  3597. CExtPaintManager::stat_GetMonitorParms( _mp, pWndSearchMon );
  3598. CRect rcDesktop =
  3599. g_bUseDesktopWorkArea
  3600. ? _mp.m_rcWorkArea
  3601. : _mp.m_rcMonitor
  3602. ;
  3603. CExtPaintManager * pPM = PmBridge_GetPM();
  3604. ASSERT_VALID( pPM );
  3605. CRect rcWnd( CPoint(0,0), pPM->ScreenTip_Measure( dc, m_cmdScreenTip, this ) );
  3606. e_tip_style_t eTS = GetTipStyle();
  3607. switch( eTS )
  3608. {
  3609. case __ETS_BALLOON:
  3610. case __ETS_BALLOON_NO_ICON:
  3611. {
  3612. rcWnd.InflateRect( m_sizeRounders );
  3613. if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
  3614. {
  3615. rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  3616. if( rcWnd.Height() < m_sizeRenderingIcon.cy )
  3617. rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
  3618. }
  3619. POINT ptLeader[3];
  3620. ptLeader[0].x = rcWnd.Width() - m_sizeRounders.cx;
  3621. ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
  3622. ptLeader[1].x = ptLeader[0].x;
  3623. ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
  3624. ptLeader[2].x = ptLeader[0].x - m_sizeLeader.cx;
  3625. ptLeader[2].y = rcWnd.Height() - m_sizeRounders.cy;
  3626. CRect rcRoundRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
  3627. CRect rcRectRgn( 0, 0, rcWnd.Width(), rcWnd.Height() + m_sizeLeader.cy );
  3628. if( ( m_ptTrack.x - rcWnd.Width() ) < rcDesktop.left )
  3629. {
  3630. m_bFlipHorz = true;
  3631. ptLeader[0].x = m_sizeRounders.cx;
  3632. ptLeader[0].y = rcWnd.Height() - m_sizeRounders.cy;
  3633. ptLeader[1].x = ptLeader[0].x;
  3634. ptLeader[1].y = ptLeader[0].y + m_sizeLeader.cy;
  3635. ptLeader[2].x = ptLeader[0].x + m_sizeLeader.cx;
  3636. ptLeader[2].y = ptLeader[0].y;
  3637. }
  3638. if( ( m_ptTrack.y - rcWnd.Height() - m_sizeRounders.cy * 2 ) < rcDesktop.top )
  3639. {
  3640. m_bFlipVert = true;
  3641. ptLeader[0].y -= rcWnd.Height() - m_sizeRounders.cy * 2;
  3642. ptLeader[1].y = ptLeader[0].y - m_sizeLeader.cy;
  3643. ptLeader[2].y -= ptLeader[0].y;
  3644. }
  3645. CRgn rgnLeader, rgnCaption;
  3646. rgnCaption.CreateRoundRectRgn(
  3647. rcRoundRectRgn.left,
  3648. rcRoundRectRgn.top,
  3649. rcRoundRectRgn.right,
  3650. rcRoundRectRgn.bottom,
  3651. m_sizeRounders.cx,
  3652. m_sizeRounders.cy
  3653. );
  3654. rgnLeader.CreatePolygonRgn(
  3655. ptLeader,
  3656. 3,
  3657. ALTERNATE
  3658. );
  3659. hRegion = ::CreateRectRgnIndirect( &rcRectRgn );
  3660. if( hRegion == NULL )
  3661. {
  3662. ASSERT( FALSE );
  3663. return NULL;
  3664. }
  3665. ::CombineRgn(
  3666. hRegion,
  3667. rgnCaption. operator HRGN (),
  3668. rgnLeader. operator HRGN (),
  3669. RGN_OR
  3670. );
  3671. if( m_bFlipVert )
  3672. ::OffsetRgn(
  3673. hRegion,
  3674. 0,
  3675. m_sizeLeader.cy
  3676. );
  3677. if( pSize != NULL )
  3678. {
  3679. pSize->cx = rcWnd.Width();
  3680. pSize->cy = rcWnd.Height() + m_sizeLeader.cy;
  3681. }
  3682. } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
  3683. break;
  3684. case __ETS_RECTANGLE:
  3685. case __ETS_RECTANGLE_NO_ICON:
  3686. case __ETS_INV_RECTANGLE:
  3687. case __ETS_INV_RECTANGLE_NO_ICON:
  3688. {
  3689. if( eTS != __ETS_RECTANGLE_NO_ICON
  3690. && eTS != __ETS_INV_RECTANGLE_NO_ICON
  3691. && (! m_icon.IsEmpty() ) )
  3692. {
  3693. rcWnd.right += m_sizeRenderingIcon.cx + m_nIconMarginDX;
  3694. if( rcWnd.Height() < m_sizeRenderingIcon.cy )
  3695. rcWnd.bottom = rcWnd.top + m_sizeRenderingIcon.cy;
  3696. }
  3697. rcWnd.InflateRect( m_sizeClassicMargins );
  3698. int nSizeShadow = CalcShadowSize();
  3699. ASSERT( nSizeShadow >= 0 );
  3700. rcWnd.InflateRect( 0, 0, nSizeShadow, nSizeShadow );
  3701. CRect rcRectRgn( CPoint( 0, 0 ), rcWnd.Size() );
  3702. hRegion =  ::CreateRectRgnIndirect( &rcRectRgn );
  3703. if( hRegion != NULL )
  3704. PmBridge_GetPM()->AdvTip_CalcRgn(
  3705. hRegion,