]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/html/htmprint.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmprint.h
3 // Purpose: interface of wxHtmlDCRenderer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHtmlDCRenderer
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
14 or wxHtmlPrintout is strongly recommended.
19 class wxHtmlDCRenderer
: public wxObject
28 Returns the width of the HTML text in pixels.
30 This can be compared with the width parameter of SetSize() to check if
31 the document being printed fits into the page boundary.
37 int GetTotalWidth() const;
40 Returns the height of the HTML text in pixels.
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.
49 int GetTotalHeight() const;
52 Renders HTML text to the DC.
55 position of upper-left corner of printing rectangle (see SetSize()).
56 @param known_pagebreaks
59 y-coordinate of the very first visible cell.
61 if @true then this method only returns y coordinate of the next page
62 and does not output anything.
64 y-coordinate of the last visible cell.
66 Returned value is y coordinate of first cell than didn't fit onto page.
67 Use this value as from in next call to Render() in order to print
71 The following three methods @b must always be called before any call to
72 Render(), in this order:
77 @note Render() changes the DC's user scale and does NOT restore it.
79 int Render(int x
, int y
, wxArrayInt
& known_pagebreaks
, int from
= 0,
80 int dont_render
= false, int to
= INT_MAX
);
83 Assign DC instance to the renderer.
85 @a pixel_scale can be used when rendering to high-resolution DCs (e.g. printer)
86 to adjust size of pixel metrics.
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.)
91 void SetDC(wxDC
* dc
, double pixel_scale
= 1.0);
94 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
98 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
99 const int* sizes
= NULL
);
102 Assign text to the renderer. Render() then draws the text onto DC.
105 HTML text. This is not a filename.
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.
110 @false if basepath is filename, @true if it is directory name
111 (see wxFileSystem for detailed explanation).
113 void SetHtmlText(const wxString
& html
,
114 const wxString
& basepath
= wxEmptyString
,
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.)
122 void SetSize(int width
, int height
);
128 @class wxHtmlEasyPrinting
130 This class provides very simple interface to printing architecture.
131 It allows you to print HTML documents using only a few commands.
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.
139 @category{html,printing}
141 class wxHtmlEasyPrinting
: public wxObject
148 Name of the printing object. Used by preview frames and setup dialogs.
150 pointer to the window that will own the preview frame and setup dialogs.
153 wxHtmlEasyPrinting(const wxString
& name
= "Printing",
154 wxWindow
* parentWindow
= NULL
);
157 Returns a pointer to wxPageSetupDialogData instance used by this class.
158 You can set its parameters (via SetXXXX methods).
160 wxPageSetupDialogData
* GetPageSetupData();
163 Gets the parent window for dialogs.
165 wxWindow
* GetParentWindow() const;
168 Returns pointer to wxPrintData instance used by this class.
169 You can set its parameters (via SetXXXX methods).
171 wxPrintData
* GetPrintData();
174 Display page setup dialog and allows the user to modify settings.
181 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
182 information about the kind of the error.
184 bool PreviewFile(const wxString
& htmlfile
);
187 Preview HTML text (not file!).
189 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
190 information about the kind of the error.
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.
198 bool PreviewText(const wxString
& htmltext
,
199 const wxString
& basepath
= wxEmptyString
);
204 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
205 information about the kind of the error.
207 bool PrintFile(const wxString
& htmlfile
);
210 Print HTML text (not file!).
212 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
213 information about the kind of the error.
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.
221 bool PrintText(const wxString
& htmltext
,
222 const wxString
& basepath
= wxEmptyString
);
225 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
227 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
228 const int* sizes
= NULL
);
231 Set page footer. The following macros can be used inside it:
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
239 HTML text to be used as footer.
241 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
243 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
246 Set page header. The following macros can be used inside it:
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
254 HTML text to be used as header.
256 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
258 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
261 Sets the parent window for dialogs.
263 void SetParentWindow(wxWindow
* window
);
267 Check whether the document fits into the page area.
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).
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.
281 @true if wxHtmlPrintout should continue or @false to cancel
286 virtual bool CheckFit(const wxSize
& pageArea
, const wxSize
& docArea
) const;
292 @class wxHtmlPrintout
294 This class serves as printout class for HTML documents.
297 @category{html,printing}
299 class wxHtmlPrintout
: public wxPrintout
305 wxHtmlPrintout(const wxString
& title
= "Printout");
308 Adds a filter to the static list of filters for wxHtmlPrintout.
309 See wxHtmlFilter for further information.
311 static void AddFilter(wxHtmlFilter
* filter
);
314 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
316 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
317 const int* sizes
= NULL
);
320 Set page footer. The following macros can be used inside it:
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
328 HTML text to be used as footer.
330 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
332 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
335 Set page header. The following macros can be used inside it:
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
343 HTML text to be used as header.
345 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
347 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
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.
353 void SetHtmlFile(const wxString
& htmlfile
);
356 Prepare the class for printing this HTML text.
359 HTML text. (NOT file!)
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.
364 @false if basepath is filename, @true if it is directory name
365 (see wxFileSystem for detailed explanation).
367 void SetHtmlText(const wxString
& html
,
368 const wxString
& basepath
= wxEmptyString
,
372 Sets margins in millimeters.
373 Defaults to 1 inch for margins and 0.5cm for space between text and header
376 void SetMargins(float top
= 25.2, float bottom
= 25.2,