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