]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{Printing overview}\label{printingoverview} |
2 | ||
7bcb11d3 JS |
3 | Classes: \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} | |
a660d684 KB |
12 | |
13 | The printing framework relies on the application to provide classes | |
14 | whose member functions can respond to particular requests, such | |
15 | as `print this page' or `does this page exist in the document?'. | |
fc2171bd | 16 | This method allows wxWidgets to take over the housekeeping duties of |
a660d684 KB |
17 | turning preview pages, calling the print dialog box, creating |
18 | the printer device context, and so on: the application can concentrate | |
19 | on the rendering of the information onto a device context. | |
a660d684 | 20 | |
c436b310 RR |
21 | The \helpref{document/view framework}{docviewoverview} creates a default |
22 | wxPrintout object for every view, calling wxView::OnDraw to achieve a | |
a660d684 KB |
23 | prepackaged print/preview facility. |
24 | ||
25 | A document's printing ability is represented in an application by a | |
26 | derived wxPrintout class. This class prints a page on request, and can | |
27 | be passed to the Print function of a wxPrinter object to actually print | |
28 | the document, or can be passed to a wxPrintPreview object to initiate | |
29 | previewing. The following code (from the printing sample) shows how easy | |
30 | it is to initiate printing, previewing and the print setup dialog, once the wxPrintout | |
31 | functionality has been defined. Notice the use of MyPrintout for | |
32 | both printing and previewing. All the preview user interface functionality | |
fc2171bd | 33 | is taken care of by wxWidgets. For details on how MyPrintout is defined, |
a660d684 KB |
34 | please look at the printout sample code. |
35 | ||
36 | \begin{verbatim} | |
37 | case WXPRINT_PRINT: | |
38 | { | |
39 | wxPrinter printer; | |
40 | MyPrintout printout("My printout"); | |
cc81d32f | 41 | printer.Print(this, &printout, true); |
a660d684 KB |
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); | |
dbd94b75 | 48 | wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650)); |
a660d684 KB |
49 | frame->Centre(wxBOTH); |
50 | frame->Initialize(); | |
cc81d32f | 51 | frame->Show(true); |
a660d684 KB |
52 | break; |
53 | } | |
a660d684 KB |
54 | \end{verbatim} |
55 | ||
c436b310 RR |
56 | \section{Printing under Unix (GTK+)}\label{unixprinting} |
57 | ||
58 | Printing under Unix has always been a cause of problems as Unix | |
59 | does not provide a standard way to display text and graphics | |
60 | on screen and print it to a printer using the same application | |
61 | programming interface - instead, displaying on screen is done | |
62 | via the X11 library while printing has to be done with using | |
63 | PostScript commands. This was particularly difficult to handle | |
64 | for the case of fonts with the result that only a selected | |
65 | number of application could offer WYSIWYG under Unix. Equally, | |
66 | wxWidgets offered its own printing implementation using PostScript | |
67 | which never really matched the screen display. | |
68 | ||
69 | Starting with version 2.8.X, the GNOME project provides printing | |
70 | support through the libgnomeprint and libgnomeprintui libraries | |
71 | by which especially the font problem is mostly solved. Beginning | |
72 | with version 2.5.4, the GTK+ port of wxWidgets can make use of | |
73 | these libraries if wxWidgets is configured accordingly and if the | |
74 | libraries are present. You need to configure wxWidgets with the | |
75 | {\it configure --with-gnomeprint} switch and you application will | |
76 | then search for the GNOME print libraries at runtime. If they | |
77 | are found, printing will be done through these, otherwise the | |
78 | application will fall back to the old PostScript printing code. | |
79 | Note that the application will not require the GNOME print libraries | |
80 | to be installed in order to run (there will be no dependency on | |
81 | these libraries). | |
82 | ||
83 | It is expected that the printing code that is currently implemented | |
84 | in the GNOME print libraries will be moved into GTK+ later. |