Source code of Windows XP (NT5)
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.

1582 lines
64 KiB

  1. /*
  2. ** Copyright (c) 2001 Microsoft Corporation
  3. */
  4. #include <stdafx.h>
  5. #include <UxTheme.h>
  6. #include <MPC_HTML.h>
  7. // CURSOR: <text>
  8. // MARGIN: <text>
  9. // FONT: <name> <size> <weight>
  10. // COLOR: <color>
  11. // BACKGROUND: <color>
  12. // BORDER: <color>
  13. // GRADIENT: <color1> <color2> <H or V> <RTZ or not>
  14. // HYPERLINK: <color1> <color2>
  15. struct Environment;
  16. struct Font
  17. {
  18. LPCSTR m_szName;
  19. LPCSTR m_szSize;
  20. LPCSTR m_szStyle;
  21. LPCSTR m_szWeight;
  22. void Generate( /*[in]*/ Environment& env ) const;
  23. HRESULT LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn );
  24. void Release ( );
  25. #ifdef DEBUG
  26. HRESULT GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const;
  27. #endif
  28. };
  29. struct Color
  30. {
  31. LPCSTR m_szDef1;
  32. LPCSTR m_szDef2;
  33. int m_iRatio;
  34. void Generate( /*[in]*/ Environment& env, /*[in]*/ LPCSTR szStyle ) const;
  35. HRESULT LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn );
  36. void Release ( );
  37. #ifdef DEBUG
  38. HRESULT GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const;
  39. #endif
  40. };
  41. struct Gradient
  42. {
  43. Color m_start;
  44. Color m_end;
  45. bool m_fHorizontal;
  46. bool m_fReturnToZero;
  47. void Generate( /*[in]*/ Environment& env ) const;
  48. HRESULT LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn );
  49. void Release ( );
  50. #ifdef DEBUG
  51. HRESULT GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const;
  52. #endif
  53. };
  54. struct Hyperlink
  55. {
  56. Color m_colorNormal;
  57. Color m_colorHover;
  58. Color m_colorActive;
  59. bool m_fUnderlineAlways;
  60. enum PseudoClass
  61. {
  62. PC_NORMAL,
  63. PC_HOVER ,
  64. PC_ACTIVE,
  65. };
  66. void Generate( /*[in]*/ Environment& env, /*[in]*/ PseudoClass cls ) const;
  67. HRESULT LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn );
  68. void Release ( );
  69. #ifdef DEBUG
  70. HRESULT GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const;
  71. #endif
  72. };
  73. struct ElementName
  74. {
  75. LPCSTR m_szName;
  76. LPCSTR m_szComment;
  77. };
  78. struct ElementFONT
  79. {
  80. const ElementName* m_name;
  81. const Font* m_font;
  82. };
  83. struct ElementCOLOR
  84. {
  85. const ElementName* m_name;
  86. const Color* m_color;
  87. };
  88. struct ElementBACKGROUND
  89. {
  90. const ElementName* m_name;
  91. const Color* m_color;
  92. };
  93. struct ElementBORDER
  94. {
  95. const ElementName* m_name;
  96. const Color* m_color;
  97. };
  98. struct ElementGRADIENT
  99. {
  100. const ElementName* m_name;
  101. const Gradient* m_gradient;
  102. };
  103. struct ElementHYPERLINK
  104. {
  105. const ElementName* m_name;
  106. const Hyperlink* m_hyperlink;
  107. };
  108. struct StyleSheet
  109. {
  110. LPCWSTR m_szName;
  111. const ElementFONT* m_fonts ; int m_iFonts;
  112. const ElementCOLOR* m_colors ; int m_iColors;
  113. const ElementBACKGROUND* m_backgrounds; int m_iBackgrounds;
  114. const ElementBORDER* m_borders ; int m_iBorders;
  115. const ElementGRADIENT* m_gradients ; int m_iGradients;
  116. const ElementHYPERLINK* m_hyperlinks ; int m_iHyperlinks;
  117. };
  118. struct Environment
  119. {
  120. MPC::string& m_strOutput;
  121. NONCLIENTMETRICSA m_ncm;
  122. int m_iPixel;
  123. MPC::XmlUtil m_xmlOEM;
  124. bool m_fOEM;
  125. bool m_fCustomizing;
  126. ////////////////////
  127. Environment( /*[in]*/ MPC::string& strOutput );
  128. HRESULT Init();
  129. bool IsCustomizationPresent( /*[in]*/ const ElementName* name );
  130. void OpenClass ( /*[in]*/ const ElementName* name, /*[in]*/ LPCSTR szPrefix = NULL, /*[in]*/ LPCSTR szSuffix = NULL );
  131. void CloseClass( );
  132. void GenerateClass( /*[in]*/ const ElementFONT& ptr );
  133. void GenerateClass( /*[in]*/ const ElementCOLOR& ptr );
  134. void GenerateClass( /*[in]*/ const ElementBACKGROUND& ptr );
  135. void GenerateClass( /*[in]*/ const ElementBORDER& ptr );
  136. void GenerateClass( /*[in]*/ const ElementGRADIENT& ptr );
  137. void GenerateClass( /*[in]*/ const ElementHYPERLINK& ptr );
  138. void AddAttribute( /*[in]*/ LPCSTR szName, /*[in]*/ LPCSTR szValue );
  139. HRESULT GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ CComVariant& v );
  140. HRESULT GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ LPCSTR& v );
  141. HRESULT GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ int& v );
  142. HRESULT GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ bool& v );
  143. HRESULT GenerateStyleSheet( /*[in]*/ const StyleSheet& def );
  144. #ifdef DEBUG
  145. HRESULT CreateNode( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ const ElementName* elem, /*[in]*/ LPCWSTR szType, /*[in/out]*/ CComPtr<IXMLDOMNode>& xdn );
  146. HRESULT CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ LPCSTR szValue );
  147. HRESULT CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ bool fValue );
  148. HRESULT CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ int iValue );
  149. HRESULT CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ CComVariant& vValue );
  150. HRESULT GenerateStyleSheetXML( /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ const StyleSheet& def );
  151. HRESULT DumpStyle();
  152. HRESULT DumpStyleXML();
  153. #endif
  154. };
  155. ////////////////////////////////////////////////////////////////////////////////
  156. ////////////////////////////////////////////////////////////////////////////////
  157. ElementName NAME_sys_bottompane_bgcolor = { ".sys-bottompane-bgcolor" , "primary fill color" };
  158. ElementName NAME_sys_bottompane_color_border = { ".sys-bottompane-color-border" , "outline color" };
  159. ElementName NAME_sys_bottompane_header_bgcolor = { ".sys-bottompane-header-bgcolor", "left to right gradient colors in the header" };
  160. ElementName NAME_sys_bottompane_header_color = { ".sys-bottompane-header-color" , "text color in bottom nav pane" };
  161. ElementName NAME_sys_color_body = { ".sys-color-body" , "color of normal text (usually black)" };
  162. ElementName NAME_sys_color_body_alert = { ".sys-color-body-alert" , "used when the body text color needs to indicate an alert (usually red)" };
  163. ElementName NAME_sys_color_body_helpee = { ".sys-color-body-helpee" , "color of normal text (usually dark grey)" };
  164. ElementName NAME_sys_color_body_helper = { ".sys-color-body-helper" , "color of normal text (usually dark blue)" };
  165. ElementName NAME_sys_color_body_ok = { ".sys-color-body-ok" , "used when the body text color needs to indicate status ok (usually green)" };
  166. ElementName NAME_sys_color_body_sec = { ".sys-color-body-sec" , "used for text that is gray or demoted, such as secondary descriptive text" };
  167. ElementName NAME_sys_font_body = { ".sys-font-body" , "used throughout the hsc, primary font that all information uses" };
  168. ElementName NAME_sys_font_body_bold = { ".sys-font-body-bold" , "bold variant of the body text font" };
  169. ElementName NAME_sys_font_heading1 = { ".sys-font-heading1" , "used for the HSC logo in the header, largest font in HSC" };
  170. ElementName NAME_sys_font_heading2 = { ".sys-font-heading2" , "used on splash pages and the homepage" };
  171. ElementName NAME_sys_font_heading3 = { ".sys-font-heading3" , "used on subsite and centers content pages and search label in header" };
  172. ElementName NAME_sys_font_heading4 = { ".sys-font-heading4" , "used on splash pages as smaller message text" };
  173. ElementName NAME_sys_header_bgcolor = { ".sys-header-bgcolor" , "used to flat fill the header area with a solid color" };
  174. ElementName NAME_sys_header_color = { ".sys-header-color" , "used for any text that is not a link and is meant to be demoted" };
  175. ElementName NAME_sys_header_color_logo = { ".sys-header-color-logo" , "used for the 'Help and Support Center' logo in the header" };
  176. ElementName NAME_sys_header_gradient_H = { ".sys-header-gradient-H" , "used to separate tool bar from content area" };
  177. ElementName NAME_sys_header_gradient_V = { ".sys-header-gradient-V" , "used to separate left pane from right pane" };
  178. ElementName NAME_sys_background_strong = { ".sys-background-strong" , "strong background, doesn't get wiped out by High-Contrast" };
  179. ElementName NAME_sys_homepage_bgcolor = { ".sys-homepage-bgcolor" , "color fill on the homepage background" };
  180. ElementName NAME_sys_homepage_color = { ".sys-homepage-color" , "used for any non-hyperlink text on the homepage" };
  181. ElementName NAME_sys_inlineform_bgcolor1 = { ".sys-inlineform-bgcolor1" , "alert or modal dialogs in the rhp" };
  182. ElementName NAME_sys_inlineform_bgcolor2 = { ".sys-inlineform-bgcolor2" , "forms or neutral tone dialogs in the rhp" };
  183. ElementName NAME_sys_inlineform_bgcolor3 = { ".sys-inlineform-bgcolor3" , "table header for status in the rhp" };
  184. ElementName NAME_sys_lhp_bgcolor = { ".sys-lhp-bgcolor" , "top to bottom gradient colors in the left hand pane background" };
  185. ElementName NAME_sys_lhp_bgcolor_scope = { ".sys-lhp-bgcolor-scope" , "color used in the search scope area, just above the navigation panes" };
  186. ElementName NAME_sys_lhp_color = { ".sys-lhp-color" , "any text that is in the lhp, not included in the task panes" };
  187. ElementName NAME_sys_link_header = { ".sys-link-header" , "the 'set search options' link in the header" };
  188. ElementName NAME_sys_link_homepage = { ".sys-link-homepage" , "hyperlinks on the homepage, where the background is not white (Luna=blue)" };
  189. ElementName NAME_sys_link_normal = { ".sys-link-normal" , "links in RHP, normal blue hyperlinks used throughout hsc" };
  190. ElementName NAME_sys_link_splash = { ".sys-link-splash" , "links in splash pages" };
  191. ElementName NAME_sys_RA_gradient_H = { ".sys-RA-gradient-H" , NULL };
  192. ElementName NAME_sys_RA_gradient_V = { ".sys-RA-gradient-V" , NULL };
  193. ElementName NAME_sys_rhp_bgcolor = { ".sys-rhp-bgcolor" , "color used to fill the background of the content pages in the RHP (normally white)" };
  194. ElementName NAME_sys_rhp_color_title = { ".sys-rhp-color-title" , "color used for titles in the content pages in the RHP" };
  195. ElementName NAME_sys_rhp_splash_bgcolor = { ".sys-rhp-splash-bgcolor" , "color of background of the splash pages in the RHP" };
  196. ElementName NAME_sys_rhp_splash_color = { ".sys-rhp-splash-color" , "color of smaller message text on subsite and center splash pages" };
  197. ElementName NAME_sys_rhp_splash_color_title = { ".sys-rhp-splash-color-title" , "color of text on subsite and center splash pages" };
  198. ElementName NAME_sys_table_cell_bgcolor1 = { ".sys-table-cell-bgcolor1" , "alternating color 1 for table rows" };
  199. ElementName NAME_sys_table_cell_bgcolor2 = { ".sys-table-cell-bgcolor2" , "alternating color 2 for table rows" };
  200. ElementName NAME_sys_table_cell_bgcolor3 = { ".sys-table-cell-bgcolor3" , "color for vertical cells in tables and Remote Assistance" };
  201. ElementName NAME_sys_table_cell_bgcolor4 = { ".sys-table-cell-bgcolor4" , "color for empty helper screen in Remote Assistance" };
  202. ElementName NAME_sys_table_cell_bgcolor5 = { ".sys-table-cell-bgcolor5" , "color for content panes in Remote Assistance (will be removed if no gradient)" };
  203. ElementName NAME_sys_table_color_border = { ".sys-table-color-border" , "color for all table cell outlines" };
  204. ElementName NAME_sys_table_header_bgcolor1 = { ".sys-table-header-bgcolor1" , "primary header color for tables of data" };
  205. ElementName NAME_sys_table_header_bgcolor2 = { ".sys-table-header-bgcolor2" , "secondary header color for tables of data, column header color" };
  206. ElementName NAME_sys_toppane_bgcolor = { ".sys-toppane-bgcolor" , "primary fill color" };
  207. ElementName NAME_sys_toppane_color_border = { ".sys-toppane-color-border" , "outline color" };
  208. ElementName NAME_sys_toppane_header_bgcolor = { ".sys-toppane-header-bgcolor" , "left to right gradient colors in the header" };
  209. ElementName NAME_sys_toppane_header_color = { ".sys-toppane-header-color" , "text color in top nav pane" };
  210. ElementName NAME_sys_toppane_selection = { ".sys-toppane-selection" , "color for selected nodes in the pane" };
  211. ////////////////////////////////////////////////////////////////////////////////
  212. ////////////////////////////////////////////////////////////////////////////////
  213. namespace THEME_Luna
  214. {
  215. static const Font FONT_sys_font_body = { "messagebox" , NULL , NULL, NULL };
  216. static const Font FONT_sys_font_body_bold = { "messagebox" , NULL , NULL, "bold" };
  217. static const Font FONT_sys_font_heading1 = { "Franklin Gothic Medium", "18pt", NULL, "normal" };
  218. static const Font FONT_sys_font_heading2 = { "Franklin Gothic Medium", "18pt", NULL, "normal" };
  219. static const Font FONT_sys_font_heading3 = { "Franklin Gothic Medium", "14pt", NULL, "normal" };
  220. static const Font FONT_sys_font_heading4 = { "Verdana" , "10pt", NULL, "normal" };
  221. static const Color COLOR_sys_bottompane_bgcolor = { "#EDF2FC", NULL, 0 };
  222. static const Color COLOR_sys_bottompane_color_border = { "#FFFFFF", NULL, 0 };
  223. static const Color COLOR_sys_bottompane_header_color = { "#215DC6", NULL, 0 };
  224. static const Color COLOR_sys_color_body = { "#000000", NULL, 0 };
  225. static const Color COLOR_sys_color_body_alert = { "#FF0000", NULL, 0 };
  226. static const Color COLOR_sys_color_body_helpee = { "#848E94", NULL, 0 };
  227. static const Color COLOR_sys_color_body_helper = { "#0309C0", NULL, 0 };
  228. static const Color COLOR_sys_color_body_ok = { "#009900", NULL, 0 };
  229. static const Color COLOR_sys_color_body_sec = { "#808080", NULL, 0 };
  230. static const Color COLOR_sys_header_bgcolor = { "#003399", NULL, 0 };
  231. static const Color COLOR_sys_header_color = { "#D6DFF5", NULL, 0 };
  232. static const Color COLOR_sys_header_color_logo = { "#FFFFFF", NULL, 0 };
  233. static const Color COLOR_sys_homepage_bgcolor = { "#6375D6", NULL, 0 };
  234. static const Color COLOR_sys_homepage_color = { "#D6DFF5", NULL, 0 };
  235. static const Color COLOR_sys_inlineform_bgcolor1 = { "#FFF7E7", NULL, 0 };
  236. static const Color COLOR_sys_inlineform_bgcolor2 = { "#D6DFF5", NULL, 0 };
  237. static const Color COLOR_sys_inlineform_bgcolor3 = { "#1051BD", NULL, 0 };
  238. static const Color COLOR_sys_lhp_bgcolor_scope = { "#8CAAE6", NULL, 0 };
  239. static const Color COLOR_sys_lhp_color = { "#FFFFFF", NULL, 0 };
  240. static const Color COLOR_sys_rhp_bgcolor = { "#FFFFFF", NULL, 0 };
  241. static const Color COLOR_sys_rhp_color_title = { "#5A7EDC", NULL, 0 };
  242. static const Color COLOR_sys_rhp_splash_bgcolor = { "#6487DC", NULL, 0 };
  243. static const Color COLOR_sys_rhp_splash_color = { "#FFFFFF", NULL, 0 };
  244. static const Color COLOR_sys_rhp_splash_color_title = { "#FFFFFF", NULL, 0 };
  245. static const Color COLOR_sys_table_cell_bgcolor1 = { "#FFFFFF", NULL, 0 };
  246. static const Color COLOR_sys_table_cell_bgcolor2 = { "#D6DFF5", NULL, 0 };
  247. static const Color COLOR_sys_table_cell_bgcolor3 = { "#C6D3F7", NULL, 0 };
  248. static const Color COLOR_sys_table_cell_bgcolor4 = { "#EFF3FF", NULL, 0 };
  249. static const Color COLOR_sys_table_color_border = { "#6681D9", NULL, 0 };
  250. static const Color COLOR_sys_table_header_bgcolor1 = { "#6681D9", NULL, 0 };
  251. static const Color COLOR_sys_table_header_bgcolor2 = { "#6681D9", NULL, 0 };
  252. static const Color COLOR_sys_toppane_bgcolor = { "#EDF2FC", NULL, 0 };
  253. static const Color COLOR_sys_toppane_color_border = { "#5582D2", NULL, 0 };
  254. static const Color COLOR_sys_toppane_header_color = { "#FFFFFF", NULL, 0 };
  255. static const Color COLOR_sys_toppane_selection = { "#C7D8FA", NULL, 0 };
  256. static const Hyperlink HYPER_sys_link_header = { { "#FFFFFF", NULL, 0 }, { "#FFFFFF", NULL, 0 }, { NULL , NULL, 0 }, false };
  257. static const Hyperlink HYPER_sys_link_homepage = { { "#FFFFFF", NULL, 0 }, { "#FFFFFF", NULL, 0 }, { "black", NULL, 0 }, false };
  258. static const Hyperlink HYPER_sys_link_normal = { { "#3333FF", NULL, 0 }, { "#6666FF", NULL, 0 }, { NULL , NULL, 0 }, false };
  259. static const Hyperlink HYPER_sys_link_splash = { { "#FFFFFF", NULL, 0 }, { "#FFFFFF", NULL, 0 }, { "black", NULL, 0 }, true };
  260. /*fHorizontal fReturnToZero*/
  261. static const Gradient GRAD_sys_bottompane_header_bgcolor = { { "#FFFFFF", NULL, 0 }, { "#C5D2F0", NULL, 0 }, true , false };
  262. static const Gradient GRAD_sys_header_gradient_H = { { "#2E52AF", NULL, 0 }, { "#D8EAF3", NULL, 0 }, true , true };
  263. static const Gradient GRAD_sys_header_gradient_V = { { "#8CAAE6", NULL, 0 }, { "#C8DEFF", NULL, 0 }, false , true };
  264. static const Gradient GRAD_sys_lhp_bgcolor = { { "#8CAAE6", NULL, 0 }, { "#6487DC", NULL, 0 }, false , false };
  265. static const Gradient GRAD_sys_RA_gradient_H = { { "#A4B9EA", NULL, 0 }, { "#7396DF", NULL, 0 }, true , false };
  266. static const Gradient GRAD_sys_RA_gradient_V = { { "#7396DF", NULL, 0 }, { "#A4B9EA", NULL, 0 }, false , true };
  267. static const Gradient GRAD_sys_table_cell_bgcolor5 = { { "#C5D2F0", NULL, 0 }, { "#FFFFFF", NULL, 0 }, true , false };
  268. static const Gradient GRAD_sys_toppane_header_bgcolor = { { "#0148B2", NULL, 0 }, { "#285BC5", NULL, 0 }, true , false };
  269. static const Gradient GRAD_sys_background_strong = { { "#8CAAE6", NULL, 0 }, { "#8CAAE6", NULL, 0 }, true , false };
  270. ////////////////////
  271. static const ElementFONT rgFONT[] =
  272. {
  273. { &NAME_sys_font_body , & FONT_sys_font_body },
  274. { &NAME_sys_font_body_bold, & FONT_sys_font_body_bold },
  275. { &NAME_sys_font_heading1 , & FONT_sys_font_heading1 },
  276. { &NAME_sys_font_heading2 , & FONT_sys_font_heading2 },
  277. { &NAME_sys_font_heading3 , & FONT_sys_font_heading3 },
  278. { &NAME_sys_font_heading4 , & FONT_sys_font_heading4 },
  279. };
  280. static const ElementCOLOR rgCOLOR[] =
  281. {
  282. { &NAME_sys_bottompane_header_color, &COLOR_sys_bottompane_header_color },
  283. { &NAME_sys_color_body , &COLOR_sys_color_body },
  284. { &NAME_sys_color_body_alert , &COLOR_sys_color_body_alert },
  285. { &NAME_sys_color_body_helpee , &COLOR_sys_color_body_helpee },
  286. { &NAME_sys_color_body_helper , &COLOR_sys_color_body_helper },
  287. { &NAME_sys_color_body_ok , &COLOR_sys_color_body_ok },
  288. { &NAME_sys_color_body_sec , &COLOR_sys_color_body_sec },
  289. { &NAME_sys_header_color , &COLOR_sys_header_color },
  290. { &NAME_sys_header_color_logo , &COLOR_sys_header_color_logo },
  291. { &NAME_sys_homepage_color , &COLOR_sys_homepage_color },
  292. { &NAME_sys_lhp_color , &COLOR_sys_lhp_color },
  293. { &NAME_sys_rhp_color_title , &COLOR_sys_rhp_color_title },
  294. { &NAME_sys_rhp_splash_color , &COLOR_sys_rhp_splash_color },
  295. { &NAME_sys_rhp_splash_color_title , &COLOR_sys_rhp_splash_color_title },
  296. { &NAME_sys_toppane_header_color , &COLOR_sys_toppane_header_color },
  297. };
  298. static const ElementBACKGROUND rgBACKGROUND[] =
  299. {
  300. { &NAME_sys_bottompane_bgcolor , &COLOR_sys_bottompane_bgcolor },
  301. { &NAME_sys_header_bgcolor , &COLOR_sys_header_bgcolor },
  302. { &NAME_sys_homepage_bgcolor , &COLOR_sys_homepage_bgcolor },
  303. { &NAME_sys_inlineform_bgcolor1 , &COLOR_sys_inlineform_bgcolor1 },
  304. { &NAME_sys_inlineform_bgcolor2 , &COLOR_sys_inlineform_bgcolor2 },
  305. { &NAME_sys_inlineform_bgcolor3 , &COLOR_sys_inlineform_bgcolor3 },
  306. { &NAME_sys_lhp_bgcolor_scope , &COLOR_sys_lhp_bgcolor_scope },
  307. { &NAME_sys_rhp_bgcolor , &COLOR_sys_rhp_bgcolor },
  308. { &NAME_sys_rhp_splash_bgcolor , &COLOR_sys_rhp_splash_bgcolor },
  309. { &NAME_sys_table_cell_bgcolor1 , &COLOR_sys_table_cell_bgcolor1 },
  310. { &NAME_sys_table_cell_bgcolor2 , &COLOR_sys_table_cell_bgcolor2 },
  311. { &NAME_sys_table_cell_bgcolor3 , &COLOR_sys_table_cell_bgcolor3 },
  312. { &NAME_sys_table_cell_bgcolor4 , &COLOR_sys_table_cell_bgcolor4 },
  313. { &NAME_sys_table_header_bgcolor1, &COLOR_sys_table_header_bgcolor1 },
  314. { &NAME_sys_table_header_bgcolor2, &COLOR_sys_table_header_bgcolor2 },
  315. { &NAME_sys_toppane_bgcolor , &COLOR_sys_toppane_bgcolor },
  316. { &NAME_sys_toppane_selection , &COLOR_sys_toppane_selection },
  317. };
  318. static const ElementBORDER rgBORDER[] =
  319. {
  320. { &NAME_sys_bottompane_color_border, &COLOR_sys_bottompane_color_border },
  321. { &NAME_sys_table_color_border , &COLOR_sys_table_color_border },
  322. { &NAME_sys_toppane_color_border , &COLOR_sys_toppane_color_border },
  323. };
  324. static const ElementGRADIENT rgGRADIENT[] =
  325. {
  326. { &NAME_sys_bottompane_header_bgcolor, &GRAD_sys_bottompane_header_bgcolor },
  327. { &NAME_sys_header_gradient_H , &GRAD_sys_header_gradient_H },
  328. { &NAME_sys_header_gradient_V , &GRAD_sys_header_gradient_V },
  329. { &NAME_sys_background_strong , &GRAD_sys_background_strong },
  330. { &NAME_sys_lhp_bgcolor , &GRAD_sys_lhp_bgcolor },
  331. { &NAME_sys_RA_gradient_H , &GRAD_sys_RA_gradient_H },
  332. { &NAME_sys_RA_gradient_V , &GRAD_sys_RA_gradient_V },
  333. { &NAME_sys_table_cell_bgcolor5 , &GRAD_sys_table_cell_bgcolor5 },
  334. { &NAME_sys_toppane_header_bgcolor , &GRAD_sys_toppane_header_bgcolor },
  335. };
  336. static const ElementHYPERLINK rgHYPERLINK[] =
  337. {
  338. { &NAME_sys_link_header , &HYPER_sys_link_header },
  339. { &NAME_sys_link_homepage, &HYPER_sys_link_homepage },
  340. { &NAME_sys_link_normal , &HYPER_sys_link_normal },
  341. { &NAME_sys_link_splash , &HYPER_sys_link_splash },
  342. };
  343. static const StyleSheet g_def =
  344. {
  345. L"Luna",
  346. rgFONT , ARRAYSIZE(rgFONT ),
  347. rgCOLOR , ARRAYSIZE(rgCOLOR ),
  348. rgBACKGROUND, ARRAYSIZE(rgBACKGROUND),
  349. rgBORDER , ARRAYSIZE(rgBORDER ),
  350. rgGRADIENT , ARRAYSIZE(rgGRADIENT ),
  351. rgHYPERLINK , ARRAYSIZE(rgHYPERLINK ),
  352. };
  353. }
  354. ////////////////////////////////////////////////////////////////////////////////
  355. ////////////////////////////////////////////////////////////////////////////////
  356. namespace THEME_Classic
  357. {
  358. static const Font FONT_sys_font_body = { "messagebox" , NULL , NULL, NULL };
  359. static const Font FONT_sys_font_body_bold = { "messagebox" , NULL , NULL, "bold" };
  360. static const Font FONT_sys_font_heading1 = { "Franklin Gothic Medium", "18pt", NULL, "normal" };
  361. static const Font FONT_sys_font_heading2 = { "Franklin Gothic Medium", "18pt", NULL, "normal" };
  362. static const Font FONT_sys_font_heading3 = { "Franklin Gothic Medium", "14pt", NULL, "normal" };
  363. static const Font FONT_sys_font_heading4 = { "Verdana" , "10pt", NULL, "normal" };
  364. static const Color COLOR_sys_bottompane_bgcolor = { "window" , NULL , 0 };
  365. static const Color COLOR_sys_bottompane_color_border = { "buttonface" , NULL , 0 };
  366. static const Color COLOR_sys_bottompane_header_color = { "windowtext" , NULL , 0 };
  367. static const Color COLOR_sys_color_body = { "windowtext" , NULL , 0 };
  368. static const Color COLOR_sys_color_body_alert = { "#FF0000" , NULL , 0 };
  369. static const Color COLOR_sys_color_body_helpee = { "windowtext" , "hotlight" , +25 };
  370. static const Color COLOR_sys_color_body_helper = { "windowtext" , NULL , 0 };
  371. static const Color COLOR_sys_color_body_ok = { "#009900" , NULL , 0 };
  372. static const Color COLOR_sys_color_body_sec = { "#808080" , NULL , 0 };
  373. static const Color COLOR_sys_header_bgcolor = { "activecaption" , NULL , 0 };
  374. static const Color COLOR_sys_header_color = { "activecaption" , "window" , +50 };
  375. static const Color COLOR_sys_header_color_logo = { "captiontext" , NULL , 0 };
  376. static const Color COLOR_sys_homepage_bgcolor = { "window" , NULL , 0 };
  377. static const Color COLOR_sys_homepage_color = { "windowtext" , NULL , 0 };
  378. static const Color COLOR_sys_inlineform_bgcolor1 = { "window" , NULL , 0 };
  379. static const Color COLOR_sys_inlineform_bgcolor2 = { "buttonface" , NULL , 0 };
  380. static const Color COLOR_sys_inlineform_bgcolor3 = { "buttonface" , NULL , 0 };
  381. static const Color COLOR_sys_lhp_bgcolor_scope = { "window" , NULL , 0 };
  382. static const Color COLOR_sys_lhp_color = { "window" , NULL , 0 };
  383. static const Color COLOR_sys_rhp_bgcolor = { "window" , NULL , 0 };
  384. static const Color COLOR_sys_rhp_color_title = { "activecaption" , NULL , 0 };
  385. static const Color COLOR_sys_rhp_splash_bgcolor = { "window" , NULL , 0 };
  386. static const Color COLOR_sys_rhp_splash_color = { "windowtext" , NULL , 0 };
  387. static const Color COLOR_sys_rhp_splash_color_title = { "windowtext" , NULL , 0 };
  388. static const Color COLOR_sys_table_cell_bgcolor1 = { "window" , NULL , 0 };
  389. static const Color COLOR_sys_table_cell_bgcolor2 = { "infobackground", NULL , 0 };
  390. static const Color COLOR_sys_table_cell_bgcolor3 = { "buttonface" , NULL , 0 };
  391. static const Color COLOR_sys_table_cell_bgcolor4 = { "window" , NULL , 0 };
  392. static const Color COLOR_sys_table_color_border = { "buttonface" , NULL , 0 };
  393. static const Color COLOR_sys_table_header_bgcolor1 = { "activecaption" , NULL , 0 };
  394. static const Color COLOR_sys_table_header_bgcolor2 = { "buttonface" , NULL , 0 };
  395. static const Color COLOR_sys_toppane_bgcolor = { "window" , NULL , 0 };
  396. static const Color COLOR_sys_toppane_color_border = { "activecaption" , NULL , 0 };
  397. static const Color COLOR_sys_toppane_header_color = { "captiontext" , NULL , 0 };
  398. static const Color COLOR_sys_toppane_selection = { "buttonface" , NULL , 0 };
  399. static const Hyperlink HYPER_sys_link_header = { { "captiontext", NULL, 0 }, { "captiontext", NULL, 0 }, { NULL, NULL, 0 }, false };
  400. static const Hyperlink HYPER_sys_link_homepage = { { "hotlight" , NULL, 0 }, { "hotlight" , NULL, 0 }, { NULL, NULL, 0 }, false };
  401. static const Hyperlink HYPER_sys_link_normal = { { "hotlight" , NULL, 0 }, { "hotlight" , NULL, 0 }, { NULL, NULL, 0 }, false };
  402. static const Hyperlink HYPER_sys_link_splash = { { "hotlight" , NULL, 0 }, { "hotlight" , NULL, 0 }, { NULL, NULL, 0 }, false };
  403. /*fHorizontal fReturnToZero*/
  404. static const Gradient GRAD_sys_bottompane_header_bgcolor = { { "buttonface" , NULL, 0 }, { "buttonface" , NULL, 0 }, true , false };
  405. static const Gradient GRAD_sys_header_gradient_H = { { "activecaption", NULL, 0 }, { "window" , NULL, 0 }, true , true };
  406. static const Gradient GRAD_sys_header_gradient_V = { { "window" , NULL, 0 }, { "buttonface" , NULL, 0 }, false , true };
  407. static const Gradient GRAD_sys_lhp_bgcolor = { { "window" , NULL, 0 }, { "window" , NULL, 0 }, false , false };
  408. static const Gradient GRAD_sys_RA_gradient_H = { { "window" , NULL, 0 }, { "window" , NULL, 0 }, true , false };
  409. static const Gradient GRAD_sys_RA_gradient_V = { { "window" , NULL, 0 }, { "window" , NULL, 0 }, false , true };
  410. static const Gradient GRAD_sys_table_cell_bgcolor5 = { { "window" , NULL, 0 }, { "window" , NULL, 0 }, true , false };
  411. static const Gradient GRAD_sys_toppane_header_bgcolor = { { "activecaption", NULL, 0 }, { "activecaption", NULL, 0 }, true , false };
  412. static const Gradient GRAD_sys_background_strong = { { "window" , NULL, 0 }, { "window" , NULL, 0 }, true , false };
  413. ////////////////////
  414. static const ElementFONT rgFONT[] =
  415. {
  416. { &NAME_sys_font_body , & FONT_sys_font_body },
  417. { &NAME_sys_font_body_bold, & FONT_sys_font_body_bold },
  418. { &NAME_sys_font_heading1 , & FONT_sys_font_heading1 },
  419. { &NAME_sys_font_heading2 , & FONT_sys_font_heading2 },
  420. { &NAME_sys_font_heading3 , & FONT_sys_font_heading3 },
  421. { &NAME_sys_font_heading4 , & FONT_sys_font_heading4 },
  422. };
  423. static const ElementCOLOR rgCOLOR[] =
  424. {
  425. { &NAME_sys_bottompane_header_color, &COLOR_sys_bottompane_header_color },
  426. { &NAME_sys_color_body , &COLOR_sys_color_body },
  427. { &NAME_sys_color_body_alert , &COLOR_sys_color_body_alert },
  428. { &NAME_sys_color_body_helpee , &COLOR_sys_color_body_helpee },
  429. { &NAME_sys_color_body_helper , &COLOR_sys_color_body_helper },
  430. { &NAME_sys_color_body_ok , &COLOR_sys_color_body_ok },
  431. { &NAME_sys_color_body_sec , &COLOR_sys_color_body_sec },
  432. { &NAME_sys_header_color , &COLOR_sys_header_color },
  433. { &NAME_sys_header_color_logo , &COLOR_sys_header_color_logo },
  434. { &NAME_sys_homepage_color , &COLOR_sys_homepage_color },
  435. { &NAME_sys_lhp_color , &COLOR_sys_lhp_color },
  436. { &NAME_sys_rhp_color_title , &COLOR_sys_rhp_color_title },
  437. { &NAME_sys_rhp_splash_color , &COLOR_sys_rhp_splash_color },
  438. { &NAME_sys_rhp_splash_color_title , &COLOR_sys_rhp_splash_color_title },
  439. { &NAME_sys_toppane_header_color , &COLOR_sys_toppane_header_color },
  440. };
  441. static const ElementBACKGROUND rgBACKGROUND[] =
  442. {
  443. { &NAME_sys_bottompane_bgcolor , &COLOR_sys_bottompane_bgcolor },
  444. { &NAME_sys_header_bgcolor , &COLOR_sys_header_bgcolor },
  445. { &NAME_sys_homepage_bgcolor , &COLOR_sys_homepage_bgcolor },
  446. { &NAME_sys_inlineform_bgcolor1 , &COLOR_sys_inlineform_bgcolor1 },
  447. { &NAME_sys_inlineform_bgcolor2 , &COLOR_sys_inlineform_bgcolor2 },
  448. { &NAME_sys_inlineform_bgcolor3 , &COLOR_sys_inlineform_bgcolor3 },
  449. { &NAME_sys_lhp_bgcolor_scope , &COLOR_sys_lhp_bgcolor_scope },
  450. { &NAME_sys_rhp_bgcolor , &COLOR_sys_rhp_bgcolor },
  451. { &NAME_sys_rhp_splash_bgcolor , &COLOR_sys_rhp_splash_bgcolor },
  452. { &NAME_sys_table_cell_bgcolor1 , &COLOR_sys_table_cell_bgcolor1 },
  453. { &NAME_sys_table_cell_bgcolor2 , &COLOR_sys_table_cell_bgcolor2 },
  454. { &NAME_sys_table_cell_bgcolor3 , &COLOR_sys_table_cell_bgcolor3 },
  455. { &NAME_sys_table_cell_bgcolor4 , &COLOR_sys_table_cell_bgcolor4 },
  456. { &NAME_sys_table_header_bgcolor1, &COLOR_sys_table_header_bgcolor1 },
  457. { &NAME_sys_table_header_bgcolor2, &COLOR_sys_table_header_bgcolor2 },
  458. { &NAME_sys_toppane_bgcolor , &COLOR_sys_toppane_bgcolor },
  459. { &NAME_sys_toppane_selection , &COLOR_sys_toppane_selection },
  460. };
  461. static const ElementBORDER rgBORDER[] =
  462. {
  463. { &NAME_sys_bottompane_color_border, &COLOR_sys_bottompane_color_border },
  464. { &NAME_sys_table_color_border , &COLOR_sys_table_color_border },
  465. { &NAME_sys_toppane_color_border , &COLOR_sys_toppane_color_border },
  466. };
  467. static const ElementGRADIENT rgGRADIENT[] =
  468. {
  469. { &NAME_sys_bottompane_header_bgcolor, &GRAD_sys_bottompane_header_bgcolor },
  470. { &NAME_sys_header_gradient_H , &GRAD_sys_header_gradient_H },
  471. { &NAME_sys_header_gradient_V , &GRAD_sys_header_gradient_V },
  472. { &NAME_sys_background_strong , &GRAD_sys_background_strong },
  473. { &NAME_sys_lhp_bgcolor , &GRAD_sys_lhp_bgcolor },
  474. { &NAME_sys_RA_gradient_H , &GRAD_sys_RA_gradient_H },
  475. { &NAME_sys_RA_gradient_V , &GRAD_sys_RA_gradient_V },
  476. { &NAME_sys_table_cell_bgcolor5 , &GRAD_sys_table_cell_bgcolor5 },
  477. { &NAME_sys_toppane_header_bgcolor , &GRAD_sys_toppane_header_bgcolor },
  478. };
  479. static const ElementHYPERLINK rgHYPERLINK[] =
  480. {
  481. { &NAME_sys_link_header , &HYPER_sys_link_header },
  482. { &NAME_sys_link_homepage, &HYPER_sys_link_homepage },
  483. { &NAME_sys_link_normal , &HYPER_sys_link_normal },
  484. { &NAME_sys_link_splash , &HYPER_sys_link_splash },
  485. };
  486. static const StyleSheet g_def =
  487. {
  488. L"Classic",
  489. rgFONT , ARRAYSIZE(rgFONT ),
  490. rgCOLOR , ARRAYSIZE(rgCOLOR ),
  491. rgBACKGROUND, ARRAYSIZE(rgBACKGROUND),
  492. rgBORDER , ARRAYSIZE(rgBORDER ),
  493. rgGRADIENT , ARRAYSIZE(rgGRADIENT ),
  494. rgHYPERLINK , ARRAYSIZE(rgHYPERLINK ),
  495. };
  496. }
  497. ////////////////////////////////////////////////////////////////////////////////
  498. static const StyleSheet* g_def[] =
  499. {
  500. &THEME_Luna ::g_def,
  501. &THEME_Classic::g_def,
  502. };
  503. ////////////////////////////////////////////////////////////////////////////////
  504. ////////////////////////////////////////////////////////////////////////////////
  505. void Font::Generate( /*[in]*/ Environment& env ) const
  506. {
  507. CHAR rgName [64];
  508. CHAR rgSize [64];
  509. CHAR rgStyle[64];
  510. strncpy( rgName , SAFEASTR(m_szName ), MAXSTRLEN(rgName ) );
  511. strncpy( rgSize , SAFEASTR(m_szSize ), MAXSTRLEN(rgSize ) );
  512. strncpy( rgStyle, SAFEASTR(m_szStyle), MAXSTRLEN(rgStyle) );
  513. if(!strcmp( rgName, "messagebox" ))
  514. {
  515. strncpy( rgName , env.m_ncm.lfMessageFont.lfFaceName, MAXSTRLEN(rgName) );
  516. sprintf( rgSize , "%dpt", -env.m_ncm.lfMessageFont.lfHeight * 72 / env.m_iPixel );
  517. }
  518. env.AddAttribute( "font-family", rgName );
  519. env.AddAttribute( "font-size ", rgSize );
  520. env.AddAttribute( "font-style ", rgStyle );
  521. env.AddAttribute( "font-weight", m_szWeight );
  522. }
  523. HRESULT Font::LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn )
  524. {
  525. __HCP_FUNC_ENTRY( "Font::LoadFromXML" );
  526. HRESULT hr;
  527. __MPC_EXIT_IF_METHOD_FAILS(hr, env.GetValue( xdn, L"FAMILY", m_szName ));
  528. (void) env.GetValue( xdn, L"SIZE" , m_szSize );
  529. (void) env.GetValue( xdn, L"STYLE" , m_szStyle );
  530. (void) env.GetValue( xdn, L"WEIGHT", m_szWeight );
  531. hr = S_OK;
  532. __HCP_FUNC_CLEANUP;
  533. __HCP_FUNC_EXIT(hr);
  534. }
  535. void Font::Release()
  536. {
  537. free( (void*)m_szName );
  538. free( (void*)m_szSize );
  539. free( (void*)m_szStyle );
  540. free( (void*)m_szWeight );
  541. }
  542. #ifdef DEBUG
  543. HRESULT Font::GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const
  544. {
  545. __HCP_FUNC_ENTRY( "Font::GenerateXML" );
  546. HRESULT hr;
  547. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"FAMILY", m_szName ));
  548. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"SIZE" , m_szSize ));
  549. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"STYLE" , m_szStyle ));
  550. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"WEIGHT", m_szWeight ));
  551. hr = S_OK;
  552. __HCP_FUNC_CLEANUP;
  553. __HCP_FUNC_EXIT(hr);
  554. }
  555. #endif
  556. ////////////////////
  557. inline int ScaleColor( int iColor1, int iColor2, int iRatio )
  558. {
  559. iColor1 += ((iColor2 - iColor1) * iRatio) / 100;
  560. if(iColor1 < 0) iColor1 = 0;
  561. if(iColor1 > 255) iColor1 = 255;
  562. return iColor1;
  563. }
  564. void Color::Generate( /*[in]*/ Environment& env ,
  565. /*[in]*/ LPCSTR szStyle ) const
  566. {
  567. char rgBuf[128];
  568. COLORREF color1;
  569. COLORREF color2;
  570. bool fSystem1;
  571. bool fSystem2;
  572. if(!MPC::HTML::ConvertColor( CComVariant( m_szDef1 ), color1, fSystem1 ))
  573. {
  574. env.AddAttribute( szStyle, m_szDef1 );
  575. return;
  576. }
  577. if(m_szDef2 && MPC::HTML::ConvertColor( CComVariant( m_szDef2 ), color2, fSystem2 ))
  578. {
  579. sprintf( rgBuf, "#%02x%02x%02x" ,
  580. ScaleColor( GetRValue(color1), GetRValue(color2), m_iRatio ) ,
  581. ScaleColor( GetGValue(color1), GetGValue(color2), m_iRatio ) ,
  582. ScaleColor( GetBValue(color1), GetBValue(color2), m_iRatio ) );
  583. }
  584. else
  585. {
  586. sprintf( rgBuf, "#%02x%02x%02x" ,
  587. GetRValue(color1) ,
  588. GetGValue(color1) ,
  589. GetBValue(color1) );
  590. }
  591. #ifdef DEBUG
  592. if(strcmp( rgBuf, m_szDef1 ))
  593. {
  594. char rgBuf2[256];
  595. if(m_szDef1 && m_szDef2)
  596. {
  597. sprintf( rgBuf2, " /* %s -> %s at %d%% */", m_szDef1, m_szDef2, m_iRatio );
  598. }
  599. else
  600. {
  601. sprintf( rgBuf2, " /* %s */", m_szDef1 );
  602. }
  603. strcat( rgBuf, rgBuf2 );
  604. }
  605. #endif
  606. env.AddAttribute( szStyle, rgBuf );
  607. }
  608. HRESULT Color::LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn )
  609. {
  610. __HCP_FUNC_ENTRY( "Color::LoadFromXML" );
  611. HRESULT hr;
  612. __MPC_EXIT_IF_METHOD_FAILS(hr, env.GetValue( xdn, L"VALUE" , m_szDef1 ));
  613. (void) env.GetValue( xdn, L"VALUE_100", m_szDef2 );
  614. (void) env.GetValue( xdn, L"PERCENT" , m_iRatio );
  615. hr = S_OK;
  616. __HCP_FUNC_CLEANUP;
  617. __HCP_FUNC_EXIT(hr);
  618. }
  619. void Color::Release()
  620. {
  621. free( (void*)m_szDef1 );
  622. free( (void*)m_szDef2 );
  623. }
  624. #ifdef DEBUG
  625. HRESULT Color::GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const
  626. {
  627. __HCP_FUNC_ENTRY( "Color::GenerateXML" );
  628. HRESULT hr;
  629. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"VALUE" , m_szDef1 ));
  630. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"VALUE_100", m_szDef2 ));
  631. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"PERCENT" , m_iRatio ));
  632. hr = S_OK;
  633. __HCP_FUNC_CLEANUP;
  634. __HCP_FUNC_EXIT(hr);
  635. }
  636. #endif
  637. ////////////////////
  638. void Gradient::Generate( /*[in]*/ Environment& env ) const
  639. {
  640. env .AddAttribute( "behavior " , "url(#default#pch_gradient)" );
  641. m_start.Generate ( env, "start-color " );
  642. m_end .Generate ( env, "end-color " );
  643. env .AddAttribute( "gradient-type " , m_fHorizontal ? "1" : "0" );
  644. env .AddAttribute( "return-to-zero" , m_fReturnToZero ? "1" : "0" );
  645. }
  646. HRESULT Gradient::LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn )
  647. {
  648. __HCP_FUNC_ENTRY( "Gradient::LoadFromXML" );
  649. HRESULT hr;
  650. MPC::XmlUtil xml( xdn );
  651. {
  652. CComPtr<IXMLDOMNode> xdn2;
  653. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetNode( L"COLOR_START", &xdn2 ));
  654. __MPC_EXIT_IF_METHOD_FAILS(hr, m_start.LoadFromXML( env, xdn2 ));
  655. }
  656. {
  657. CComPtr<IXMLDOMNode> xdn2;
  658. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetNode( L"COLOR_END", &xdn2 ));
  659. __MPC_EXIT_IF_METHOD_FAILS(hr, m_end.LoadFromXML( env, xdn2 ));
  660. }
  661. (void)env.GetValue( xdn, L"HORIZONTAL" , m_fHorizontal );
  662. (void)env.GetValue( xdn, L"RETURNTOZERO", m_fReturnToZero );
  663. hr = S_OK;
  664. __HCP_FUNC_CLEANUP;
  665. __HCP_FUNC_EXIT(hr);
  666. }
  667. void Gradient::Release()
  668. {
  669. m_start.Release();
  670. m_end .Release();
  671. }
  672. #ifdef DEBUG
  673. HRESULT Gradient::GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const
  674. {
  675. __HCP_FUNC_ENTRY( "Gradient::GenerateXML" );
  676. HRESULT hr;
  677. CComPtr<IXMLDOMNode> xdnSub;
  678. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"COLOR_START", &xdnSub, xdn )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_start.GenerateXML( env, xml, xdnSub )); xdnSub.Release();
  679. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"COLOR_END" , &xdnSub, xdn )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_end .GenerateXML( env, xml, xdnSub )); xdnSub.Release();
  680. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"HORIZONTAL" , m_fHorizontal ));
  681. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"RETURNTOZERO", m_fReturnToZero ));
  682. hr = S_OK;
  683. __HCP_FUNC_CLEANUP;
  684. __HCP_FUNC_EXIT(hr);
  685. }
  686. #endif
  687. ////////////////////
  688. void Hyperlink::Generate( /*[in]*/ Environment& env ,
  689. /*[in]*/ PseudoClass cls ) const
  690. {
  691. const Color* color;
  692. bool fFlag;
  693. switch(cls)
  694. {
  695. case PC_NORMAL: color = &m_colorNormal; fFlag = m_fUnderlineAlways; break;
  696. case PC_HOVER : color = &m_colorHover ; fFlag = true ; break;
  697. case PC_ACTIVE: color = &m_colorActive; fFlag = m_fUnderlineAlways; break;
  698. }
  699. if(!color->m_szDef1) color = &m_colorNormal;
  700. color->Generate ( env, "color " );
  701. env.AddAttribute( "text-decoration", fFlag ? "underline" : "none" );
  702. }
  703. HRESULT Hyperlink::LoadFromXML( /*[in]*/ Environment& env, /*[in]*/ IXMLDOMNode *xdn )
  704. {
  705. __HCP_FUNC_ENTRY( "Hyperlink::LoadFromXML" );
  706. HRESULT hr;
  707. MPC::XmlUtil xml( xdn );
  708. {
  709. CComPtr<IXMLDOMNode> xdn2;
  710. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetNode( L"NORMAL", &xdn2 ));
  711. __MPC_EXIT_IF_METHOD_FAILS(hr, m_colorNormal.LoadFromXML( env, xdn2 ));
  712. }
  713. {
  714. CComPtr<IXMLDOMNode> xdn2;
  715. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetNode( L"HOVER", &xdn2 ));
  716. __MPC_EXIT_IF_METHOD_FAILS(hr, m_colorHover.LoadFromXML( env, xdn2 ));
  717. }
  718. {
  719. CComPtr<IXMLDOMNode> xdn2;
  720. if(SUCCEEDED(xml.GetNode( L"ACTIVE", &xdn2 )))
  721. {
  722. (void)m_colorActive.LoadFromXML( env, xdn2 );
  723. }
  724. }
  725. (void)env.GetValue( xdn, L"UNDERLINEALWAYS", m_fUnderlineAlways );
  726. hr = S_OK;
  727. __HCP_FUNC_CLEANUP;
  728. __HCP_FUNC_EXIT(hr);
  729. }
  730. void Hyperlink::Release()
  731. {
  732. m_colorNormal.Release();
  733. m_colorHover .Release();
  734. m_colorActive.Release();
  735. }
  736. #ifdef DEBUG
  737. HRESULT Hyperlink::GenerateXML( /*[in]*/ Environment& env, /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode *xdn ) const
  738. {
  739. __HCP_FUNC_ENTRY( "Hyperlink::GenerateXML" );
  740. HRESULT hr;
  741. CComPtr<IXMLDOMNode> xdnSub;
  742. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"NORMAL", &xdnSub, xdn )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_colorNormal.GenerateXML( env, xml, xdnSub )); xdnSub.Release();
  743. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"HOVER" , &xdnSub, xdn )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_colorHover .GenerateXML( env, xml, xdnSub )); xdnSub.Release();
  744. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"ACTIVE", &xdnSub, xdn )); __MPC_EXIT_IF_METHOD_FAILS(hr, m_colorActive.GenerateXML( env, xml, xdnSub )); xdnSub.Release();
  745. __MPC_EXIT_IF_METHOD_FAILS(hr, env.CreateValue( xml, xdn, L"UNDERLINEALWAYS", m_fUnderlineAlways ));
  746. hr = S_OK;
  747. __HCP_FUNC_CLEANUP;
  748. __HCP_FUNC_EXIT(hr);
  749. }
  750. #endif
  751. ////////////////////////////////////////////////////////////////////////////////
  752. Environment::Environment( /*[in]*/ MPC::string& strOutput ) : m_strOutput( strOutput )
  753. {
  754. // MPC::string& m_strOutput;
  755. // NONCLIENTMETRICSA m_ncm;
  756. // int m_iPixel;
  757. //
  758. // MPC::XmlUtil m_xmlOEM;
  759. m_fOEM = false; // bool m_fOEM;
  760. m_fCustomizing = false; // bool m_fCustomizing;
  761. }
  762. HRESULT Environment::Init()
  763. {
  764. __HCP_FUNC_ENTRY( "Environment::Init" );
  765. HRESULT hr;
  766. HDC hdc = NULL;
  767. m_ncm.cbSize = sizeof(NONCLIENTMETRICSA);
  768. __MPC_EXIT_IF_CALL_RETURNS_FALSE(hr, ::SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, 0, &m_ncm, 0 ));
  769. __MPC_EXIT_IF_CALL_RETURNS_NULL(hr, hdc = ::CreateCompatibleDC( NULL ));
  770. m_iPixel = ::GetDeviceCaps( hdc, LOGPIXELSY ); if(!m_iPixel) m_iPixel = 60; // Pick a default.
  771. m_strOutput.reserve( 16384 );
  772. m_strOutput.assign( "/*\n"
  773. "** Copyright (c) 2001 Microsoft Corporation\n"
  774. "*/\n\n"
  775. "BODY\n"
  776. "{\n"
  777. "\tcursor : default;\n"
  778. "\tmargin : 0px;\n"
  779. "}\n\n" );
  780. hr = S_OK;
  781. __HCP_FUNC_CLEANUP;
  782. if(hdc) ::DeleteDC( hdc );
  783. __HCP_FUNC_EXIT(hr);
  784. }
  785. void Environment::OpenClass( /*[in]*/ const ElementName* name, /*[in]*/ LPCSTR szPrefix, /*[in]*/ LPCSTR szSuffix )
  786. {
  787. #ifdef DEBUG
  788. if(name->m_szComment)
  789. {
  790. m_strOutput.append( "/* " );
  791. m_strOutput.append( name->m_szComment );
  792. m_strOutput.append( " */\n" );
  793. }
  794. #endif
  795. if(szPrefix) m_strOutput.append( szPrefix );
  796. m_strOutput.append( name->m_szName );
  797. if(szSuffix) m_strOutput.append( szSuffix );
  798. m_strOutput.append( "\n{\n" );
  799. }
  800. void Environment::AddAttribute( /*[in]*/ LPCSTR szName, /*[in]*/ LPCSTR szValue )
  801. {
  802. if(STRINGISPRESENT(szValue))
  803. {
  804. m_strOutput.append( " " );
  805. m_strOutput.append( szName );
  806. m_strOutput.append( " : " );
  807. m_strOutput.append( szValue );
  808. m_strOutput.append( ";\n" );
  809. }
  810. }
  811. void Environment::CloseClass()
  812. {
  813. m_strOutput.append( "}\n\n" );
  814. }
  815. void Environment::GenerateClass( /*[in]*/ const ElementFONT& ptr )
  816. {
  817. if(IsCustomizationPresent( ptr.m_name )) return;
  818. OpenClass( ptr.m_name );
  819. ptr.m_font->Generate( *this );
  820. CloseClass();
  821. }
  822. void Environment::GenerateClass( /*[in]*/ const ElementCOLOR& ptr )
  823. {
  824. if(IsCustomizationPresent( ptr.m_name )) return;
  825. OpenClass( ptr.m_name );
  826. ptr.m_color->Generate( *this, "color" );
  827. CloseClass();
  828. }
  829. void Environment::GenerateClass( /*[in]*/ const ElementBACKGROUND& ptr )
  830. {
  831. if(IsCustomizationPresent( ptr.m_name )) return;
  832. OpenClass( ptr.m_name );
  833. ptr.m_color->Generate( *this, "background-color" );
  834. CloseClass();
  835. }
  836. void Environment::GenerateClass( /*[in]*/ const ElementBORDER& ptr )
  837. {
  838. if(IsCustomizationPresent( ptr.m_name )) return;
  839. OpenClass( ptr.m_name );
  840. ptr.m_color->Generate( *this, "border-color" );
  841. CloseClass();
  842. }
  843. void Environment::GenerateClass( /*[in]*/ const ElementGRADIENT& ptr )
  844. {
  845. if(IsCustomizationPresent( ptr.m_name )) return;
  846. OpenClass( ptr.m_name );
  847. ptr.m_gradient->Generate( *this );
  848. CloseClass();
  849. }
  850. void Environment::GenerateClass( /*[in]*/ const ElementHYPERLINK& ptr )
  851. {
  852. if(IsCustomizationPresent( ptr.m_name )) return;
  853. OpenClass( ptr.m_name, "A" );
  854. ptr.m_hyperlink->Generate( *this, Hyperlink::PC_NORMAL );
  855. CloseClass();
  856. OpenClass( ptr.m_name, "A", ":hover" );
  857. ptr.m_hyperlink->Generate( *this, Hyperlink::PC_HOVER );
  858. CloseClass();
  859. OpenClass( ptr.m_name, "A", ":active" );
  860. ptr.m_hyperlink->Generate( *this, Hyperlink::PC_ACTIVE );
  861. CloseClass();
  862. }
  863. ////////////////////
  864. #define MACRO_CHECK_CUSTOMIZATION( text, objectCls, elementCls ) \
  865. if(!MPC::StrICmp( bstrValue, text )) \
  866. { \
  867. objectCls obj; ::ZeroMemory( &obj, sizeof(obj) ); \
  868. \
  869. if(SUCCEEDED(obj.LoadFromXML( *this, node ))) \
  870. { \
  871. elementCls elem = { name, &obj }; \
  872. \
  873. GenerateClass( elem ); \
  874. fProcessed = true; \
  875. } \
  876. \
  877. obj.Release(); \
  878. }
  879. bool Environment::IsCustomizationPresent( /*[in]*/ const ElementName* name )
  880. {
  881. bool fProcessed = false;
  882. if(m_fOEM && m_fCustomizing == false)
  883. {
  884. CComBSTR bstrName( name->m_szName );
  885. CComPtr<IXMLDOMNodeList> lst;
  886. bool fLoaded;
  887. bool fFound;
  888. m_fCustomizing = true;
  889. if(SUCCEEDED(m_xmlOEM.GetNodes( L"CLASS", &lst )) && lst)
  890. {
  891. CComPtr<IXMLDOMNode> node;
  892. for(;SUCCEEDED(lst->nextNode( &node )) && node != NULL; node = NULL)
  893. {
  894. CComBSTR bstrValue;
  895. if(SUCCEEDED(m_xmlOEM.GetAttribute( NULL, L"NAME", bstrValue, fFound, node )) && fFound)
  896. {
  897. if(!MPC::StrICmp( bstrName, bstrValue ))
  898. {
  899. if(SUCCEEDED(m_xmlOEM.GetAttribute( NULL, L"TYPE", bstrValue, fFound, node )) && fFound)
  900. {
  901. MACRO_CHECK_CUSTOMIZATION( L"BGCOLOR" , Color , ElementBACKGROUND );
  902. MACRO_CHECK_CUSTOMIZATION( L"BORDER" , Color , ElementBORDER );
  903. MACRO_CHECK_CUSTOMIZATION( L"COLOR" , Color , ElementCOLOR );
  904. MACRO_CHECK_CUSTOMIZATION( L"FONT" , Font , ElementFONT );
  905. MACRO_CHECK_CUSTOMIZATION( L"GRADIENT" , Gradient , ElementGRADIENT );
  906. MACRO_CHECK_CUSTOMIZATION( L"HYPERLINK", Hyperlink, ElementHYPERLINK );
  907. }
  908. break;
  909. }
  910. }
  911. }
  912. }
  913. m_fCustomizing = false;
  914. }
  915. return fProcessed;
  916. }
  917. ////////////////////
  918. HRESULT Environment::GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ CComVariant& v )
  919. {
  920. __HCP_FUNC_ENTRY( "Environment::GetValue" );
  921. HRESULT hr;
  922. MPC::XmlUtil xml( xdn );
  923. bool fFound;
  924. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetValue( szName, v, fFound ));
  925. if(!fFound)
  926. {
  927. __MPC_SET_ERROR_AND_EXIT(hr, E_FAIL);
  928. }
  929. hr = S_OK;
  930. __HCP_FUNC_CLEANUP;
  931. __HCP_FUNC_EXIT(hr);
  932. }
  933. HRESULT Environment::GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ LPCSTR& v )
  934. {
  935. __HCP_FUNC_ENTRY( "Environment::GetValue" );
  936. USES_CONVERSION;
  937. HRESULT hr;
  938. CComVariant v2;
  939. LPCSTR val;
  940. __MPC_EXIT_IF_METHOD_FAILS(hr, GetValue( xdn, szName, v2 ));
  941. __MPC_EXIT_IF_METHOD_FAILS(hr, v2.ChangeType( VT_BSTR ));
  942. if(v2.bstrVal)
  943. {
  944. val = W2A( v2.bstrVal );
  945. }
  946. else
  947. {
  948. val = "";
  949. }
  950. __MPC_EXIT_IF_ALLOC_FAILS(hr, v, _strdup( val ));
  951. hr = S_OK;
  952. __HCP_FUNC_CLEANUP;
  953. __HCP_FUNC_EXIT(hr);
  954. }
  955. HRESULT Environment::GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ int& v )
  956. {
  957. __HCP_FUNC_ENTRY( "Environment::GetValue" );
  958. USES_CONVERSION;
  959. HRESULT hr;
  960. CComVariant v2;
  961. __MPC_EXIT_IF_METHOD_FAILS(hr, GetValue( xdn, szName, v2 ));
  962. __MPC_EXIT_IF_METHOD_FAILS(hr, v2.ChangeType( VT_I4 ));
  963. v = v2.lVal;
  964. hr = S_OK;
  965. __HCP_FUNC_CLEANUP;
  966. __HCP_FUNC_EXIT(hr);
  967. }
  968. HRESULT Environment::GetValue( /*[in]*/ IXMLDOMNode *xdn, /*[in]*/ LPCWSTR szName, /*[out]*/ bool& v )
  969. {
  970. __HCP_FUNC_ENTRY( "Environment::GetValue" );
  971. USES_CONVERSION;
  972. HRESULT hr;
  973. CComVariant v2;
  974. __MPC_EXIT_IF_METHOD_FAILS(hr, GetValue( xdn, szName, v2 ));
  975. __MPC_EXIT_IF_METHOD_FAILS(hr, v2.ChangeType( VT_BOOL ));
  976. v = (v2.boolVal == VARIANT_TRUE);
  977. hr = S_OK;
  978. __HCP_FUNC_CLEANUP;
  979. __HCP_FUNC_EXIT(hr);
  980. }
  981. ////////////////////
  982. HRESULT Environment::GenerateStyleSheet( /*[in]*/ const StyleSheet& def )
  983. {
  984. __HCP_FUNC_ENTRY( "GenerateStyleSheet" );
  985. HRESULT hr;
  986. int i;
  987. __MPC_EXIT_IF_METHOD_FAILS(hr, Init());
  988. {
  989. bool fLoaded;
  990. bool fFound;
  991. if(SUCCEEDED(m_xmlOEM.Load( L"hcp://system/css/shared.xml", L"STYLESHEET", fLoaded, &fFound )) && fLoaded && fFound)
  992. {
  993. CComPtr<IXMLDOMNodeList> lst;
  994. if(SUCCEEDED(m_xmlOEM.GetNodes( L"THEME", &lst )) && lst)
  995. {
  996. CComPtr<IXMLDOMNode> node;
  997. for(;SUCCEEDED(lst->nextNode( &node )) && node != NULL; node = NULL)
  998. {
  999. CComBSTR bstrName;
  1000. if(SUCCEEDED(m_xmlOEM.GetAttribute( NULL, L"NAME", bstrName, fFound, node )) && fFound)
  1001. {
  1002. if(!MPC::StrICmp( bstrName, def.m_szName ))
  1003. {
  1004. m_xmlOEM = node;
  1005. m_fOEM = true;
  1006. break;
  1007. }
  1008. }
  1009. }
  1010. }
  1011. }
  1012. }
  1013. for(i=0; i<def.m_iFonts ; i++) GenerateClass( def.m_fonts [i] );
  1014. for(i=0; i<def.m_iColors ; i++) GenerateClass( def.m_colors [i] );
  1015. for(i=0; i<def.m_iBackgrounds; i++) GenerateClass( def.m_backgrounds[i] );
  1016. for(i=0; i<def.m_iBorders ; i++) GenerateClass( def.m_borders [i] );
  1017. for(i=0; i<def.m_iGradients ; i++) GenerateClass( def.m_gradients [i] );
  1018. for(i=0; i<def.m_iHyperlinks ; i++) GenerateClass( def.m_hyperlinks [i] );
  1019. hr = S_OK;
  1020. __HCP_FUNC_CLEANUP;
  1021. __HCP_FUNC_EXIT(hr);
  1022. }
  1023. ////////////////////
  1024. #ifdef DEBUG
  1025. HRESULT Environment::CreateNode( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ const ElementName* elem, /*[in]*/ LPCWSTR szType, /*[in/out]*/ CComPtr<IXMLDOMNode>& xdn )
  1026. {
  1027. __HCP_FUNC_ENTRY( "Environment::CreateNode" );
  1028. HRESULT hr;
  1029. bool fFound;
  1030. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"CLASS", &xdn ));
  1031. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.PutAttribute( NULL, L"NAME", elem->m_szName, fFound, xdn ));
  1032. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.PutAttribute( NULL, L"TYPE", szType , fFound, xdn ));
  1033. if(STRINGISPRESENT(elem->m_szComment))
  1034. {
  1035. CComPtr<IXMLDOMDocument> doc;
  1036. CComPtr<IXMLDOMComment> xdc;
  1037. CComPtr<IXMLDOMNode> xdn2;
  1038. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.GetDocument( &doc ));
  1039. __MPC_EXIT_IF_METHOD_FAILS(hr, doc->createComment( CComBSTR( elem->m_szComment ), &xdc ));
  1040. __MPC_EXIT_IF_METHOD_FAILS(hr, xdn->appendChild( xdc, &xdn2 ));
  1041. }
  1042. hr = S_OK;
  1043. __HCP_FUNC_CLEANUP;
  1044. __HCP_FUNC_EXIT(hr);
  1045. }
  1046. HRESULT Environment::CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ LPCSTR szValue )
  1047. {
  1048. // if(!STRINGISPRESENT(szValue)) return S_OK;
  1049. return CreateValue( xml, xdn, szName, CComVariant( szValue ) );
  1050. }
  1051. HRESULT Environment::CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ bool fValue )
  1052. {
  1053. return CreateValue( xml, xdn, szName, CComVariant( fValue ? L"TRUE" : L"FALSE" ) );
  1054. }
  1055. HRESULT Environment::CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ int iValue )
  1056. {
  1057. // if(iValue == 0) return S_OK;
  1058. return CreateValue( xml, xdn, szName, CComVariant( iValue ) );
  1059. }
  1060. HRESULT Environment::CreateValue( /*[in]*/ MPC::XmlUtil& xml, /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ LPCWSTR szName, /*[in]*/ CComVariant& vValue )
  1061. {
  1062. __HCP_FUNC_ENTRY( "Environment::CreateValue" );
  1063. HRESULT hr;
  1064. CComPtr<IXMLDOMNode> xdnSub;
  1065. bool fFound;
  1066. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( szName, &xdnSub, xdn ));
  1067. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.PutValue( NULL, vValue, fFound, xdnSub ));
  1068. hr = S_OK;
  1069. __HCP_FUNC_CLEANUP;
  1070. __HCP_FUNC_EXIT(hr);
  1071. }
  1072. HRESULT Environment::GenerateStyleSheetXML( /*[in]*/ IXMLDOMNode* xdn, /*[in]*/ const StyleSheet& def )
  1073. {
  1074. __HCP_FUNC_ENTRY( "GenerateStyleSheetXML" );
  1075. HRESULT hr;
  1076. MPC::XmlUtil xml( xdn );
  1077. int i;
  1078. for(i=0; i<def.m_iFonts; i++)
  1079. {
  1080. const ElementFONT& ptr = def.m_fonts[i];
  1081. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"FONT", xdnSub ));
  1082. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_font->GenerateXML( *this, xml, xdnSub ));
  1083. }
  1084. for(i=0; i<def.m_iColors; i++)
  1085. {
  1086. const ElementCOLOR& ptr = def.m_colors[i];
  1087. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"COLOR", xdnSub ));
  1088. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_color->GenerateXML( *this, xml, xdnSub ));
  1089. }
  1090. for(i=0; i<def.m_iBackgrounds; i++)
  1091. {
  1092. const ElementBACKGROUND& ptr = def.m_backgrounds[i];
  1093. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"BGCOLOR", xdnSub ));
  1094. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_color->GenerateXML( *this, xml, xdnSub ));
  1095. }
  1096. for(i=0; i<def.m_iBorders; i++)
  1097. {
  1098. const ElementBORDER& ptr = def.m_borders[i];
  1099. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"BORDER", xdnSub ));
  1100. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_color->GenerateXML( *this, xml, xdnSub ));
  1101. }
  1102. for(i=0; i<def.m_iGradients; i++)
  1103. {
  1104. const ElementGRADIENT& ptr = def.m_gradients[i];
  1105. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"GRADIENT", xdnSub ));
  1106. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_gradient->GenerateXML( *this, xml, xdnSub ));
  1107. }
  1108. for(i=0; i<def.m_iHyperlinks; i++)
  1109. {
  1110. const ElementHYPERLINK& ptr = def.m_hyperlinks[i];
  1111. CComPtr<IXMLDOMNode> xdnSub; __MPC_EXIT_IF_METHOD_FAILS(hr, CreateNode( xml, ptr.m_name, L"HYPERLINK", xdnSub ));
  1112. __MPC_EXIT_IF_METHOD_FAILS(hr, ptr.m_hyperlink->GenerateXML( *this, xml, xdnSub ));
  1113. }
  1114. hr = S_OK;
  1115. __HCP_FUNC_CLEANUP;
  1116. __HCP_FUNC_EXIT(hr);
  1117. }
  1118. HRESULT Environment::DumpStyle()
  1119. {
  1120. __HCP_FUNC_ENTRY( "Environment::DumpStyle" );
  1121. HRESULT hr;
  1122. MPC::wstring strFile( L"%TEMP%\\HSS_style.css" ); MPC::SubstituteEnvVariables( strFile );
  1123. HANDLE hfFile = NULL;
  1124. DWORD dwWritten;
  1125. __MPC_EXIT_IF_INVALID_HANDLE__CLEAN(hr, hfFile, ::CreateFileW( strFile.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ));
  1126. __MPC_EXIT_IF_CALL_RETURNS_FALSE(hr, ::WriteFile( hfFile, m_strOutput.c_str(), m_strOutput.size(), &dwWritten, NULL ));
  1127. hr = S_OK;
  1128. __HCP_FUNC_CLEANUP;
  1129. if(hfFile) ::CloseHandle( hfFile );
  1130. __HCP_FUNC_EXIT(hr);
  1131. }
  1132. HRESULT Environment::DumpStyleXML()
  1133. {
  1134. __HCP_FUNC_ENTRY( "Environment::DumpStyleXML" );
  1135. HRESULT hr;
  1136. MPC::wstring strFile( L"%TEMP%\\HSS_style.xml" ); MPC::SubstituteEnvVariables( strFile );
  1137. MPC::XmlUtil xml;
  1138. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.New( L"STYLESHEET", L"UTF-8" ));
  1139. for(int i=0; i<ARRAYSIZE(g_def); i++)
  1140. {
  1141. CComPtr<IXMLDOMNode> xdn;
  1142. bool fFound;
  1143. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.CreateNode( L"THEME", &xdn ));
  1144. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.PutAttribute( NULL, L"NAME", g_def[i]->m_szName, fFound, xdn ));
  1145. __MPC_EXIT_IF_METHOD_FAILS(hr, GenerateStyleSheetXML( xdn, *(g_def[i]) ));
  1146. }
  1147. __MPC_EXIT_IF_METHOD_FAILS(hr, xml.Save( strFile.c_str() ));
  1148. hr = S_OK;
  1149. __HCP_FUNC_CLEANUP;
  1150. __HCP_FUNC_EXIT(hr);
  1151. }
  1152. #endif
  1153. ////////////////////////////////////////////////////////////////////////////////
  1154. HRESULT CHCPProtocolEnvironment::ProcessCSS()
  1155. {
  1156. HRESULT hr;
  1157. const StyleSheet* style = &THEME_Classic::g_def;
  1158. WCHAR rgName[MAX_PATH]; rgName[0] = 0;
  1159. if(m_strCSS.size()) return S_OK;
  1160. if(IsThemeActive())
  1161. {
  1162. WCHAR rgThemeFileName[MAX_PATH];
  1163. WCHAR rgColor [MAX_PATH];
  1164. WCHAR rgSize [MAX_PATH];
  1165. if(SUCCEEDED(GetCurrentThemeName( rgThemeFileName, MAXSTRLEN(rgThemeFileName) ,
  1166. rgColor , MAXSTRLEN(rgColor ) ,
  1167. rgSize , MAXSTRLEN(rgSize ) )))
  1168. {
  1169. if(SUCCEEDED(GetThemeDocumentationProperty( rgThemeFileName, SZ_THDOCPROP_CANONICALNAME, rgName, MAXSTRLEN( rgName ) )))
  1170. {
  1171. ;
  1172. }
  1173. else
  1174. {
  1175. rgName[0] = 0;
  1176. }
  1177. }
  1178. }
  1179. #ifdef DEBUG
  1180. if(g_Debug_FORCESTYLE[0])
  1181. {
  1182. wcsncpy( rgName, g_Debug_FORCESTYLE, MAXSTRLEN( rgName ) );
  1183. }
  1184. #endif
  1185. for(int i=0; i<ARRAYSIZE(g_def); i++)
  1186. {
  1187. if(!_wcsicmp( rgName, g_def[i]->m_szName ))
  1188. {
  1189. style = g_def[i];
  1190. break;
  1191. }
  1192. }
  1193. {
  1194. Environment env( m_strCSS );
  1195. hr = env.GenerateStyleSheet( *style );
  1196. #ifdef DEBUG
  1197. env.DumpStyle ();
  1198. env.DumpStyleXML();
  1199. #endif
  1200. }
  1201. return hr;
  1202. }