XTPPopupControl.h
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:31k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPPopupControl.h: interface for the CXTPPopupControl class.
  2. //
  3. // This file is a part of the XTREME CONTROLS MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. //{{AFX_CODEJOCK_PRIVATE
  21. #if !defined(_XTPPOPUPCONTROL_H__)
  22. #define _XTPPOPUPCONTROL_H__
  23. //}}AFX_CODEJOCK_PRIVATE
  24. #if _MSC_VER > 1000
  25. #pragma once
  26. #endif // _MSC_VER > 1000
  27. class CXTPPopupItem;
  28. class CXTPPopupPaintManager;
  29. class CXTPImageManager;
  30. class CXTPImageManagerIcon;
  31. class CXTPMarkupContext;
  32. #include "XTNotify.h"
  33. //-----------------------------------------------------------------------
  34. // Summary:
  35. //     Enumeration used to determine the popup window theme in use
  36. // Example:
  37. //     <code>m_wndPopupControl.SetTheme(xtpPopupThemeOffice2000);</code>
  38. // See Also: CXTPPopupControl::SetTheme, CXTPPopupControl::GetTheme
  39. //
  40. // <KEYWORDS xtpPopupThemeOffice2000, xtpPopupThemeOfficeXP, xtpPopupThemeOffice2003, xtpPopupThemeMSN, xtpPopupThemeCustom>
  41. //-----------------------------------------------------------------------
  42. enum XTPPopupPaintTheme
  43. {
  44. xtpPopupThemeOffice2000,    // The theme like to a Office2000
  45. xtpPopupThemeOfficeXP,      // The theme like to a OfficeXP
  46. xtpPopupThemeOffice2003,    // The theme like to a Office2003
  47. xtpPopupThemeMSN,           // The theme like to a MSN Messenger
  48. xtpPopupThemeOffice2007,    // The theme like to a Office2007
  49. xtpPopupThemeCustom         // The custom theme
  50. };
  51. //-----------------------------------------------------------------------
  52. // Summary:
  53. //     Enumeration used to determine the popup window animation in use
  54. // Example:
  55. //     <code>m_wndPopupControl.SetPopupAnimation(xtpPopupAnimationFade);</code>
  56. // See Also: CXTPPopupControl::SetPopupAnimation, CXTPPopupControl::GetPopupAnimation
  57. //
  58. // <KEYWORDS xtpPopupAnimationNone, xtpPopupAnimationFade, xtpPopupAnimationSlide, xtpPopupAnimationUnfold>
  59. //-----------------------------------------------------------------------
  60. enum XTPPopupAnimation
  61. {
  62. xtpPopupAnimationNone,      // Animation is not used
  63. xtpPopupAnimationFade,      // Fade method animation
  64. xtpPopupAnimationSlide,     // Slide method animation
  65. xtpPopupAnimationUnfold     // Unfold method animation
  66. };
  67. //-----------------------------------------------------------------------
  68. // Summary:
  69. //     Enumeration used to determine a current popup window state
  70. // Example:
  71. // <code>
  72. // if (pControl->GetPopupState() == xtpPopupStateClosed)
  73. // {
  74. //     EnableItems(TRUE);
  75. // }
  76. // </code>
  77. // See Also: CXTPPopupControl::GetPopupState, CXTPPopupControl::SetPopupState
  78. //
  79. // <KEYWORDS xtpPopupStateClosed, xtpPopupStateExpanding, xtpPopupStateShow, xtpPopupStateCollapsing>
  80. //-----------------------------------------------------------------------
  81. enum XTPPopupState
  82. {
  83. xtpPopupStateClosed,        // The popup window is closed
  84. xtpPopupStateExpanding,     // The popup window is expanding
  85. xtpPopupStateShow,          // The popup window is shown
  86. xtpPopupStateCollapsing     // The popup window is collapsing
  87. };
  88. //-----------------------------------------------------------------------
  89. // Summary:
  90. //     The XTPWM_POPUPCONTROL_NOTIFY message is sent to the CXTPPopupControl owner window
  91. //     whenever an action occurs within the CXTPPopupControl
  92. // Parameters:
  93. //     nAction -  Value of wParam specifies a Popup Control value that indicates the user's
  94. //                request. Can be any of the values listed in the Remarks section.
  95. // Remarks:
  96. //     nAction parameter can be one of the following:
  97. //     * <b>XTP_PCN_ITEMCLICK</b> Indicates the user clicked on the popup control item.
  98. //     * <b>XTP_PCN_STATECHANGED</b> Indicates the state of control changed.
  99. // Returns:
  100. //     If the application is to process this message, the return value should be TRUE, otherwise the
  101. //     return value is FALSE.
  102. // Example:
  103. //     Here is an example of how an application would process the XTPWM_POPUPCONTROL_NOTIFY
  104. //     message.
  105. // <code>
  106. //
  107. // BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  108. //     //{{AFX_MSG_MAP(CMainFrame)
  109. //     ON_MESSAGE(XTPWM_POPUPCONTROL_NOTIFY, OnPopUpNotify)
  110. //     //}}AFX_MSG_MAP
  111. // END_MESSAGE_MAP()
  112. //
  113. // LRESULT CMainFrame::OnPopUpNotify(WPARAM wParam, LPARAM lParam)
  114. // {
  115. //      if (wParam == XTP_PCN_ITEMCLICK)
  116. //      {
  117. //          CXTPPopupItem* pItem = (CXTPPopupItem*)lParam;
  118. //          ASSERT(pItem);
  119. //
  120. //          m_wndPopupControl.Close();
  121. //
  122. //          if (pItem->GetID() == ID_GOTO_SITE)
  123. //          {
  124. //              ::ShellExecute(NULL, _T("open"), _T("http://www.codejock.com/"), NULL, NULL, SW_SHOW);
  125. //          }
  126. //      }
  127. //      else if (wParam == XTP_PCN_STATECHANGED)
  128. //      {
  129. //          CXTPPopupControl* pControl = (CXTPPopupControl*)lParam;
  130. //          ASSERT(pControl);
  131. //
  132. //          if (pControl->GetPopupState() == xtpPopupStateClosed)
  133. //          {
  134. //              EnableItems(TRUE);
  135. //          }
  136. //      }
  137. //      return TRUE;
  138. //  }
  139. // </code>
  140. // See Also:
  141. //     XTP_PCN_ITEMCLICK, XTP_PCN_STATECHANGED, CXTPPopupControl
  142. //-----------------------------------------------------------------------
  143. const UINT XTPWM_POPUPCONTROL_NOTIFY = (WM_XTP_CONTROLS_BASE + 37);
  144. //-----------------------------------------------------------------------
  145. // Summary:
  146. //     XTP_PCN_ITEMCLICK is used to indicate that the user clicked on a popup control item.
  147. // Remarks:
  148. //     XTP_PCN_ITEMCLICK is sent in the XTPWM_POPUPCONTROL_NOTIFY message to the
  149. //     owner window when the user has clicked on a popup control item.
  150. // Example:
  151. //   See example of XTPWM_POPUPCONTROL_NOTIFY
  152. // See Also:
  153. //     XTPWM_POPUPCONTROL_NOTIFY, XTP_PCN_STATECHANGED
  154. //-----------------------------------------------------------------------
  155. const UINT XTP_PCN_ITEMCLICK = 1;
  156. //-----------------------------------------------------------------------
  157. // Summary:
  158. //     XTP_PCN_STATECHANGED is used to indicate that the state of popup control changed
  159. // Remarks:
  160. //     XTP_PCN_STATECHANGED is sent in the XTPWM_POPUPCONTROL_NOTIFY message to the
  161. //     owner window when the state of popup control changed.
  162. //     It can be one of the following states:
  163. //         * <b>xtpPopupStateClosed</b> Indicates the the popup window is closed
  164. //         * <b>xtpPopupStateExpanding</b> Indicates the popup window is expanding
  165. //         * <b>xtpPopupStateShow</b> Indicates the popup window is shown
  166. //         * <b>xtpPopupStateCollapsing</b> Indicates the popup window is collapsing
  167. // Example:
  168. //   See example of XTPWM_POPUPCONTROL_NOTIFY
  169. // See Also:
  170. //     XTPWM_POPUPCONTROL_NOTIFY, XTP_PCN_ITEMCLICK
  171. //-----------------------------------------------------------------------
  172. const UINT XTP_PCN_STATECHANGED = 2;
  173. const UINT XTP_PCN_POSCHANGED = 3;
  174. //===========================================================================
  175. // Summary:
  176. //     CXTPPopupControl is a class for control of popup window
  177. //===========================================================================
  178. class _XTP_EXT_CLASS CXTPPopupControl : public CWnd
  179. {
  180. protected:
  181. //-----------------------------------------------------------------------
  182. // Summary:
  183. //     Popup state descriptor
  184. // See Also: CXTPPopupControl::m_stateTarget, CXTPPopupControl::m_stateCurrent
  185. //-----------------------------------------------------------------------
  186. struct POPUPSTATE
  187. {
  188. CRect rcPopup;                              // Popup position
  189. int nTransparency;                          // Popup transparency
  190. };
  191. public:
  192. //-----------------------------------------------------------------------
  193. // Summary:
  194. //     Constructs a CXTPPopupControl object.
  195. //-----------------------------------------------------------------------
  196. CXTPPopupControl();
  197. //-----------------------------------------------------------------------
  198. // Summary:
  199. //     Destroys a CXTPPopupControl object, all handles cleanup and
  200. //     deallocation.
  201. //-----------------------------------------------------------------------
  202. virtual ~CXTPPopupControl();
  203. public:
  204. //-----------------------------------------------------------------------
  205. // Summary:
  206. //     Call this member function to set the position of a popup
  207. //     window.
  208. // Parameters:
  209. //     ptPopup  - a CPoint object containing XY location.
  210. //-----------------------------------------------------------------------
  211. void SetPopupPos(CPoint ptPopup);
  212. //-----------------------------------------------------------------------
  213. // Summary:
  214. //     Call this member function to get the position of a  popup
  215. //     window.
  216. // Returns:
  217. //     A CPoint object containing XY location.
  218. //-----------------------------------------------------------------------
  219. CPoint GetPopupPos() const;
  220. //-----------------------------------------------------------------------
  221. // Summary:
  222. //     Call this member function to set the size of a popup window.
  223. // Parameters:
  224. //     szPopup  - A CSize object containing XY size.
  225. //-----------------------------------------------------------------------
  226. void SetPopupSize(CSize szPopup);
  227. //-----------------------------------------------------------------------
  228. // Summary:
  229. //     Call this member function to get the size of a popup window.
  230. // Returns:
  231. //     A CSize object containing XY size.
  232. //-----------------------------------------------------------------------
  233. CSize GetPopupSize() const;
  234. //-----------------------------------------------------------------------
  235. // Summary:
  236. //     Call this member for create and starting expanding state
  237. //     of a popup window
  238. // Parameters:
  239. //     pParent - points to a CWnd object that represents the parent
  240. //     window.
  241. // Returns:
  242. //     TRUE if successful, otherwise returns FALSE.
  243. //-----------------------------------------------------------------------
  244. BOOL Show(CWnd* pParent);
  245. //-----------------------------------------------------------------------
  246. // Summary:
  247. //     Call this member for starting collapsing state of a popup
  248. //     window with the posterior destroy.
  249. //-----------------------------------------------------------------------
  250. void Hide();
  251. //-----------------------------------------------------------------------
  252. // Summary:
  253. //     Call this member to destroy a popup window.
  254. // Returns:
  255. //     TRUE if successful, otherwise returns FALSE.
  256. //-----------------------------------------------------------------------
  257. BOOL Close();
  258. //-----------------------------------------------------------------------
  259. // Summary:
  260. //     Call this member function to set the transparency value of a
  261. //     popup window.
  262. // Parameters:
  263. //     bTransp - value of transparency (0...255).
  264. //     If bTransp = 0 the popup window is full transparent, otherwise
  265. //     if bTransp = 255 the popup window is full opaque.
  266. //-----------------------------------------------------------------------
  267. void SetTransparency(BYTE bTransp);
  268. //-----------------------------------------------------------------------
  269. // Summary:
  270. //     Call this member function to get the transparency value a popup
  271. //     window.
  272. // Returns:
  273. //     Transparency value of a popup window.
  274. //-----------------------------------------------------------------------
  275. BYTE GetTransparency() const;
  276. //-----------------------------------------------------------------------
  277. // Summary:
  278. //     Call this member function to set the value of show delay a
  279. //     popup window.
  280. // Parameters:
  281. //     dwShowDelay - value of show delay in milliseconds.
  282. //-----------------------------------------------------------------------
  283. void SetShowDelay(DWORD dwShowDelay);
  284. //-----------------------------------------------------------------------
  285. // Summary:
  286. //     Call this member function to get the value of show delay a
  287. //     popup window.
  288. // Returns:
  289. //     Transparency value of show delay in milliseconds.
  290. //-----------------------------------------------------------------------
  291. DWORD GetShowDelay() const;
  292. //-----------------------------------------------------------------------
  293. // Summary:
  294. //     Call this member function to set the value of animate delay
  295. //     a popup window.
  296. // Parameters:
  297. //     dwAnimateDelay - value of animate delay in milliseconds .
  298. //-----------------------------------------------------------------------
  299. void SetAnimateDelay(DWORD dwAnimateDelay);
  300. //-----------------------------------------------------------------------
  301. // Summary:
  302. //     Call this member function to get the value of animate
  303. //     delay a popup window.
  304. // Returns:
  305. //     Transparency value of animate delay in milliseconds.
  306. //-----------------------------------------------------------------------
  307. DWORD GetAnimateDelay() const;
  308. //-----------------------------------------------------------------------
  309. // Summary:
  310. //     Call this member function to set the popup animation method.
  311. // Parameters:
  312. //     popupAnimation - method in use, see XTPPopupAnimation enum.
  313. //-----------------------------------------------------------------------
  314. void SetPopupAnimation(XTPPopupAnimation popupAnimation);
  315. //-----------------------------------------------------------------------
  316. // Summary:
  317. //     Call this member function to set the default popup animation method.
  318. //-----------------------------------------------------------------------
  319. void SetPopupAnimation();
  320. //-----------------------------------------------------------------------
  321. // Summary:
  322. //     Call this member function to get the popup animation method.
  323. // Returns:
  324. //     Method in use, see XTPPopupAnimation enum.
  325. //-----------------------------------------------------------------------
  326. XTPPopupAnimation GetPopupAnimation() const;
  327. //-----------------------------------------------------------------------
  328. // Summary:
  329. //     Call this member function to get the current state of a popup
  330. //     window.
  331. // Returns:
  332. //     Current state, see XTPPopupState enum.
  333. //-----------------------------------------------------------------------
  334. XTPPopupState GetPopupState() const;
  335. //-----------------------------------------------------------------------
  336. // Summary:
  337. //     Call this member function to set the paint manager or paint theme used
  338. //     for drawing a popup window.
  339. // Parameters:
  340. //     theme - theme of popup window drawing, see XTPPopupPaintTheme
  341. //     enum.
  342. //     pPaintManager - point of paint manager object.
  343. //-----------------------------------------------------------------------
  344. void SetTheme(XTPPopupPaintTheme theme);
  345. void SetTheme(CXTPPopupPaintManager* pPaintManager); // <combine CXTPPopupControl::SetTheme@XTPPopupPaintTheme>
  346. //-----------------------------------------------------------------------
  347. // Summary:
  348. //     Call this member function to get the paint manager object used
  349. //     for drawing a popup window.
  350. // Returns:
  351. //     Point of paint manager object.
  352. //-----------------------------------------------------------------------
  353. CXTPPopupPaintManager* GetPaintManager() const;
  354. //-----------------------------------------------------------------------
  355. // Summary:
  356. //     Call this member to get the theme that the popup window is
  357. //     currently using.
  358. // Returns:
  359. //     The currently used theme of the popup window drawing.
  360. // See Also: SetTheme, XTPPopupPaintTheme
  361. //-----------------------------------------------------------------------
  362. XTPPopupPaintTheme GetTheme() const;
  363. //-----------------------------------------------------------------------
  364. // Summary:
  365. //     Call this member function to redraw all controlled items of a
  366. //     popup window.
  367. //-----------------------------------------------------------------------
  368. void RedrawControl();
  369. //-----------------------------------------------------------------------
  370. // Summary:
  371. //     Call this member function to install new controlled item in
  372. //     a popup window.
  373. // Parameters:
  374. //     pItem - Point to CXTPPopupItem object which will be installed
  375. //     in a popup window.
  376. // Returns:
  377. //     Point to the installed CXTPPopupItem object.
  378. //-----------------------------------------------------------------------
  379. CXTPPopupItem* AddItem(CXTPPopupItem* pItem);
  380. //-----------------------------------------------------------------------
  381. // Summary:
  382. //     Call this member function to remove all controlled items from
  383. //     a popup window.
  384. //-----------------------------------------------------------------------
  385. void RemoveAllItems();
  386. //-----------------------------------------------------------------------
  387. // Summary:
  388. //     Call this member function to remove controlled item from
  389. //     a popup window.
  390. // Parameters:
  391. //     pItem  - Point to CXTPPopupItem object which will be removed
  392. //     nIndex - Index of item to remove from control
  393. //-----------------------------------------------------------------------
  394. void RemoveItem(CXTPPopupItem* pItem);
  395. void RemoveItem(int nIndex); // <combine CXTPPopupControl::RemoveItem@CXTPPopupItem*>
  396. //-----------------------------------------------------------------------
  397. // Summary:
  398. //     Call this member function to get count of controlled items
  399. //     a popup window.
  400. // Returns:
  401. //     Count of controlled items.
  402. //-----------------------------------------------------------------------
  403. int GetItemCount() const;
  404. //-----------------------------------------------------------------------
  405. // Summary:
  406. //     Call this member function to get a controlled item on an index
  407. // Parameters:
  408. //     nIndex - Index of a controlled item.
  409. // Returns:
  410. //     Point to CXTPPopupItem object.
  411. //-----------------------------------------------------------------------
  412. CXTPPopupItem* GetItem(int nIndex) const;
  413. //-----------------------------------------------------------------------
  414. // Summary:
  415. //     Call this member function to testing a point for controlled
  416. //     items of a popup window.
  417. // Parameters:
  418. //     pt - a CPoint object containing XY location for testing.
  419. // Returns:
  420. //     Point to CXTPPopupItem object if test is successful, otherwise
  421. //     returns NULL.
  422. //-----------------------------------------------------------------------
  423. CXTPPopupItem* HitTest(CPoint pt) const;
  424. //-----------------------------------------------------------------------
  425. // Summary:
  426. //     Call this member to specify whether the user can click and drag
  427. //     the popup window when it is displayed.
  428. // Parameters:
  429. //     bAllowMove - TRUE to allow the user can click and drag the popup
  430. //                  window anywhere on the screen.
  431. //                  If FALSE, the popup window cannot be moved by the user.
  432. //-----------------------------------------------------------------------
  433. void AllowMove(BOOL bAllowMove);
  434. //-----------------------------------------------------------------------
  435. // Summary:
  436. //     Call this member to set bitmap index for background.
  437. // Parameters:
  438. //     nBackgroundBitmap - Index of bitmap in IamgeMnaager to set as background and region for control
  439. //-----------------------------------------------------------------------
  440. void SetBackgroundBitmap(int nBackgroundBitmap);
  441. //-----------------------------------------------------------------------
  442. // Summary:
  443. //     Call this member to get bitmap index for background.
  444. // See Also: SetBackgroundBitmap
  445. //-----------------------------------------------------------------------
  446. int GetBackgroundBitmap() const;
  447. //-----------------------------------------------------------------------
  448. // Summary:
  449. //     Call this member to let popup control delete self.
  450. // Parameters:
  451. //     bAutoDelete - TRUE to delete control automatically after popup control will be closed.
  452. //-----------------------------------------------------------------------
  453. void SetAutoDelete(BOOL bAutoDelete);
  454. public:
  455. //-----------------------------------------------------------------------
  456. // Summary:
  457. //     Determines if right-to-left mode was set.
  458. // Returns:
  459. //     TRUE if text is displayed using right-to-left reading-order properties.
  460. //-----------------------------------------------------------------------
  461. BOOL IsLayoutRTL() const;
  462. //-----------------------------------------------------------------------
  463. // Summary:
  464. //     Call this member to set right-to-left mode.
  465. // Parameters:
  466. //     bRightToLeft - TRUE to set right-to-left reading-order properties.
  467. //-----------------------------------------------------------------------
  468. void SetLayoutRTL(BOOL bRightToLeft);
  469. //-----------------------------------------------------------------------
  470. // Summary:
  471. //     Call this method to set new image manager.
  472. // Parameters:
  473. //     pImageManager - Points to a CXTPImageManager object to be set
  474. // Example:
  475. // <code>
  476. //     CXTPImageManager* pImageManager = new CXTPImageManager();
  477. //     pImageManager->SetIcons(IDR_MAINFRAME);
  478. //     m_wndPopupControl.SetImageManager(pImageManager);
  479. // </code>
  480. // See Also:
  481. //     GetImageManager
  482. //-----------------------------------------------------------------------
  483. void SetImageManager(CXTPImageManager* pImageManager);
  484. //-----------------------------------------------------------------------
  485. // Summary:
  486. //     Call this method to get a pointer to the image manager of popup
  487. //      control.
  488. // Returns:
  489. //     Pointer to the image manager of popup control.
  490. // Remarks:
  491. //     The image manager is used to hold all of the icons displayed in the
  492. //     popup control.
  493. // See Also:
  494. //     SetImageManager
  495. //-----------------------------------------------------------------------
  496. CXTPImageManager* GetImageManager() const;
  497. void EnableMarkup(BOOL bEnableMarkup);
  498. protected:
  499. //-----------------------------------------------------------------------
  500. // Summary:
  501. //     Creates a popup window
  502. // Parameters:
  503. //     pParentWnd - Pointer to the parent window.
  504. // Returns:
  505. //     TRUE if successful, otherwise returns FALSE.
  506. //-----------------------------------------------------------------------
  507. virtual BOOL Create(CWnd* pParentWnd);
  508. //-----------------------------------------------------------------------
  509. // Summary:
  510. //     This method is called when user click on controlled item
  511. // Parameters:
  512. //     pItem - Item has been clicked.
  513. //-----------------------------------------------------------------------
  514. virtual void OnClick(CXTPPopupItem* pItem);
  515. //-----------------------------------------------------------------------
  516. // Summary:
  517. //     This method is called to start expanding animation
  518. // Parameters:
  519. //     bUpdateCurrent - TRUE to update current state.
  520. //-----------------------------------------------------------------------
  521. virtual void OnExpanding(BOOL bUpdateCurrent);
  522. //-------------------------------------------------------------------------
  523. // Summary:
  524. //     This method is called to start collapsing animation
  525. //-------------------------------------------------------------------------
  526. virtual void OnCollapsing();
  527. //-------------------------------------------------------------------------
  528. // Summary:
  529. //     This method is called to show control
  530. //-------------------------------------------------------------------------
  531. virtual void OnShow();
  532. //-----------------------------------------------------------------------
  533. // Summary:
  534. //     This method is called to notify parent about action.
  535. // Parameters:
  536. //     wParam - Occured action
  537. //     lParam - Extended parameter.
  538. //-----------------------------------------------------------------------
  539. virtual void Notify(WPARAM wParam, LPARAM lParam);
  540. //-----------------------------------------------------------------------
  541. // Summary:
  542. //     This method animates popup control
  543. // Parameters:
  544. //     nStep - Current step of animation.
  545. //-----------------------------------------------------------------------
  546. void Animate(int nStep);
  547. //-----------------------------------------------------------------------
  548. // Summary:
  549. //     Updates position in animation according current animation step
  550. // Parameters:
  551. //     bInit - Initial step of animation.
  552. //-----------------------------------------------------------------------
  553. void UpdateState(BOOL bInit = FALSE);
  554. //-----------------------------------------------------------------------
  555. // Summary:
  556. //     This method is called when current state of control changed.
  557. // Parameters:
  558. //     popupState - Current state of control.
  559. //-----------------------------------------------------------------------
  560. void SetPopupState(XTPPopupState popupState);
  561. //-----------------------------------------------------------------------
  562. // Summary:
  563. //     Updates current control transparency
  564. // Parameters:
  565. //     bAlpha - Current alpha level of window
  566. // Returns:
  567. //     TRUE if successful, otherwise returns FALSE.
  568. //-----------------------------------------------------------------------
  569. BOOL SetLayeredWindowAttributes(int bAlpha);
  570. //-------------------------------------------------------------------------
  571. // Summary:
  572. //     Loop of control moving.
  573. //-------------------------------------------------------------------------
  574. void TrackMove();
  575. CXTPMarkupContext* GetMarkupContext() const;
  576. protected:
  577. //{{AFX_CODEJOCK_PRIVATE
  578. DECLARE_MESSAGE_MAP()
  579. virtual void PostNcDestroy();
  580. //{{AFX_MSG(CXTPPopupControl)
  581. afx_msg void OnTimer(UINT_PTR nIDEvent);
  582. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  583. afx_msg void OnPaint();
  584. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  585. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  586. afx_msg void OnCaptureChanged(CWnd* pWnd);
  587. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  588. afx_msg void OnMouseLeave();
  589. afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
  590. //}}AFX_MSG
  591. //}}AFX_CODEJOCK_PRIVATE
  592. private:
  593. BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  594. void UpdateBitmapRegion();
  595. HRGN BitmapToRegion(CXTPImageManagerIcon* pIcon);
  596. void SetRegionAlphaLayer(CXTPImageManagerIcon* pIcon);
  597. protected:
  598. CXTPPopupPaintManager* m_pPaintManager;         // point to CXTPPopupPaintManager object
  599. CArray<CXTPPopupItem*, CXTPPopupItem*> m_arrItems; // array for controlled items
  600. CXTPPopupItem* m_pSelected;                     // point to selected item
  601. CXTPPopupItem* m_pPressed;                      // point to pressed item
  602. XTPPopupAnimation m_popupAnimation;             // current animation method
  603. XTPPopupState m_popupState;                     // current popup state
  604. CSize m_szPopup;                                // current XY location of a popup window
  605. CPoint m_ptPopup;                               // current XY size of a popup window
  606. int m_nTransparency;                           // current value transparency of a popup window
  607. int m_nCurrentTransparency;
  608. UINT m_uShowDelay;                              // value of show delay of a popup window
  609. UINT m_uAnimationDelay;                         // value of animation delay of a popup window
  610. UINT m_nAnimationInterval;                      // value of animation interval of a popup window
  611. int  m_nStep;                                   // value of step animation of a popup window
  612. XTPPopupPaintTheme m_paintTheme;                // Currently used theme.
  613. BOOL m_bAllowMove;                              // If TRUE, the user can click and drag the popup window anywhere on the screen.  If FALSE, the popup window cannot be moved by the user.
  614. POPUPSTATE  m_stateTarget;                      // Target descriptor
  615. POPUPSTATE  m_stateCurrent;                     // Current descriptor
  616. CXTPImageManager* m_pImageManager;              // Images of popup items.
  617. BOOL m_bRightToLeft;                            // Right-To-Left layout
  618. CXTPMarkupContext* m_pMarkupContext;
  619. int m_nBackgroundBitmap;
  620. BOOL m_bAutoDelete;
  621. private:
  622. typedef BOOL (WINAPI *PFNSETLAYEREDWINDOWATTRIBUTES) (HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
  623. typedef BOOL(WINAPI* LPFNUPDATELAYEREDWINDOW) (HWND hwnd, HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
  624. PFNSETLAYEREDWINDOWATTRIBUTES m_pfnSetLayeredWindowAttributes;    // point to Transparency proc in USER32.dll module
  625. LPFNUPDATELAYEREDWINDOW m_pfnUpdateLayeredWindow;
  626. BOOL        m_bCapture;                         // capture flag of mouse event
  627. BOOL m_bLayered;
  628. friend class CXTPPopupItem;
  629. friend class CPopupControlCtrl;
  630. };
  631. /////////////////////////////////////////////////////////////////////////////
  632. AFX_INLINE CXTPPopupPaintManager* CXTPPopupControl::GetPaintManager() const {
  633. return m_pPaintManager;
  634. }
  635. AFX_INLINE void CXTPPopupControl::SetPopupSize(CSize szPopup) {
  636. m_szPopup = szPopup;
  637. }
  638. AFX_INLINE CSize CXTPPopupControl::GetPopupSize() const {
  639. return m_szPopup;
  640. }
  641. AFX_INLINE void CXTPPopupControl::SetPopupPos(CPoint ptPopup) {
  642. m_ptPopup = ptPopup;
  643. }
  644. AFX_INLINE void CXTPPopupControl::SetShowDelay(DWORD dwShowDelay) {
  645. m_uShowDelay = dwShowDelay;
  646. }
  647. AFX_INLINE DWORD CXTPPopupControl::GetShowDelay() const {
  648. return m_uShowDelay;
  649. }
  650. AFX_INLINE void CXTPPopupControl::SetAnimateDelay(DWORD dwAnimateDelay) {
  651. m_uAnimationDelay = dwAnimateDelay;
  652. }
  653. AFX_INLINE DWORD CXTPPopupControl::GetAnimateDelay() const {
  654. return m_uAnimationDelay;
  655. }
  656. AFX_INLINE BYTE CXTPPopupControl::GetTransparency() const {
  657. return (BYTE)m_nTransparency;
  658. }
  659. AFX_INLINE void CXTPPopupControl::SetTransparency(BYTE nTransparency) {
  660. m_nTransparency = nTransparency;
  661. }
  662. AFX_INLINE void CXTPPopupControl::SetAutoDelete(BOOL bAutoDelete) {
  663. m_bAutoDelete = bAutoDelete;
  664. }
  665. AFX_INLINE XTPPopupAnimation CXTPPopupControl::GetPopupAnimation() const {
  666. return m_popupAnimation;
  667. }
  668. AFX_INLINE void CXTPPopupControl::SetPopupAnimation(XTPPopupAnimation popupAnimation) {
  669. m_popupAnimation = popupAnimation;
  670. }
  671. AFX_INLINE XTPPopupPaintTheme CXTPPopupControl::GetTheme() const {
  672. return m_paintTheme;
  673. }
  674. AFX_INLINE void CXTPPopupControl::AllowMove(BOOL bAllowMove) {
  675. m_bAllowMove = bAllowMove;
  676. }
  677. AFX_INLINE BOOL CXTPPopupControl::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) {
  678. return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  679. }
  680. AFX_INLINE BOOL CXTPPopupControl::IsLayoutRTL() const {
  681. return m_bRightToLeft;
  682. }
  683. AFX_INLINE void CXTPPopupControl::SetBackgroundBitmap(int nBackgroundBitmap) {
  684. m_nBackgroundBitmap = nBackgroundBitmap;
  685. UpdateBitmapRegion();
  686. }
  687. AFX_INLINE int CXTPPopupControl::GetBackgroundBitmap() const {
  688. return m_nBackgroundBitmap;
  689. }
  690. AFX_INLINE CXTPMarkupContext* CXTPPopupControl::GetMarkupContext() const {
  691. return m_pMarkupContext;
  692. }
  693. #endif // !defined(_XTPPOPUPCONTROL_H__)