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