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