]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/print.tex
applied doc patch for wxPostEvent().
[wxWidgets.git] / docs / latex / wx / print.tex
1 \section{\class{wxPrintData}}\label{wxprintdata}
2
3 This class holds a variety of information related to printers and
4 printer device contexts. This class is used to create a wxPrinterDC
5 and a wxPostScriptDC. It is also used as a data member of wxPrintDialogData
6 and wxPageSetupDialogData, as part of the mechanism for transferring data
7 between the print dialogs and the application.
8
9 \wxheading{Derived from}
10
11 \helpref{wxObject}{wxobject}
12
13 \wxheading{Include files}
14
15 <wx/cmndata.h>
16
17 \wxheading{See also}
18
19 \helpref{wxPrintDialog}{wxprintdialog},
20 \helpref{wxPageSetupDialog}{wxpagesetupdialog},
21 \helpref{wxPrintDialogData}{wxprintdialogdata},
22 \helpref{wxPageSetupDialogData}{wxpagesetupdialogdata},
23 \helpref{wxPrintDialog Overview}{wxprintdialogoverview},
24 \helpref{wxPrinterDC}{wxprinterdc},
25 \helpref{wxPostScriptDC}{wxpostscriptdc}
26
27 \wxheading{Remarks}
28
29 The following functions are specific to PostScript printing
30 and have not yet been documented:
31
32 \begin{verbatim}
33 const wxString& GetPrinterCommand() const ;
34 const wxString& GetPrinterOptions() const ;
35 const wxString& GetPreviewCommand() const ;
36 const wxString& GetFilename() const ;
37 const wxString& GetFontMetricPath() const ;
38 double GetPrinterScaleX() const ;
39 double GetPrinterScaleY() const ;
40 long GetPrinterTranslateX() const ;
41 long GetPrinterTranslateY() const ;
42 // wxPRINT_MODE_PREVIEW, wxPRINT_MODE_FILE, wxPRINT_MODE_PRINTER
43 wxPrintMode GetPrintMode() const ;
44
45 void SetPrinterCommand(const wxString& command) ;
46 void SetPrinterOptions(const wxString& options) ;
47 void SetPreviewCommand(const wxString& command) ;
48 void SetFilename(const wxString& filename) ;
49 void SetFontMetricPath(const wxString& path) ;
50 void SetPrinterScaleX(double x) ;
51 void SetPrinterScaleY(double y) ;
52 void SetPrinterScaling(double x, double y) ;
53 void SetPrinterTranslateX(long x) ;
54 void SetPrinterTranslateY(long y) ;
55 void SetPrinterTranslation(long x, long y) ;
56 void SetPrintMode(wxPrintMode printMode) ;
57 \end{verbatim}
58
59 \latexignore{\rtfignore{\wxheading{Members}}}
60
61 \membersection{wxPrintData::wxPrintData}
62
63 \func{}{wxPrintData}{\void}
64
65 Default constructor.
66
67 \func{}{wxPrintData}{\param{const wxPrintData\&}{ data}}
68
69 Copy constructor.
70
71 \membersection{wxPrintData::\destruct{wxPrintData}}
72
73 \func{}{\destruct{wxPrintData}}{\void}
74
75 Destructor.
76
77 \membersection{wxPrintData::GetCollate}\label{wxprintdatagetcollate}
78
79 \constfunc{bool}{GetCollate}{\void}
80
81 Returns TRUE if collation is on.
82
83 \membersection{wxPrintData::GetColour}\label{wxprintdatagetcolour}
84
85 \constfunc{bool}{GetColour}{\void}
86
87 Returns TRUE if colour printing is on.
88
89 \membersection{wxPrintData::GetDuplex}\label{wxprintdatagetduplex}
90
91 \constfunc{wxDuplexMode}{GetDuplex}{\void}
92
93 Returns the duplex mode. One of wxDUPLEX\_SIMPLEX, wxDUPLEX\_HORIZONTAL, wxDUPLEX\_VERTICAL.
94
95 \membersection{wxPrintData::GetNoCopies}\label{wxprintdatagetnocopies}
96
97 \constfunc{int}{GetNoCopies}{\void}
98
99 Returns the number of copies requested by the user.
100
101 \membersection{wxPrintData::GetOrientation}\label{wxprintdatagetorientation}
102
103 \constfunc{int}{GetOrientation}{\void}
104
105 Gets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
106
107 \membersection{wxPrintData::GetPaperId}\label{wxprintdatagetpaperid}
108
109 \constfunc{wxPaperSize}{GetPaperId}{\void}
110
111 Returns the paper size id. For more information, see \helpref{wxPrintData::SetPaperId}{wxprintdatasetpaperid}.
112
113 \membersection{wxPrintData::GetPrinterName}\label{wxprintdatagetprintername}
114
115 \constfunc{const wxString\&}{GetPrinterName}{\void}
116
117 Returns the printer name. If the printer name is the empty string, it indicates that the default
118 printer should be used.
119
120 \membersection{wxPrintData::GetQuality}\label{wxprintdatagetquality}
121
122 \constfunc{wxPaperQuality}{GetQuality}{\void}
123
124 Returns the current print quality. This can be a positive integer, denoting the number of dots per inch, or
125 one of the following identifiers:
126
127 \begin{verbatim}
128 wxPRINT_QUALITY_HIGH
129 wxPRINT_QUALITY_MEDIUM
130 wxPRINT_QUALITY_LOW
131 wxPRINT_QUALITY_DRAFT
132 \end{verbatim}
133
134 On input you should pass one of these identifiers, but on return you may get back a positive integer
135 indicating the current resolution setting.
136
137 \membersection{wxPrintData::SetCollate}\label{wxprintdatasetcollate}
138
139 \func{void}{SetCollate}{\param{bool }{flag}}
140
141 Sets collation to on or off.
142
143 \membersection{wxPrintData::SetColour}\label{wxprintdatasetcolour}
144
145 \func{void}{SetColour}{\param{bool }{flag}}
146
147 Sets colour printing on or off.
148
149 \membersection{wxPrintData::SetDuplex}\label{wxprintdatasetduplex}
150
151 \func{void}{SetDuplex}{\param{wxDuplexMode}{ mode}}
152
153 Returns the duplex mode. One of wxDUPLEX\_SIMPLEX, wxDUPLEX\_HORIZONTAL, wxDUPLEX\_VERTICAL.
154
155 \membersection{wxPrintData::SetNoCopies}\label{wxprintdatasetnocopies}
156
157 \func{void}{SetNoCopies}{\param{int }{n}}
158
159 Sets the default number of copies to be printed out.
160
161 \membersection{wxPrintData::SetOrientation}\label{wxprintdatasetorientation}
162
163 \func{void}{SetOrientation}{\param{int }{orientation}}
164
165 Sets the orientation. This can be wxLANDSCAPE or wxPORTRAIT.
166
167 \membersection{wxPrintData::SetPaperId}\label{wxprintdatasetpaperid}
168
169 \func{void}{SetPaperId}{\param{wxPaperSize}{ paperId}}
170
171 \index{wxPaperSize}Sets the paper id. This indicates the type of paper to be used. For a mapping between
172 paper id, paper size and string name, see wxPrintPaperDatabase in {\tt paper.h} (not yet documented).
173
174 {\it paperId} can be one of:
175
176 {\small
177 \begin{verbatim}
178 wxPAPER_NONE, // Use specific dimensions
179 wxPAPER_LETTER, // Letter, 8 1/2 by 11 inches
180 wxPAPER_LEGAL, // Legal, 8 1/2 by 14 inches
181 wxPAPER_A4, // A4 Sheet, 210 by 297 millimeters
182 wxPAPER_CSHEET, // C Sheet, 17 by 22 inches
183 wxPAPER_DSHEET, // D Sheet, 22 by 34 inches
184 wxPAPER_ESHEET, // E Sheet, 34 by 44 inches
185 wxPAPER_LETTERSMALL, // Letter Small, 8 1/2 by 11 inches
186 wxPAPER_TABLOID, // Tabloid, 11 by 17 inches
187 wxPAPER_LEDGER, // Ledger, 17 by 11 inches
188 wxPAPER_STATEMENT, // Statement, 5 1/2 by 8 1/2 inches
189 wxPAPER_EXECUTIVE, // Executive, 7 1/4 by 10 1/2 inches
190 wxPAPER_A3, // A3 sheet, 297 by 420 millimeters
191 wxPAPER_A4SMALL, // A4 small sheet, 210 by 297 millimeters
192 wxPAPER_A5, // A5 sheet, 148 by 210 millimeters
193 wxPAPER_B4, // B4 sheet, 250 by 354 millimeters
194 wxPAPER_B5, // B5 sheet, 182-by-257-millimeter paper
195 wxPAPER_FOLIO, // Folio, 8-1/2-by-13-inch paper
196 wxPAPER_QUARTO, // Quarto, 215-by-275-millimeter paper
197 wxPAPER_10X14, // 10-by-14-inch sheet
198 wxPAPER_11X17, // 11-by-17-inch sheet
199 wxPAPER_NOTE, // Note, 8 1/2 by 11 inches
200 wxPAPER_ENV_9, // #9 Envelope, 3 7/8 by 8 7/8 inches
201 wxPAPER_ENV_10, // #10 Envelope, 4 1/8 by 9 1/2 inches
202 wxPAPER_ENV_11, // #11 Envelope, 4 1/2 by 10 3/8 inches
203 wxPAPER_ENV_12, // #12 Envelope, 4 3/4 by 11 inches
204 wxPAPER_ENV_14, // #14 Envelope, 5 by 11 1/2 inches
205 wxPAPER_ENV_DL, // DL Envelope, 110 by 220 millimeters
206 wxPAPER_ENV_C5, // C5 Envelope, 162 by 229 millimeters
207 wxPAPER_ENV_C3, // C3 Envelope, 324 by 458 millimeters
208 wxPAPER_ENV_C4, // C4 Envelope, 229 by 324 millimeters
209 wxPAPER_ENV_C6, // C6 Envelope, 114 by 162 millimeters
210 wxPAPER_ENV_C65, // C65 Envelope, 114 by 229 millimeters
211 wxPAPER_ENV_B4, // B4 Envelope, 250 by 353 millimeters
212 wxPAPER_ENV_B5, // B5 Envelope, 176 by 250 millimeters
213 wxPAPER_ENV_B6, // B6 Envelope, 176 by 125 millimeters
214 wxPAPER_ENV_ITALY, // Italy Envelope, 110 by 230 millimeters
215 wxPAPER_ENV_MONARCH, // Monarch Envelope, 3 7/8 by 7 1/2 inches
216 wxPAPER_ENV_PERSONAL, // 6 3/4 Envelope, 3 5/8 by 6 1/2 inches
217 wxPAPER_FANFOLD_US, // US Std Fanfold, 14 7/8 by 11 inches
218 wxPAPER_FANFOLD_STD_GERMAN, // German Std Fanfold, 8 1/2 by 12 inches
219 wxPAPER_FANFOLD_LGL_GERMAN, // German Legal Fanfold, 8 1/2 by 13 inches
220
221 Windows 95 only:
222 wxPAPER_ISO_B4, // B4 (ISO) 250 x 353 mm
223 wxPAPER_JAPANESE_POSTCARD, // Japanese Postcard 100 x 148 mm
224 wxPAPER_9X11, // 9 x 11 in
225 wxPAPER_10X11, // 10 x 11 in
226 wxPAPER_15X11, // 15 x 11 in
227 wxPAPER_ENV_INVITE, // Envelope Invite 220 x 220 mm
228 wxPAPER_LETTER_EXTRA, // Letter Extra 9 \275 x 12 in
229 wxPAPER_LEGAL_EXTRA, // Legal Extra 9 \275 x 15 in
230 wxPAPER_TABLOID_EXTRA, // Tabloid Extra 11.69 x 18 in
231 wxPAPER_A4_EXTRA, // A4 Extra 9.27 x 12.69 in
232 wxPAPER_LETTER_TRANSVERSE, // Letter Transverse 8 \275 x 11 in
233 wxPAPER_A4_TRANSVERSE, // A4 Transverse 210 x 297 mm
234 wxPAPER_LETTER_EXTRA_TRANSVERSE, // Letter Extra Transverse 9\275 x 12 in
235 wxPAPER_A_PLUS, // SuperA/SuperA/A4 227 x 356 mm
236 wxPAPER_B_PLUS, // SuperB/SuperB/A3 305 x 487 mm
237 wxPAPER_LETTER_PLUS, // Letter Plus 8.5 x 12.69 in
238 wxPAPER_A4_PLUS, // A4 Plus 210 x 330 mm
239 wxPAPER_A5_TRANSVERSE, // A5 Transverse 148 x 210 mm
240 wxPAPER_B5_TRANSVERSE, // B5 (JIS) Transverse 182 x 257 mm
241 wxPAPER_A3_EXTRA, // A3 Extra 322 x 445 mm
242 wxPAPER_A5_EXTRA, // A5 Extra 174 x 235 mm
243 wxPAPER_B5_EXTRA, // B5 (ISO) Extra 201 x 276 mm
244 wxPAPER_A2, // A2 420 x 594 mm
245 wxPAPER_A3_TRANSVERSE, // A3 Transverse 297 x 420 mm
246 wxPAPER_A3_EXTRA_TRANSVERSE // A3 Extra Transverse 322 x 445 mm
247 \end{verbatim}
248 }
249
250 \membersection{wxPrintData::SetPrinterName}\label{wxprintdatasetprintername}
251
252 \func{void}{SetPrinterName}{\param{const wxString\& }{printerName}}
253
254 Sets the printer name. This can be the empty string to indicate that the default
255 printer should be used.
256
257 \membersection{wxPrintData::SetQuality}\label{wxprintdatasetquality}
258
259 \func{void}{SetQuality}{\param{wxPaperQuality}{ quality}}
260
261 Sets the desired print quality. This can be a positive integer, denoting the number of dots per inch, or
262 one of the following identifiers:
263
264 \begin{verbatim}
265 wxPRINT_QUALITY_HIGH
266 wxPRINT_QUALITY_MEDIUM
267 wxPRINT_QUALITY_LOW
268 wxPRINT_QUALITY_DRAFT
269 \end{verbatim}
270
271 On input you should pass one of these identifiers, but on return you may get back a positive integer
272 indicating the current resolution setting.
273
274 \membersection{wxPrintData::operator $=$}\label{wxprintdataassign}
275
276 \func{void}{operator $=$}{\param{const wxPrintData\&}{ data}}
277
278 Assigns print data to this object.
279
280 \func{void}{operator $=$}{\param{const wxPrintSetupData\&}{ data}}
281
282 Assigns print setup data to this object. wxPrintSetupData is deprecated,
283 but retained for backward compatibility.
284
285 \section{\class{wxPrintDialog}}\label{wxprintdialog}
286
287 This class represents the print and print setup common dialogs.
288 You may obtain a \helpref{wxPrinterDC}{wxprinterdc} device context from
289 a successfully dismissed print dialog.
290
291 \wxheading{Derived from}
292
293 \helpref{wxDialog}{wxdialog}\\
294 \helpref{wxWindow}{wxwindow}\\
295 \helpref{wxEvtHandler}{wxevthandler}\\
296 \helpref{wxObject}{wxobject}
297
298 \wxheading{Include files}
299
300 <wx/printdlg.h>
301
302 \wxheading{See also}
303
304 \helpref{wxPrintDialog Overview}{wxprintdialogoverview}
305
306 \latexignore{\rtfignore{\wxheading{Members}}}
307
308 \membersection{wxPrintDialog::wxPrintDialog}
309
310 \func{}{wxPrintDialog}{\param{wxWindow* }{parent}, \param{wxPrintDialogData* }{data = NULL}}
311
312 Constructor. Pass a parent window, and optionally a pointer to a block of print
313 data, which will be copied to the print dialog's print data.
314
315 \wxheading{See also}
316
317 \helpref{wxPrintDialogData}{wxprintdialogdata}
318
319 \membersection{wxPrintDialog::\destruct{wxPrintDialog}}
320
321 \func{}{\destruct{wxPrintDialog}}{\void}
322
323 Destructor. If wxPrintDialog::GetPrintDC has {\it not} been called,
324 the device context obtained by the dialog (if any) will be deleted.
325
326 \membersection{wxPrintDialog::GetPrintDialogData}\label{wxprintdialoggetprintdialogdata}
327
328 \func{wxPrintDialogData\&}{GetPrintDialogData}{\void}
329
330 Returns the \helpref{print dialog data}{wxprintdialogdata} associated with the print dialog.
331
332 \membersection{wxPrintDialog::GetPrintDC}\label{wxprintdialoggetprintdc}
333
334 \func{wxDC* }{GetPrintDC}{\void}
335
336 Returns the device context created by the print dialog, if any.
337 When this function has been called, the ownership of the device context
338 is transferred to the application, so it must then be deleted
339 explicitly.
340
341 \membersection{wxPrintDialog::ShowModal}\label{wxprintdialogshowmodal}
342
343 \func{int}{ShowModal}{\void}
344
345 Shows the dialog, returning wxID\_OK if the user pressed OK, and wxID\_CANCEL
346 otherwise. After this function is called, a device context may
347 be retrievable using \helpref{wxPrintDialog::GetPrintDC}{wxprintdialoggetprintdc}.
348
349 \section{\class{wxPrintDialogData}}\label{wxprintdialogdata}
350
351 This class holds information related to the visual characteristics of wxPrintDialog.
352 It contains a wxPrintData object with underlying printing settings.
353
354 \wxheading{Derived from}
355
356 \helpref{wxObject}{wxobject}
357
358 \wxheading{Include files}
359
360 <wx/cmndata.h>
361
362 \wxheading{See also}
363
364 \helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintDialog Overview}{wxprintdialogoverview}
365
366 \latexignore{\rtfignore{\wxheading{Members}}}
367
368 \membersection{wxPrintDialogData::wxPrintDialogData}
369
370 \func{}{wxPrintDialogData}{\void}
371
372 Default constructor.
373
374 \func{}{wxPrintDialogData}{\param{wxPrintDialogData\&}{ dialogData}}
375
376 Copy constructor.
377
378 \func{}{wxPrintDialogData}{\param{wxPrintData\&}{ printData}}
379
380 Construct an object from a print dialog data object.
381
382 \membersection{wxPrintDialogData::\destruct{wxprintdialogdata}}
383
384 \func{}{\destruct{wxPrintDialogData}}{\void}
385
386 Destructor.
387
388 \membersection{wxPrintDialogData::EnableHelp}\label{wxprintdialogdataenablehelp}
389
390 \func{void}{EnableHelp}{\param{bool }{flag}}
391
392 Enables or disables the `Help' button.
393
394 \membersection{wxPrintDialogData::EnablePageNumbers}\label{wxprintdialogdataenablepagenumbers}
395
396 \func{void}{EnablePageNumbers}{\param{bool }{flag}}
397
398 Enables or disables the `Page numbers' controls.
399
400 \membersection{wxPrintDialogData::EnablePrintToFile}\label{wxprintdialogdataenableprinttofile}
401
402 \func{void}{EnablePrintToFile}{\param{bool }{flag}}
403
404 Enables or disables the `Print to file' checkbox.
405
406 \membersection{wxPrintDialogData::EnableSelection}\label{wxprintdialogdataenableselection}
407
408 \func{void}{EnableSelection}{\param{bool }{flag}}
409
410 Enables or disables the `Selection' radio button.
411
412 \membersection{wxPrintDialogData::GetAllPages}\label{wxprintdialogdatagetallpages}
413
414 \constfunc{bool}{GetAllPages}{\void}
415
416 Returns TRUE if the user requested that all pages be printed.
417
418 \membersection{wxPrintDialogData::GetCollate}\label{wxprintdialogdatagetcollate}
419
420 \constfunc{bool}{GetCollate}{\void}
421
422 Returns TRUE if the user requested that the document(s) be collated.
423
424 \membersection{wxPrintDialogData::GetFromPage}\label{wxprintdialogdatagetfrompage}
425
426 \constfunc{int}{GetFromPage}{\void}
427
428 Returns the {\it from} page number, as entered by the user.
429
430 \membersection{wxPrintDialogData::GetMaxPage}\label{wxprintdialogdatagetmaxpage}
431
432 \constfunc{int}{GetMaxPage}{\void}
433
434 Returns the {\it maximum} page number.
435
436 \membersection{wxPrintDialogData::GetMinPage}\label{wxprintdialogdatagetminpage}
437
438 \constfunc{int}{GetMinPage}{\void}
439
440 Returns the {\it minimum} page number.
441
442 \membersection{wxPrintDialogData::GetNoCopies}\label{wxprintdialogdatagetnocopies}
443
444 \constfunc{int}{GetNoCopies}{\void}
445
446 Returns the number of copies requested by the user.
447
448 \membersection{wxPrintDialogData::GetPrintData}\label{wxprintdialogdatagetprintdata}
449
450 \func{wxPrintData\&}{GetPrintData}{\void}
451
452 Returns a reference to the internal wxPrintData object.
453
454 \membersection{wxPrintDialogData::GetPrintToFile}\label{wxprintdialogdatagetprinttofile}
455
456 \constfunc{bool}{GetPrintToFile}{\void}
457
458 Returns TRUE if the user has selected printing to a file.
459
460 \membersection{wxPrintDialogData::GetSelection}\label{wxprintdialogdatagetselection}
461
462 \constfunc{bool}{GetSelection}{\void}
463
464 Returns TRUE if the user requested that the selection be printed (where 'selection' is
465 a concept specific to the application).
466
467 \membersection{wxPrintDialogData::GetToPage}\label{wxprintdialogdatagettopage}
468
469 \constfunc{int}{GetToPage}{\void}
470
471 Returns the {\it to} page number, as entered by the user.
472
473 \membersection{wxPrintDialogData::SetCollate}\label{wxprintdialogdatasetcollate}
474
475 \func{void}{SetCollate}{\param{bool }{flag}}
476
477 Sets the 'Collate' checkbox to TRUE or FALSE.
478
479 \membersection{wxPrintDialogData::SetFromPage}\label{wxprintdialogdatasetfrompage}
480
481 \func{void}{SetFromPage}{\param{int }{page}}
482
483 Sets the {\it from} page number.
484
485 \membersection{wxPrintDialogData::SetMaxPage}\label{wxprintdialogdatasetmaxpage}
486
487 \func{void}{SetMaxPage}{\param{int }{page}}
488
489 Sets the {\it maximum} page number.
490
491 \membersection{wxPrintDialogData::SetMinPage}\label{wxprintdialogdatasetminpage}
492
493 \func{void}{SetMinPage}{\param{int }{page}}
494
495 Sets the {\it minimum} page number.
496
497 \membersection{wxPrintDialogData::SetNoCopies}\label{wxprintdialogdatasetnocopies}
498
499 \func{void}{SetNoCopies}{\param{int }{n}}
500
501 Sets the default number of copies the user has requested to be printed out.
502
503 \membersection{wxPrintDialogData::SetPrintData}\label{wxprintdialogdatasetprintdata}
504
505 \func{void}{SetPrintData}{\param{const wxPrintData\& }{printData}}
506
507 Sets the internal wxPrintData.
508
509 \membersection{wxPrintDialogData::SetPrintToFile}\label{wxprintdialogdatasetprinttofile}
510
511 \func{void}{SetPrintToFile}{\param{bool }{flag}}
512
513 Sets the 'Print to file' checkbox to TRUE or FALSE.
514
515 \membersection{wxPrintDialogData::SetSelection}\label{wxprintdialogdatasetselection}
516
517 \func{void}{SetSelection}{\param{bool}{ flag}}
518
519 Selects the 'Selection' radio button. The effect of printing the selection depends on how the application
520 implements this command, if at all.
521
522 \membersection{wxPrintDialogData::SetSetupDialog}\label{wxprintdialogdatasetsetupdialog}
523
524 \func{void}{SetSetupDialog}{\param{bool }{flag}}
525
526 Determines whether the dialog to be shown will be the Print dialog
527 (pass FALSE) or Print Setup dialog (pass TRUE).
528
529 Note that the setup dialog is (according to Microsoft) obsolete from
530 Windows 95, though retained for backward compatibility.
531
532 \membersection{wxPrintDialogData::SetToPage}\label{wxprintdialogdatasettopage}
533
534 \func{void}{SetToPage}{\param{int }{page}}
535
536 Sets the {\it to} page number.
537
538 \membersection{wxPrintDialogData::operator $=$}\label{wxprintdialogdataassign}
539
540 \func{void}{operator $=$}{\param{const wxPrintData\&}{ data}}
541
542 Assigns print data to this object.
543
544 \func{void}{operator $=$}{\param{const wxPrintDialogData\&}{ data}}
545
546 Assigns another print dialog data object to this object.
547
548 \section{\class{wxPrinter}}\label{wxprinter}
549
550 This class represents the Windows or PostScript printer, and is the vehicle through
551 which printing may be launched by an application. Printing can also
552 be achieved through using of lower functions and classes, but
553 this and associated classes provide a more convenient and general
554 method of printing.
555
556 \wxheading{Derived from}
557
558 \helpref{wxObject}{wxobject}
559
560 \wxheading{Include files}
561
562 <wx/print.h>
563
564 \wxheading{See also}
565
566 \helpref{Printing framework overview}{printingoverview}, \helpref{wxPrinterDC}{wxprinterdc}, \helpref{wxPrintDialog}{wxprintdialog},\rtfsp
567 \helpref{wxPrintout}{wxprintout}, \helpref{wxPrintPreview}{wxprintpreview}.
568
569 \latexignore{\rtfignore{\wxheading{Members}}}
570
571 \membersection{wxPrinter::wxPrinter}
572
573 \func{}{wxPrinter}{\param{wxPrintDialogData* }{data = NULL}}
574
575 Constructor. Pass an optional pointer to a block of print
576 dialog data, which will be copied to the printer object's local data.
577
578 \wxheading{See also}
579
580 \helpref{wxPrintDialogData}{wxprintdialogdata},
581 \helpref{wxPrintData}{wxprintdata}
582
583 \membersection{wxPrinter::\destruct{wxPrinter}}
584
585 \func{}{\destruct{wxPrinter}}{\void}
586
587 Destructor.
588
589 \membersection{wxPrinter::Abort}\label{wxprinterabort}
590
591 \func{bool}{Abort}{\void}
592
593 Returns TRUE if the user has aborted the print job.
594
595 \membersection{wxPrinter::CreateAbortWindow}\label{wxprintercreateabortwindow}
596
597 \func{void}{CreateAbortWindow}{\param{wxWindow* }{parent}, \param{wxPrintout* }{printout}}
598
599 Creates the default printing abort window, with a cancel button.
600
601
602 \membersection{wxPrinter::GetLastError}\label{wxprintergetlasterror}
603
604 \func{static wxPrinterError}{GetLastError}{\void}
605
606 Return last error. Valid after calling \helpref{Print}{wxprinterprint},
607 \helpref{PrintDialog}{wxprinterprintdialog} or
608 \helpref{wxPrintPreview::Print}{wxprintpreviewprint}. These functions
609 set last error to {\bf wxPRINTER\_NO\_ERROR} if no error happened.
610
611 Returned value is one of the following:
612
613 \twocolwidtha{7cm}
614 \begin{twocollist}\itemsep=0pt
615 \twocolitem{{\bf wxPRINTER\_NO\_ERROR}}{No error happened.}
616 \twocolitem{{\bf wxPRINTER\_CANCELLED}}{The user cancelled printing.}
617 \twocolitem{{\bf wxPRINTER\_ERROR}}{There was an error during printing.}
618 \end{twocollist}
619
620
621 \membersection{wxPrinter::GetPrintDialogData}\label{wxprintergetprintdialogdata}
622
623 \func{wxPrintDialogData\&}{GetPrintDialogData}{\void}
624
625 Returns the \helpref{print data}{wxprintdata} associated with the printer object.
626
627 \membersection{wxPrinter::Print}\label{wxprinterprint}
628
629 \func{bool}{Print}{\param{wxWindow *}{parent}, \param{wxPrintout *}{printout}, \param{bool }{prompt=TRUE}}
630
631 Starts the printing process. Provide a parent window, a user-defined wxPrintout object which controls
632 the printing of a document, and whether the print dialog should be invoked first.
633
634 Print could return FALSE if there was a problem initializing the printer device context
635 (current printer not set, for example) or the user cancelled printing. Call
636 \helpref{wxPrinter::GetLastError}{wxprintergetlasterror} to get detailed
637 information about the kind of the error.
638
639 \membersection{wxPrinter::PrintDialog}\label{wxprinterprintdialog}
640
641 \func{wxDC*}{PrintDialog}{\param{wxWindow *}{parent}}
642
643 Invokes the print dialog. If successful (the user did not press Cancel
644 and no error occurred), a suitable device context will be returned
645 (otherwise NULL is returned -- call
646 \helpref{wxPrinter::GetLastError}{wxprintergetlasterror} to get detailed
647 information about the kind of the error).
648
649 The application must delete this device context to avoid a memory leak.
650
651 \membersection{wxPrinter::ReportError}\label{wxprinterreporterror}
652
653 \func{void}{ReportError}{\param{wxWindow *}{parent}, \param{wxPrintout *}{printout}, \param{const wxString\& }{message}}
654
655 Default error-reporting function.
656
657 \membersection{wxPrinter::Setup}\label{wxprintersetup}
658
659 \func{bool}{Setup}{\param{wxWindow *}{parent}}
660
661 Invokes the print setup dialog. Note that the setup dialog is obsolete from
662 Windows 95, though retained for backward compatibility.
663
664 \section{\class{wxPrinterDC}}\label{wxprinterdc}
665
666 A printer device context is specific to Windows, and allows access to
667 any printer with a Windows driver. See \helpref{wxDC}{wxdc} for further information
668 on device contexts, and \helpref{wxDC::GetSize}{wxdcgetsize} for advice on
669 achieving the correct scaling for the page.
670
671 \wxheading{Derived from}
672
673 \helpref{wxDC}{wxdc}\\
674 \helpref{wxObject}{wxdc}
675
676 \wxheading{Include files}
677
678 <wx/dcprint.h>
679
680 \wxheading{See also}
681
682 \helpref{wxDC}{wxdc}, \helpref{Printing framework overview}{printingoverview}
683
684 \latexignore{\rtfignore{\wxheading{Members}}}
685
686 \membersection{wxPrinterDC::wxPrinterDC}
687
688 \func{}{wxPrinterDC}{\param{const wxPrintData\& }{printData}}
689
690 Pass a \helpref{wxPrintData}{wxprintdata} object with information
691 necessary for setting up a suitable printer device context. This
692 is the recommended way to construct a wxPrinterDC.
693
694 \func{}{wxPrinterDC}{\param{const wxString\& }{driver}, \param{const wxString\& }{device}, \param{const wxString\& }{output},
695 \param{const bool }{interactive = TRUE}, \param{int }{orientation = wxPORTRAIT}}
696
697 Constructor. With empty strings for the first three arguments, the default printer dialog is
698 displayed. {\it device} indicates the type of printer and {\it output}
699 is an optional file for printing to. The {\it driver} parameter is
700 currently unused. Use the {\it Ok} member to test whether the
701 constructor was successful in creating a useable device context.
702
703 This constructor is deprecated and retained only for backward compatibility.
704
705 \section{\class{wxPrintout}}\label{wxprintout}
706
707 This class encapsulates the functionality of printing out an
708 application document. A new class must be derived and members
709 overridden to respond to calls such as OnPrintPage and HasPage.
710 Instances of this class are passed to wxPrinter::Print or a
711 wxPrintPreview object to initiate printing or previewing.
712
713 \wxheading{Derived from}
714
715 \helpref{wxObject}{wxobject}
716
717 \wxheading{Include files}
718
719 <wx/print.h>
720
721 \wxheading{See also}
722
723 \helpref{Printing framework overview}{printingoverview}, \helpref{wxPrinterDC}{wxprinterdc}, \helpref{wxPrintDialog}{wxprintdialog},\rtfsp
724 \helpref{wxPrinter}{wxprinter}, \helpref{wxPrintPreview}{wxprintpreview}
725
726 \latexignore{\rtfignore{\wxheading{Members}}}
727
728 \membersection{wxPrintout::wxPrintout}
729
730 \func{}{wxPrintout}{\param{const wxString\& }{title = "Printout"}}
731
732 Constructor. Pass an optional title argument (currently unused).
733
734 \membersection{wxPrintout::\destruct{wxPrintout}}
735
736 \func{}{\destruct{wxPrintout}}{\void}
737
738 Destructor.
739
740 \membersection{wxPrintout::GetDC}\label{wxprintoutgetdc}
741
742 \func{wxDC *}{GetDC}{\void}
743
744 Returns the device context associated with the printout (given to the printout at start of
745 printing or previewing). This will be a wxPrinterDC if printing under Windows,
746 a wxPostScriptDC if printing on other platforms, and a wxMemoryDC if previewing.
747
748 \membersection{wxPrintout::GetPageInfo}\label{wxprintoutgetpageinfo}
749
750 \func{void}{GetPageInfo}{\param{int *}{minPage}, \param{int *}{maxPage}, \param{int *}{pageFrom}, \param{int *}{pageTo}}
751
752 Called by the framework to obtain information from the application about minimum and maximum page values that
753 the user can select, and the required page range to be printed. By default this
754 returns 1, 32000 for the page minimum and maximum values, and 1, 1 for the required page range.
755
756 If {\it minPage} is zero, the page number controls in the print dialog will be disabled.
757
758 \pythonnote{When this method is implemented in a derived Python class,
759 it should be designed to take no parameters (other than the self
760 reference) and to return a tuple of four integers.
761 }
762
763 \perlnote{When this method is overridden in a derived class,
764 it must not take any parameters, an return a 4-element list.
765 }
766
767 \membersection{wxPrintout::GetPageSizeMM}\label{wxprintoutgetpagesizemm}
768
769 \func{void}{GetPageSizeMM}{\param{int *}{w}, \param{int *}{h}}
770
771 Returns the size of the printer page in millimetres.
772
773 \pythonnote{This method returns the output-only parameters as a tuple.}
774
775 \perlnote{In wxPerl this method takes no arguments and returns a
776 2-element list {\tt ( w, h )}}
777
778 \membersection{wxPrintout::GetPageSizePixels}\label{wxprintoutgetpagesizepixels}
779
780 \func{void}{GetPageSizePixels}{\param{int *}{w}, \param{int *}{h}}
781
782 Returns the size of the printer page in pixels. These may not be the
783 same as the values returned from \helpref{wxDC::GetSize}{wxdcgetsize} if
784 the printout is being used for previewing, since in this case, a
785 memory device context is used, using a bitmap size reflecting the current
786 preview zoom. The application must take this discrepancy into account if
787 previewing is to be supported.
788
789 \pythonnote{This method returns the output-only parameters as a tuple.}
790
791 \perlnote{In wxPerl this method takes no arguments and returns a
792 2-element list {\tt ( w, h )}}
793
794 \membersection{wxPrintout::GetPPIPrinter}\label{wxprintoutgetppiprinter}
795
796 \func{void}{GetPPIPrinter}{\param{int *}{w}, \param{int *}{h}}
797
798 Returns the number of pixels per logical inch of the printer device context.
799 Dividing the printer PPI by the screen PPI can give a suitable scaling
800 factor for drawing text onto the printer. Remember to multiply
801 this by a scaling factor to take the preview DC size into account.
802
803 \pythonnote{This method returns the output-only parameters as a tuple.}
804
805 \perlnote{In wxPerl this method takes no arguments and returns a
806 2-element list {\tt ( w, h )}}
807
808 \membersection{wxPrintout::GetPPIScreen}\label{wxprintoutgetppiscreen}
809
810 \func{void}{GetPPIScreen}{\param{int *}{w}, \param{int *}{h}}
811
812 Returns the number of pixels per logical inch of the screen device context.
813 Dividing the printer PPI by the screen PPI can give a suitable scaling
814 factor for drawing text onto the printer. Remember to multiply
815 this by a scaling factor to take the preview DC size into account.
816
817 \pythonnote{This method returns the output-only parameters as a tuple.}
818
819 \perlnote{In wxPerl this method takes no arguments and returns a
820 2-element list {\tt ( w, h )}}
821
822 \membersection{wxPrintout::HasPage}\label{wxprintouthaspage}
823
824 \func{bool}{HasPage}{\param{int}{ pageNum}}
825
826 Should be overridden to return TRUE if the document has this page, or FALSE
827 if not. Returning FALSE signifies the end of the document. By default,
828 HasPage behaves as if the document has only one page.
829
830 \membersection{wxPrintout::IsPreview}\label{wxprintoutispreview}
831
832 \func{bool}{IsPreview}{\void}
833
834 Returns TRUE if the printout is currently being used for previewing.
835
836 \membersection{wxPrintout::OnBeginDocument}\label{wxprintoutonbegindocument}
837
838 \func{bool}{OnBeginDocument}{\param{int}{ startPage}, \param{int}{ endPage}}
839
840 Called by the framework at the start of document printing. Return FALSE from
841 this function cancels the print job. OnBeginDocument is called once for every
842 copy printed.
843
844 The base wxPrintout::OnBeginDocument {\it must} be called (and the return value
845 checked) from within the overridden function, since it calls wxDC::StartDoc.
846
847 \pythonnote{If this method is overridden in a Python class then the
848 base class version can be called by using the method
849 {\tt base\_OnBeginDocument(startPage, endPage)}. }
850
851 \membersection{wxPrintout::OnEndDocument}\label{wxprintoutonenddocument}
852
853 \func{void}{OnEndDocument}{\void}
854
855 Called by the framework at the end of document printing. OnEndDocument
856 is called once for every copy printed.
857
858 The base wxPrintout::OnEndDocument {\it must} be called
859 from within the overridden function, since it calls wxDC::EndDoc.
860
861 \membersection{wxPrintout::OnBeginPrinting}\label{wxprintoutonbeginprinting}
862
863 \func{void}{OnBeginPrinting}{\void}
864
865 Called by the framework at the start of printing. OnBeginPrinting is called once for every
866 print job (regardless of how many copies are being printed).
867
868 \membersection{wxPrintout::OnEndPrinting}\label{wxprintoutonendprinting}
869
870 \func{void}{OnEndPrinting}{\void}
871
872 Called by the framework at the end of printing. OnEndPrinting
873 is called once for every print job (regardless of how many copies are being printed).
874
875 \membersection{wxPrintout::OnPreparePrinting}\label{wxprintoutonprepareprinting}
876
877 \func{void}{OnPreparePrinting}{\void}
878
879 Called once by the framework before any other demands are made of the
880 wxPrintout object. This gives the object an opportunity to calculate the
881 number of pages in the document, for example.
882
883 \membersection{wxPrintout::OnPrintPage}\label{wxprintoutonprintpage}
884
885 \func{bool}{OnPrintPage}{\param{int}{ pageNum}}
886
887 Called by the framework when a page should be printed. Returning FALSE cancels
888 the print job. The application can use wxPrintout::GetDC to obtain a device
889 context to draw on.
890
891 \section{\class{wxPrintPreview}}\label{wxprintpreview}
892
893 Objects of this class manage the print preview process. The object is passed
894 a wxPrintout object, and the wxPrintPreview object itself is passed to
895 a wxPreviewFrame object. Previewing is started by initializing and showing
896 the preview frame. Unlike wxPrinter::Print, flow of control returns to the application
897 immediately after the frame is shown.
898
899 \wxheading{Derived from}
900
901 \helpref{wxObject}{wxobject}
902
903 \wxheading{Include files}
904
905 <wx/print.h>
906
907 \wxheading{See also}
908
909 \overview{Printing framework overview}{printingoverview}, \helpref{wxPrinterDC}{wxprinterdc}, \helpref{wxPrintDialog}{wxprintdialog},\rtfsp
910 \helpref{wxPrintout}{wxprintout}, \helpref{wxPrinter}{wxprinter},\rtfsp
911 \helpref{wxPreviewCanvas}{wxpreviewcanvas}, \helpref{wxPreviewControlBar}{wxpreviewcontrolbar},\rtfsp
912 \helpref{wxPreviewFrame}{wxpreviewframe}.
913
914 \latexignore{\rtfignore{\wxheading{Members}}}
915
916 \membersection{wxPrintPreview::wxPrintPreview}
917
918 \func{}{wxPrintPreview}{\param{wxPrintout* }{printout}, \param{wxPrintout* }{printoutForPrinting},
919 \param{wxPrintData* }{data=NULL}}
920
921 Constructor. Pass a printout object, an optional printout object to be
922 used for actual printing, and the address of an optional
923 block of printer data, which will be copied to the print preview object's
924 print data.
925
926 If {\it printoutForPrinting} is non-NULL, a {\bf Print...} button will be placed on the
927 preview frame so that the user can print directly from the preview interface.
928
929 Do not explicitly delete the printout objects once this destructor has been
930 called, since they will be deleted in the wxPrintPreview constructor.
931 The same does not apply to the {\it data} argument.
932
933 Test the Ok member to check whether the wxPrintPreview object was created correctly.
934 Ok could return FALSE if there was a problem initializing the printer device context
935 (current printer not set, for example).
936
937 \membersection{wxPrintPreview::\destruct{wxPrintPreview}}
938
939 \func{}{\destruct{wxPrinter}}{\void}
940
941 Destructor. Deletes both print preview objects, so do not destroy these objects
942 in your application.
943
944 \membersection{wxPrintPreview::DrawBlankPage}\label{wxprintpreviewdrawblankpage}
945
946 \func{bool}{DrawBlankPage}{\param{wxWindow* }{window}}
947
948 Draws a representation of the blank page into the preview window. Used
949 internally.
950
951 \membersection{wxPrintPreview::GetCanvas}\label{wxprintpreviewgetcanvas}
952
953 \func{wxWindow* }{GetCanvas}{\void}
954
955 Gets the preview window used for displaying the print preview image.
956
957 \membersection{wxPrintPreview::GetCurrentPage}\label{wxprintpreviewgetcurrentpage}
958
959 \func{int}{GetCurrentPage}{\void}
960
961 Gets the page currently being previewed.
962
963 \membersection{wxPrintPreview::GetFrame}\label{wxprintpreviewgetframe}
964
965 \func{wxFrame *}{GetFrame}{\void}
966
967 Gets the frame used for displaying the print preview canvas
968 and control bar.
969
970 \membersection{wxPrintPreview::GetMaxPage}\label{wxprintpreviewgetmaxpage}
971
972 \func{int}{GetMaxPage}{\void}
973
974 Returns the maximum page number.
975
976 \membersection{wxPrintPreview::GetMinPage}\label{wxprintpreviewgetminpage}
977
978 \func{int}{GetMinPage}{\void}
979
980 Returns the minimum page number.
981
982 \membersection{wxPrintPreview::GetPrintData}\label{wxprintpreviewgetprintdata}
983
984 \func{wxPrintData\&}{GetPrintData}{\void}
985
986 Returns a reference to the internal print data.
987
988 \membersection{wxPrintPreview::GetPrintout}\label{wxprintpreviewgetprintout}
989
990 \func{wxPrintout *}{GetPrintout}{\void}
991
992 Gets the preview printout object associated with the wxPrintPreview object.
993
994 \membersection{wxPrintPreview::GetPrintoutForPrinting}\label{wxprintpreviewgetprintoutforprinting}
995
996 \func{wxPrintout *}{GetPrintoutForPrinting}{\void}
997
998 Gets the printout object to be used for printing from within the preview interface,
999 or NULL if none exists.
1000
1001 \membersection{wxPrintPreview::Ok}\label{wxprintpreviewok}
1002
1003 \func{bool}{Ok}{\void}
1004
1005 Returns TRUE if the wxPrintPreview is valid, FALSE otherwise. It could return FALSE if there was a
1006 problem initializing the printer device context (current printer not set, for example).
1007
1008 \membersection{wxPrintPreview::PaintPage}\label{wxprintpreviewpaintpage}
1009
1010 \func{bool}{PaintPage}{\param{wxWindow* }{window}}
1011
1012 This refreshes the preview window with the preview image.
1013 It must be called from the preview window's OnPaint member.
1014
1015 The implementation simply blits the preview bitmap onto
1016 the canvas, creating a new preview bitmap if none exists.
1017
1018 \membersection{wxPrintPreview::Print}\label{wxprintpreviewprint}
1019
1020 \func{bool}{Print}{\param{bool }{prompt}}
1021
1022 Invokes the print process using the second wxPrintout object
1023 supplied in the wxPrintPreview constructor.
1024 Will normally be called by the {\bf Print...} panel item on the
1025 preview frame's control bar.
1026
1027 Returns FALSE in case of error -- call
1028 \helpref{wxPrinter::GetLastError}{wxprintergetlasterror} to get detailed
1029 information about the kind of the error.
1030
1031 \membersection{wxPrintPreview::RenderPage}\label{wxprintpreviewrenderpage}
1032
1033 \func{bool}{RenderPage}{\param{int }{pageNum}}
1034
1035 Renders a page into a wxMemoryDC. Used internally by wxPrintPreview.
1036
1037 \membersection{wxPrintPreview::SetCanvas}\label{wxprintpreviewsetcanvas}
1038
1039 \func{void}{SetCanvas}{\param{wxWindow* }{window}}
1040
1041 Sets the window to be used for displaying the print preview image.
1042
1043 \membersection{wxPrintPreview::SetCurrentPage}\label{wxprintpreviewsetcurrentpage}
1044
1045 \func{void}{SetCurrentPage}{\param{int}{ pageNum}}
1046
1047 Sets the current page to be previewed.
1048
1049 \membersection{wxPrintPreview::SetFrame}\label{wxprintpreviewsetframe}
1050
1051 \func{void}{SetFrame}{\param{wxFrame *}{frame}}
1052
1053 Sets the frame to be used for displaying the print preview canvas
1054 and control bar.
1055
1056 \membersection{wxPrintPreview::SetPrintout}\label{wxprintpreviewsetprintout}
1057
1058 \func{void}{SetPrintout}{\param{wxPrintout *}{printout}}
1059
1060 Associates a printout object with the wxPrintPreview object.
1061
1062 \membersection{wxPrintPreview::SetZoom}\label{wxprintpreviewsetzoom}
1063
1064 \func{void}{SetZoom}{\param{int}{ percent}}
1065
1066 Sets the percentage preview zoom, and refreshes the preview canvas
1067 accordingly.
1068