2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: html/winpars.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxHtmlTagsModule
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHtmlTagsModule
|
|
|
|
@headerfile winpars.h wx/html/winpars.h
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This class provides easy way of filling wxHtmlWinParser's table of
|
|
|
|
tag handlers. It is used almost exclusively together with the set of
|
|
|
|
@ref overview_handlers "TAGS_MODULE_* macros"
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{FIXME}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see @ref overview_handlers "Tag Handlers", wxHtmlTagHandler,
|
|
|
|
wxHtmlWinTagHandler,
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxHtmlTagsModule : public wxModule
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
You must override this method. In most common case its body consists
|
|
|
|
only of lines of the following type:
|
2008-03-09 12:33:59 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
I recommend using the @b TAGS_MODULE_* macros.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param parser
|
2008-03-09 12:33:59 +00:00
|
|
|
Pointer to the parser that requested tables filling.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
virtual void FillHandlersTable(wxHtmlWinParser parser);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxHtmlWinTagHandler
|
|
|
|
@headerfile winpars.h wx/html/winpars.h
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This is basically wxHtmlTagHandler except that
|
|
|
|
it is extended with protected member m_WParser pointing to
|
|
|
|
the wxHtmlWinParser object (value of this member is identical
|
|
|
|
to wxHtmlParser's m_Parser).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{html}
|
|
|
|
*/
|
|
|
|
class wxHtmlWinTagHandler : public wxHtmlTagHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
@b wxHtmlWinParser* m_WParser
|
|
|
|
Value of this attribute is identical to value of m_Parser. The only different
|
|
|
|
is that m_WParser points to wxHtmlWinParser object while m_Parser
|
|
|
|
points to wxHtmlParser object. (The same object, but overcast.)
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxHtmlWinParser
|
|
|
|
@headerfile winpars.h wx/html/winpars.h
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This class is derived from wxHtmlParser and
|
|
|
|
its main goal is to parse HTML input so that it can be displayed in
|
2008-03-08 14:43:31 +00:00
|
|
|
wxHtmlWindow. It uses a special
|
2008-03-08 13:52:38 +00:00
|
|
|
wxHtmlWinTagHandler.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{html}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see @ref overview_handlers "Handlers overview"
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxHtmlWinParser : public wxHtmlParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructor. Don't use the default one, use constructor with
|
2008-03-09 12:33:59 +00:00
|
|
|
@a wndIface parameter (@a wndIface is a pointer to interface object for
|
2008-03-08 13:52:38 +00:00
|
|
|
the associated wxHtmlWindow or other HTML rendering
|
|
|
|
window such as wxHtmlListBox).
|
|
|
|
*/
|
|
|
|
wxHtmlWinParser();
|
2008-03-08 14:43:31 +00:00
|
|
|
wxHtmlWinParser(wxHtmlWindowInterface wndIface);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-10 15:24:38 +00:00
|
|
|
Adds module() to the list of wxHtmlWinParser tag handler.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static void AddModule(wxHtmlTagsModule module);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Closes the container, sets actual container to the parent one
|
2008-03-10 15:24:38 +00:00
|
|
|
and returns pointer to it (see Overview()).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxHtmlContainerCell* CloseContainer();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Creates font based on current setting (see
|
|
|
|
SetFontSize(),
|
|
|
|
SetFontBold(),
|
|
|
|
SetFontItalic(),
|
|
|
|
SetFontFixed(),
|
2008-03-08 13:52:38 +00:00
|
|
|
wxHtmlWinParser::SetFontUnderlined)
|
|
|
|
and returns pointer to it.
|
|
|
|
If the font was already created only a pointer is returned.
|
|
|
|
*/
|
|
|
|
virtual wxFont* CreateCurrentFont();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual text colour.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxColour GetActualColor() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns default horizontal alignment.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetAlign() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns (average) char height in standard font. It is used as DC-independent
|
|
|
|
metrics.
|
|
|
|
@b Note: This function doesn't return the @e actual height. If you want to
|
|
|
|
know the height of the current font, call @c GetDC - GetCharHeight().
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetCharHeight() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns average char width in standard font. It is used as DC-independent
|
|
|
|
metrics.
|
|
|
|
@b Note: This function doesn't return the @e actual width. If you want to
|
|
|
|
know the height of the current font, call @c GetDC - GetCharWidth()
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetCharWidth() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-10 15:24:38 +00:00
|
|
|
Returns pointer to the currently opened container (see Overview()).
|
2008-03-08 13:52:38 +00:00
|
|
|
Common use:
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxHtmlContainerCell* GetContainer() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns pointer to the DC used during parsing.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxDC* GetDC();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns wxEncodingConverter class used
|
2008-03-08 14:43:31 +00:00
|
|
|
to do conversion between @ref getinputencoding() "input encoding"
|
2008-03-08 13:52:38 +00:00
|
|
|
and @ref getoutputencoding() "output encoding".
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxEncodingConverter* GetEncodingConverter() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is bold, @false otherwise.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFontBold() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual font face name.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetFontFace() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is fixed face, @false otherwise.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFontFixed() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is italic, @false otherwise.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFontItalic() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual font size (HTML size varies from -2 to +4)
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFontSize() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is underlined, @false otherwise.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetFontUnderlined() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns input encoding.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxFontEncoding GetInputEncoding() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Returns actual hypertext link. (This value has a non-empty
|
2008-03-08 13:52:38 +00:00
|
|
|
@ref wxHtmlLinkInfo::gethref Href string
|
|
|
|
if the parser is between @c A and @c /A tags,
|
|
|
|
wxEmptyString otherwise.)
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxHtmlLinkInfo GetLink() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the colour of hypertext link text.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
const wxColour GetLinkColor() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns output encoding, i.e. closest match to document's input encoding
|
|
|
|
that is supported by operating system.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxFontEncoding GetOutputEncoding() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns associated window (wxHtmlWindow). This may be @NULL! (You should always
|
|
|
|
test if it is non-@NULL. For example @c TITLE handler sets window
|
|
|
|
title only if some window is associated, otherwise it does nothing)
|
|
|
|
*/
|
|
|
|
wxHtmlWindow* GetWindow();
|
|
|
|
|
|
|
|
/**
|
2008-03-10 15:24:38 +00:00
|
|
|
Opens new container and returns pointer to it (see Overview()).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxHtmlContainerCell* OpenContainer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets actual text colour. Note: this DOESN'T change the colour!
|
|
|
|
You must create wxHtmlColourCell yourself.
|
|
|
|
*/
|
|
|
|
void SetActualColor(const wxColour& clr);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Sets default horizontal alignment (see
|
2008-03-08 13:52:38 +00:00
|
|
|
wxHtmlContainerCell::SetAlignHor.)
|
|
|
|
Alignment of newly opened container is set to this value.
|
|
|
|
*/
|
|
|
|
void SetAlign(int a);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allows you to directly set opened container. This is not recommended - you
|
|
|
|
should use OpenContainer
|
|
|
|
wherever possible.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxHtmlContainerCell* SetContainer(wxHtmlContainerCell* c);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the DC. This must be called before wxHtmlParser::Parse!
|
2008-03-09 12:33:59 +00:00
|
|
|
@a pixel_scale can be used when rendering to high-resolution
|
2008-03-08 14:43:31 +00:00
|
|
|
DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in
|
2008-03-08 13:52:38 +00:00
|
|
|
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.)
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
virtual void SetDC(wxDC dc, double pixel_scale = 1.0);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Sets bold flag of actualfont. @a x is either @true of @false.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetFontBold(int x);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets current font face to @e face. This affects either fixed size
|
2008-03-08 14:43:31 +00:00
|
|
|
font or proportional, depending on context (whether the parser is
|
2008-03-08 13:52:38 +00:00
|
|
|
inside @c TT tag or not).
|
|
|
|
*/
|
|
|
|
void SetFontFace(const wxString& face);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Sets fixed face flag of actualfont. @a x is either @true of @false.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetFontFixed(int x);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Sets italic flag of actualfont. @a x is either @true of @false.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetFontItalic(int x);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets actual font size (HTML size varies from 1 to 7)
|
|
|
|
*/
|
|
|
|
void SetFontSize(int s);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
Sets underlined flag of actualfont. @a x is either @true of @false.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetFontUnderlined(int x);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets fonts. See wxHtmlWindow::SetFonts for
|
|
|
|
detailed description.
|
|
|
|
*/
|
|
|
|
void SetFonts(const wxString& normal_face,
|
|
|
|
const wxString& fixed_face,
|
2008-03-09 12:33:59 +00:00
|
|
|
const int sizes = NULL);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets input encoding. The parser uses this information to build conversion
|
|
|
|
tables from document's encoding to some encoding supported by operating
|
|
|
|
system.
|
|
|
|
*/
|
|
|
|
void SetInputEncoding(wxFontEncoding enc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets actual hypertext link. Empty link is represented
|
|
|
|
by wxHtmlLinkInfo with @e Href equal
|
|
|
|
to wxEmptyString.
|
|
|
|
*/
|
|
|
|
void SetLink(const wxHtmlLinkInfo& link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets colour of hypertext link.
|
|
|
|
*/
|
|
|
|
void SetLinkColor(const wxColour& clr);
|
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|