Version: 3.1.0
wxHtmlWinParser Class Reference

#include <wx/html/winpars.h>

+ Inheritance diagram for wxHtmlWinParser:

Detailed Description

This class is derived from wxHtmlParser and its main goal is to parse HTML input so that it can be displayed in wxHtmlWindow.

It uses a special wxHtmlWinTagHandler.

Note
The product of parsing is a wxHtmlCell (resp. wxHtmlContainer) object.

Library:  wxHTML
Category:  HTML
See Also
Tag Handlers

Public Member Functions

 wxHtmlWinParser (wxHtmlWindowInterface *wndIface=NULL)
 Constructor.
 
wxHtmlContainerCellCloseContainer ()
 Closes the container, sets actual container to the parent one and returns pointer to it (see Cells and Containers).
 
virtual wxFontCreateCurrentFont ()
 Creates font based on current setting (see SetFontSize(), SetFontBold(), SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined) and returns pointer to it.
 
const wxColourGetActualColor () const
 Returns actual text colour.
 
int GetAlign () const
 Returns default horizontal alignment.
 
int GetCharHeight () const
 Returns (average) char height in standard font.
 
int GetCharWidth () const
 Returns average char width in standard font.
 
wxHtmlContainerCellGetContainer () const
 Returns pointer to the currently opened container (see Cells and Containers).
 
wxDCGetDC ()
 Returns pointer to the DC used during parsing.
 
wxEncodingConverterGetEncodingConverter () const
 Returns wxEncodingConverter class used to do conversion between the input encoding and the output encoding.
 
int GetFontBold () const
 Returns true if actual font is bold, false otherwise.
 
wxString GetFontFace () const
 Returns actual font face name.
 
int GetFontFixed () const
 Returns true if actual font is fixed face, false otherwise.
 
int GetFontItalic () const
 Returns true if actual font is italic, false otherwise.
 
int GetFontSize () const
 Returns actual font size (HTML size varies from -2 to +4)
 
int GetFontUnderlined () const
 Returns true if actual font is underlined, false otherwise.
 
wxFontEncoding GetInputEncoding () const
 Returns input encoding.
 
const wxHtmlLinkInfoGetLink () const
 Returns actual hypertext link.
 
const wxColourGetLinkColor () const
 Returns the colour of hypertext link text.
 
wxFontEncoding GetOutputEncoding () const
 Returns output encoding, i.e.
 
wxHtmlWindowInterfaceGetWindowInterface ()
 Returns associated window (wxHtmlWindow).
 
wxHtmlContainerCellOpenContainer ()
 Opens new container and returns pointer to it (see Cells and Containers).
 
void SetActualColor (const wxColour &clr)
 Sets actual text colour.
 
void SetAlign (int a)
 Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).
 
wxHtmlContainerCellSetContainer (wxHtmlContainerCell *c)
 Allows you to directly set opened container.
 
virtual void SetDC (wxDC *dc, double pixel_scale=1.0e+0)
 Sets the DC.
 
void SetFontBold (int x)
 Sets bold flag of actualfont.
 
void SetFontFace (const wxString &face)
 Sets current font face to face.
 
void SetFontFixed (int x)
 Sets fixed face flag of actualfont.
 
void SetFontItalic (int x)
 Sets italic flag of actualfont.
 
void SetFontSize (int s)
 Sets actual font size (HTML size varies from 1 to 7).
 
void SetFontUnderlined (int x)
 Sets underlined flag of actualfont.
 
void SetFonts (const wxString &normal_face, const wxString &fixed_face, const int *sizes=0)
 Sets fonts.
 
void SetInputEncoding (wxFontEncoding enc)
 Sets input encoding.
 
void SetLink (const wxHtmlLinkInfo &link)
 Sets actual hypertext link.
 
void SetLinkColor (const wxColour &clr)
 Sets colour of hypertext link.
 
- Public Member Functions inherited from wxHtmlParser
 wxHtmlParser ()
 Constructor.
 
virtual void AddTagHandler (wxHtmlTagHandler *handler)
 Adds handler to the internal list ( hash table) of handlers.
 
virtual void AddWord (const wxString &txt)
 Must be overwritten in derived class.
 
void DoParsing (const const_iterator &begin_pos, const const_iterator &end_pos)
 Parses the m_Source from begin_pos to end_pos - 1.
 
void DoParsing ()
 Parses the whole m_Source.
 
virtual void DoneParser ()
 This must be called after DoParsing().
 
wxFileSystemGetFS () const
 Returns pointer to the file system.
 
virtual wxObjectGetProduct ()=0
 Returns product of parsing.
 
const wxStringGetSource ()
 Returns pointer to the source being parsed.
 
virtual void InitParser (const wxString &source)
 Setups the parser for parsing the source string.
 
virtual wxFSFileOpenURL (wxHtmlURLType type, const wxString &url) const
 Opens given URL and returns wxFSFile object that can be used to read data from it.
 
wxObjectParse (const wxString &source)
 Proceeds parsing of the document.
 
void PopTagHandler ()
 Restores parser's state before last call to PushTagHandler().
 
void PushTagHandler (wxHtmlTagHandler *handler, const wxString &tags)
 Forces the handler to handle additional tags (not returned by wxHtmlTagHandler::GetSupportedTags).
 
void SetFS (wxFileSystem *fs)
 Sets the virtual file system that will be used to request additional files.
 
virtual void StopParsing ()
 Call this function to interrupt parsing from a tag handler.
 

Static Public Member Functions

static void AddModule (wxHtmlTagsModule *module)
 Adds module() to the list of wxHtmlWinParser tag handler.
 

Additional Inherited Members

- Protected Member Functions inherited from wxHtmlParser
virtual void AddTag (const wxHtmlTag &tag)
 This may (and may not) be overwritten in derived class.
 

Constructor & Destructor Documentation

wxHtmlWinParser::wxHtmlWinParser ( wxHtmlWindowInterface wndIface = NULL)

Constructor.

Don't use the default one, use the constructor with wndIface parameter (wndIface is a pointer to interface object for the associated wxHtmlWindow or other HTML rendering window such as wxHtmlListBox).

Member Function Documentation

static void wxHtmlWinParser::AddModule ( wxHtmlTagsModule module)
static

Adds module() to the list of wxHtmlWinParser tag handler.

wxHtmlContainerCell* wxHtmlWinParser::CloseContainer ( )

Closes the container, sets actual container to the parent one and returns pointer to it (see Cells and Containers).

virtual wxFont* wxHtmlWinParser::CreateCurrentFont ( )
virtual

Creates font based on current setting (see SetFontSize(), SetFontBold(), SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined) and returns pointer to it.

If the font was already created only a pointer is returned.

const wxColour& wxHtmlWinParser::GetActualColor ( ) const

Returns actual text colour.

int wxHtmlWinParser::GetAlign ( ) const

Returns default horizontal alignment.

int wxHtmlWinParser::GetCharHeight ( ) const

Returns (average) char height in standard font.

It is used as DC-independent metrics.

Note
This function doesn't return the actual height. If you want to know the height of the current font, call GetDC->GetCharHeight().
int wxHtmlWinParser::GetCharWidth ( ) const

Returns average char width in standard font.

It is used as DC-independent metrics.

Note
This function doesn't return the actual width. If you want to know the height of the current font, call GetDC->GetCharWidth().
wxHtmlContainerCell* wxHtmlWinParser::GetContainer ( ) const

Returns pointer to the currently opened container (see Cells and Containers).

Common use:

m_WParser -> GetContainer() -> InsertCell(new ...);
wxDC* wxHtmlWinParser::GetDC ( )

Returns pointer to the DC used during parsing.

wxEncodingConverter* wxHtmlWinParser::GetEncodingConverter ( ) const

Returns wxEncodingConverter class used to do conversion between the input encoding and the output encoding.

int wxHtmlWinParser::GetFontBold ( ) const

Returns true if actual font is bold, false otherwise.

wxString wxHtmlWinParser::GetFontFace ( ) const

Returns actual font face name.

int wxHtmlWinParser::GetFontFixed ( ) const

Returns true if actual font is fixed face, false otherwise.

int wxHtmlWinParser::GetFontItalic ( ) const

Returns true if actual font is italic, false otherwise.

int wxHtmlWinParser::GetFontSize ( ) const

Returns actual font size (HTML size varies from -2 to +4)

int wxHtmlWinParser::GetFontUnderlined ( ) const

Returns true if actual font is underlined, false otherwise.

wxFontEncoding wxHtmlWinParser::GetInputEncoding ( ) const

Returns input encoding.

const wxHtmlLinkInfo& wxHtmlWinParser::GetLink ( ) const

Returns actual hypertext link.

(This value has a non-empty wxHtmlLinkInfo::GetHref Href string if the parser is between <A> and </A> tags, wxEmptyString otherwise.)

const wxColour& wxHtmlWinParser::GetLinkColor ( ) const

Returns the colour of hypertext link text.

wxFontEncoding wxHtmlWinParser::GetOutputEncoding ( ) const

Returns output encoding, i.e.

closest match to document's input encoding that is supported by operating system.

wxHtmlWindowInterface* wxHtmlWinParser::GetWindowInterface ( )

Returns associated window (wxHtmlWindow).

This may be NULL! (You should always test if it is non-NULL. For example TITLE handler sets window title only if some window is associated, otherwise it does nothing.

wxHtmlContainerCell* wxHtmlWinParser::OpenContainer ( )

Opens new container and returns pointer to it (see Cells and Containers).

void wxHtmlWinParser::SetActualColor ( const wxColour clr)

Sets actual text colour.

Note: this DOESN'T change the colour! You must create wxHtmlColourCell yourself.

void wxHtmlWinParser::SetAlign ( int  a)

Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).

Alignment of newly opened container is set to this value.

wxHtmlContainerCell* wxHtmlWinParser::SetContainer ( wxHtmlContainerCell c)

Allows you to directly set opened container.

This is not recommended - you should use OpenContainer() wherever possible.

virtual void wxHtmlWinParser::SetDC ( wxDC dc,
double  pixel_scale = 1.0e+0 
)
virtual

Sets the DC.

This must be called before wxHtmlParser::Parse!

pixel_scale can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in HTML are given in pixels – e.g. image sizes. 300x300 image would be only one inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)

void wxHtmlWinParser::SetFontBold ( int  x)

Sets bold flag of actualfont.

x is either true of false.

void wxHtmlWinParser::SetFontFace ( const wxString face)

Sets current font face to face.

This affects either fixed size font or proportional, depending on context (whether the parser is inside <TT> tag or not).

void wxHtmlWinParser::SetFontFixed ( int  x)

Sets fixed face flag of actualfont.

x is either true of false.

void wxHtmlWinParser::SetFontItalic ( int  x)

Sets italic flag of actualfont.

x is either true of false.

void wxHtmlWinParser::SetFonts ( const wxString normal_face,
const wxString fixed_face,
const int *  sizes = 0 
)

Sets fonts.

See wxHtmlWindow::SetFonts for detailed description.

void wxHtmlWinParser::SetFontSize ( int  s)

Sets actual font size (HTML size varies from 1 to 7).

void wxHtmlWinParser::SetFontUnderlined ( int  x)

Sets underlined flag of actualfont.

x is either true of false.

void wxHtmlWinParser::SetInputEncoding ( wxFontEncoding  enc)

Sets input encoding.

The parser uses this information to build conversion tables from document's encoding to some encoding supported by operating system.

void wxHtmlWinParser::SetLink ( const wxHtmlLinkInfo link)

Sets actual hypertext link.

Empty link is represented by wxHtmlLinkInfo with Href equal to wxEmptyString.

void wxHtmlWinParser::SetLinkColor ( const wxColour clr)

Sets colour of hypertext link.