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

对话框与窗口

开发平台:

Visual C++

  1. // XTPTaskDialogClient.h: interface for the CXTPTaskDialogClient class.
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO 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(__XTPTASKCLIENTWND_H__)
  22. #define __XTPTASKCLIENTWND_H__
  23. //}}AFX_CODEJOCK_PRIVATE
  24. #if _MSC_VER > 1000
  25. #pragma once
  26. #endif // _MSC_VER > 1000
  27. #include "XTPTaskDialogControls.h"
  28. class CXTPTaskDialogFrame;
  29. class CXTPImageManagerIcon;
  30. class CXTPMarkupUIElement;
  31. class CXTPMarkupContext;
  32. class CXTPMarkupObject;
  33. class CXTPMarkupRoutedEventArgs;
  34. enum XTPTaskSection
  35. {
  36. xtpNone,
  37. xtpMainInstruction,
  38. xtpContent,
  39. xtpCommand,
  40. xtpFooter,
  41. xtpExpandedInformation,
  42. };
  43. #define XTP_IDC_VERIFY                      10
  44. #define XTP_IDC_EXPANDO                     11
  45. //===========================================================================
  46. // CXTPTaskDialogClient window
  47. //===========================================================================
  48. class _XTP_EXT_CLASS CXTPTaskDialogClient : public CDialog
  49. {
  50. public:
  51. class CStringMarkup
  52. {
  53. public:
  54. CStringMarkup();
  55. ~CStringMarkup();
  56. public:
  57. BOOL IsEmpty() const {
  58. return m_strCaption.IsEmpty();
  59. }
  60. void SetCaption(const CString& strCaption);
  61. operator const CString& () const {
  62. return m_strCaption;
  63. }
  64. void SetFinalRect(const CRect& rcFinalRect);
  65. public:
  66. CString m_strCaption;
  67. CXTPMarkupUIElement* m_pUIElement;
  68. CXTPTaskDialogClient* m_pClient;
  69. CRect m_rcFinalRect;
  70. };
  71. public:
  72. CXTPTaskDialogClient();
  73. virtual ~CXTPTaskDialogClient();
  74. public:
  75. HRESULT SendNotify(UINT uNotify, WPARAM wParam = 0, LPARAM lParam = 0);
  76. public:
  77. virtual BOOL CreateClient(BOOL bMoveWindow);
  78. // flag checks
  79. BOOL IsLinkButtonsUsed() const;
  80. BOOL IsLinkButtonsIconVisible() const;
  81. BOOL HasLinkButtons() const;
  82. BOOL IsExpandedByDefault() const;
  83. BOOL IsExpandFooterArea() const;
  84. BOOL HasFixedWidth() const;
  85. BOOL IsPositionRelativeToWindow() const;
  86. BOOL IsProgressBarVisible() const;
  87. BOOL IsHyperlinksEnabled() const;
  88. BOOL IsFooterIconHandleUsed() const;
  89. BOOL IsMainIconHandleUsed() const;
  90. BOOL CanCancel() const;
  91. protected:
  92. int                                     m_nIdealWidth;
  93. int                                     m_nSection;
  94. int                                     m_nMaxClientWidth;
  95. int                                     m_nMinClientWidth;
  96. int                                     m_nPadding;
  97. BOOL                                    m_bExpanded;
  98. BOOL                                    m_bVerification;
  99. BOOL                                    m_bUseSysIcons;
  100. BOOL                                    m_bThemeReady;
  101. HICON                                   m_hIconFooter;
  102. HICON                                   m_hIconMain;
  103. CXTPImageManagerIcon*                   m_pIconLinkGlyph;
  104. COLORREF                                m_crContext;
  105. COLORREF                                m_crContextText;
  106. COLORREF                                m_crFooter;
  107. COLORREF                                m_crFooterText;
  108. COLORREF                                m_crMainText;
  109. COLORREF                                m_cr3DLight;
  110. COLORREF                                m_cr3DShadow;
  111. COLORREF                                m_cr3DHighLight;
  112. CFont                                   m_font;
  113. CFont                                   m_fontLarge;
  114. CPoint                                  m_ptMargin;
  115. CPoint                                  m_ptPadding;
  116. CPoint                                  m_ptBtnSpacing;
  117. CPoint                                  m_ptBorder;
  118. CSize                                   m_sizeIconFooter;
  119. CSize                                   m_sizeIconMain;
  120. CSize                                   m_sizeCommandButton;
  121. CRect                                   m_rcMainInstruction;
  122. CRect                                   m_rcContent;
  123. CRect                                   m_rcCommandButtons;
  124. CRect                                   m_rcExpandedInformation;
  125. CRect                                   m_rcFooter;
  126. CRect                                   m_rcRadioButtons;
  127. CRect                                   m_rcLinkButtons;
  128. CStringMarkup                           m_strMainInstruction;
  129. CStringMarkup                           m_strContent;
  130. CStringMarkup                           m_strFooter;
  131. CStringMarkup                           m_strVerificationText;
  132. CStringMarkup                           m_strExpandedInformation;
  133. CStringMarkup                           m_strExpandedControlText;
  134. CStringMarkup                           m_strCollapsedControlText;
  135. TASKDIALOGCONFIG*                       m_pConfig;
  136. CXTPMarkupContext*                      m_pMarkupContext;
  137. CButton*                                m_pBtnVerify;
  138. CXTButton*                              m_pBtnExpando;
  139. CXTPTaskDialogLinkCtrl                  m_wndContent;
  140. CXTPTaskDialogLinkCtrl                  m_wndExpandedInformation;
  141. CXTPTaskDialogLinkCtrl                  m_wndFooter;
  142. CXTPTaskDialogProgressCtrl              m_wndProgressBar;
  143. CArray<CButton*,CButton*>               m_arrCommandButtons;
  144. CArray<CButton*,CButton*>               m_arrLinkButtons;
  145. CArray<CButton*,CButton*>               m_arrRadioButtons;
  146. int                                     m_nSelRadioButtonID; // ID of the radio button that was selected when the task dialog was closed.
  147. CMap<CWnd*,CWnd*,SIZE,SIZE&> m_mapWndSize;
  148. BOOL                                    m_bMessageBoxStyle;
  149. BOOL                                    m_bEnableMarkup;
  150. protected:
  151. BOOL IsWindow(CWnd* pWnd) const;
  152. // initialization
  153. void CreateIcons();
  154. void LoadStrings();
  155. void CreateFonts();
  156. CString LoadItemString(PCWSTR pszBuffer);
  157. BOOL CreateCommandButtons();
  158. BOOL CreateLinkButtons();
  159. BOOL CreateRadioButtons();
  160. BOOL CreateVerifyExpandButtons();
  161. BOOL CreateProgressBar();
  162. CButton* AddCommandButton(int nButtonID, int nIDLabel, CSize sizeButton);
  163. CButton* AddCommandButton(int nButtonID, LPCTSTR lpszLabel, CSize sizeButton);
  164. CButton* CreateButton(int nButtonID, LPCTSTR lpszLabel, CSize sizeButton, DWORD dwButtonStyle = BS_PUSHBUTTON | BS_MULTILINE, CXTButtonTheme* pTheme = NULL);
  165. HICON CreateIcon(HICON hIcon, PCWSTR lpwzIcon, CSize sizeIcon, BOOL bUseHandle);
  166. // layout
  167. CSize CalcCommandButtonSize();
  168. CSize CalcButtonSize(CString strButton, CPoint* pMarginButton = NULL, int nMaxWidth = 0);
  169. CSize CalcLinkButtonSize(CString strButton, int nMaxCmdLinkWidth);
  170. CSize CalcDynamicLayout(int nIdealWidth);
  171. CRect CalcCommandRect(int nIdealWidth);
  172. int CalcIdealTextWidth(const CStringMarkup& strItemText, int nMinWidth, BOOL bLargeFont);
  173. CRect CalcTextRect(const CStringMarkup& strItemText, int nWidth, BOOL bLargeFont);
  174. int CalcLinkButtonIdealWidth(CString strButton, int cxWidth);
  175. void DrawText(CDC* pDC, const CStringMarkup& strItemText, CRect rcItem, COLORREF clrText, CFont* pFont);
  176. void RecalcLayout(BOOL bMoveWindow = FALSE);
  177. BOOL ResizeParentToFit(CSize szClient, BOOL bMoveWindow);
  178. void SetCommandButtonPos();
  179. void SetLinkButtonPos();
  180. void SetVerifyButtonPos();
  181. void SetExpandoButtonPos();
  182. void SetLinkCtrlPos();
  183. BOOL MoveButton(CButton* pButton, int x, int y, int cx, int cy, BOOL bRedraw = FALSE);
  184. BOOL MoveButton(CButton* pButton, const CRect& rect, BOOL bRedraw = FALSE);
  185. void ZOrder(CWnd* pWnd);
  186. void UpdateZOrder();
  187. int CalcClientWidth();
  188. // Drawing
  189. void RefreshMetrics();
  190. void RefreshColors();
  191. void DeleteControls();
  192. virtual void DrawMainInstruction(CDC* pDC);
  193. virtual void DrawContent(CDC* pDC);
  194. virtual void DrawFootNote(CDC* pDC);
  195. virtual void DrawBackground(CDC* pDC, CRect rect);
  196. virtual void DrawExpandedInfo(CDC* pDC);
  197. void DrawIcon(CDC* pDC, HICON hIcon, CPoint pt, CSize sz);
  198. void OnExpandExpandoClicked();
  199. //{{AFX_VIRTUAL(CXTPTaskDialogClient)
  200. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  201. BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  202. //}}AFX_VIRTUAL
  203. //{{AFX_MSG(CXTPTaskDialogClient)
  204. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  205. afx_msg void OnSysColorChange();
  206. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  207. afx_msg void OnPaint();
  208. afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  209. afx_msg void OnMarkupHyperlinkClick(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs);
  210. //}}AFX_MSG
  211. DECLARE_MESSAGE_MAP()
  212. friend class CStringMarkup;
  213. };
  214. AFX_INLINE BOOL CXTPTaskDialogClient::IsLinkButtonsUsed() const {
  215. return ((m_pConfig->dwFlags & (TDF_USE_COMMAND_LINKS | TDF_USE_COMMAND_LINKS_NO_ICON)) != 0);
  216. }
  217. AFX_INLINE BOOL CXTPTaskDialogClient::IsProgressBarVisible() const {
  218. return ((m_pConfig->dwFlags & (TDF_SHOW_PROGRESS_BAR | TDF_SHOW_MARQUEE_PROGRESS_BAR)) != 0);
  219. }
  220. AFX_INLINE BOOL CXTPTaskDialogClient::IsLinkButtonsIconVisible() const {
  221. return ((m_pConfig->dwFlags & TDF_USE_COMMAND_LINKS_NO_ICON) == 0);
  222. }
  223. AFX_INLINE BOOL CXTPTaskDialogClient::HasLinkButtons() const {
  224. return ((m_pConfig->pButtons != NULL) && (m_pConfig->cButtons > 0) && IsLinkButtonsUsed());
  225. }
  226. AFX_INLINE BOOL CXTPTaskDialogClient::IsExpandedByDefault() const {
  227. return ((m_pConfig->dwFlags & TDF_EXPANDED_BY_DEFAULT) != 0);
  228. }
  229. AFX_INLINE BOOL CXTPTaskDialogClient::IsExpandFooterArea() const {
  230. return ((m_pConfig->dwFlags & TDF_EXPAND_FOOTER_AREA) != 0);
  231. }
  232. AFX_INLINE BOOL CXTPTaskDialogClient::HasFixedWidth() const {
  233. return (m_pConfig->cxWidth != 0);
  234. }
  235. AFX_INLINE BOOL CXTPTaskDialogClient::IsPositionRelativeToWindow() const {
  236. return m_pConfig->hwndParent && (m_pConfig->dwFlags & TDF_POSITION_RELATIVE_TO_WINDOW);
  237. }
  238. AFX_INLINE BOOL CXTPTaskDialogClient::IsHyperlinksEnabled() const {
  239. return ((m_pConfig->dwFlags & TDF_ENABLE_HYPERLINKS) != 0);
  240. }
  241. AFX_INLINE BOOL CXTPTaskDialogClient::IsFooterIconHandleUsed() const {
  242. return ((m_pConfig->dwFlags & TDF_USE_HICON_FOOTER) != 0);
  243. }
  244. AFX_INLINE BOOL CXTPTaskDialogClient::IsMainIconHandleUsed() const {
  245. return ((m_pConfig->dwFlags & TDF_USE_HICON_MAIN) != 0);
  246. }
  247. AFX_INLINE BOOL CXTPTaskDialogClient::IsWindow(CWnd* pWnd) const {
  248. return (pWnd && ::IsWindow(pWnd->GetSafeHwnd()));
  249. }
  250. AFX_INLINE BOOL CXTPTaskDialogClient::MoveButton(CButton* pButton, const CRect& rect, BOOL bRedraw /*=FALSE*/) {
  251. return MoveButton(pButton, rect.left, rect.top, rect.Width(), rect.Height(), bRedraw);
  252. }
  253. /////////////////////////////////////////////////////////////////////////////
  254. //{{AFX_INSERT_LOCATION}}
  255. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  256. #endif // !defined(__XTPTASKCLIENTWND_H__)