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