]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/html/winpars.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/winpars.h
3 // Purpose: interface of wxHtmlTagsModule
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 @class wxHtmlTagsModule
11 This class provides easy way of filling wxHtmlWinParser's table of
12 tag handlers. It is used almost exclusively together with the set of
13 @ref overview_html_handlers "TAGS_MODULE_* macros"
18 @see @ref overview_html_handlers, wxHtmlTagHandler, wxHtmlWinTagHandler
20 class wxHtmlTagsModule
: public wxModule
24 You must override this method. In most common case its body consists
25 only of lines of the following type:
27 parser -> AddTagHandler(new MyHandler);
30 It's recommended to use the @b TAGS_MODULE_* macros.
33 Pointer to the parser that requested tables filling.
35 virtual void FillHandlersTable(wxHtmlWinParser
* parser
);
41 @class wxHtmlWinTagHandler
43 This is basically wxHtmlTagHandler except that it is extended with protected
44 member m_WParser pointing to the wxHtmlWinParser object (value of this member
45 is identical to wxHtmlParser's m_Parser).
50 class wxHtmlWinTagHandler
: public wxHtmlTagHandler
56 wxHtmlWinTagHandler();
59 Assigns @a parser to this handler. Each @b instance of handler
60 is guaranteed to be called only from the one parser.
62 virtual void SetParser(wxHtmlWinParser
* parser
);
66 Value of this attribute is identical to value of m_Parser.
67 The only difference is that m_WParser points to wxHtmlWinParser object
68 while m_Parser points to wxHtmlParser object. (The same object, but overcast.)
70 wxHtmlWinParser
* m_WParser
;
76 @class wxHtmlWinParser
78 This class is derived from wxHtmlParser and its main goal is to parse HTML
79 input so that it can be displayed in wxHtmlWindow.
80 It uses a special wxHtmlWinTagHandler.
82 @note The product of parsing is a wxHtmlCell (resp. wxHtmlContainer) object.
87 @see @ref overview_html_handlers
89 class wxHtmlWinParser
: public wxHtmlParser
95 Don't use the default one, use the constructor with @a wndIface parameter
96 (@a wndIface is a pointer to interface object for the associated wxHtmlWindow
97 or other HTML rendering window such as wxHtmlListBox).
99 wxHtmlWinParser(wxHtmlWindowInterface
* wndIface
= NULL
);
102 Adds module() to the list of wxHtmlWinParser tag handler.
104 static void AddModule(wxHtmlTagsModule
* module);
107 Closes the container, sets actual container to the parent one
108 and returns pointer to it (see @ref overview_html_cells).
110 wxHtmlContainerCell
* CloseContainer();
113 Creates font based on current setting (see SetFontSize(), SetFontBold(),
114 SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined)
115 and returns pointer to it.
117 If the font was already created only a pointer is returned.
119 virtual wxFont
* CreateCurrentFont();
122 Returns actual text colour.
124 const wxColour
& GetActualColor() const;
127 Returns default horizontal alignment.
129 int GetAlign() const;
132 Returns (average) char height in standard font.
133 It is used as DC-independent metrics.
135 @note This function doesn't return the @e actual height. If you want to
136 know the height of the current font, call @c GetDC->GetCharHeight().
138 int GetCharHeight() const;
141 Returns average char width in standard font.
142 It is used as DC-independent metrics.
144 @note This function doesn't return the @e actual width. If you want to
145 know the height of the current font, call @c GetDC->GetCharWidth().
147 int GetCharWidth() const;
150 Returns pointer to the currently opened container (see @ref overview_html_cells).
153 m_WParser -> GetContainer() -> InsertCell(new ...);
156 wxHtmlContainerCell
* GetContainer() const;
159 Returns pointer to the DC used during parsing.
164 Returns wxEncodingConverter class used to do conversion between the
165 @ref GetInputEncoding() "input encoding" and the
166 @ref GetOutputEncoding() "output encoding".
168 wxEncodingConverter
* GetEncodingConverter() const;
171 Returns @true if actual font is bold, @false otherwise.
173 int GetFontBold() const;
176 Returns actual font face name.
178 wxString
GetFontFace() const;
181 Returns @true if actual font is fixed face, @false otherwise.
183 int GetFontFixed() const;
186 Returns @true if actual font is italic, @false otherwise.
188 int GetFontItalic() const;
191 Returns actual font size (HTML size varies from -2 to +4)
193 int GetFontSize() const;
196 Returns @true if actual font is underlined, @false otherwise.
198 int GetFontUnderlined() const;
201 Returns input encoding.
203 wxFontEncoding
GetInputEncoding() const;
206 Returns actual hypertext link.
207 (This value has a non-empty @ref wxHtmlLinkInfo::GetHref Href string
208 if the parser is between \<A\> and \</A\> tags, wxEmptyString otherwise.)
210 const wxHtmlLinkInfo
& GetLink() const;
213 Returns the colour of hypertext link text.
215 const wxColour
& GetLinkColor() const;
218 Returns output encoding, i.e. closest match to document's input encoding
219 that is supported by operating system.
221 wxFontEncoding
GetOutputEncoding() const;
224 Returns associated window (wxHtmlWindow). This may be @NULL!
225 (You should always test if it is non-@NULL.
226 For example @c TITLE handler sets window title only if some window is
227 associated, otherwise it does nothing.
229 wxHtmlWindowInterface
* GetWindowInterface();
232 Opens new container and returns pointer to it (see @ref overview_html_cells).
234 wxHtmlContainerCell
* OpenContainer();
237 Sets actual text colour. Note: this DOESN'T change the colour!
238 You must create wxHtmlColourCell yourself.
240 void SetActualColor(const wxColour
& clr
);
243 Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).
244 Alignment of newly opened container is set to this value.
246 void SetAlign(int a
);
249 Allows you to directly set opened container.
250 This is not recommended - you should use OpenContainer() wherever possible.
252 wxHtmlContainerCell
* SetContainer(wxHtmlContainerCell
* c
);
255 Sets the DC. This must be called before wxHtmlParser::Parse!
257 @a pixel_scale can be used when rendering to high-resolution
258 DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in
259 HTML are given in pixels -- e.g. image sizes. 300x300 image would be only one
260 inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)
262 virtual void SetDC(wxDC
* dc
, double pixel_scale
= 1.0e+0);
265 Sets bold flag of actualfont. @a x is either @true of @false.
267 void SetFontBold(int x
);
270 Sets current font face to @a face. This affects either fixed size
271 font or proportional, depending on context (whether the parser is
272 inside @c \<TT\> tag or not).
274 void SetFontFace(const wxString
& face
);
277 Sets fixed face flag of actualfont. @a x is either @true of @false.
279 void SetFontFixed(int x
);
282 Sets italic flag of actualfont. @a x is either @true of @false.
284 void SetFontItalic(int x
);
287 Sets actual font size (HTML size varies from 1 to 7).
289 void SetFontSize(int s
);
292 Sets underlined flag of actualfont. @a x is either @true of @false.
294 void SetFontUnderlined(int x
);
297 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
299 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
300 const int* sizes
= 0);
303 Sets input encoding. The parser uses this information to build conversion
304 tables from document's encoding to some encoding supported by operating system.
306 void SetInputEncoding(wxFontEncoding enc
);
309 Sets actual hypertext link.
310 Empty link is represented by wxHtmlLinkInfo with @e Href equal
313 void SetLink(const wxHtmlLinkInfo
& link
);
316 Sets colour of hypertext link.
318 void SetLinkColor(const wxColour
& clr
);