Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
9.7 KiB

  1. //
  2. // cuitheme.h
  3. //
  4. #ifndef CUITHEME_H
  5. #define CUITHEME_H
  6. #include "uxtheme.h"
  7. #include "tmschema.h"
  8. extern BOOL CUIIsThemeAPIAvail( void );
  9. extern BOOL CUIIsThemeActive( void );
  10. extern HTHEME CUIOpenThemeData( HWND hwnd, LPCWSTR pszClassList );
  11. extern HRESULT CUICloseThemeData( HTHEME hTheme );
  12. extern HRESULT CUISetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
  13. extern HRESULT CUIDrawThemeBackground( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, const RECT *pRect, DWORD dwBgFlags );
  14. extern HRESULT CUIDrawThemeParentBackground( HWND hwnd, HDC hDC, const RECT *pRect);
  15. extern HRESULT CUIDrawThemeText( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect );
  16. extern HRESULT CUIDrawThemeIcon( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex );
  17. extern HRESULT CUIGetThemeBackgroundExtent( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, const RECT *pContentRect, RECT *pExtentRect );
  18. extern HRESULT CUIGetThemeBackgroundContentRect( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect );
  19. extern HRESULT CUIGetThemeTextExtent( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, const RECT *pBoundingRect, RECT *pExtentRect );
  20. extern HRESULT CUIGetThemePartSize( HTHEME hTheme, HDC hDC, int iPartId, int iStateId, RECT *prc, enum THEMESIZE eSize, SIZE *pSize );
  21. extern HRESULT CUIDrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect);
  22. extern HRESULT CUIGetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF *pColor);
  23. extern HRESULT CUIGetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins);
  24. extern HRESULT CUIGetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *plf);
  25. extern COLORREF CUIGetThemeSysColor(HTHEME hTheme, int iColorId);
  26. extern int CUIGetThemeSysSize(HTHEME hTheme, int iSizeId);
  27. class CUIFTheme
  28. {
  29. public:
  30. CUIFTheme()
  31. {
  32. m_pszThemeClassList = NULL;
  33. m_hTheme = NULL;
  34. }
  35. ~CUIFTheme()
  36. {
  37. CloseThemeData();
  38. }
  39. BOOL IsThemeActive()
  40. {
  41. return CUIIsThemeActive();
  42. }
  43. HRESULT EnsureThemeData( HWND hwnd)
  44. {
  45. if (m_hTheme)
  46. return S_OK;
  47. return InternalOpenThemeData(hwnd);
  48. }
  49. HRESULT OpenThemeData( HWND hwnd)
  50. {
  51. Assert(!m_hTheme);
  52. return InternalOpenThemeData(hwnd);
  53. }
  54. HRESULT InternalOpenThemeData( HWND hwnd)
  55. {
  56. if (!hwnd)
  57. return E_FAIL;
  58. if (!m_pszThemeClassList)
  59. return E_FAIL;
  60. m_hTheme = CUIOpenThemeData(hwnd, m_pszThemeClassList);
  61. return m_hTheme ? S_OK : E_FAIL;
  62. }
  63. HRESULT CloseThemeData()
  64. {
  65. if (!m_hTheme)
  66. return S_OK;
  67. HRESULT hr = CUICloseThemeData( m_hTheme );
  68. m_hTheme = NULL;
  69. return hr;
  70. }
  71. HRESULT SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList)
  72. {
  73. return CUISetWindowTheme(hwnd, pszSubAppName, pszSubIdList);
  74. }
  75. virtual HRESULT DrawThemeBackground(HDC hDC, int iStateId, const RECT *pRect, DWORD dwBgFlags )
  76. {
  77. Assert(!!m_hTheme);
  78. return CUIDrawThemeBackground(m_hTheme,
  79. hDC,
  80. m_iDefThemePartID,
  81. iStateId,
  82. pRect,
  83. dwBgFlags );
  84. }
  85. virtual HRESULT DrawThemeParentBackground(HWND hwnd, HDC hDC, const RECT *pRect)
  86. {
  87. Assert(!!m_hTheme);
  88. return CUIDrawThemeParentBackground(hwnd, hDC, pRect);
  89. }
  90. virtual HRESULT DrawThemeText(HDC hDC, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect )
  91. {
  92. Assert(!!m_hTheme);
  93. return CUIDrawThemeText(m_hTheme,
  94. hDC,
  95. m_iDefThemePartID,
  96. iStateId,
  97. pszText,
  98. iCharCount,
  99. dwTextFlags,
  100. dwTextFlags2,
  101. pRect );
  102. }
  103. virtual HRESULT DrawThemeIcon(HDC hDC, int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex )
  104. {
  105. Assert(!!m_hTheme);
  106. return CUIDrawThemeIcon(m_hTheme,
  107. hDC,
  108. m_iDefThemePartID,
  109. iStateId,
  110. pRect,
  111. himl,
  112. iImageIndex );
  113. }
  114. virtual HRESULT GetThemeBackgroundExtent(HDC hDC, int iStateId, const RECT *pContentRect, RECT *pExtentRect )
  115. {
  116. Assert(!!m_hTheme);
  117. return CUIGetThemeBackgroundExtent(m_hTheme,
  118. hDC,
  119. m_iDefThemePartID,
  120. iStateId,
  121. pContentRect,
  122. pExtentRect );
  123. }
  124. virtual HRESULT GetThemeBackgroundContentRect(HDC hDC, int iStateId, const RECT *pBoundingRect, RECT *pContentRect )
  125. {
  126. Assert(!!m_hTheme);
  127. return CUIGetThemeBackgroundContentRect(m_hTheme,
  128. hDC,
  129. m_iDefThemePartID,
  130. iStateId,
  131. pBoundingRect,
  132. pContentRect );
  133. }
  134. virtual HRESULT GetThemeTextExtent(HDC hdc, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, const RECT *pBoundingRect, RECT *pExtentRect )
  135. {
  136. Assert(!!m_hTheme);
  137. return CUIGetThemeTextExtent(m_hTheme,
  138. hdc,
  139. m_iDefThemePartID,
  140. iStateId,
  141. pszText,
  142. iCharCount,
  143. dwTextFlags,
  144. pBoundingRect,
  145. pExtentRect );
  146. }
  147. virtual HRESULT GetThemePartSize(HDC hDC, int iStateId, RECT *prc, enum THEMESIZE eSize, SIZE *pSize )
  148. {
  149. Assert(!!m_hTheme);
  150. return CUIGetThemePartSize(m_hTheme,
  151. hDC,
  152. m_iDefThemePartID,
  153. iStateId,
  154. prc,
  155. eSize,
  156. pSize );
  157. }
  158. virtual HRESULT DrawThemeEdge(HDC hdc, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect = NULL)
  159. {
  160. Assert(!!m_hTheme);
  161. return CUIDrawThemeEdge(m_hTheme,
  162. hdc,
  163. m_iDefThemePartID,
  164. iStateId,
  165. pDestRect,
  166. uEdge,
  167. uFlags,
  168. pContentRect);
  169. }
  170. virtual HRESULT GetThemeColor(int iStateId, int iPropId, COLORREF *pColor)
  171. {
  172. Assert(!!m_hTheme);
  173. return CUIGetThemeColor(m_hTheme,
  174. m_iDefThemePartID,
  175. iStateId,
  176. iPropId,
  177. pColor);
  178. }
  179. virtual HRESULT GetThemeMargins(HDC hdc, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
  180. {
  181. Assert(!!m_hTheme);
  182. return CUIGetThemeMargins(m_hTheme,
  183. hdc,
  184. m_iDefThemePartID,
  185. iStateId,
  186. iPropId,
  187. prc,
  188. pMargins);
  189. }
  190. virtual HRESULT GetThemeFont(HDC hdc, int iStateId, int iPropId, LOGFONTW *plf)
  191. {
  192. Assert(!!m_hTheme);
  193. return CUIGetThemeFont(m_hTheme,
  194. hdc,
  195. m_iDefThemePartID,
  196. iStateId,
  197. iPropId,
  198. plf);
  199. }
  200. virtual COLORREF GetThemeSysColor(int iColorId)
  201. {
  202. Assert(!!m_hTheme);
  203. return CUIGetThemeSysColor(m_hTheme, iColorId);
  204. }
  205. virtual int GetThemeSysSize(int iSizeId)
  206. {
  207. Assert(!!m_hTheme);
  208. return CUIGetThemeSysSize(m_hTheme, iSizeId);
  209. }
  210. virtual void SetActiveTheme(LPCWSTR pszClassList, int iPartID = 0, int iStateID = 0)
  211. {
  212. m_iDefThemePartID = iPartID;
  213. m_iDefThemeStateID = iStateID;
  214. m_pszThemeClassList = pszClassList;
  215. }
  216. int GetDefThemePartID() {return m_iDefThemePartID;}
  217. int GetDefThemeStateID() {return m_iDefThemeStateID;}
  218. void SetDefThemePartID(int iPartId) {m_iDefThemePartID = iPartId;}
  219. private:
  220. LPCWSTR m_pszThemeClassList;
  221. int m_iDefThemePartID;
  222. int m_iDefThemeStateID;
  223. HTHEME m_hTheme;
  224. };
  225. #endif CUITHEME_H