1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/winpars.h
3 // Purpose: interface of wxHtmlTagsModule
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHtmlTagsModule
12 This class provides easy way of filling wxHtmlWinParser's table of
13 tag handlers. It is used almost exclusively together with the set of
14 @ref overview_html_handlers "TAGS_MODULE_* macros"
19 @see @ref overview_html_handlers, wxHtmlTagHandler, wxHtmlWinTagHandler
21 class wxHtmlTagsModule
: public wxModule
25 You must override this method. In most common case its body consists
26 only of lines of the following type:
28 parser -> AddTagHandler(new MyHandler);
31 It's recommended to use the @b TAGS_MODULE_* macros.
34 Pointer to the parser that requested tables filling.
36 virtual void FillHandlersTable(wxHtmlWinParser
* parser
);
42 @class wxHtmlWinTagHandler
44 This is basically wxHtmlTagHandler except that it is extended with protected
45 member m_WParser pointing to the wxHtmlWinParser object (value of this member
46 is identical to wxHtmlParser's m_Parser).
51 class wxHtmlWinTagHandler
: public wxHtmlTagHandler
55 Value of this attribute is identical to value of m_Parser.
56 The only difference is that m_WParser points to wxHtmlWinParser object
57 while m_Parser points to wxHtmlParser object. (The same object, but overcast.)
59 wxHtmlWinParser
* m_WParser
;
65 @class wxHtmlWinParser
67 This class is derived from wxHtmlParser and its main goal is to parse HTML
68 input so that it can be displayed in wxHtmlWindow.
69 It uses a special wxHtmlWinTagHandler.
71 @note The product of parsing is a wxHtmlCell (resp. wxHtmlContainer) object.
76 @see @ref overview_html_handlers
78 class wxHtmlWinParser
: public wxHtmlParser
86 Don't use the default one, use constructor with @a wndIface parameter
87 (@a wndIface is a pointer to interface object for the associated wxHtmlWindow
88 or other HTML rendering window such as wxHtmlListBox).
90 wxHtmlWinParser(wxHtmlWindowInterface wndIface
);
93 Adds module() to the list of wxHtmlWinParser tag handler.
95 static void AddModule(wxHtmlTagsModule
module);
98 Closes the container, sets actual container to the parent one
99 and returns pointer to it (see @ref overview_html_cells).
101 wxHtmlContainerCell
* CloseContainer();
104 Creates font based on current setting (see SetFontSize(), SetFontBold(),
105 SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined)
106 and returns pointer to it.
108 If the font was already created only a pointer is returned.
110 virtual wxFont
* CreateCurrentFont();
113 Returns actual text colour.
115 const wxColour
& GetActualColor() const;
118 Returns default horizontal alignment.
120 int GetAlign() const;
123 Returns (average) char height in standard font.
124 It is used as DC-independent metrics.
126 @note This function doesn't return the @e actual height. If you want to
127 know the height of the current font, call @c GetDC->GetCharHeight().
129 int GetCharHeight() const;
132 Returns average char width in standard font.
133 It is used as DC-independent metrics.
135 @note This function doesn't return the @e actual width. If you want to
136 know the height of the current font, call @c GetDC->GetCharWidth().
138 int GetCharWidth() const;
141 Returns pointer to the currently opened container (see @ref overview_html_cells).
144 m_WParser -> GetContainer() -> InsertCell(new ...);
147 wxHtmlContainerCell
* GetContainer() const;
150 Returns pointer to the DC used during parsing.
155 Returns wxEncodingConverter class used to do conversion between the
156 @ref GetInputEncoding() "input encoding" and the
157 @ref GetOutputEncoding() "output encoding".
159 wxEncodingConverter
* GetEncodingConverter() const;
162 Returns @true if actual font is bold, @false otherwise.
164 int GetFontBold() const;
167 Returns actual font face name.
169 wxString
GetFontFace() const;
172 Returns @true if actual font is fixed face, @false otherwise.
174 int GetFontFixed() const;
177 Returns @true if actual font is italic, @false otherwise.
179 int GetFontItalic() const;
182 Returns actual font size (HTML size varies from -2 to +4)
184 int GetFontSize() const;
187 Returns @true if actual font is underlined, @false otherwise.
189 int GetFontUnderlined() const;
192 Returns input encoding.
194 wxFontEncoding
GetInputEncoding() const;
197 Returns actual hypertext link.
198 (This value has a non-empty @ref wxHtmlLinkInfo::GetHref Href string
199 if the parser is between \<A\> and \</A\> tags, wxEmptyString otherwise.)
201 const wxHtmlLinkInfo
& GetLink() const;
204 Returns the colour of hypertext link text.
206 const wxColour
& GetLinkColor() const;
209 Returns output encoding, i.e. closest match to document's input encoding
210 that is supported by operating system.
212 wxFontEncoding
GetOutputEncoding() const;
215 Returns associated window (wxHtmlWindow). This may be @NULL!
216 (You should always test if it is non-@NULL.
217 For example @c TITLE handler sets window title only if some window is
218 associated, otherwise it does nothing.
220 wxHtmlWindow
* GetWindow();
223 Opens new container and returns pointer to it (see @ref overview_html_cells).
225 wxHtmlContainerCell
* OpenContainer();
228 Sets actual text colour. Note: this DOESN'T change the colour!
229 You must create wxHtmlColourCell yourself.
231 void SetActualColor(const wxColour
& clr
);
234 Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).
235 Alignment of newly opened container is set to this value.
237 void SetAlign(int a
);
240 Allows you to directly set opened container.
241 This is not recommended - you should use OpenContainer() wherever possible.
243 wxHtmlContainerCell
* SetContainer(wxHtmlContainerCell
* c
);
246 Sets the DC. This must be called before wxHtmlParser::Parse!
248 @a pixel_scale can be used when rendering to high-resolution
249 DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in
250 HTML are given in pixels -- e.g. image sizes. 300x300 image would be only one
251 inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)
253 virtual void SetDC(wxDC
* dc
, double pixel_scale
= 1.0e+0);
256 Sets bold flag of actualfont. @a x is either @true of @false.
258 void SetFontBold(int x
);
261 Sets current font face to @a face. This affects either fixed size
262 font or proportional, depending on context (whether the parser is
263 inside @c \<TT\> tag or not).
265 void SetFontFace(const wxString
& face
);
268 Sets fixed face flag of actualfont. @a x is either @true of @false.
270 void SetFontFixed(int x
);
273 Sets italic flag of actualfont. @a x is either @true of @false.
275 void SetFontItalic(int x
);
278 Sets actual font size (HTML size varies from 1 to 7).
280 void SetFontSize(int s
);
283 Sets underlined flag of actualfont. @a x is either @true of @false.
285 void SetFontUnderlined(int x
);
288 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
290 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
291 const int* sizes
= 0);
294 Sets input encoding. The parser uses this information to build conversion
295 tables from document's encoding to some encoding supported by operating system.
297 void SetInputEncoding(wxFontEncoding enc
);
300 Sets actual hypertext link.
301 Empty link is represented by wxHtmlLinkInfo with @e Href equal
304 void SetLink(const wxHtmlLinkInfo
& link
);
307 Sets colour of hypertext link.
309 void SetLinkColor(const wxColour
& clr
);