]>
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 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
, wxArrayInt
& known_pagebreaks
, int from
= 0,
58 int dont_render
= 0, int to
= INT_MAX
);
61 Assign DC instance to the renderer.
63 @a pixel_scale can be used when rendering to high-resolution DCs (e.g. printer)
64 to adjust size of pixel metrics.
65 (Many dimensions in HTML are given in pixels -- e.g. image sizes. 300x300
66 image would be only one inch wide on typical printer. With pixel_scale = 3.0
67 it would be 3 inches.)
69 void SetDC(wxDC
* dc
, double pixel_scale
= 1.0);
72 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
76 void SetFonts(const wxString
& normal_face
, 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
, const wxString
& fixed_face
,
206 const int* sizes
= NULL
);
209 Set page footer. The following macros can be used inside it:
210 @@DATE@ is replaced by the current date in default format
211 @@PAGENUM@ is replaced by page number
212 @@PAGESCNT@ is replaced by total number of pages
213 @@TIME@ is replaced by the current time in default format
214 @@TITLE@ is replaced with the title of the document
217 HTML text to be used as footer.
219 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
221 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
224 Set page header. The following macros can be used inside it:
225 - @@DATE@ is replaced by the current date in default format
226 - @@PAGENUM@ is replaced by page number
227 - @@PAGESCNT@ is replaced by total number of pages
228 - @@TIME@ is replaced by the current time in default format
229 - @@TITLE@ is replaced with the title of the document
232 HTML text to be used as header.
234 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
236 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
239 Sets the parent window for dialogs.
241 void SetParentWindow(wxWindow
* window
);
247 @class wxHtmlPrintout
249 This class serves as printout class for HTML documents.
252 @category{html,printing}
254 class wxHtmlPrintout
: public wxPrintout
260 wxHtmlPrintout(const wxString
& title
= "Printout");
263 Adds a filter to the static list of filters for wxHtmlPrintout.
264 See wxHtmlFilter for further information.
266 static void AddFilter(wxHtmlFilter
* filter
);
269 Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
271 void SetFonts(const wxString
& normal_face
, const wxString
& fixed_face
,
272 const int* sizes
= NULL
);
275 Set page footer. The following macros can be used inside it:
276 - @@DATE@ is replaced by the current date in default format
277 - @@PAGENUM@ is replaced by page number
278 - @@PAGESCNT@ is replaced by total number of pages
279 - @@TIME@ is replaced by the current time in default format
280 - @@TITLE@ is replaced with the title of the document
283 HTML text to be used as footer.
285 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
287 void SetFooter(const wxString
& footer
, int pg
= wxPAGE_ALL
);
290 Set page header. The following macros can be used inside it:
291 - @@DATE@ is replaced by the current date in default format
292 - @@PAGENUM@ is replaced by page number
293 - @@PAGESCNT@ is replaced by total number of pages
294 - @@TIME@ is replaced by the current time in default format
295 - @@TITLE@ is replaced with the title of the document
298 HTML text to be used as header.
300 one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
302 void SetHeader(const wxString
& header
, int pg
= wxPAGE_ALL
);
305 Prepare the class for printing this HTML @b file.
306 The file may be located on any virtual file system or it may be normal file.
308 void SetHtmlFile(const wxString
& htmlfile
);
311 Prepare the class for printing this HTML text.
314 HTML text. (NOT file!)
316 base directory (html string would be stored there if it was in file).
317 It is used to determine path for loading images, for example.
319 @false if basepath is filename, @true if it is directory name
320 (see wxFileSystem for detailed explanation).
322 void SetHtmlText(const wxString
& html
,
323 const wxString
& basepath
= wxEmptyString
,
327 Sets margins in millimeters.
328 Defaults to 1 inch for margins and 0.5cm for space between text and header
331 void SetMargins(float top
= 25.2, float bottom
= 25.2,