]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: html/winpars.h | |
e54c96f1 | 3 | // Purpose: interface of wxHtmlTagsModule |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | /** | |
9 | @class wxHtmlTagsModule | |
7c913512 | 10 | |
23324ae1 FM |
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 | |
5bddd46d | 13 | @ref overview_html_handlers "TAGS_MODULE_* macros" |
7c913512 | 14 | |
23324ae1 | 15 | @library{wxhtml} |
5bddd46d | 16 | @category{html} |
7c913512 | 17 | |
5bddd46d | 18 | @see @ref overview_html_handlers, wxHtmlTagHandler, wxHtmlWinTagHandler |
23324ae1 FM |
19 | */ |
20 | class wxHtmlTagsModule : public wxModule | |
21 | { | |
22 | public: | |
23 | /** | |
24 | You must override this method. In most common case its body consists | |
25 | only of lines of the following type: | |
5bddd46d FM |
26 | @code |
27 | parser -> AddTagHandler(new MyHandler); | |
28 | @endcode | |
29 | ||
30 | It's recommended to use the @b TAGS_MODULE_* macros. | |
31 | ||
7c913512 | 32 | @param parser |
4cc4bfaf | 33 | Pointer to the parser that requested tables filling. |
23324ae1 | 34 | */ |
5bddd46d | 35 | virtual void FillHandlersTable(wxHtmlWinParser* parser); |
23324ae1 FM |
36 | }; |
37 | ||
38 | ||
e54c96f1 | 39 | |
23324ae1 FM |
40 | /** |
41 | @class wxHtmlWinTagHandler | |
7c913512 | 42 | |
5bddd46d FM |
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). | |
7c913512 | 46 | |
23324ae1 FM |
47 | @library{wxhtml} |
48 | @category{html} | |
49 | */ | |
50 | class wxHtmlWinTagHandler : public wxHtmlTagHandler | |
51 | { | |
047ea2e2 | 52 | public: |
c0d87687 RD |
53 | /** |
54 | Constructor. | |
55 | */ | |
56 | wxHtmlWinTagHandler(); | |
3f7564f2 | 57 | |
047ea2e2 RD |
58 | /** |
59 | Assigns @a parser to this handler. Each @b instance of handler | |
60 | is guaranteed to be called only from the one parser. | |
61 | */ | |
62 | virtual void SetParser(wxHtmlWinParser* parser); | |
63 | ||
5bddd46d | 64 | protected: |
23324ae1 | 65 | /** |
5bddd46d FM |
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.) | |
23324ae1 | 69 | */ |
5bddd46d | 70 | wxHtmlWinParser* m_WParser; |
23324ae1 FM |
71 | }; |
72 | ||
73 | ||
e54c96f1 | 74 | |
23324ae1 FM |
75 | /** |
76 | @class wxHtmlWinParser | |
7c913512 | 77 | |
5bddd46d FM |
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. | |
81 | ||
82 | @note The product of parsing is a wxHtmlCell (resp. wxHtmlContainer) object. | |
7c913512 | 83 | |
23324ae1 FM |
84 | @library{wxhtml} |
85 | @category{html} | |
7c913512 | 86 | |
5bddd46d | 87 | @see @ref overview_html_handlers |
23324ae1 FM |
88 | */ |
89 | class wxHtmlWinParser : public wxHtmlParser | |
90 | { | |
91 | public: | |
23324ae1 | 92 | /** |
5bddd46d FM |
93 | Constructor. |
94 | ||
50ec54b6 | 95 | Don't use the default one, use the constructor with @a wndIface parameter |
5bddd46d FM |
96 | (@a wndIface is a pointer to interface object for the associated wxHtmlWindow |
97 | or other HTML rendering window such as wxHtmlListBox). | |
23324ae1 | 98 | */ |
50ec54b6 | 99 | wxHtmlWinParser(wxHtmlWindowInterface* wndIface = NULL); |
23324ae1 FM |
100 | |
101 | /** | |
e54c96f1 | 102 | Adds module() to the list of wxHtmlWinParser tag handler. |
23324ae1 | 103 | */ |
382f12e4 | 104 | static void AddModule(wxHtmlTagsModule* module); |
23324ae1 FM |
105 | |
106 | /** | |
107 | Closes the container, sets actual container to the parent one | |
5bddd46d | 108 | and returns pointer to it (see @ref overview_html_cells). |
23324ae1 FM |
109 | */ |
110 | wxHtmlContainerCell* CloseContainer(); | |
111 | ||
112 | /** | |
5bddd46d FM |
113 | Creates font based on current setting (see SetFontSize(), SetFontBold(), |
114 | SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined) | |
23324ae1 | 115 | and returns pointer to it. |
5bddd46d | 116 | |
23324ae1 FM |
117 | If the font was already created only a pointer is returned. |
118 | */ | |
119 | virtual wxFont* CreateCurrentFont(); | |
120 | ||
121 | /** | |
122 | Returns actual text colour. | |
123 | */ | |
95b4a59e | 124 | const wxColour& GetActualColor() const; |
23324ae1 FM |
125 | |
126 | /** | |
127 | Returns default horizontal alignment. | |
128 | */ | |
328f5751 | 129 | int GetAlign() const; |
23324ae1 FM |
130 | |
131 | /** | |
5bddd46d FM |
132 | Returns (average) char height in standard font. |
133 | It is used as DC-independent metrics. | |
134 | ||
cdbcf4c2 | 135 | @note This function doesn't return the @e actual height. If you want to |
5bddd46d | 136 | know the height of the current font, call @c GetDC->GetCharHeight(). |
23324ae1 | 137 | */ |
328f5751 | 138 | int GetCharHeight() const; |
23324ae1 FM |
139 | |
140 | /** | |
5bddd46d FM |
141 | Returns average char width in standard font. |
142 | It is used as DC-independent metrics. | |
143 | ||
cdbcf4c2 | 144 | @note This function doesn't return the @e actual width. If you want to |
5bddd46d | 145 | know the height of the current font, call @c GetDC->GetCharWidth(). |
23324ae1 | 146 | */ |
328f5751 | 147 | int GetCharWidth() const; |
23324ae1 FM |
148 | |
149 | /** | |
5bddd46d | 150 | Returns pointer to the currently opened container (see @ref overview_html_cells). |
23324ae1 | 151 | Common use: |
5bddd46d FM |
152 | @code |
153 | m_WParser -> GetContainer() -> InsertCell(new ...); | |
154 | @endcode | |
23324ae1 | 155 | */ |
328f5751 | 156 | wxHtmlContainerCell* GetContainer() const; |
23324ae1 FM |
157 | |
158 | /** | |
159 | Returns pointer to the DC used during parsing. | |
160 | */ | |
4cc4bfaf | 161 | wxDC* GetDC(); |
23324ae1 FM |
162 | |
163 | /** | |
5bddd46d FM |
164 | Returns wxEncodingConverter class used to do conversion between the |
165 | @ref GetInputEncoding() "input encoding" and the | |
166 | @ref GetOutputEncoding() "output encoding". | |
23324ae1 | 167 | */ |
328f5751 | 168 | wxEncodingConverter* GetEncodingConverter() const; |
23324ae1 FM |
169 | |
170 | /** | |
171 | Returns @true if actual font is bold, @false otherwise. | |
172 | */ | |
328f5751 | 173 | int GetFontBold() const; |
23324ae1 FM |
174 | |
175 | /** | |
176 | Returns actual font face name. | |
177 | */ | |
328f5751 | 178 | wxString GetFontFace() const; |
23324ae1 FM |
179 | |
180 | /** | |
181 | Returns @true if actual font is fixed face, @false otherwise. | |
182 | */ | |
328f5751 | 183 | int GetFontFixed() const; |
23324ae1 FM |
184 | |
185 | /** | |
186 | Returns @true if actual font is italic, @false otherwise. | |
187 | */ | |
328f5751 | 188 | int GetFontItalic() const; |
23324ae1 FM |
189 | |
190 | /** | |
191 | Returns actual font size (HTML size varies from -2 to +4) | |
192 | */ | |
328f5751 | 193 | int GetFontSize() const; |
23324ae1 FM |
194 | |
195 | /** | |
196 | Returns @true if actual font is underlined, @false otherwise. | |
197 | */ | |
328f5751 | 198 | int GetFontUnderlined() const; |
23324ae1 FM |
199 | |
200 | /** | |
201 | Returns input encoding. | |
202 | */ | |
328f5751 | 203 | wxFontEncoding GetInputEncoding() const; |
23324ae1 FM |
204 | |
205 | /** | |
5bddd46d FM |
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.) | |
23324ae1 | 209 | */ |
95b4a59e | 210 | const wxHtmlLinkInfo& GetLink() const; |
23324ae1 FM |
211 | |
212 | /** | |
213 | Returns the colour of hypertext link text. | |
214 | */ | |
95b4a59e | 215 | const wxColour& GetLinkColor() const; |
23324ae1 FM |
216 | |
217 | /** | |
218 | Returns output encoding, i.e. closest match to document's input encoding | |
219 | that is supported by operating system. | |
220 | */ | |
328f5751 | 221 | wxFontEncoding GetOutputEncoding() const; |
23324ae1 FM |
222 | |
223 | /** | |
5bddd46d FM |
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. | |
90f011dc RD |
228 | */ |
229 | wxHtmlWindowInterface* GetWindowInterface(); | |
23324ae1 FM |
230 | |
231 | /** | |
5bddd46d | 232 | Opens new container and returns pointer to it (see @ref overview_html_cells). |
23324ae1 FM |
233 | */ |
234 | wxHtmlContainerCell* OpenContainer(); | |
235 | ||
236 | /** | |
237 | Sets actual text colour. Note: this DOESN'T change the colour! | |
238 | You must create wxHtmlColourCell yourself. | |
239 | */ | |
240 | void SetActualColor(const wxColour& clr); | |
241 | ||
242 | /** | |
5bddd46d | 243 | Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor). |
23324ae1 FM |
244 | Alignment of newly opened container is set to this value. |
245 | */ | |
246 | void SetAlign(int a); | |
247 | ||
248 | /** | |
5bddd46d FM |
249 | Allows you to directly set opened container. |
250 | This is not recommended - you should use OpenContainer() wherever possible. | |
23324ae1 | 251 | */ |
4cc4bfaf | 252 | wxHtmlContainerCell* SetContainer(wxHtmlContainerCell* c); |
23324ae1 FM |
253 | |
254 | /** | |
255 | Sets the DC. This must be called before wxHtmlParser::Parse! | |
5bddd46d | 256 | |
4cc4bfaf | 257 | @a pixel_scale can be used when rendering to high-resolution |
7c913512 | 258 | DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in |
23324ae1 FM |
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.) | |
261 | */ | |
95b4a59e | 262 | virtual void SetDC(wxDC* dc, double pixel_scale = 1.0e+0); |
23324ae1 FM |
263 | |
264 | /** | |
4cc4bfaf | 265 | Sets bold flag of actualfont. @a x is either @true of @false. |
23324ae1 FM |
266 | */ |
267 | void SetFontBold(int x); | |
268 | ||
269 | /** | |
5bddd46d | 270 | Sets current font face to @a face. This affects either fixed size |
7c913512 | 271 | font or proportional, depending on context (whether the parser is |
5bddd46d | 272 | inside @c \<TT\> tag or not). |
23324ae1 FM |
273 | */ |
274 | void SetFontFace(const wxString& face); | |
275 | ||
276 | /** | |
4cc4bfaf | 277 | Sets fixed face flag of actualfont. @a x is either @true of @false. |
23324ae1 FM |
278 | */ |
279 | void SetFontFixed(int x); | |
280 | ||
281 | /** | |
4cc4bfaf | 282 | Sets italic flag of actualfont. @a x is either @true of @false. |
23324ae1 FM |
283 | */ |
284 | void SetFontItalic(int x); | |
285 | ||
286 | /** | |
5bddd46d | 287 | Sets actual font size (HTML size varies from 1 to 7). |
23324ae1 FM |
288 | */ |
289 | void SetFontSize(int s); | |
290 | ||
291 | /** | |
4cc4bfaf | 292 | Sets underlined flag of actualfont. @a x is either @true of @false. |
23324ae1 FM |
293 | */ |
294 | void SetFontUnderlined(int x); | |
295 | ||
296 | /** | |
5bddd46d | 297 | Sets fonts. See wxHtmlWindow::SetFonts for detailed description. |
23324ae1 | 298 | */ |
95b4a59e FM |
299 | void SetFonts(const wxString& normal_face, const wxString& fixed_face, |
300 | const int* sizes = 0); | |
23324ae1 FM |
301 | |
302 | /** | |
303 | Sets input encoding. The parser uses this information to build conversion | |
5bddd46d | 304 | tables from document's encoding to some encoding supported by operating system. |
23324ae1 FM |
305 | */ |
306 | void SetInputEncoding(wxFontEncoding enc); | |
307 | ||
308 | /** | |
5bddd46d FM |
309 | Sets actual hypertext link. |
310 | Empty link is represented by wxHtmlLinkInfo with @e Href equal | |
23324ae1 FM |
311 | to wxEmptyString. |
312 | */ | |
313 | void SetLink(const wxHtmlLinkInfo& link); | |
314 | ||
315 | /** | |
316 | Sets colour of hypertext link. | |
317 | */ | |
318 | void SetLinkColor(const wxColour& clr); | |
319 | }; | |
e54c96f1 | 320 |