]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/tprint.tex
Various documentation changes, makefile fixes
[wxWidgets.git] / docs / latex / wx / tprint.tex
1 \section{Printing overview}\label{printingoverview}
2
3 Classes: \helpref{wxPrintout}{wxprintout}, \helpref{wxPrinter}{wxprinter},\rtfsp
4 \helpref{wxPrintPreview}{wxprintpreview}, \helpref{wxPrinterDC}{wxprinterdc},\rtfsp
5 \helpref{wxPrintDialog}{wxprintdialog}.
6
7 The printing framework relies on the application to provide classes
8 whose member functions can respond to particular requests, such
9 as `print this page' or `does this page exist in the document?'.
10 This method allows wxWindows to take over the housekeeping duties of
11 turning preview pages, calling the print dialog box, creating
12 the printer device context, and so on: the application can concentrate
13 on the rendering of the information onto a device context.
14 The printing framework is mainly a Windows feature; PostScript
15 support under non-Windows platforms is emerging but has not been rigorously tested.
16
17 The \helpref{document/view framework}{docviewoverview} creates a default wxPrintout
18 object for every view, calling wxView::OnDraw to achieve a
19 prepackaged print/preview facility.
20
21 A document's printing ability is represented in an application by a
22 derived wxPrintout class. This class prints a page on request, and can
23 be passed to the Print function of a wxPrinter object to actually print
24 the document, or can be passed to a wxPrintPreview object to initiate
25 previewing. The following code (from the printing sample) shows how easy
26 it is to initiate printing, previewing and the print setup dialog, once the wxPrintout
27 functionality has been defined. Notice the use of MyPrintout for
28 both printing and previewing. All the preview user interface functionality
29 is taken care of by wxWindows. For details on how MyPrintout is defined,
30 please look at the printout sample code.
31
32 \begin{verbatim}
33 case WXPRINT_PRINT:
34 {
35 wxPrinter printer;
36 MyPrintout printout("My printout");
37 printer.Print(this, &printout, TRUE);
38 break;
39 }
40 case WXPRINT_PREVIEW:
41 {
42 // Pass two printout objects: for preview, and possible printing.
43 wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout);
44 wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", 100, 100, 600, 650);
45 frame->Centre(wxBOTH);
46 frame->Initialize();
47 frame->Show(TRUE);
48 break;
49 }
50 case WXPRINT_PRINT_SETUP:
51 {
52 wxPrintDialog printerDialog(this);
53 printerDialog.GetPrintData().SetSetupDialog(TRUE);
54 printerDialog.Show(TRUE);
55 break;
56 }
57 \end{verbatim}
58
59