SPPropertyGridPaintManager.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. /********************************************
  2. ** 工作室:S&P工作室
  3. ** 作者 :张东斌
  4. ** 日期 :2007年6月
  5. *********************************************/
  6. #if !defined(_SPPROPERTYGRIDPAINTMANAGER_H__)
  7. #define _SPPROPERTYGRIDPAINTMANAGER_H__
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11. class CSPPropertyGrid;
  12. class CSPPropertyGridInplaceButton;
  13. class CSPPropertyGridItem;
  14. //-----------------------------------------------------------------------
  15. // Summary:
  16. // Visual theme enumeration
  17. // Example:
  18. // <code> m_wndPropertyGrid.SetTheme(SPGridThemeWhidbey); </code>
  19. // See Also: CSPPropertyGrid::SetTheme, CSPPropertyGrid::GetCurrentTheme
  20. //
  21. // <KEYWORDS SPGridThemeDefault, SPGridThemeNativeWinXP, SPGridThemeOffice2003, SPGridThemeCool, SPGridThemeSimple, SPGridThemeDelphi, SPGridThemeWhidbey>
  22. //-----------------------------------------------------------------------
  23. enum SPPropertyGridPaintTheme
  24. {
  25. SPGridThemeDefault , // Default theme.
  26. SPGridThemeNativeWinXP , // WinXP style theme.
  27. SPGridThemeOffice2003 , // Office 2003 style theme.
  28. SPGridThemeCool , // Cool theme.
  29. SPGridThemeSimple , // Visual Basic style theme.
  30. SPGridThemeDelphi , // Delphi style theme.
  31. SPGridThemeWhidbey // Visual Studio 2005 "Whidbey" style theme.
  32. };
  33. //===========================================================================
  34. // Summary:
  35. // Standalone class used by CSPPropertyGrid as the paint manager.
  36. //===========================================================================
  37. class CSPPropertyGridPaintManager
  38. {
  39. public:
  40. //-----------------------------------------------------------------------
  41. // Summary:
  42. // Constructs a CSPPropertyGridPaintManager object.
  43. // Parameters:
  44. // pGrid - Points to a CSPPropertyGrid object
  45. //-----------------------------------------------------------------------
  46. CSPPropertyGridPaintManager( CSPPropertyGrid * pGrid );
  47. //-----------------------------------------------------------------------
  48. // Summary:
  49. // Destroys a CSPPropertyGridPaintManager object, handles cleanup
  50. // and deallocation.
  51. //-----------------------------------------------------------------------
  52. virtual ~CSPPropertyGridPaintManager();
  53. public:
  54. //-----------------------------------------------------------------------
  55. // Summary:
  56. // This method is called to draw property grid background.
  57. // Parameters:
  58. // pDC - Pointer to a valid device context
  59. //-----------------------------------------------------------------------
  60. virtual void FillPropertyGrid( CDC * pDC );
  61. //-----------------------------------------------------------------------
  62. // Summary:
  63. // This method is called to draw view background.
  64. // Parameters:
  65. // pDC - Pointer to a valid device context
  66. // bClient - TRUE to draw client area; FALSE to draw frame.
  67. //-----------------------------------------------------------------------
  68. virtual void FillPropertyGridView( CDC * pDC , BOOL bClient );
  69. //-----------------------------------------------------------------------
  70. // Summary:
  71. // This method is called to draw single item of the grid.
  72. // Parameters:
  73. // lpDrawItemStruct - A long pointer to a DRAWITEMSTRUCT structure
  74. // that contains information about the type of drawing required.
  75. //-----------------------------------------------------------------------
  76. virtual void DrawItem( PDRAWITEMSTRUCT lpDrawItemStruct );
  77. //-----------------------------------------------------------------------
  78. // Summary:
  79. // Override this method and fill in the MEASUREITEMSTRUCT structure
  80. // to inform Windows of the list-box dimensions.
  81. // Parameters:
  82. // lpMeasureItemStruct - Specifies a long pointer to a MEASUREITEMSTRUCT
  83. // structure.
  84. //-----------------------------------------------------------------------
  85. virtual void MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
  86. //-----------------------------------------------------------------------
  87. // Summary:
  88. // This method is called to draw in-place button of the grid.
  89. // Parameters:
  90. // pDC - Pointer to a valid device context
  91. // pButton - Points to a CSPPropertyGridInplaceButton object
  92. //-----------------------------------------------------------------------
  93. virtual void FillInplaceButton( CDC * pDC , CSPPropertyGridInplaceButton * pButton );
  94. //-----------------------------------------------------------------------
  95. // Summary:
  96. // This method is called to refresh the visual metrics of manager.
  97. //-----------------------------------------------------------------------
  98. virtual void RefreshMetrics();
  99. //-----------------------------------------------------------------------
  100. // Summary:
  101. // Call this member to determine if a verb is at a specific point.
  102. // Parameters:
  103. // pDC - Reference to a valid device context
  104. // rcVerbs - Bounding rectangle of all verbs.
  105. // pt - Point to test.
  106. // Returns:
  107. // Index of verb within collection if the point was on a verb,
  108. // otherwise -1.
  109. //-----------------------------------------------------------------------
  110. int HitTestVerbs( CDC * pDC , CRect rcVerbs , CPoint pt );
  111. protected:
  112. //-----------------------------------------------------------------------
  113. // Summary:
  114. // This method is called to draw expand buttons of the grid.
  115. // Parameters:
  116. // dc - Reference to a valid device context
  117. // pItem - Points to a CSPPropertyGridItem object
  118. // rcCaption - Caption button rectangle.
  119. //-----------------------------------------------------------------------
  120. virtual void DrawExpandButton( CDC & dc , CSPPropertyGridItem * pItem , CRect rcCaption );
  121. //-----------------------------------------------------------------------
  122. // Summary:
  123. // This member is called to draw the bounding rectangle for a
  124. // category caption.
  125. // Parameters:
  126. // pDC - Reference to a valid device context
  127. // rc - Bounding rectangle of Category抯 caption.
  128. //-----------------------------------------------------------------------
  129. virtual void DrawCategoryCaptionBackground( CDC * pDC , CRect rc );
  130. protected:
  131. CSPPropertyGrid * m_pGrid; // Parent grid class.
  132. BOOL m_bThemed; // TRUE to use WinXP themes.
  133. CFont m_fntVerbUnderline; // Font used to display the caption of verbs with underline
  134. CFont m_fntVerbNormal; // Font used to display the caption of verbs without underline
  135. //CSPWinThemeWrapper m_themeTree; // Themes for Tree controls.
  136. //CSPWinThemeWrapper m_themeButton; // Themes for button controls
  137. //CSPWinThemeWrapper m_themeCombo; // Themes for combo button.
  138. COLORREF m_clrFace; // Face color.
  139. COLORREF m_clrShadow; // Shadow color.
  140. COLORREF m_clrVerbFace; // Text color of verbs.
  141. };
  142. namespace SPPropertyGridPaintThemes
  143. {
  144. //===========================================================================
  145. // Summary:
  146. // CSPPropertyGridOffice2003Theme is a CSPPropertyGridPaintManager derived
  147. // class. This represents an Office 2003 style theme.
  148. //===========================================================================
  149. class CSPPropertyGridOffice2003Theme : public CSPPropertyGridPaintManager
  150. {
  151. public:
  152. //-----------------------------------------------------------------------
  153. // Summary:
  154. // Constructs a CSPPropertyGridOffice2003Theme object.
  155. // Parameters:
  156. // pGrid - Points to a CSPPropertyGrid object
  157. //-----------------------------------------------------------------------
  158. CSPPropertyGridOffice2003Theme( CSPPropertyGrid * pGrid );
  159. //-------------------------------------------------------------------------
  160. // Summary:
  161. // This method is called to refresh the visual metrics of the
  162. // property grid.
  163. //-------------------------------------------------------------------------
  164. virtual void RefreshMetrics();
  165. protected:
  166. BOOL m_bLunaTheme; // TRUE to use luna colors, FALSE otherwise
  167. };
  168. //===========================================================================
  169. // Summary:
  170. // CSPPropertyGridNativeXPTheme is a CSPPropertyGridPaintManager derived
  171. // class. This represents a Native Windows XP style theme.
  172. //===========================================================================
  173. class CSPPropertyGridNativeXPTheme : public CSPPropertyGridPaintManager
  174. {
  175. public:
  176. //-----------------------------------------------------------------------
  177. // Summary:
  178. // Constructs a CSPPropertyGridNativeXPTheme object.
  179. // Parameters:
  180. // pGrid - Points to a CSPPropertyGrid object
  181. //-----------------------------------------------------------------------
  182. CSPPropertyGridNativeXPTheme( CSPPropertyGrid * pGrid );
  183. //-------------------------------------------------------------------------
  184. // Summary:
  185. // This method is called to refresh the visual metrics of the
  186. // property grid.
  187. //-------------------------------------------------------------------------
  188. virtual void RefreshMetrics();
  189. };
  190. //===========================================================================
  191. // Summary:
  192. // CSPPropertyGridCoolTheme is a CSPPropertyGridPaintManager derived
  193. // class. This represents a Cool style theme.
  194. //===========================================================================
  195. class CSPPropertyGridCoolTheme : public CSPPropertyGridPaintManager
  196. {
  197. public:
  198. //-----------------------------------------------------------------------
  199. // Summary:
  200. // Constructs a CSPPropertyGridCoolTheme object.
  201. // Parameters:
  202. // pGrid - Points to a CSPPropertyGrid object
  203. //-----------------------------------------------------------------------
  204. CSPPropertyGridCoolTheme( CSPPropertyGrid * pGrid );
  205. //-----------------------------------------------------------------------
  206. // Summary:
  207. // This method is called to draw single item of the grid.
  208. // Parameters:
  209. // lpDrawItemStruct - A long pointer to a DRAWITEMSTRUCT structure
  210. // that contains information about the type of drawing required.
  211. //-----------------------------------------------------------------------
  212. virtual void DrawItem( PDRAWITEMSTRUCT lpDrawItemStruct );
  213. //-------------------------------------------------------------------------
  214. // Summary:
  215. // This method is called to refresh the visual metrics of the
  216. // property grid.
  217. //-------------------------------------------------------------------------
  218. void RefreshMetrics();
  219. };
  220. //===========================================================================
  221. // Summary:
  222. // CSPPropertyGridSimpleTheme is a CSPPropertyGridPaintManager derived
  223. // class. This represents a Simple style theme.
  224. //===========================================================================
  225. class CSPPropertyGridSimpleTheme : public CSPPropertyGridPaintManager
  226. {
  227. public:
  228. //-----------------------------------------------------------------------
  229. // Summary:
  230. // Constructs a CSPPropertyGridSimpleTheme object.
  231. // Parameters:
  232. // pGrid - Points to a CSPPropertyGrid object
  233. //-----------------------------------------------------------------------
  234. CSPPropertyGridSimpleTheme( CSPPropertyGrid * pGrid );
  235. //-----------------------------------------------------------------------
  236. // Summary:
  237. // This method is called to draw single item of the grid.
  238. // Parameters:
  239. // lpDrawItemStruct - A long pointer to a DRAWITEMSTRUCT structure
  240. // that contains information about the type of drawing required.
  241. //-----------------------------------------------------------------------
  242. virtual void DrawItem( PDRAWITEMSTRUCT lpDrawItemStruct );
  243. //-------------------------------------------------------------------------
  244. // Summary:
  245. // This method is called to refresh the visual metrics of the
  246. // property grid.
  247. //-------------------------------------------------------------------------
  248. void RefreshMetrics();
  249. };
  250. //===========================================================================
  251. // Summary:
  252. // CSPPropertyGridDelphiTheme is a CSPPropertyGridPaintManager derived
  253. // class. This represents a Delphi style theme.
  254. //===========================================================================
  255. class CSPPropertyGridDelphiTheme : public CSPPropertyGridPaintManager
  256. {
  257. public:
  258. //-----------------------------------------------------------------------
  259. // Summary:
  260. // Constructs a CSPPropertyGridDelphiTheme object.
  261. // Parameters:
  262. // pGrid - Points to a CSPPropertyGrid object
  263. //-----------------------------------------------------------------------
  264. CSPPropertyGridDelphiTheme( CSPPropertyGrid * pGrid );
  265. //-----------------------------------------------------------------------
  266. // Summary:
  267. // This method is called to draw single item of the grid.
  268. // Parameters:
  269. // lpDrawItemStruct - A long pointer to a DRAWITEMSTRUCT structure
  270. // that contains information about the type of drawing required.
  271. //-----------------------------------------------------------------------
  272. virtual void DrawItem( PDRAWITEMSTRUCT lpDrawItemStruct );
  273. //-------------------------------------------------------------------------
  274. // Summary:
  275. // This method is called to refresh the visual metrics of the
  276. // property grid.
  277. //-------------------------------------------------------------------------
  278. virtual void RefreshMetrics();
  279. };
  280. //===========================================================================
  281. // Summary:
  282. // CSPPropertyGridWhidbeyTheme is a CSPPropertyGridPaintManager derived
  283. // class. This represents a Visual Studio 2005 "Whidbey" style theme.
  284. //===========================================================================
  285. class CSPPropertyGridWhidbeyTheme : public CSPPropertyGridPaintManager
  286. {
  287. public:
  288. //-----------------------------------------------------------------------
  289. // Summary:
  290. // Constructs a CSPPropertyGridWhidbeyTheme object.
  291. // Parameters:
  292. // pGrid - Points to a CSPPropertyGrid object
  293. //-----------------------------------------------------------------------
  294. CSPPropertyGridWhidbeyTheme( CSPPropertyGrid * pGrid );
  295. protected:
  296. //-----------------------------------------------------------------------
  297. // Summary:
  298. // This member is called to draw the bounding rectangle for a
  299. // category caption.
  300. // Parameters:
  301. // pDC - Reference to a valid device context
  302. // rc - Bounding rectangle of Category抯 caption.
  303. //-----------------------------------------------------------------------
  304. void DrawCategoryCaptionBackground( CDC * pDC , CRect rc );
  305. //-------------------------------------------------------------------------
  306. // Summary:
  307. // This method is called to refresh the visual metrics of the
  308. // property grid.
  309. //-------------------------------------------------------------------------
  310. void RefreshMetrics();
  311. //-----------------------------------------------------------------------
  312. // Summary:
  313. // This method is called to draw expand buttons of the grid.
  314. // Parameters:
  315. // dc - Reference to a valid device context
  316. // pItem - Points to a CSPPropertyGridItem object
  317. // rcCaption - Caption button rectangle.
  318. //-----------------------------------------------------------------------
  319. void DrawExpandButton( CDC & dc , CSPPropertyGridItem * pItem , CRect rcCaption );
  320. };
  321. }
  322. using namespace SPPropertyGridPaintThemes;
  323. #endif // !defined(_SPPROPERTYGRIDPAINTMANAGER_H__)