PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/BotE Game/branch/plotnik/Source/include/CPPToolTip/PPHtmlDrawer.h

#
C++ Header | 618 lines | 385 code | 95 blank | 138 comment | 0 complexity | 4d40f3d4cda15e453c1a1c6951ef5132 MD5 | raw file
Possible License(s): GPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.0
  1. //
  2. // Class: CPPHtmlDrawer
  3. //
  4. // Compiler: Visual C++
  5. // Tested on: Visual C++ 6.0
  6. // Visual C++ .NET 2003
  7. //
  8. // Version: See GetVersionC() or GetVersionI()
  9. //
  10. // Created: xx/xxxx/2004
  11. // Updated: 21/November/2004
  12. //
  13. // Author: Eugene Pustovoyt pustovoyt@mail.ru
  14. //
  15. // Disclaimer
  16. // ----------
  17. // THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT
  18. // ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE
  19. // DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE
  20. // RISK OF USING THIS SOFTWARE.
  21. //
  22. // Terms of use
  23. // ------------
  24. // THIS SOFTWARE IS FREE FOR PERSONAL USE OR FREEWARE APPLICATIONS.
  25. // IF YOU WISH TO THANK MY WORK, YOU MAY DONATE ANY SUM OF MONEY TO ME
  26. // FOR SUPPORT OF DEVELOPMENT OF THIS CLASS.
  27. // IF YOU USE THIS SOFTWARE IN COMMERCIAL OR SHAREWARE APPLICATIONS YOU
  28. // ARE GENTLY ASKED TO DONATE ANY SUM OF MONEY TO THE AUTHOR:
  29. //
  30. //--- History ------------------------------
  31. // 2004/03/01 *** Releases version 1.0 ***
  32. //------------------------------------------
  33. // 2004/04/13 [ADD] Added a "speed" parameter to a <ilst> tag for animation
  34. // 2004/04/20 [ADD] For non-MFC program added STL class CStdString
  35. // 2004/05/05 [ADD] Added an EnableOutput method
  36. // [FIX] Fixed an error in SetImageList method (thanks to topus)
  37. //------------------------------------------
  38. // 2004/05/05 *** Releases version 1.1 ***
  39. //------------------------------------------
  40. // 2004/06/06 [FIX] Fixed an error on select a reference to the handle of the font
  41. // instead select a handle of the font
  42. // 2004/06/24 [ADD] Added SetMaxWidth and GetMaxWidth methods for supporting a text wrapping
  43. // [ADD] Added EnableTextWrap and IsTextWrapEnabled methods to sets a text wrap
  44. // mode or to retrieves a mode status.
  45. // [ADD] Added common character entities.
  46. // 2004/06/25 [ADD] Added SetTabSize method.
  47. // [ADD] Implemented a support to output a justified text.
  48. // [ADD] Added new <justify> tag to output a justified text.
  49. // 2004/07/18 [ADD] Support a disabled draw in the tables
  50. // 2004/09/07 [FIX] Fixed minor errors of drawing table's cells
  51. // 2004/10/13 [FIX] The last line of the paragraph alignment on fields now is not applied
  52. // 2004/10/20 [FIX] Fixed error in GetLengthUnit method. Thanks to Reinhard Steiner
  53. // 2004/10/26 [FIX] Corrected work of the justify for the multifont text in one line
  54. // [ADD] Support a word wrapping for the text with the images
  55. // 2004/10/28 [ADD] Now cx and cy parameters of the <ilst> tag is an optional information
  56. //------------------------------------------
  57. // 2004/10/30 *** Releases version 1.2 ***
  58. //------------------------------------------
  59. // 2004/11/30 [FIX] Fixed an error in the drawing nested tables
  60. // 2004/12/05 [CHN] Replaces CImageList to HIMAGELIST
  61. // [CHN] Replaces MFC classes (CSize, CPoint, CRect) to API structures
  62. // 2004/12/14 [FIX] Fixed an error in determinates of the hyperlink area
  63. // [FIX] Fixed an error in drawing of the horizontal line (<hr> tag)
  64. // 2005/01/15 [ADD] Not fixed columns will resize to the width of the client area
  65. // 2005/03/01 [FIX] Fixed an error of the imagelist drawing
  66. /////////////////////////////////////////////////////////////////////
  67. //
  68. // "GotoURL" function by Stuart Patterson
  69. // As seen in the August, 1997 Windows Developer's Journal.
  70. // Copyright 1997 by Miller Freeman, Inc. All rights reserved.
  71. // Modified by Chris Maunder to use TCHARs instead of chars.
  72. //
  73. // "Default hand cursor" from Paul DiLascia's Jan 1998 MSJ article.
  74. // Modified by Zorglab to use standard hand cursor on WinMe,2k,XP
  75. //
  76. /////////////////////////////////////////////////////////////////////
  77. #ifndef _PPHTMLDRAWER_H_
  78. #define _PPHTMLDRAWER_H_
  79. #if _MSC_VER > 1000
  80. #pragma once
  81. #endif // _MSC_VER > 1000
  82. #include "PPDrawManager.h"
  83. // disable warning C4786: symbol greater than 255 character, okay to ignore
  84. #ifdef _MSC_VER
  85. #pragma warning( disable : 4503 )
  86. #pragma warning( disable : 4786 )
  87. #endif
  88. #include <vector>
  89. #include <map>
  90. #ifdef _MFC_VER
  91. #define CPPString CString //MFC program
  92. #else
  93. #include "StdString.h"
  94. #ifdef _UNICODE
  95. #define CPPString CStdStringW //non-MFC program UNICODE
  96. #else
  97. #define CPPString CStdStringA //non-MFC program ANSI
  98. #endif
  99. #endif
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CPPHtmlDrawer window
  102. class CPPHtmlDrawer
  103. {
  104. // Construction
  105. public:
  106. CPPHtmlDrawer();
  107. // Attributes
  108. public:
  109. // Operations
  110. public:
  111. //Drawing methods
  112. void Draw(HDC hDC, LPCTSTR lpszHtml, LPPOINT lpPoint);
  113. void PrepareOutput(HDC hDC, LPCTSTR lpszHtml, LPSIZE lpSize); //Prepares to draw the HTML string
  114. void DrawPreparedOutput(HDC hDC, LPCRECT lpRect);
  115. void EnableEscapeSequences(BOOL bEnable = TRUE);
  116. void EnableOutput(BOOL bEnable = TRUE);
  117. void SetDisabledColor(COLORREF color);
  118. //Shadow of the image
  119. void SetImageShadow(int nOffsetX, int nOffsetY, BYTE nDarkenPercent = 50, BOOL bGradient = TRUE, int nDepthX = 7, int nDepthY = 7);
  120. CPPString GetResCommandPrompt(UINT nID, UINT nNumParam = 0);
  121. //Functions for the styles
  122. void SetTextStyle(LPCTSTR lpszStyleName, LPCTSTR lpszStyleValue);
  123. void SetCssStyles(LPCTSTR lpszCssString = NULL); //Sets the CSS styles
  124. void SetCssStyles(DWORD dwIdCssString, LPCTSTR lpszPathDll = NULL); //Sets the CSS styles
  125. LPCTSTR GetCssStyles(); //Returns the current CSS styles
  126. void OnLButtonDown(LPPOINT lpClient);
  127. BOOL OnSetCursor(LPPOINT lpClient);
  128. BOOL OnTimer(); //New timer count
  129. void SetHyperlinkCursor(HCURSOR hCursor = NULL); //Sets the cursor to be displayed when moving the mouse over a link. Specifying NULL will cause the control to display its default 'hand' cursor.
  130. HCURSOR GetHyperlinkCursor() const; //Returns the current link cursor.
  131. void SetCallbackHyperlink(HWND hWnd, UINT nMessage, LPARAM lParam = 0); //Sets the callback message: "Mouse over the link".
  132. void SetCallbackRepaint(HWND hWnd, UINT nMessage, LPARAM lParam = 0); //Sets the callback message: "Please repaint me".
  133. //Functions for images
  134. void SetImageList(UINT nIdBitmap, int cx, int cy, int nCount, COLORREF crMask = RGB(255, 0, 255));
  135. void SetImageList(HBITMAP hBitmap, int cx, int cy, int nCount, COLORREF crMask = RGB(255, 0, 255));
  136. void LoadResourceDll(LPCTSTR lpszPathDll, DWORD dwFlags = 0); //Sets the path to the resource's DLL
  137. void SetResourceDll(HINSTANCE hInstDll = NULL); //Sets the handle of the loaded resource's DLL
  138. void SetMaxWidth(int nWidth = 0) {m_nMaxWidth = nWidth;}; //Sets the maximum width of the output window.
  139. int GetMaxWidth() {return m_nMaxWidth;}; //Gets the maximum width of the output window.
  140. // void EnableTextWrap(BOOL bEnable = TRUE){
  141. // m_bIsTextWrapEnabled = bEnable;};
  142. // BOOL IsTextWrapEnabled() {return m_bIsTextWrapEnabled;};
  143. void SetTabSize(int nSize) {m_nTabSize = nSize;};
  144. CPPDrawManager * GetDrawManager();
  145. static short GetVersionI() {return 0x13;}
  146. static LPCTSTR GetVersionC() {return (LPCTSTR)_T("1.3 beta");}
  147. // Overrides
  148. // ClassWizard generated virtual function overrides
  149. //{{AFX_VIRTUAL(CPPHtmlDrawer)
  150. //}}AFX_VIRTUAL
  151. // Implementation
  152. public:
  153. virtual ~CPPHtmlDrawer();
  154. protected:
  155. enum{ ALIGN_LEFT = 0,
  156. ALIGN_CENTER,
  157. ALIGN_RIGHT,
  158. ALIGN_JUSTIFY
  159. };
  160. enum{ ALIGN_TOP = 0,
  161. ALIGN_VCENTER,
  162. ALIGN_BOTTOM,
  163. ALIGN_BASELINE
  164. };
  165. enum{ LINK_NONE = 0,
  166. LINK_HREF,
  167. LINK_MESSAGE
  168. };
  169. enum{ TEXT_TRANSFORM_NONE = 0,
  170. TEXT_TRANSFORM_UPPERCASE,
  171. TEXT_TRANSFORM_LOWERCASE,
  172. TEXT_TRANSFORM_CAPITALIZE
  173. };
  174. enum{ BORDER_STYLE_NONE = 0,
  175. BORDER_STYLE_SOLID,
  176. BORDER_STYLE_DOTTED,
  177. BORDER_STYLE_DASHED,
  178. BORDER_STYLE_DOUBLE,
  179. };
  180. enum { TAG_NONE = 0,
  181. TAG_BOLD,
  182. TAG_ITALIC,
  183. TAG_UNDERLINE,
  184. TAG_STRIKEOUT,
  185. TAG_FONT,
  186. TAG_HLINE,
  187. TAG_NEWLINE,
  188. TAG_TABULATION,
  189. TAG_LEFT,
  190. TAG_CENTER,
  191. TAG_RIGHT,
  192. TAG_JUSTIFY,
  193. TAG_BASELINE,
  194. TAG_TOP,
  195. TAG_VCENTER,
  196. TAG_BOTTOM,
  197. TAG_BITMAP,
  198. TAG_ICON,
  199. TAG_IMAGELIST,
  200. TAG_STRING,
  201. TAG_NEWSTYLE,
  202. TAG_SPAN,
  203. TAG_HYPERLINK
  204. };
  205. #pragma pack(1)
  206. typedef struct _STRUCT_TAGPROP
  207. {
  208. DWORD dwTagIndex; // The hot rect of the hyperlink
  209. CPPString strTagName; // The type of the hyperlink
  210. } STRUCT_TAGPROP;
  211. #pragma pack()
  212. #pragma pack(1)
  213. typedef struct _STRUCT_ANIMATION
  214. {
  215. int nIndex; //The current index of the image
  216. int nMaxImages; //The max images in the bitmap
  217. int nTimerCount;//The current time position
  218. int nSpeed; //The speed of animation
  219. } STRUCT_ANIMATION;
  220. #pragma pack()
  221. #pragma pack(1)
  222. typedef struct _STRUCT_HYPERLINK
  223. {
  224. RECT rcArea; // The hot rect of the hyperlink
  225. int nTypeLink; // The type of the hyperlink
  226. int nIndexLink; // The index of the hyperlink
  227. CPPString sHyperlink; // The hyperlink
  228. } STRUCT_HYPERLINK;
  229. #pragma pack()
  230. #pragma pack(1)
  231. typedef struct _STRUCT_CHANGESTYLE
  232. {
  233. CPPString strTag; //The name of the last opened tag
  234. //Font
  235. int nSizeFont; //The height of the logic font
  236. int nWeightFont; //The weight of the logic font
  237. BOOL bItalicFont; //Is italic logic font?
  238. BOOL bUnderlineFont;//Is underline logic font?
  239. BOOL bStrikeOutFont;//Is strikeout logic font?
  240. BOOL bOverlineFont; //Is overline logic font?
  241. CPPString sFaceFont; //The face name of the logic font
  242. //Color
  243. COLORREF crText; //The foreground color
  244. COLORREF crBkgnd; //The background color (also begin for the gradient)
  245. COLORREF crBorderLight; //The border color
  246. COLORREF crBorderDark; //The border color
  247. COLORREF crMidBkgnd;//The middle background color
  248. COLORREF crEndBkgnd;//The end background color
  249. //Fill
  250. int nBkMode; //The background mode for the text (TRANSPARENT, OPAQUE)
  251. int nFillBkgnd; //The fill effect of the background
  252. CPPString strNameResBk;
  253. //Align
  254. int nHorzAlign; //The horizontal align
  255. int nVertAlign; //The vertical align
  256. //Border
  257. int nBorderStyle; //The border style
  258. int nBorderWidth; //The width of the border
  259. //Cell Sizes
  260. int nCellWidth; //The width of the cell
  261. int nCellHeight; //The height of the cell
  262. BOOL bCellWidthPercent; //The width value in the percent
  263. BOOL bCellHeightPercent; //The height value in the percent
  264. //Text
  265. int nTextTransform;//Transformation of the text (NONE, UPPERCASE, LOWERCASE, CAPITALIZE)
  266. int nMargin; //Margins
  267. int nPadding; //Padding
  268. //Hyperlink
  269. int nTypeLink; //The type of the link (NONE, HREF, MESSAGE)
  270. CPPString sHyperlink; //The additional parameter for the link
  271. } STRUCT_CHANGESTYLE;
  272. #pragma pack()
  273. #pragma pack(1)
  274. typedef struct _STRUCT_IMAGE
  275. {
  276. int nIndexImageList;//image's index of the image list
  277. int nIdRes; //ID resource from app
  278. int nIdDll; //ID resource from dll
  279. int nHandle; //handle of the resource
  280. int cx; //horizontal size of image
  281. int cy; //vertical size of image
  282. int nWidth; //width of image
  283. int nHeight; //height of image
  284. int nSpeed; //speed for animation
  285. UINT nStyles; //styles of image
  286. UINT nHotStyles; //hot styles of image
  287. BOOL bUseMask; //
  288. BOOL bPercentWidth;
  289. BOOL bPercentHeight;
  290. COLORREF crMask; //color of mask
  291. CPPString strSrcFile; //path on the source file
  292. CPPString strPathDll; //path on the resource dll
  293. } STRUCT_IMAGE;
  294. #pragma pack()
  295. #pragma pack(1)
  296. typedef struct _STRUCT_CALLBACK
  297. {
  298. HWND hWnd; /* ƒескриптор окна, принимающего сообщение */
  299. UINT nMessage; // Message identifier
  300. WPARAM wParam;
  301. LPARAM lParam;
  302. } STRUCT_CALLBACK;
  303. #pragma pack()
  304. #pragma pack(1)
  305. typedef struct _STRUCT_HTMLLINE
  306. {
  307. int nWidthLine;
  308. int nHeightLine;
  309. int nDescentLine;
  310. int nAddPercentWidth;
  311. int nHorzAlign;
  312. int nSpaceChars; //a count of space chars in the line
  313. BOOL bWrappedLine; //TRUE if text was wrapped in the current line
  314. } STRUCT_HTMLLINE;
  315. #pragma pack()
  316. #pragma pack(1)
  317. typedef struct _STRUCT_CELL
  318. {
  319. int nColSpan; //-1 = Cell isn't used, >0 - How much columns was spaned
  320. int nRowSpan; //-1 = Cell isn't used, >0 - How much rows was spaned
  321. SIZE szText; //Real size of the text's area
  322. SIZE szCell; //Real size of the cell
  323. BOOL bFixedWidth; //TRUE if width of this cell was fixed
  324. // vecHtmlLine vecLines;
  325. // int nWidth; //Width of the cell
  326. // int nHeight; //Height of the cell
  327. // BOOL bWidthPercent; //if TRUE nWidth member in a percents
  328. // BOOL bHeightPercent; //if TRUE nHeight member in a percents
  329. } STRUCT_CELL;
  330. #pragma pack()
  331. //Cells of Table
  332. typedef std::vector<STRUCT_CELL> vecRow; //Alone row
  333. typedef std::vector<vecRow> vecTable; //Vector of the rows is a table
  334. typedef std::vector<int> vecSize; //Width of the columns or height of the rows
  335. typedef std::vector<BOOL> vecFlag; //Flags for fixed widthes of the columns
  336. #pragma pack(1)
  337. typedef struct _STRUCT_TABLE
  338. {
  339. vecTable cells; //Info about each cell of the table
  340. vecSize width; //Dimensions of the width of the columns
  341. vecSize height; //Dimensions of the height of the rows
  342. vecFlag fixed_width; //
  343. } STRUCT_TABLE;
  344. #pragma pack()
  345. typedef std::vector<STRUCT_TABLE> vecTables;
  346. vecTables m_arrTables; //All tables
  347. int m_nCurTable; //The current index of the table
  348. int m_nCurTableRow; //The current row of the table
  349. STRUCT_CALLBACK m_csCallbackRepaint; //Callback for repaint HTML drawer
  350. STRUCT_CALLBACK m_csCallbackLink; //Callback for hyperlink message
  351. STRUCT_CHANGESTYLE m_defStyle;
  352. STRUCT_HTMLLINE m_hline;
  353. CPPDrawManager m_drawmanager;
  354. //Values of the system context
  355. HIMAGELIST m_hImageList;
  356. SIZE m_szImageList;
  357. HINSTANCE m_hInstDll;
  358. BOOL m_bFreeInstDll;
  359. HCURSOR m_hLinkCursor;
  360. HFONT m_hOldFont;
  361. int m_nOldBkMode;
  362. COLORREF m_crOldText;
  363. COLORREF m_crOldBk;
  364. // BOOL m_bIsTextWrapEnabled; //Is text wrap enabled
  365. BOOL m_bIsEnable; //TRUE for fullcolor output, FALSE for disabled output
  366. COLORREF m_crDisabled;
  367. // SIZE m_szOutput; // Output size
  368. RECT m_rcOutput; //Output rectangle
  369. // POINT m_ptOutput; //Output coordinates
  370. HDC m_hDC; //Device context to output or to prepare
  371. CPPString m_csHtmlText; //String to output
  372. // COLORREF m_clrShadow;
  373. int m_nNumPass; //The number or type of the pass
  374. int m_nTabSize; // The max size for the each tabulation
  375. int m_nMaxWidth; // The max width for wrapping output
  376. int m_nCurLine; // The current drawing line
  377. int m_nNumCurTable; //The number of the current table
  378. // RECT m_rect; //
  379. // int m_nLineHeight; //The height of the current line
  380. // int m_nLineDescent;
  381. int m_nHoverIndexLink; //The index of the link under the mouse
  382. int m_nCurIndexLink;
  383. int m_nCurIndexAni; //The index of the animation
  384. BOOL m_bLastValueIsPercent;
  385. BOOL m_bEnableEscapeSequences; //
  386. //Shadow of the image
  387. BOOL m_bGradientShadow;
  388. SIZE m_szOffsetShadow;
  389. SIZE m_szDepthShadow;
  390. BYTE m_nDarkenShadow;
  391. COLORREF m_crShadow;
  392. TEXTMETRIC m_tm;
  393. LOGFONT m_lfDefault; //Default font
  394. HFONT m_hFont;
  395. //Wrapper string
  396. CPPString m_strPrefix; //Prefix string
  397. CPPString m_strPostfix; //Postfix string
  398. CPPString m_strCssStyles;
  399. //Vectors
  400. typedef std::vector<STRUCT_HTMLLINE> vecHtmlLine;
  401. vecHtmlLine m_arrHtmlLine;
  402. //Vector of the stack
  403. typedef std::vector<STRUCT_CHANGESTYLE> arrStack;
  404. arrStack m_arrStack;
  405. //Vector of the hyperlinks
  406. typedef std::vector<STRUCT_HYPERLINK> arrLink;
  407. arrLink m_arrLinks;
  408. typedef std::vector<STRUCT_ANIMATION> arrAni;
  409. arrAni m_arrAni;
  410. //Map of the colors by name
  411. typedef std::map<CPPString, COLORREF> mapColors;
  412. typedef std::map<CPPString, COLORREF>::iterator iterMapColors;
  413. mapColors m_mapColors;
  414. //Map of the styles
  415. typedef std::map<CPPString, CPPString> mapStyles;
  416. typedef std::map<CPPString, CPPString>::iterator iter_mapStyles;
  417. mapStyles m_mapStyles;
  418. mapStyles m_mapSpecChars;
  419. //Map of the colors by name
  420. typedef std::map<CPPString, STRUCT_TAGPROP> mapTags;
  421. typedef mapTags::iterator iterMapTags;
  422. mapTags m_mapTags;
  423. // mapTags m_mapTableProp;
  424. protected:
  425. void SetListOfTags(); //Fill a map of tags
  426. void AddTagToList(LPCTSTR lpszName, DWORD dwTagIndex, LPCTSTR lpszFullName); //Add tag to the list of tags
  427. DWORD GetTagFromList(CPPString sTagName, CPPString & strFullName, BOOL & bCloseTag); //Get tag from the list
  428. void SetListSpecChars();
  429. void AddSpecChar(LPCTSTR lpszAlias, TCHAR tch);
  430. void AddSpecChar(LPCTSTR lpszAlias, LPCTSTR lpszValue);
  431. void ReplaceSpecChars();
  432. //The resource's methods
  433. HICON GetIconFromResources(DWORD dwID, int nWidth = 0, int nHeight = 0) const; //Load an icon from the app resources
  434. HICON GetIconFromFile(LPCTSTR lpszPath, int nWidth = 0, int nHeight = 0) const; //Load an icon from the file
  435. HICON GetIconFromDll(DWORD dwID, int nWidth = 0, int nHeight = 0, LPCTSTR lpszPathDll = NULL) const; //Load an icon from the dll resources
  436. HBITMAP GetBitmapFromResources(DWORD dwID) const; //Load a bitmap from the app resources
  437. HBITMAP GetBitmapFromFile(LPCTSTR lpszPath) const; //Load a bitmap from the file
  438. HBITMAP GetBitmapFromDll(DWORD dwID, LPCTSTR lpszPathDll = NULL) const; //Load a bitmap from the dll resources
  439. CPPString GetStringFromResource(DWORD dwID) const; //Load a string from the app resources
  440. CPPString GetStringFromDll(DWORD dwID, LPCTSTR lpszPathDll = NULL) const; //Load a string from the dll resources
  441. //The drawing methods
  442. void DrawHtml(LPSIZE lpSize, LPCRECT lpRect); //Draws the HTML text on device context or gets the size of the output area.
  443. SIZE DrawHtmlTable(CPPString & sTable, LPCRECT lpRect); //Draws the HTML table on device context or gets the size of the output area.
  444. // SIZE DrawHtmlTableRow(CPPString & sRow, LPCRECT lpRect, vecCol & row); //Draws the HTML row of the table
  445. void DrawHtmlTableRow(CPPString & sRow, LPCRECT lpRect, STRUCT_TABLE & st, int nRow);
  446. void DrawHtmlTableCell(CPPString & sCell, LPCRECT lpRect, STRUCT_CELL & sc); //Draws the HTML cell of the table
  447. SIZE DrawHtmlString(CPPString & sHtml, LPCRECT lpRect); //Draws the HTML string on device context or gets the size of the output area.
  448. //public:
  449. //The methods
  450. void SetDefaultCssStyles();
  451. void SetDefaultCursor();
  452. LPLOGFONT GetSystemToolTipFont() const; //Gets the system logfont
  453. CPPString SearchNextTag(CPPString & str, CPPString & strTag, int & nIndex); //Search next tag
  454. BOOL SearchTag(CPPString & str, int & nIndex, CPPString strTag); //Search begin of the specified tag
  455. CPPString GetTagBody(CPPString & str, int & nIndex); //Gets a name of tag and the parameters of tag
  456. CPPString SplitTag(CPPString & sTag); //Split a tag to the tag's name and parameters
  457. CPPString GetNextProperty(CPPString & str, int & nIndex, CPPString & sProp); //Gets next property
  458. CPPString SearchPropertyOfTag(CPPString & str, int & nIndex); //Search a name or a property of a tag
  459. SIZE AnalyseCellParam(CPPString & sTag, _STRUCT_CHANGESTYLE & cs, BOOL bTable);
  460. void AnalyseImageParam(CPPString & strTag, _STRUCT_IMAGE & si);
  461. BOOL IsImageWithShadow(_STRUCT_IMAGE & si);
  462. //Functions for hyperlink
  463. int PtInHyperlink(LPPOINT lpPoint);
  464. void JumpToHyperlink(int nLink);
  465. void StoreHyperlinkArea(int left, int top, int right, int bottom);
  466. HINSTANCE GotoURL(LPCTSTR url, int showcmd = SW_SHOW);
  467. LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
  468. //Functions for notify
  469. void CallbackOnClickHyperlink(LPCTSTR sLink);
  470. void CallbackOnRepaint(int nIndexLink);
  471. //Running tag
  472. int VerticalAlignText(int y, int nHeight);
  473. int VerticalAlignImage(int y, int nHeight);
  474. void UpdateContext();
  475. BOOL StoreRestoreStyle(BOOL bRestore);
  476. void Tag_NewLine(LPPOINT lpPoint, int nNum, LPSIZE lpSize);
  477. void Tag_Tabulation(LPPOINT lpPoint, int nNum);
  478. int InitNewLine(int x);
  479. void SelectNewHtmlStyle(LPCTSTR lpszNameStyle, STRUCT_CHANGESTYLE & cs);
  480. SIZE GetTableDimensions(CPPString & sTable); //Gets dimensions of the table
  481. void SearchEndOfTable(CPPString & str, int & nIndex); //Searching end of the table
  482. void SearchEndOfRow(CPPString & str, int & nIndex); //Searching end of the row
  483. void SearchEndOfCell(CPPString & str, int & nIndex); //Searching end of the cell
  484. //Functions for the map of the styles
  485. void SetTableOfColors();
  486. void SetColorName(LPCTSTR lpszColorName, COLORREF color);
  487. COLORREF GetColorByName(LPCTSTR lpszColorName, COLORREF crDefColor = RGB(0, 0, 0));
  488. BOOL GetIndexNextAlphaNum(CPPString & str, int & nIndex, BOOL bArithmetic = FALSE);
  489. BOOL GetBeginParameter(CPPString & str, int & nIndex, TCHAR chSeparator = _T(':'));
  490. TCHAR GetIndexNextChars(CPPString & str, int & nIndex, CPPString strChars);
  491. TCHAR GetIndexNextNoChars(CPPString & str, int & nIndex, CPPString strChars);
  492. CPPString GetParameterString(CPPString & str, int & nIndex, TCHAR chBeginParam = _T(':'), CPPString strSeparators = _T(";"));
  493. CPPString GetNameOfTag(CPPString & str, int & nIndex);
  494. CPPString GetWordWrap(CPPString & str, int nMaxSize, int & nRealSize);
  495. //Functions for the map of the styles
  496. LPCTSTR GetTextStyle(LPCTSTR lpszStyleName);
  497. void RemoveTextStyle(LPCTSTR lpszStyleName);
  498. void AddToTextStyle(LPCTSTR lpszStyleName, LPCTSTR lpszAddStyle);
  499. void UnpackTextStyle(CPPString strStyle, _STRUCT_CHANGESTYLE & cs);
  500. //Functions for analyzing parameters
  501. void SetDefaultStyles(_STRUCT_CHANGESTYLE & cs);
  502. BOOL GetStyleFontStyle(CPPString & str, BOOL bDefault);
  503. int GetStyleFontWeight(CPPString & str, int nDefault);
  504. int GetStyleHorzAlign(CPPString & str, int nDefault);
  505. int GetStyleVertAlign(CPPString & str, int nDefault);
  506. COLORREF GetStyleColor(CPPString & str, COLORREF crDefault);
  507. int GetStyleTextTransform(CPPString & str, int nDefault);
  508. CPPString GetStyleString(CPPString str, CPPString strDefault);
  509. void GetStyleFontShortForm(CPPString & str);
  510. UINT GetStyleImageShortForm(CPPString & str);
  511. int GetStyleBkgndEffect(CPPString & str, int nDefault);
  512. void StyleTextDecoration(CPPString & str, _STRUCT_CHANGESTYLE & cs);
  513. int StyleBorderWidth(CPPString & str, int Default);
  514. int StyleBorder(CPPString & str, int nDefault);
  515. //Get
  516. int GetLengthUnit(CPPString & str, int nDefault, BOOL bFont = FALSE);
  517. BOOL IsPercentableValue(CPPString & str);
  518. int GetTableWidth(CPPString & str, int nClientWidth, int nMinWidth, BOOL bSet = FALSE);
  519. //Drawing
  520. void DrawBackgroundImage(HDC hDC, int nDestX, int nDestY, int nWidth, int nHeight, CPPString strNameImage);
  521. int GetCountOfChars(CPPString str, TCHAR tchar = _T(' ')); //Gets counts of chars
  522. };
  523. #endif //_PPHTMLDRAWER_H_