aduiRichEditCtrl.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef _aduiRichEditCtrl_h
  11. #define _aduiRichEditCtrl_h
  12. #pragma pack (push, 8)
  13. #pragma once
  14. #include "AdAChar.h"
  15. #ifndef _ADESK_MAC_
  16. #pragma warning(push)
  17. #pragma warning(disable : 4275)
  18. class CAdUiRichEditCtrl;
  19. class CAdUiRichEditThemeModReactor : public CAdUiThemeModifiedReactor // INTERNAL USE ONLY
  20. {
  21. public:
  22. CAdUiRichEditThemeModReactor(CAdUiRichEditCtrl* pCtrl); // INTERNAL USE ONLY
  23. /// <summary>
  24. /// Virtual method that receives the theme modification event.
  25. /// </summary>
  26. /// <param name="pTheme">
  27. /// The pointer to the theme that was modified.
  28. /// </param>
  29. /// <param name="element">
  30. /// A index of the theme element that was modified.
  31. /// </param>
  32. /// <remarks>
  33. /// This method is also called when the theme uses the active theme colors
  34. /// and the active theme is changed. In that case, element = kUnknownElements
  35. /// </remarks>
  36. virtual void ThemeModified(const CAdUiTheme * pTheme, AdUiThemeElement element); // INTERNAL USE ONLY
  37. private:
  38. CAdUiRichEditCtrl * m_pCtrl;
  39. };
  40. ///////////////////////////////////////////////////////////
  41. // class CAdUiRichEditCtrl
  42. ///////////////////////////////////////////////////////////
  43. /// <summary>
  44. /// This class is the CRichEditCtrl-derived control that
  45. /// can be themed.
  46. /// </summary>
  47. class ADUI_PORT CAdUiRichEditCtrl: public CRichEditCtrl{
  48. friend class CAdUiRichEditThemeModReactor; // INTERNAL USE ONLY
  49. DECLARE_DYNAMIC(CAdUiRichEditCtrl)
  50. public:
  51. CAdUiRichEditCtrl (bool bIsThemed = false);
  52. virtual ~CAdUiRichEditCtrl ();
  53. // Misc.
  54. protected:
  55. public:
  56. /// <summary>
  57. /// Clears the contents and frees memory.
  58. /// </summary>
  59. ///
  60. void clear();
  61. /// <summary>
  62. /// Method to set the background and text colors for the rich edit control (overridden
  63. /// if themed).
  64. /// </summary>
  65. ///
  66. /// <param name="bgColor">
  67. /// Background control color.
  68. /// </param>
  69. ///
  70. /// <param name="textColor">
  71. /// Control text color.
  72. /// </param>
  73. ///
  74. void SetBackgroundAndTextColor(COLORREF bgColor, COLORREF textColor);
  75. /// <summary>
  76. /// Utility method that will append a string to content, optionally flagging it for
  77. /// bold display.
  78. /// </summary>
  79. ///
  80. /// <param name="str">
  81. /// The string to append to the existing content.
  82. /// </param>
  83. ///
  84. /// <param name="bBoldFormat">
  85. /// Set to true if the string will be displayed bold, false otherwise.
  86. /// </param>
  87. ///
  88. void AppendString(CString& str, bool bBoldFormat);
  89. /// <summary>
  90. /// Streams the content in.
  91. /// </summary>
  92. ///
  93. void streamIn();
  94. /// <summary>
  95. /// Establishes control horizontal (left/right) and vertical (top/bottom) margins.
  96. /// </summary>
  97. ///
  98. /// <param name="horizontal">
  99. /// Left and right offsets used for margin.
  100. /// </param>
  101. ///
  102. /// <param name="vertical">
  103. /// Top and bottom offsets used for margin.
  104. /// </param>
  105. ///
  106. void SetMargins(int horizontal, int vertical);
  107. /// <summary>
  108. /// Obtain the horizontal (left and right) margin.
  109. /// </summary>
  110. ///
  111. /// <returns>
  112. /// Returns the horizontal margin for the control (left and right).
  113. /// </returns>
  114. ///
  115. int GetHorizontalMargin();
  116. /// <summary>
  117. /// Obtain the vertical (top and bottom) margin.
  118. /// </summary>
  119. ///
  120. /// <returns>
  121. /// Returns the vertical margin for the control (top and bottom).
  122. /// </returns>
  123. ///
  124. int GetVerticalMargin();
  125. /// <summary>
  126. /// Indicates whether this control was marked as themed.
  127. /// </summary>
  128. ///
  129. /// <returns>
  130. /// Returns true if themed, false otherwise.
  131. /// </returns>
  132. ///
  133. bool IsThemed() { return m_bIsThemed; };
  134. /// <summary>
  135. /// Sets the theme flag on the control.
  136. /// </summary>
  137. ///
  138. /// <param name="pTheme">
  139. /// Set to true if the control can be themed, false otherwise.
  140. /// </param>
  141. ///
  142. void SetIsThemed(bool isThemed);
  143. /// <summary>
  144. /// Sets the text title of the control.
  145. /// </summary>
  146. ///
  147. /// <param name="pszTitle">
  148. /// The text to set for the title.
  149. /// </param>
  150. ///
  151. void SetTitle(LPCTSTR pszTitle) {m_csTitle = pszTitle;} ;
  152. /// <summary>
  153. /// Virtual Windows PreTranslateMessage for handling rich edit control messages.
  154. /// </summary>
  155. ///
  156. /// <param name="pMsg">
  157. /// Pointer to MSG. See Windows documentation for more information.
  158. /// </param>
  159. ///
  160. /// <returns>
  161. /// Returns TRUE if the message was handled, FALSE otherwise.
  162. /// </returns>
  163. ///
  164. virtual BOOL PreTranslateMessage(MSG* pMsg);
  165. static bool m_bInitOnce;
  166. // AdUi message handlers
  167. protected:
  168. CWnd *m_aduiParent;
  169. // ClassWizard-controlled
  170. public:
  171. //{{AFX_VIRTUAL(CAdUiRichEditCtrl)
  172. //}}AFX_VIRTUAL
  173. protected:
  174. //{{AFX_MSG(CAdUiEdit)
  175. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  176. afx_msg void OnSetFocus(CWnd* pOldWnd);
  177. afx_msg void OnSize(UINT nType, int cx, int cy);
  178. afx_msg BOOL OnEnLink(NMHDR *pNMHDR, LRESULT *pResult);
  179. //}}AFX_MSG
  180. DECLARE_MESSAGE_MAP()
  181. /// <summary>
  182. /// Virtual method that receives the theme modification event.
  183. /// </summary>
  184. /// <param name="element">
  185. /// A index of the theme element that was modified.
  186. /// </param>
  187. /// <remarks>
  188. /// This method is also called when the theme uses the active theme colors
  189. /// and the active theme is changed. In that case, element = kUnknownElements
  190. /// </remarks>
  191. virtual void ThemeModified(AdUiThemeElement element);
  192. private:
  193. CString m_csTitle;
  194. CString m_csText;
  195. int m_horizontalMargin;
  196. int m_verticalMargin;
  197. bool m_bIsThemed;
  198. CAdUiRichEditThemeModReactor * m_pThemeModReactor;
  199. CAdUiTheme * m_pTheme;
  200. COLORREF mBackgroundColor;
  201. COLORREF mTextColor;
  202. };
  203. #pragma warning(pop)
  204. #endif //_ADESK_MAC_
  205. /////////////////////////////////////////////////////////////////////////////
  206. //{{AFX_INSERT_LOCATION}}
  207. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  208. #pragma pack (pop)
  209. #endif //_aduiRichEditCtrl_h
  210. /////////////////////////////////////////////////////////////////////////////