]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/html/htmprint.h
document wxFont(wxString) ctor
[wxWidgets.git] / interface / wx / html / htmprint.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: html/htmprint.h
e54c96f1 3// Purpose: interface of wxHtmlDCRenderer
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHtmlDCRenderer
7c913512 11
5bddd46d
FM
12 This class can render HTML document into a specified area of a DC.
13 You can use it in your own printing code, although use of wxHtmlEasyPrinting
23324ae1 14 or wxHtmlPrintout is strongly recommended.
7c913512 15
23324ae1 16 @library{wxhtml}
5bddd46d 17 @category{html}
23324ae1
FM
18*/
19class wxHtmlDCRenderer : public wxObject
20{
21public:
22 /**
23 Constructor.
24 */
25 wxHtmlDCRenderer();
26
27 /**
4209475c
VZ
28 Returns the width of the HTML text in pixels.
29
30 This can be compared with the width parameter of SetSize() to check if
31 the document being printed fits into the page boundary.
32
33 @see GetTotalHeight()
34
35 @since 2.9.0
36 */
37 int GetTotalWidth() const;
38
39 /**
40 Returns the height of the HTML text in pixels.
41
42 This is important if area height (see wxHtmlDCRenderer::SetSize) is
43 smaller that total height and thus the page cannot fit into it. In that
44 case you're supposed to call Render() as long as its return value is
45 smaller than GetTotalHeight()'s.
46
47 @see GetTotalWidth()
23324ae1 48 */
4209475c 49 int GetTotalHeight() const;
23324ae1
FM
50
51 /**
52 Renders HTML text to the DC.
5bddd46d 53
7c913512 54 @param x,y
f21dd16b
FM
55 position of upper-left corner of printing rectangle (see SetSize()).
56 @param known_pagebreaks
57 @todo docme
7c913512 58 @param from
f21dd16b 59 y-coordinate of the very first visible cell.
7c913512 60 @param dont_render
4cc4bfaf 61 if @true then this method only returns y coordinate of the next page
f21dd16b
FM
62 and does not output anything.
63 @param to
64 y-coordinate of the last visible cell.
5bddd46d
FM
65
66 Returned value is y coordinate of first cell than didn't fit onto page.
131fc120
VS
67 Use this value as from in next call to Render() in order to print
68 multipages document.
5bddd46d 69
131fc120
VS
70 @note
71 The following three methods @b must always be called before any call to
72 Render(), in this order:
5bddd46d
FM
73 - SetDC()
74 - SetSize()
75 - SetHtmlText()
131fc120
VS
76
77 @note Render() changes the DC's user scale and does NOT restore it.
23324ae1 78 */
5267aefd 79 int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
a44f3b5a 80 int dont_render = false, int to = INT_MAX);
23324ae1
FM
81
82 /**
83 Assign DC instance to the renderer.
5bddd46d 84
4cc4bfaf 85 @a pixel_scale can be used when rendering to high-resolution DCs (e.g. printer)
23324ae1 86 to adjust size of pixel metrics.
5bddd46d
FM
87 (Many dimensions in HTML are given in pixels -- e.g. image sizes. 300x300
88 image would be only one inch wide on typical printer. With pixel_scale = 3.0
89 it would be 3 inches.)
23324ae1 90 */
4cc4bfaf 91 void SetDC(wxDC* dc, double pixel_scale = 1.0);
23324ae1
FM
92
93 /**
5bddd46d
FM
94 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
95
96 @see SetSize()
23324ae1 97 */
5267aefd
FM
98 void SetFonts(const wxString& normal_face, const wxString& fixed_face,
99 const int* sizes = NULL);
23324ae1
FM
100
101 /**
5bddd46d
FM
102 Assign text to the renderer. Render() then draws the text onto DC.
103
7c913512 104 @param html
4cc4bfaf 105 HTML text. This is not a filename.
7c913512 106 @param basepath
5bddd46d
FM
107 base directory (html string would be stored there if it was in file).
108 It is used to determine path for loading images, for example.
7c913512 109 @param isdir
4cc4bfaf 110 @false if basepath is filename, @true if it is directory name
5bddd46d 111 (see wxFileSystem for detailed explanation).
23324ae1
FM
112 */
113 void SetHtmlText(const wxString& html,
114 const wxString& basepath = wxEmptyString,
4cc4bfaf 115 bool isdir = true);
23324ae1
FM
116
117 /**
118 Set size of output rectangle, in pixels. Note that you @b can't change
119 width of the rectangle between calls to wxHtmlDCRenderer::Render!
120 (You can freely change height.)
121 */
122 void SetSize(int width, int height);
123};
124
125
e54c96f1 126
23324ae1
FM
127/**
128 @class wxHtmlEasyPrinting
7c913512 129
5bddd46d
FM
130 This class provides very simple interface to printing architecture.
131 It allows you to print HTML documents using only a few commands.
132
133 @note
134 Do not create this class on the stack only. You should create an instance
135 on app startup and use this instance for all printing operations.
136 The reason is that this class stores various settings in it.
7c913512 137
23324ae1 138 @library{wxhtml}
5bddd46d 139 @category{html,printing}
23324ae1
FM
140*/
141class wxHtmlEasyPrinting : public wxObject
142{
143public:
144 /**
145 Constructor.
5bddd46d 146
7c913512 147 @param name
4cc4bfaf 148 Name of the printing object. Used by preview frames and setup dialogs.
7c913512 149 @param parentWindow
4cc4bfaf 150 pointer to the window that will own the preview frame and setup dialogs.
5bddd46d 151 May be @NULL.
23324ae1
FM
152 */
153 wxHtmlEasyPrinting(const wxString& name = "Printing",
4cc4bfaf 154 wxWindow* parentWindow = NULL);
23324ae1
FM
155
156 /**
5bddd46d
FM
157 Returns a pointer to wxPageSetupDialogData instance used by this class.
158 You can set its parameters (via SetXXXX methods).
23324ae1
FM
159 */
160 wxPageSetupDialogData* GetPageSetupData();
161
162 /**
163 Gets the parent window for dialogs.
164 */
328f5751 165 wxWindow* GetParentWindow() const;
23324ae1
FM
166
167 /**
5bddd46d
FM
168 Returns pointer to wxPrintData instance used by this class.
169 You can set its parameters (via SetXXXX methods).
23324ae1
FM
170 */
171 wxPrintData* GetPrintData();
172
173 /**
174 Display page setup dialog and allows the user to modify settings.
175 */
176 void PageSetup();
177
178 /**
7c913512 179 Preview HTML file.
5bddd46d
FM
180
181 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
23324ae1
FM
182 information about the kind of the error.
183 */
184 bool PreviewFile(const wxString& htmlfile);
185
186 /**
7c913512 187 Preview HTML text (not file!).
5bddd46d
FM
188
189 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
23324ae1 190 information about the kind of the error.
5bddd46d 191
7c913512 192 @param htmltext
4cc4bfaf 193 HTML text.
7c913512 194 @param basepath
5bddd46d
FM
195 base directory (html string would be stored there if it was in file).
196 It is used to determine path for loading images, for example.
23324ae1
FM
197 */
198 bool PreviewText(const wxString& htmltext,
199 const wxString& basepath = wxEmptyString);
200
201 /**
202 Print HTML file.
5bddd46d
FM
203
204 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
23324ae1
FM
205 information about the kind of the error.
206 */
207 bool PrintFile(const wxString& htmlfile);
208
209 /**
7c913512 210 Print HTML text (not file!).
5bddd46d
FM
211
212 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
23324ae1 213 information about the kind of the error.
5bddd46d 214
7c913512 215 @param htmltext
4cc4bfaf 216 HTML text.
7c913512 217 @param basepath
5bddd46d
FM
218 base directory (html string would be stored there if it was in file).
219 It is used to determine path for loading images, for example.
23324ae1
FM
220 */
221 bool PrintText(const wxString& htmltext,
222 const wxString& basepath = wxEmptyString);
223
224 /**
5bddd46d 225 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
23324ae1 226 */
5267aefd
FM
227 void SetFonts(const wxString& normal_face, const wxString& fixed_face,
228 const int* sizes = NULL);
23324ae1
FM
229
230 /**
231 Set page footer. The following macros can be used inside it:
2f663107
VZ
232 @@DATE@ is replaced by the current date in default format
233 @@PAGENUM@ is replaced by page number
234 @@PAGESCNT@ is replaced by total number of pages
235 @@TIME@ is replaced by the current time in default format
236 @@TITLE@ is replaced with the title of the document
5bddd46d 237
7c913512 238 @param footer
4cc4bfaf 239 HTML text to be used as footer.
7c913512 240 @param pg
4cc4bfaf 241 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
23324ae1
FM
242 */
243 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
244
245 /**
246 Set page header. The following macros can be used inside it:
5bddd46d
FM
247 - @@DATE@ is replaced by the current date in default format
248 - @@PAGENUM@ is replaced by page number
249 - @@PAGESCNT@ is replaced by total number of pages
250 - @@TIME@ is replaced by the current time in default format
251 - @@TITLE@ is replaced with the title of the document
252
7c913512 253 @param header
4cc4bfaf 254 HTML text to be used as header.
7c913512 255 @param pg
4cc4bfaf 256 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
23324ae1
FM
257 */
258 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
259
260 /**
261 Sets the parent window for dialogs.
262 */
263 void SetParentWindow(wxWindow* window);
4209475c
VZ
264
265private:
266 /**
267 Check whether the document fits into the page area.
268
269 This function is called by the base class OnPreparePrinting()
270 implementation and by default checks whether the document fits into
271 @a pageArea horizontally and warns the user if it does not, giving him
272 the possibility to cancel printing in this case (presumably in order to
273 change some layout options and retry it again).
274
275 You may override it to either suppress this check if truncation of the
276 HTML being printed is acceptable or, on the contrary, add more checks to
277 it, e.g. for the fit in the vertical direction if the document should
278 always appear on a single page.
279
280 @return
281 @true if wxHtmlPrintout should continue or @false to cancel
282 printing.
283
284 @since 2.9.0
285 */
286 virtual bool CheckFit(const wxSize& pageArea, const wxSize& docArea) const;
23324ae1
FM
287};
288
289
e54c96f1 290
23324ae1
FM
291/**
292 @class wxHtmlPrintout
7c913512 293
23324ae1 294 This class serves as printout class for HTML documents.
7c913512 295
23324ae1 296 @library{wxhtml}
5bddd46d 297 @category{html,printing}
23324ae1
FM
298*/
299class wxHtmlPrintout : public wxPrintout
300{
301public:
302 /**
303 Constructor.
304 */
305 wxHtmlPrintout(const wxString& title = "Printout");
306
307 /**
5bddd46d
FM
308 Adds a filter to the static list of filters for wxHtmlPrintout.
309 See wxHtmlFilter for further information.
23324ae1
FM
310 */
311 static void AddFilter(wxHtmlFilter* filter);
312
313 /**
5bddd46d 314 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
23324ae1 315 */
5267aefd
FM
316 void SetFonts(const wxString& normal_face, const wxString& fixed_face,
317 const int* sizes = NULL);
23324ae1
FM
318
319 /**
320 Set page footer. The following macros can be used inside it:
5bddd46d
FM
321 - @@DATE@ is replaced by the current date in default format
322 - @@PAGENUM@ is replaced by page number
323 - @@PAGESCNT@ is replaced by total number of pages
324 - @@TIME@ is replaced by the current time in default format
325 - @@TITLE@ is replaced with the title of the document
326
7c913512 327 @param footer
4cc4bfaf 328 HTML text to be used as footer.
7c913512 329 @param pg
4cc4bfaf 330 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
23324ae1
FM
331 */
332 void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
333
334 /**
335 Set page header. The following macros can be used inside it:
5bddd46d
FM
336 - @@DATE@ is replaced by the current date in default format
337 - @@PAGENUM@ is replaced by page number
338 - @@PAGESCNT@ is replaced by total number of pages
339 - @@TIME@ is replaced by the current time in default format
340 - @@TITLE@ is replaced with the title of the document
341
7c913512 342 @param header
4cc4bfaf 343 HTML text to be used as header.
7c913512 344 @param pg
4cc4bfaf 345 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
23324ae1
FM
346 */
347 void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
348
349 /**
5bddd46d
FM
350 Prepare the class for printing this HTML @b file.
351 The file may be located on any virtual file system or it may be normal file.
23324ae1
FM
352 */
353 void SetHtmlFile(const wxString& htmlfile);
354
355 /**
356 Prepare the class for printing this HTML text.
5bddd46d 357
7c913512 358 @param html
4cc4bfaf 359 HTML text. (NOT file!)
7c913512 360 @param basepath
5bddd46d
FM
361 base directory (html string would be stored there if it was in file).
362 It is used to determine path for loading images, for example.
7c913512 363 @param isdir
4cc4bfaf 364 @false if basepath is filename, @true if it is directory name
5bddd46d 365 (see wxFileSystem for detailed explanation).
23324ae1
FM
366 */
367 void SetHtmlText(const wxString& html,
368 const wxString& basepath = wxEmptyString,
4cc4bfaf 369 bool isdir = true);
23324ae1
FM
370
371 /**
5bddd46d
FM
372 Sets margins in millimeters.
373 Defaults to 1 inch for margins and 0.5cm for space between text and header
374 and/or footer.
23324ae1
FM
375 */
376 void SetMargins(float top = 25.2, float bottom = 25.2,
377 float left = 25.2,
378 float right = 25.2,
379 float spaces = 5);
380};
e54c96f1 381