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