wxWidgets/docs/latex/wx/tprint.tex
Julian Smart fc2171bd4c Name change replacements
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27090 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-05-04 08:27:20 +00:00

63 lines
2.5 KiB
TeX

\section{Printing overview}\label{printingoverview}
Classes: \helpref{wxPrintout}{wxprintout},
\helpref{wxPrinter}{wxprinter},
\helpref{wxPrintPreview}{wxprintpreview},
\helpref{wxPrinterDC}{wxprinterdc},
\helpref{wxPrintDialog}{wxprintdialog},
\helpref{wxPrintData}{wxprintdata},
\helpref{wxPrintDialogData}{wxprintdialogdata},
\helpref{wxPageSetupDialog}{wxpagesetupdialog},
\helpref{wxPageSetupDialogData}{wxpagesetupdialogdata}
The printing framework relies on the application to provide classes
whose member functions can respond to particular requests, such
as `print this page' or `does this page exist in the document?'.
This method allows wxWidgets to take over the housekeeping duties of
turning preview pages, calling the print dialog box, creating
the printer device context, and so on: the application can concentrate
on the rendering of the information onto a device context.
The \helpref{document/view framework}{docviewoverview} creates a default wxPrintout
object for every view, calling wxView::OnDraw to achieve a
prepackaged print/preview facility.
A document's printing ability is represented in an application by a
derived wxPrintout class. This class prints a page on request, and can
be passed to the Print function of a wxPrinter object to actually print
the document, or can be passed to a wxPrintPreview object to initiate
previewing. The following code (from the printing sample) shows how easy
it is to initiate printing, previewing and the print setup dialog, once the wxPrintout
functionality has been defined. Notice the use of MyPrintout for
both printing and previewing. All the preview user interface functionality
is taken care of by wxWidgets. For details on how MyPrintout is defined,
please look at the printout sample code.
\begin{verbatim}
case WXPRINT_PRINT:
{
wxPrinter printer;
MyPrintout printout("My printout");
printer.Print(this, &printout, true);
break;
}
case WXPRINT_PREVIEW:
{
// Pass two printout objects: for preview, and possible printing.
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout);
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", 100, 100, 600, 650);
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(true);
break;
}
case WXPRINT_PRINT_SETUP:
{
wxPrintDialog printerDialog(this);
printerDialog.GetPrintData().SetSetupDialog(true);
printerDialog.Show(true);
break;
}
\end{verbatim}