]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/html/htmprint.h
7748f3915e78c02ac013487a64373577e012a944
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 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.
36 Renders HTML text to the DC.
39 position of upper-left corner of printing rectangle (see SetSize())
41 y-coordinate of the very first visible cell
43 if @true then this method only returns y coordinate of the next page
44 and does not output anything
46 Returned value is y coordinate of first cell than didn't fit onto page.
47 Use this value as from in next call to Render() in order to print multipages document.
50 The Following three methods @b must always be called before any call to
51 Render() (preferably in this order):
55 <b>Render() changes the DC's user scale and does NOT restore it.</b>
57 int Render(int x
, int y
, int from
= 0, int dont_render
= false);
60 Assign DC instance to the renderer.
62 @a pixel_scale can be used when rendering to high-resolution DCs (e.g. printer)
63 to adjust size of pixel metrics.
64 (Many dimensions in HTML are given in pixels -- e.g. image sizes. 300x300
65 image would be only one inch wide on typical printer. With pixel_scale = 3.0
66 it would be 3 inches.)
68 void SetDC(wxDC
* dc
, double pixel_scale
= 1.0);
71 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
75 void SetFonts(const wxString
& normal_face
,
76 const wxString
& fixed_face
,
77 const int sizes
= NULL
);
80 Assign text to the renderer. Render() then draws the text onto DC.
83 HTML text. This is not a filename.
85 base directory (html string would be stored there if it was in file).
86 It is used to determine path for loading images, for example.
88 @false if basepath is filename, @true if it is directory name
89 (see wxFileSystem for detailed explanation).
91 void SetHtmlText(const wxString
& html
,
92 const wxString
& basepath
= wxEmptyString
,
96 Set size of output rectangle, in pixels. Note that you @b can't change
97 width of the rectangle between calls to wxHtmlDCRenderer::Render!
98 (You can freely change height.)
100 void SetSize(int width
, int height
);
106 @class wxHtmlEasyPrinting
108 This class provides very simple interface to printing architecture.
109 It allows you to print HTML documents using only a few commands.
112 Do not create this class on the stack only. You should create an instance
113 on app startup and use this instance for all printing operations.
114 The reason is that this class stores various settings in it.
117 @category{html,printing}
119 class wxHtmlEasyPrinting
: public wxObject
126 Name of the printing object. Used by preview frames and setup dialogs.
128 pointer to the window that will own the preview frame and setup dialogs.
131 wxHtmlEasyPrinting(const wxString
& name
= "Printing",
132 wxWindow
* parentWindow
= NULL
);
135 Returns a pointer to wxPageSetupDialogData instance used by this class.
136 You can set its parameters (via SetXXXX methods).
138 wxPageSetupDialogData
* GetPageSetupData();
141 Gets the parent window for dialogs.
143 wxWindow
* GetParentWindow() const;
146 Returns pointer to wxPrintData instance used by this class.
147 You can set its parameters (via SetXXXX methods).
149 wxPrintData
* GetPrintData();
152 Display page setup dialog and allows the user to modify settings.
159 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
160 information about the kind of the error.
162 bool PreviewFile(const wxString
& htmlfile
);
165 Preview HTML text (not file!).
167 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
168 information about the kind of the error.
173 base directory (html string would be stored there if it was in file).
174 It is used to determine path for loading images, for example.
176 bool PreviewText(const wxString
& htmltext
,
177 const wxString
& basepath
= wxEmptyString
);
182 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
183 information about the kind of the error.
185 bool PrintFile(const wxString
& htmlfile
);
188 Print HTML text (not file!).
190 Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
191 information about the kind of the error.
196 base directory (html string would be stored there if it was in file).
197 It is used to determine path for loading images, for example.
199 bool PrintText(const wxString
& htmltext
,
200 const wxString
& basepath
= wxEmptyString
);
203 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
205 void SetFonts(const wxString
& normal_face
,
206 const wxString
& fixed_face
,
207 const int sizes
= NULL
);
210 Set page footer. The following macros can be used inside it:
211 @@DATE@ is replaced by the current date in default format
212 @@PAGENUM@ is replaced by page number
213 @@PAGESCNT@ is replaced by total number of pages
214 @@TIME@ is replaced by the current time in default format
215 @@TITLE@ is replaced with the title of the document
218 HTML text to be used as footer.
220 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
222 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
225 Set page header. The following macros can be used inside it:
226 - @@DATE@ is replaced by the current date in default format
227 - @@PAGENUM@ is replaced by page number
228 - @@PAGESCNT@ is replaced by total number of pages
229 - @@TIME@ is replaced by the current time in default format
230 - @@TITLE@ is replaced with the title of the document
233 HTML text to be used as header.
235 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
237 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
240 Sets the parent window for dialogs.
242 void SetParentWindow(wxWindow
* window
);
248 @class wxHtmlPrintout
250 This class serves as printout class for HTML documents.
253 @category{html,printing}
255 class wxHtmlPrintout
: public wxPrintout
261 wxHtmlPrintout(const wxString
& title
= "Printout");
264 Adds a filter to the static list of filters for wxHtmlPrintout.
265 See wxHtmlFilter for further information.
267 static void AddFilter(wxHtmlFilter
* filter
);
270 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
272 void SetFonts(const wxString
& normal_face
,
273 const wxString
& fixed_face
,
274 const int sizes
= NULL
);
277 Set page footer. The following macros can be used inside it:
278 - @@DATE@ is replaced by the current date in default format
279 - @@PAGENUM@ is replaced by page number
280 - @@PAGESCNT@ is replaced by total number of pages
281 - @@TIME@ is replaced by the current time in default format
282 - @@TITLE@ is replaced with the title of the document
285 HTML text to be used as footer.
287 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
289 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
292 Set page header. The following macros can be used inside it:
293 - @@DATE@ is replaced by the current date in default format
294 - @@PAGENUM@ is replaced by page number
295 - @@PAGESCNT@ is replaced by total number of pages
296 - @@TIME@ is replaced by the current time in default format
297 - @@TITLE@ is replaced with the title of the document
300 HTML text to be used as header.
302 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
304 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
307 Prepare the class for printing this HTML @b file.
308 The file may be located on any virtual file system or it may be normal file.
310 void SetHtmlFile(const wxString
& htmlfile
);
313 Prepare the class for printing this HTML text.
316 HTML text. (NOT file!)
318 base directory (html string would be stored there if it was in file).
319 It is used to determine path for loading images, for example.
321 @false if basepath is filename, @true if it is directory name
322 (see wxFileSystem for detailed explanation).
324 void SetHtmlText(const wxString
& html
,
325 const wxString
& basepath
= wxEmptyString
,
329 Sets margins in millimeters.
330 Defaults to 1 inch for margins and 0.5cm for space between text and header
333 void SetMargins(float top
= 25.2, float bottom
= 25.2,