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.

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