| Version: 3.2.8

Public Member Functions | Static Public Member Functions | List of all members
wxPrinter Class Reference
Class List by Category » Printing Framework

`#include <wx/print.h>`

Inheritance diagram for wxPrinter:
[legend]

## Detailed Description

This class represents the Windows or PostScript printer, and is the vehicle through which printing may be launched by an application.

Printing can also be achieved through using of lower functions and classes, but this and associated classes provide a more convenient and general method of printing.

##

Library: wxCore
Category: Printing Framework

See also
  Printing Framework Overview, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrintPreview

## Public Member Functions
| wxPrinter (wxPrintDialogData *data=NULL)
| Constructor. More...
virtual wxPrintAbortDialog * | CreateAbortWindow (wxWindow *parent, wxPrintout *printout)
| Creates the default printing abort window, with a cancel button. More...
bool | GetAbort () const
| Returns true if the user has aborted the print job. More...
virtual wxPrintDialogData & | GetPrintDialogData () const
| Returns the print data associated with the printer object. More...
virtual bool | Print (wxWindow *parent, wxPrintout *printout, bool prompt=true)
| Starts the printing process. More...
virtual wxDC * | PrintDialog (wxWindow *parent)
| Invokes the print dialog. More...
virtual void | ReportError (wxWindow *parent, wxPrintout *printout, const wxString &message)
| Default error-reporting function. More...
virtual bool | Setup (wxWindow *parent)
| Invokes the print setup dialog. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined. More...

## Static Public Member Functions
static wxPrinterError | GetLastError ()
| Return last error. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxPrinter()

wxPrinter::wxPrinter | ( | wxPrintDialogData * | data = `NULL` | ) |

Constructor.

Pass an optional pointer to a block of print dialog data, which will be copied to the printer object's local data.

See also
  wxPrintDialogData, wxPrintData

## Member Function Documentation

## ◆ CreateAbortWindow()

virtual wxPrintAbortDialog* wxPrinter::CreateAbortWindow | ( | wxWindow * | parent,
|  | wxPrintout * | printout
| ) |  |
| virtual

Creates the default printing abort window, with a cancel button.

## ◆ GetAbort()

bool wxPrinter::GetAbort | ( |  | ) | const

Returns true if the user has aborted the print job.

## ◆ GetLastError()

static wxPrinterError wxPrinter::GetLastError | ( |  | ) |
| static

Return last error.

Valid after calling Print(), PrintDialog() or wxPrintPreview::Print().

These functions set last error to `wxPRINTER_NO_ERROR` if no error happened.

Returned value is one of the following:

wxPRINTER_NO_ERROR | No error happened.
wxPRINTER_CANCELLED | The user cancelled printing.
wxPRINTER_ERROR | There was an error during printing.

## ◆ GetPrintDialogData()

virtual wxPrintDialogData& wxPrinter::GetPrintDialogData | ( |  | ) | const
| virtual

Returns the print data associated with the printer object.

## ◆ Print()

virtual bool wxPrinter::Print | ( | wxWindow * | parent,
|  | wxPrintout * | printout,
|  | bool | prompt = `true`
| ) |  |
| virtual

Starts the printing process.

Provide a parent window, a user-defined wxPrintout object which controls the printing of a document, and whether the print dialog should be invoked first.

Print() could return false if there was a problem initializing the printer device context (current printer not set, for example) or the user cancelled printing. Call GetLastError() to get detailed information about the kind of the error.

## ◆ PrintDialog()

virtual wxDC* wxPrinter::PrintDialog | ( | wxWindow * | parent | ) |
| virtual

Invokes the print dialog.

If successful (the user did not press Cancel and no error occurred), a suitable device context will be returned; otherwise NULL is returned; call GetLastError() to get detailed information about the kind of the error.

Remarks
  The application must delete this device context to avoid a memory leak.

## ◆ ReportError()

virtual void wxPrinter::ReportError | ( | wxWindow * | parent,
|  | wxPrintout * | printout,
|  | const wxString & | message
| ) |  |
| virtual

Default error-reporting function.

## ◆ Setup()

virtual bool wxPrinter::Setup | ( | wxWindow * | parent | ) |
| virtual

Invokes the print setup dialog.

Deprecated:
  The setup dialog is obsolete, though retained for backward compatibility.