Click here to Skip to main content
15,895,799 members
Articles / Desktop Programming / MFC

A Simple HTML Drawing Class

Rate me:
Please Sign up or sign in to vote.
4.72/5 (27 votes)
5 Aug 20034 min read 166.6K   5.4K   67  
Drawing HTML text onto a device context
// HTMLDrawer.h: interface for the CHTMLDrawer class.
//
//////////////////////////////////////////////////////////////////////
// (c) Jerome Sopocko 2003
// this code worked last time I saw it
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HTMLDRAWER_H__DCF0B41F_7E7D_472A_BDDB_E8902BE074D6__INCLUDED_)
#define AFX_HTMLDRAWER_H__DCF0B41F_7E7D_472A_BDDB_E8902BE074D6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CHTMLFont;

class CHTMLDrawer  
{
public:
	CHTMLDrawer();
	virtual ~CHTMLDrawer();

public:
	void DrawText(CDC * pDC, const CString & strText,const CHTMLFont & fntDefault,CRect & rctPosition,short nJustification);

protected:
	void ParseHTMLText(const CString & strSource,const CHTMLFont & Police,CObArray & arrAtoms);
	void AddText(CObArray & arrAtoms,const CString & strText,CHTMLFont & polCurrent);
	void UpdatePoliceAccordingToTag(CString & strTag,CHTMLFont & polCurrent,CObArray & arrFontStack,bool & isNewLine);
	void BreakIntoLines(CDC * pDC,CObArray & arrAtoms,CObArray & arrDisplayAtoms,CRect & rctPosition);
	void CreateNewLine(CDC * pDC,CObArray & arrDisplayAtoms,int & nStartLineAtom,int & nY);
	void RemoveLastWord(CString & strText);
	void DrawAtoms(CDC * pDC,CObArray & arrDisplayAtoms,int nShiftVertically,short nJustification,int nRight);
	long FromHex(const CString & strHex);
	static long ToLong(LPCTSTR lpszText);

};

#endif // !defined(AFX_HTMLDRAWER_H__DCF0B41F_7E7D_472A_BDDB_E8902BE074D6__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
United Kingdom United Kingdom
Known as "The Wandering Geek", I have had to often change identities and countries due to the low quality level of the numerous software I have left behind.
Never wrote a software that did more than sorting 3 numbers which actually worked.
Hey but feel free to download my stuff!


Comments and Discussions