Contents Up Previous Next

wxPrintPreview

Objects of this class manage the print preview process. The object is passed a wxPrintout object, and the wxPrintPreview object itself is passed to a wxPreviewFrame object. Previewing is started by initializing and showing the preview frame. Unlike wxPrinter::Print, flow of control returns to the application immediately after the frame is shown.

Derived from

wxObject

Include files

<wx/print.h>

See also

Printing framework overview, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrinter, wxPreviewCanvas, wxPreviewControlBar, wxPreviewFrame.

Members

wxPrintPreview::wxPrintPreview
wxPrintPreview::~wxPrintPreview
wxPrintPreview::GetCanvas
wxPrintPreview::GetCurrentPage
wxPrintPreview::GetFrame
wxPrintPreview::GetMaxPage
wxPrintPreview::GetMinPage
wxPrintPreview::GetPrintout
wxPrintPreview::GetPrintoutForPrinting
wxPrintPreview::Ok
wxPrintPreview::PaintPage
wxPrintPreview::Print
wxPrintPreview::RenderPage
wxPrintPreview::SetCanvas
wxPrintPreview::SetCurrentPage
wxPrintPreview::SetFrame
wxPrintPreview::SetPrintout
wxPrintPreview::SetZoom


wxPrintPreview::wxPrintPreview

wxPrintPreview(wxPrintout* printout, wxPrintout* printoutForPrinting, wxPrintData* data=NULL)

Constructor. Pass a printout object, an optional printout object to be used for actual printing, and the address of an optional block of printer data, which will be copied to the print preview object's print data.

If printoutForPrinting is non-NULL, a Print... button will be placed on the preview frame so that the user can print directly from the preview interface.

Do not explicitly delete the printout objects once this destructor has been called, since they will be deleted in the wxPrintPreview constructor. The same does not apply to the data argument.

Test the Ok member to check whether the wxPrintPreview object was created correctly. Ok could return false if there was a problem initializing the printer device context (current printer not set, for example).


wxPrintPreview::~wxPrintPreview

~wxPrinter()

Destructor. Deletes both print preview objects, so do not destroy these objects in your application.


wxPrintPreview::GetCanvas

wxPreviewCanvas* GetCanvas()

Gets the preview window used for displaying the print preview image.


wxPrintPreview::GetCurrentPage

int GetCurrentPage()

Gets the page currently being previewed.


wxPrintPreview::GetFrame

wxFrame * GetFrame()

Gets the frame used for displaying the print preview canvas and control bar.


wxPrintPreview::GetMaxPage

int GetMaxPage()

Returns the maximum page number.


wxPrintPreview::GetMinPage

int GetMinPage()

Returns the minimum page number.


wxPrintPreview::GetPrintout

wxPrintout * GetPrintout()

Gets the preview printout object associated with the wxPrintPreview object.


wxPrintPreview::GetPrintoutForPrinting

wxPrintout * GetPrintoutForPrinting()

Gets the printout object to be used for printing from within the preview interface, or NULL if none exists.


wxPrintPreview::Ok

bool Ok()

Returns true if the wxPrintPreview is valid, false otherwise. It could return false if there was a problem initializing the printer device context (current printer not set, for example).


wxPrintPreview::PaintPage

bool PaintPage(wxPreviewCanvas *canvas, wxDC&dc)

This refreshes the preview window with the preview image. It must be called from the preview window's OnPaint member.

The implementation simply blits the preview bitmap onto the canvas, creating a new preview bitmap if none exists.


wxPrintPreview::Print

bool Print(bool prompt)

Invokes the print process using the second wxPrintout object supplied in the wxPrintPreview constructor. Will normally be called by the Print... panel item on the preview frame's control bar.

Returns false in case of error -- call wxPrinter::GetLastError to get detailed information about the kind of the error.


wxPrintPreview::RenderPage

bool RenderPage(int pageNum)

Renders a page into a wxMemoryDC. Used internally by wxPrintPreview.


wxPrintPreview::SetCanvas

void SetCanvas(wxPreviewCanvas* window)

Sets the window to be used for displaying the print preview image.


wxPrintPreview::SetCurrentPage

void SetCurrentPage(int pageNum)

Sets the current page to be previewed.


wxPrintPreview::SetFrame

void SetFrame(wxFrame *frame)

Sets the frame to be used for displaying the print preview canvas and control bar.


wxPrintPreview::SetPrintout

void SetPrintout(wxPrintout *printout)

Associates a printout object with the wxPrintPreview object.


wxPrintPreview::SetZoom

void SetZoom(int percent)

Sets the percentage preview zoom, and refreshes the preview canvas accordingly.