]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tprint.tex
Added wxRegion version of wxWindowDC::SetClippingRegion
[wxWidgets.git] / docs / latex / wx / tprint.tex
CommitLineData
a660d684
KB
1\section{Printing overview}\label{printingoverview}
2
3Classes: \helpref{wxPrintout}{wxprintout}, \helpref{wxPrinter}{wxprinter},\rtfsp
4\helpref{wxPrintPreview}{wxprintpreview}, \helpref{wxPrinterDC}{wxprinterdc},\rtfsp
5\helpref{wxPrintDialog}{wxprintdialog}.
6
7The printing framework relies on the application to provide classes
8whose member functions can respond to particular requests, such
9as `print this page' or `does this page exist in the document?'.
10This method allows wxWindows to take over the housekeeping duties of
11turning preview pages, calling the print dialog box, creating
12the printer device context, and so on: the application can concentrate
13on the rendering of the information onto a device context.
14The printing framework is mainly a Windows feature; PostScript
15support under non-Windows platforms is emerging but has not been rigorously tested.
16
17The \helpref{document/view framework}{docviewoverview} creates a default wxPrintout
18object for every view, calling wxView::OnDraw to achieve a
19prepackaged print/preview facility.
20
21A document's printing ability is represented in an application by a
22derived wxPrintout class. This class prints a page on request, and can
23be passed to the Print function of a wxPrinter object to actually print
24the document, or can be passed to a wxPrintPreview object to initiate
25previewing. The following code (from the printing sample) shows how easy
26it is to initiate printing, previewing and the print setup dialog, once the wxPrintout
27functionality has been defined. Notice the use of MyPrintout for
28both printing and previewing. All the preview user interface functionality
29is taken care of by wxWindows. For details on how MyPrintout is defined,
30please 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