2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: html/winpars.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHtmlTagsModule
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHtmlTagsModule
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class provides easy way of filling wxHtmlWinParser's table of
|
|
|
|
tag handlers. It is used almost exclusively together with the set of
|
2008-10-25 16:44:52 -04:00
|
|
|
@ref overview_html_handlers "TAGS_MODULE_* macros"
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
2008-10-25 16:44:52 -04:00
|
|
|
@category{html}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-25 16:44:52 -04:00
|
|
|
@see @ref overview_html_handlers, wxHtmlTagHandler, wxHtmlWinTagHandler
|
2008-03-08 08:52:38 -05: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-10-25 16:44:52 -04:00
|
|
|
@code
|
|
|
|
parser -> AddTagHandler(new MyHandler);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
It's recommended to use the @b TAGS_MODULE_* macros.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parser
|
2008-03-09 08:33:59 -04:00
|
|
|
Pointer to the parser that requested tables filling.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-25 16:44:52 -04:00
|
|
|
virtual void FillHandlersTable(wxHtmlWinParser* parser);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHtmlWinTagHandler
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-25 16:44:52 -04: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 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{html}
|
|
|
|
*/
|
|
|
|
class wxHtmlWinTagHandler : public wxHtmlTagHandler
|
|
|
|
{
|
2008-10-25 16:44:52 -04:00
|
|
|
protected:
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Value of this attribute is identical to value of m_Parser.
|
|
|
|
The only difference is that m_WParser points to wxHtmlWinParser object
|
|
|
|
while m_Parser points to wxHtmlParser object. (The same object, but overcast.)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-25 16:44:52 -04:00
|
|
|
wxHtmlWinParser* m_WParser;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHtmlWinParser
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-25 16:44:52 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{html}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-25 16:44:52 -04:00
|
|
|
@see @ref overview_html_handlers
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHtmlWinParser : public wxHtmlParser
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Constructor.
|
|
|
|
|
2008-10-27 17:18:55 -04:00
|
|
|
Don't use the default one, use the constructor with @a wndIface parameter
|
2008-10-25 16:44:52 -04:00
|
|
|
(@a wndIface is a pointer to interface object for the associated wxHtmlWindow
|
|
|
|
or other HTML rendering window such as wxHtmlListBox).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-27 17:18:55 -04:00
|
|
|
wxHtmlWinParser(wxHtmlWindowInterface* wndIface = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-10 11:24:38 -04:00
|
|
|
Adds module() to the list of wxHtmlWinParser tag handler.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-10 17:42:09 -05:00
|
|
|
static void AddModule(wxHtmlTagsModule* module);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Closes the container, sets actual container to the parent one
|
2008-10-25 16:44:52 -04:00
|
|
|
and returns pointer to it (see @ref overview_html_cells).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxHtmlContainerCell* CloseContainer();
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Creates font based on current setting (see SetFontSize(), SetFontBold(),
|
|
|
|
SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined)
|
2008-03-08 08:52:38 -05:00
|
|
|
and returns pointer to it.
|
2008-10-25 16:44:52 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If the font was already created only a pointer is returned.
|
|
|
|
*/
|
|
|
|
virtual wxFont* CreateCurrentFont();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual text colour.
|
|
|
|
*/
|
2008-09-27 16:26:28 -04:00
|
|
|
const wxColour& GetActualColor() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns default horizontal alignment.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetAlign() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Returns (average) char height in standard font.
|
|
|
|
It is used as DC-independent metrics.
|
|
|
|
|
2008-04-01 09:59:28 -04:00
|
|
|
@note This function doesn't return the @e actual height. If you want to
|
2008-10-25 16:44:52 -04:00
|
|
|
know the height of the current font, call @c GetDC->GetCharHeight().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetCharHeight() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Returns average char width in standard font.
|
|
|
|
It is used as DC-independent metrics.
|
|
|
|
|
2008-04-01 09:59:28 -04:00
|
|
|
@note This function doesn't return the @e actual width. If you want to
|
2008-10-25 16:44:52 -04:00
|
|
|
know the height of the current font, call @c GetDC->GetCharWidth().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetCharWidth() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Returns pointer to the currently opened container (see @ref overview_html_cells).
|
2008-03-08 08:52:38 -05:00
|
|
|
Common use:
|
2008-10-25 16:44:52 -04:00
|
|
|
@code
|
|
|
|
m_WParser -> GetContainer() -> InsertCell(new ...);
|
|
|
|
@endcode
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxHtmlContainerCell* GetContainer() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns pointer to the DC used during parsing.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDC* GetDC();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Returns wxEncodingConverter class used to do conversion between the
|
|
|
|
@ref GetInputEncoding() "input encoding" and the
|
|
|
|
@ref GetOutputEncoding() "output encoding".
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxEncodingConverter* GetEncodingConverter() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is bold, @false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFontBold() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual font face name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetFontFace() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is fixed face, @false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFontFixed() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is italic, @false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFontItalic() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns actual font size (HTML size varies from -2 to +4)
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFontSize() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if actual font is underlined, @false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFontUnderlined() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns input encoding.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFontEncoding GetInputEncoding() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Returns actual hypertext link.
|
|
|
|
(This value has a non-empty @ref wxHtmlLinkInfo::GetHref Href string
|
|
|
|
if the parser is between \<A\> and \</A\> tags, wxEmptyString otherwise.)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 16:26:28 -04:00
|
|
|
const wxHtmlLinkInfo& GetLink() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the colour of hypertext link text.
|
|
|
|
*/
|
2008-09-27 16:26:28 -04:00
|
|
|
const wxColour& GetLinkColor() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns output encoding, i.e. closest match to document's input encoding
|
|
|
|
that is supported by operating system.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFontEncoding GetOutputEncoding() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04: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.
|
2008-11-08 10:25:07 -05:00
|
|
|
@deprecated use GetWindowInterface()->GetHTMLWindow() instead
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxHtmlWindow* GetWindow();
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Opens new container and returns pointer to it (see @ref overview_html_cells).
|
2008-03-08 08:52:38 -05: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-10-25 16:44:52 -04:00
|
|
|
Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).
|
2008-03-08 08:52:38 -05:00
|
|
|
Alignment of newly opened container is set to this value.
|
|
|
|
*/
|
|
|
|
void SetAlign(int a);
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Allows you to directly set opened container.
|
|
|
|
This is not recommended - you should use OpenContainer() wherever possible.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxHtmlContainerCell* SetContainer(wxHtmlContainerCell* c);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the DC. This must be called before wxHtmlParser::Parse!
|
2008-10-25 16:44:52 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@a pixel_scale can be used when rendering to high-resolution
|
2008-03-08 09:43:31 -05:00
|
|
|
DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in
|
2008-03-08 08:52:38 -05: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-09-27 16:26:28 -04:00
|
|
|
virtual void SetDC(wxDC* dc, double pixel_scale = 1.0e+0);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets bold flag of actualfont. @a x is either @true of @false.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontBold(int x);
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Sets current font face to @a face. This affects either fixed size
|
2008-03-08 09:43:31 -05:00
|
|
|
font or proportional, depending on context (whether the parser is
|
2008-10-25 16:44:52 -04:00
|
|
|
inside @c \<TT\> tag or not).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontFace(const wxString& face);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets fixed face flag of actualfont. @a x is either @true of @false.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontFixed(int x);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets italic flag of actualfont. @a x is either @true of @false.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontItalic(int x);
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Sets actual font size (HTML size varies from 1 to 7).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontSize(int s);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets underlined flag of actualfont. @a x is either @true of @false.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFontUnderlined(int x);
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 16:26:28 -04:00
|
|
|
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
|
|
|
|
const int* sizes = 0);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets input encoding. The parser uses this information to build conversion
|
2008-10-25 16:44:52 -04:00
|
|
|
tables from document's encoding to some encoding supported by operating system.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetInputEncoding(wxFontEncoding enc);
|
|
|
|
|
|
|
|
/**
|
2008-10-25 16:44:52 -04:00
|
|
|
Sets actual hypertext link.
|
|
|
|
Empty link is represented by wxHtmlLinkInfo with @e Href equal
|
2008-03-08 08:52:38 -05:00
|
|
|
to wxEmptyString.
|
|
|
|
*/
|
|
|
|
void SetLink(const wxHtmlLinkInfo& link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets colour of hypertext link.
|
|
|
|
*/
|
|
|
|
void SetLinkColor(const wxColour& clr);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|