2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: print.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxPreviewControlBar
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-20 20:07:31 -04:00
|
|
|
enum wxPrinterError
|
|
|
|
{
|
|
|
|
wxPRINTER_NO_ERROR = 0,
|
|
|
|
wxPRINTER_CANCELLED,
|
|
|
|
wxPRINTER_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
#define wxPREVIEW_PRINT 1
|
|
|
|
#define wxPREVIEW_PREVIOUS 2
|
|
|
|
#define wxPREVIEW_NEXT 4
|
|
|
|
#define wxPREVIEW_ZOOM 8
|
|
|
|
#define wxPREVIEW_FIRST 16
|
|
|
|
#define wxPREVIEW_LAST 32
|
|
|
|
#define wxPREVIEW_GOTO 64
|
|
|
|
|
|
|
|
#define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
|
|
|
|
|wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
|
|
|
|
|
|
|
|
// Ids for controls
|
|
|
|
#define wxID_PREVIEW_CLOSE 1
|
|
|
|
#define wxID_PREVIEW_NEXT 2
|
|
|
|
#define wxID_PREVIEW_PREVIOUS 3
|
|
|
|
#define wxID_PREVIEW_PRINT 4
|
|
|
|
#define wxID_PREVIEW_ZOOM 5
|
|
|
|
#define wxID_PREVIEW_FIRST 6
|
|
|
|
#define wxID_PREVIEW_LAST 7
|
|
|
|
#define wxID_PREVIEW_GOTO 8
|
|
|
|
#define wxID_PREVIEW_ZOOM_IN 9
|
|
|
|
#define wxID_PREVIEW_ZOOM_OUT 10
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPreviewControlBar
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is the default implementation of the preview control bar, a panel
|
2008-04-10 17:16:38 -04:00
|
|
|
with buttons and a zoom control.
|
|
|
|
|
|
|
|
You can derive a new class from this and override some or all member functions
|
|
|
|
to change the behaviour and appearance; or you can leave it as it is.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxPreviewFrame, wxPreviewCanvas, wxPrintPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPreviewControlBar : public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
2008-04-10 17:16:38 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
|
|
|
|
The @a buttons parameter may be a combination of the following, using the bitwise
|
|
|
|
'or' operator:
|
|
|
|
|
2008-04-10 18:09:29 -04:00
|
|
|
@beginFlagTable
|
|
|
|
@flag{wxPREVIEW_PRINT}
|
2008-04-10 17:16:38 -04:00
|
|
|
Create a print button.
|
2008-04-10 18:09:29 -04:00
|
|
|
@flag{wxPREVIEW_NEXT}
|
2008-04-10 17:16:38 -04:00
|
|
|
Create a next page button.
|
2008-04-10 18:09:29 -04:00
|
|
|
@flag{wxPREVIEW_PREVIOUS}
|
2008-04-10 17:16:38 -04:00
|
|
|
Create a previous page button.
|
2008-04-10 18:09:29 -04:00
|
|
|
@flag{wxPREVIEW_ZOOM}
|
2008-04-10 17:16:38 -04:00
|
|
|
Create a zoom control.
|
2008-04-10 18:09:29 -04:00
|
|
|
@flag{wxPREVIEW_DEFAULT}
|
2008-04-10 17:16:38 -04:00
|
|
|
Equivalent to a combination of @c wxPREVIEW_PREVIOUS, @c wxPREVIEW_NEXT
|
|
|
|
and @c wxPREVIEW_ZOOM.
|
2008-04-10 18:09:29 -04:00
|
|
|
@endFlagTable
|
2008-04-10 17:16:38 -04:00
|
|
|
*/
|
|
|
|
wxPreviewControlBar(wxPrintPreview* preview,
|
|
|
|
long buttons,
|
|
|
|
wxWindow* parent,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = "panel");
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxPreviewControlBar();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates buttons, according to value of the button style flags.
|
2008-04-10 18:04:29 -04:00
|
|
|
|
|
|
|
@todo which flags??
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void CreateButtons();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the print preview object associated with the control bar.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxPrintPreviewBase* GetPrintPreview() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the current zoom setting in percent.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetZoomControl();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the zoom control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetZoomControl(int percent);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPreviewCanvas
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A preview canvas is the default canvas used by the print preview
|
|
|
|
system to display the preview.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxPreviewFrame, wxPreviewControlBar, wxPrintPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPreviewCanvas : public wxScrolledWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxPreviewCanvas(wxPrintPreview* preview, wxWindow* parent,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = "canvas");
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxPreviewCanvas();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Calls wxPrintPreview::PaintPage() to refresh the canvas.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
};
|
|
|
|
|
2011-04-26 18:57:27 -04:00
|
|
|
/**
|
|
|
|
Preview frame modality kind.
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2011-04-26 18:57:27 -04:00
|
|
|
The elements of this enum can be used with wxPreviewFrame::Initialize() to
|
|
|
|
indicate how should the preview frame be shown.
|
|
|
|
|
|
|
|
@since 2.9.2
|
|
|
|
*/
|
|
|
|
enum wxPreviewFrameModalityKind
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
Disable all the other top level windows while the preview frame is shown.
|
|
|
|
|
|
|
|
This is the default behaviour.
|
|
|
|
*/
|
|
|
|
wxPreviewFrame_AppModal,
|
|
|
|
|
|
|
|
/**
|
|
|
|
Disable only the parent window while the preview frame is shown.
|
|
|
|
*/
|
|
|
|
wxPreviewFrame_WindowModal,
|
|
|
|
|
|
|
|
/**
|
|
|
|
Show the preview frame non-modally and don't disable any other windows.
|
|
|
|
*/
|
|
|
|
wxPreviewFrame_NonModal
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPreviewFrame
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class provides the default method of managing the print preview interface.
|
|
|
|
Member functions may be overridden to replace functionality, or the
|
|
|
|
class may be used without derivation.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxPreviewCanvas, wxPreviewControlBar, wxPrintPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPreviewFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
Pass a print preview object plus other normal frame arguments.
|
2008-03-08 08:52:38 -05:00
|
|
|
The print preview object will be destroyed by the frame when it closes.
|
|
|
|
*/
|
2008-10-13 09:46:42 -04:00
|
|
|
wxPreviewFrame(wxPrintPreviewBase* preview, wxWindow* parent,
|
|
|
|
const wxString& title = "Print Preview",
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2008-10-13 09:46:42 -04:00
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-03-08 08:52:38 -05:00
|
|
|
long style = wxDEFAULT_FRAME_STYLE,
|
2008-11-08 10:17:16 -05:00
|
|
|
const wxString& name = wxFrameNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxPreviewFrame();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Creates a wxPreviewCanvas.
|
|
|
|
|
|
|
|
Override this function to allow a user-defined preview canvas object
|
|
|
|
to be created.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void CreateCanvas();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Creates a wxPreviewControlBar.
|
|
|
|
|
|
|
|
Override this function to allow a user-defined preview control bar object
|
|
|
|
to be created.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void CreateControlBar();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2011-06-22 18:58:07 -04:00
|
|
|
Initializes the frame elements and prepares for showing it.
|
2011-04-26 18:57:27 -04:00
|
|
|
|
2011-06-22 18:58:07 -04:00
|
|
|
Calling this method is equivalent to calling InitializeWithModality()
|
|
|
|
with wxPreviewFrame_AppModal argument, please see its documentation for
|
|
|
|
more details.
|
2011-04-26 18:57:27 -04:00
|
|
|
|
2011-06-22 18:58:07 -04:00
|
|
|
Please notice that this function is virtual mostly for backwards
|
|
|
|
compatibility only, there is no real need to override it as it's never
|
|
|
|
called by wxWidgets itself.
|
|
|
|
*/
|
|
|
|
virtual void Initialize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes the frame elements and prepares for showing it with the
|
|
|
|
given modality kind.
|
|
|
|
|
|
|
|
This method creates the frame elements by calling CreateCanvas() and
|
|
|
|
CreateControlBar() methods (which may be overridden to customize them)
|
|
|
|
and prepares to show the frame according to the value of @a kind
|
|
|
|
parameter:
|
|
|
|
- If it is wxPreviewFrame_AppModal, all the other application
|
|
|
|
windows will be disabled when this frame is shown. This is the same
|
|
|
|
behaviour as that of simple Initialize().
|
|
|
|
- If it is wxPreviewFrame_WindowModal, only the parent window of
|
|
|
|
the preview frame will be disabled when it is shown.
|
|
|
|
- And if it is wxPreviewFrame_NonModal, no windows at all will be
|
|
|
|
disabled while the preview is shown.
|
|
|
|
|
|
|
|
Notice that this function (or Initialize()) must be called by the
|
|
|
|
application prior to showing the frame but you still must call @c
|
|
|
|
Show(true) to actually show it afterwards.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2011-04-26 18:57:27 -04:00
|
|
|
@param kind
|
2011-06-22 18:58:07 -04:00
|
|
|
The modality kind of preview frame.
|
|
|
|
|
|
|
|
@since 2.9.2
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2011-06-22 18:58:07 -04:00
|
|
|
virtual void InitializeWithModality(wxPreviewFrameModalityKind kind);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2011-04-26 18:57:27 -04:00
|
|
|
Enables any disabled frames in the application, and deletes the print preview
|
2008-03-08 08:52:38 -05:00
|
|
|
object, implicitly deleting any printout objects associated with the print
|
|
|
|
preview object.
|
|
|
|
*/
|
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPrintPreview
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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
|
2008-04-10 17:16:38 -04:00
|
|
|
the preview frame. Unlike wxPrinter::Print(), flow of control returns to the
|
|
|
|
application immediately after the frame is shown.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-06-16 04:45:39 -04:00
|
|
|
@note
|
|
|
|
The preview shown is only exact on Windows. On other platforms, the wxDC
|
|
|
|
used for preview is different from what is used for printing and the
|
|
|
|
results may be significantly different, depending on how is the output
|
|
|
|
created. In particular, printing code relying on wxDC::GetTextExtent()
|
|
|
|
heavily (for example, wxHtmlEasyPrinting and other wxHTML classes do) is
|
|
|
|
affected. It is recommended to use native preview functionality on
|
|
|
|
platforms that offer it (OS X, GTK+).
|
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-10 18:04:29 -04:00
|
|
|
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrinter,
|
|
|
|
wxPreviewCanvas, wxPreviewControlBar, wxPreviewFrame
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPrintPreview : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
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.
|
|
|
|
|
2008-04-10 18:04:29 -04:00
|
|
|
If @a printoutForPrinting is non-@NULL, a @b "Print..." button will be placed on
|
2008-04-10 17:16:38 -04:00
|
|
|
the preview frame so that the user can print directly from the preview interface.
|
|
|
|
|
|
|
|
@remarks
|
2012-04-20 20:07:31 -04:00
|
|
|
Do not explicitly delete the printout objects once this constructor has been
|
|
|
|
called, since they will be deleted in the wxPrintPreview destructor.
|
2008-03-09 08:33:59 -04:00
|
|
|
The same does not apply to the @a data argument.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2008-04-10 18:04:29 -04:00
|
|
|
Use IsOk() to check whether the wxPrintPreview object was created correctly.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxPrintPreview(wxPrintout* printout,
|
2008-11-13 16:32:53 -05:00
|
|
|
wxPrintout* printoutForPrinting = NULL,
|
|
|
|
wxPrintDialogData* data = NULL);
|
2012-04-20 20:07:31 -04:00
|
|
|
wxPrintPreview(wxPrintout* printout,
|
|
|
|
wxPrintout* printoutForPrinting,
|
|
|
|
wxPrintData* data);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Destructor.
|
|
|
|
|
|
|
|
Deletes both print preview objects, so do not destroy these objects
|
2008-03-08 08:52:38 -05:00
|
|
|
in your application.
|
|
|
|
*/
|
2012-04-20 20:07:31 -04:00
|
|
|
~wxPrintPreview();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the preview window used for displaying the print preview image.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxPreviewCanvas* GetCanvas() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the page currently being previewed.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetCurrentPage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the frame used for displaying the print preview canvas
|
|
|
|
and control bar.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxFrame* GetFrame() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum page number.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetMaxPage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the minimum page number.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetMinPage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the preview printout object associated with the wxPrintPreview object.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxPrintout* GetPrintout() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the printout object to be used for printing from within the preview
|
|
|
|
interface,
|
|
|
|
or @NULL if none exists.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxPrintout* GetPrintoutForPrinting() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
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).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This refreshes the preview window with the preview image.
|
|
|
|
It must be called from the preview window's OnPaint member.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The implementation simply blits the preview bitmap onto
|
|
|
|
the canvas, creating a new preview bitmap if none exists.
|
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
virtual bool PaintPage(wxPreviewCanvas* canvas, wxDC& dc);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Invokes the print process using the second wxPrintout object
|
|
|
|
supplied in the wxPrintPreview constructor.
|
|
|
|
Will normally be called by the @b Print... panel item on the
|
|
|
|
preview frame's control bar.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
|
|
|
Returns @false in case of error -- call wxPrinter::GetLastError()
|
|
|
|
to get detailed information about the kind of the error.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool Print(bool prompt);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Renders a page into a wxMemoryDC. Used internally by wxPrintPreview.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool RenderPage(int pageNum);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the window to be used for displaying the print preview image.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetCanvas(wxPreviewCanvas* window);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the current page to be previewed.
|
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
virtual bool SetCurrentPage(int pageNum);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the frame to be used for displaying the print preview canvas
|
|
|
|
and control bar.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFrame(wxFrame* frame);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Associates a printout object with the wxPrintPreview object.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetPrintout(wxPrintout* printout);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 18:04:29 -04:00
|
|
|
Sets the percentage preview zoom, and refreshes the preview canvas accordingly.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetZoom(int percent);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPrinter
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents the Windows or PostScript printer, and is the vehicle
|
2008-04-10 17:16:38 -04:00
|
|
|
through which printing may be launched by an application.
|
2008-04-10 18:04:29 -04:00
|
|
|
|
2008-04-10 17:16:38 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-10 18:04:29 -04:00
|
|
|
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrintPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPrinter : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
Pass an optional pointer to a block of print dialog data, which will be
|
|
|
|
copied to the printer object's local data.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxPrintDialogData, wxPrintData
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxPrinter(wxPrintDialogData* data = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the default printing abort window, with a cancel button.
|
|
|
|
*/
|
2012-08-09 11:52:08 -04:00
|
|
|
virtual wxPrintAbortDialog* CreateAbortWindow(wxWindow* parent, wxPrintout* printout);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the user has aborted the print job.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
bool GetAbort() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Return last error. Valid after calling Print(), PrintDialog() or
|
|
|
|
wxPrintPreview::Print().
|
2008-04-10 18:04:29 -04:00
|
|
|
|
|
|
|
These functions set last error to @c wxPRINTER_NO_ERROR if no error happened.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-10 17:16:38 -04:00
|
|
|
Returned value is one of the following:
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-10 17:16:38 -04:00
|
|
|
@beginTable
|
2008-04-10 18:04:29 -04:00
|
|
|
@row2col{wxPRINTER_NO_ERROR, No error happened.}
|
|
|
|
@row2col{wxPRINTER_CANCELLED, The user cancelled printing.}
|
|
|
|
@row2col{wxPRINTER_ERROR, There was an error during printing.}
|
2008-04-10 17:16:38 -04:00
|
|
|
@endTable
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxPrinterError GetLastError();
|
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Returns the @ref overview_printing_printdata "print data" associated with
|
|
|
|
the printer object.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxPrintDialogData& GetPrintDialogData() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Starts the printing process. Provide a parent window, a user-defined wxPrintout
|
2008-04-10 17:16:38 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-27 17:26:54 -04:00
|
|
|
virtual bool Print(wxWindow* parent, wxPrintout* printout,
|
|
|
|
bool prompt = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Invokes the print dialog.
|
|
|
|
|
|
|
|
If successful (the user did not press Cancel and no error occurred),
|
2008-04-10 18:04:29 -04:00
|
|
|
a suitable device context will be returned; otherwise @NULL is returned;
|
|
|
|
call GetLastError() to get detailed information about the kind of the error.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
|
|
|
@remarks
|
2008-03-08 08:52:38 -05:00
|
|
|
The application must delete this device context to avoid a memory leak.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxDC* PrintDialog(wxWindow* parent);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Default error-reporting function.
|
|
|
|
*/
|
2008-10-27 17:26:54 -04:00
|
|
|
virtual void ReportError(wxWindow* parent, wxPrintout* printout,
|
|
|
|
const wxString& message);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Invokes the print setup dialog.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
The setup dialog is obsolete from Windows 95, though retained
|
|
|
|
for backward compatibility.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool Setup(wxWindow* parent);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPrintout
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-10 17:16:38 -04:00
|
|
|
This class encapsulates the functionality of printing out an application document.
|
|
|
|
|
|
|
|
A new class must be derived and members overridden to respond to calls such as
|
|
|
|
OnPrintPage() and HasPage() and to render the print image onto an associated wxDC.
|
|
|
|
Instances of this class are passed to wxPrinter::Print() or
|
2008-03-08 08:52:38 -05:00
|
|
|
to a wxPrintPreview object to initiate printing or previewing.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Your derived wxPrintout is responsible for drawing both the preview image and
|
|
|
|
the printed page. If your windows' drawing routines accept an arbitrary DC as an
|
|
|
|
argument, you can re-use those routines within your wxPrintout subclass to draw
|
|
|
|
the printout image. You may also add additional drawing elements within your
|
|
|
|
wxPrintout subclass, like headers, footers, and/or page numbers. However, the
|
|
|
|
image on the printed page will often differ from the image drawn on the screen,
|
|
|
|
as will the print preview image -- not just in the presence of headers and
|
|
|
|
footers, but typically in scale. A high-resolution printer presents a much
|
|
|
|
larger drawing surface (i.e., a higher-resolution DC); a zoomed-out preview
|
|
|
|
image presents a much smaller drawing surface (lower-resolution DC). By using
|
|
|
|
the routines FitThisSizeToXXX() and/or MapScreenSizeToXXX() within your
|
|
|
|
wxPrintout subclass to set the user scale and origin of the associated DC, you
|
|
|
|
can easily use a single drawing routine to draw on your application's windows,
|
|
|
|
to create the print preview image, and to create the printed paper image, and
|
|
|
|
achieve a common appearance to the preview image and the printed page.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2012-10-26 21:27:23 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{printing}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-10 18:04:29 -04:00
|
|
|
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPageSetupDialog,
|
|
|
|
wxPrinter, wxPrintPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPrintout : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
Pass an optional title argument - the current filename would be a
|
|
|
|
good idea. This will appear in the printing list (at least in MSW)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxPrintout(const wxString& title = "Printout");
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxPrintout();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the user scale and device origin of the wxDC associated with this wxPrintout
|
|
|
|
so that the given image size fits entirely within the page rectangle and the
|
2008-04-10 17:16:38 -04:00
|
|
|
origin is at the top left corner of the page rectangle.
|
|
|
|
|
|
|
|
On MSW and Mac, the page rectangle is the printable area of the page.
|
|
|
|
On other platforms and PostScript printing, the page rectangle is the entire paper.
|
|
|
|
|
|
|
|
Use this if you want your printed image as large as possible, but with the caveat
|
|
|
|
that on some platforms, portions of the image might be cut off at the edges.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void FitThisSizeToPage(const wxSize& imageSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the user scale and device origin of the wxDC associated with this wxPrintout
|
|
|
|
so that the given image size fits entirely within the page margins set in the
|
2008-04-10 17:16:38 -04:00
|
|
|
given wxPageSetupDialogData object.
|
|
|
|
|
|
|
|
This function provides the greatest consistency across all platforms because it
|
|
|
|
does not depend on having access to the printable area of the paper.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
On Mac, the native wxPageSetupDialog does not let you set the page margins;
|
|
|
|
you'll have to provide your own mechanism, or you can use the Mac-only class
|
|
|
|
wxMacPageMarginsDialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void FitThisSizeToPageMargins(const wxSize& imageSize,
|
|
|
|
const wxPageSetupDialogData& pageSetupData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the user scale and device origin of the wxDC associated with this wxPrintout
|
|
|
|
so that the given image size fits entirely within the paper and the origin is at
|
2008-04-10 17:16:38 -04:00
|
|
|
the top left corner of the paper.
|
|
|
|
|
|
|
|
Use this if you're managing your own page margins.
|
|
|
|
|
|
|
|
@note
|
|
|
|
With most printers, the region around the edges of the paper are not
|
|
|
|
printable so that the edges of the image could be cut off.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void FitThisSizeToPaper(const wxSize& imageSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the device context associated with the printout (given to the printout
|
2008-04-10 17:16:38 -04:00
|
|
|
at start of printing or previewing).
|
|
|
|
|
|
|
|
The application can use GetDC() to obtain a device context to draw on.
|
|
|
|
|
|
|
|
This will be a wxPrinterDC if printing under Windows or Mac, a wxPostScriptDC
|
|
|
|
if printing on other platforms, and a wxMemoryDC if previewing.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxDC* GetDC() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return the rectangle corresponding to the page margins specified by the given
|
|
|
|
wxPageSetupDialogData object in the associated wxDC's logical coordinates for
|
2008-04-10 17:16:38 -04:00
|
|
|
the current user scale and device origin.
|
|
|
|
|
|
|
|
The page margins are specified with respect to the edges of the paper on all
|
|
|
|
platforms.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Return the rectangle corresponding to the page in the associated wxDC 's
|
2008-03-08 09:43:31 -05:00
|
|
|
logical coordinates for the current user scale and device origin.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
|
|
|
On MSW and Mac, this will be the printable area of the paper.
|
|
|
|
On other platforms and PostScript printing, this will be the full paper
|
|
|
|
rectangle.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxRect GetLogicalPageRect() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Return the rectangle corresponding to the paper in the associated wxDC 's
|
2008-03-08 08:52:38 -05:00
|
|
|
logical coordinates for the current user scale and device origin.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxRect GetLogicalPaperRect() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of pixels per logical inch of the printer device context.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Dividing the printer PPI by the screen PPI can give a suitable scaling factor
|
2008-04-10 17:16:38 -04:00
|
|
|
for drawing text onto the printer.
|
|
|
|
|
|
|
|
Remember to multiply this by a scaling factor to take the preview DC size into
|
|
|
|
account.
|
|
|
|
Or you can just use the FitThisSizeToXXX() and MapScreenSizeToXXX routines below,
|
|
|
|
which do most of the scaling calculations for you.
|
|
|
|
|
2009-10-18 13:47:01 -04:00
|
|
|
@beginWxPerlOnly
|
|
|
|
In wxPerl this method takes no arguments and returns a
|
|
|
|
2-element list (w, h).
|
|
|
|
@endWxPerlOnly
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
void GetPPIPrinter(int* w, int* h) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of pixels per logical inch of the screen device context.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Dividing the printer PPI by the screen PPI can give a suitable scaling factor
|
2008-04-10 17:16:38 -04:00
|
|
|
for drawing text onto the printer.
|
|
|
|
|
|
|
|
If you are doing your own scaling, remember to multiply this by a scaling
|
|
|
|
factor to take the preview DC size into account.
|
|
|
|
|
2009-10-18 13:47:01 -04:00
|
|
|
@beginWxPerlOnly
|
|
|
|
In wxPerl this method takes no arguments and returns a
|
|
|
|
2-element list (w, h).
|
|
|
|
@endWxPerlOnly
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
void GetPPIScreen(int* w, int* h) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Called by the framework to obtain information from the application about minimum
|
|
|
|
and maximum page values that the user can select, and the required page range to
|
2008-04-10 17:16:38 -04:00
|
|
|
be printed.
|
|
|
|
|
|
|
|
By default this returns (1, 32000) for the page minimum and maximum values, and
|
|
|
|
(1, 1) for the required page range.
|
|
|
|
|
2008-05-29 19:36:26 -04:00
|
|
|
@a minPage must be greater than zero and @a maxPage must be greater
|
|
|
|
than @a minPage.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-27 17:26:54 -04:00
|
|
|
virtual void GetPageInfo(int* minPage, int* maxPage, int* pageFrom,
|
|
|
|
int* pageTo);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the size of the printer page in millimetres.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2009-10-18 13:47:01 -04:00
|
|
|
@beginWxPerlOnly
|
|
|
|
In wxPerl this method takes no arguments and returns a
|
|
|
|
2-element list (w, h).
|
|
|
|
@endWxPerlOnly
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
void GetPageSizeMM(int* w, int* h) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the size of the printer page in pixels, called the page rectangle.
|
2008-04-10 17:16:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The page rectangle has a top left corner at (0,0) and a bottom right corner at
|
|
|
|
(w,h). These values may not be the same as the values returned from
|
2008-04-10 17:16:38 -04:00
|
|
|
wxDC::GetSize(); if the printout is being used for
|
2008-03-08 08:52:38 -05:00
|
|
|
previewing, a memory device context is used, which uses a bitmap size reflecting
|
|
|
|
the current preview zoom. The application must take this discrepancy into
|
|
|
|
account if previewing is to be supported.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
void GetPageSizePixels(int* w, int* h) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the rectangle that corresponds to the entire paper in pixels, called the
|
2008-04-10 17:16:38 -04:00
|
|
|
paper rectangle.
|
|
|
|
|
|
|
|
This distinction between paper rectangle and page rectangle reflects the fact that
|
|
|
|
most printers cannot print all the way to the edge of the paper.
|
|
|
|
The page rectangle is a rectangle whose top left corner is at (0,0) and whose width
|
|
|
|
and height are given by wxDC::GetPageSizePixels().
|
|
|
|
|
|
|
|
On MSW and Mac, the page rectangle gives the printable area of the paper, while the
|
|
|
|
paper rectangle represents the entire paper, including non-printable borders.
|
|
|
|
Thus, the rectangle returned by wxDC::GetPaperRectPixels() will have a top left corner
|
|
|
|
whose coordinates are small negative numbers and the bottom right corner will have
|
|
|
|
values somewhat larger than the width and height given by wxDC::GetPageSizePixels().
|
|
|
|
|
|
|
|
On other platforms and for PostScript printing, the paper is treated as if its entire
|
2008-03-08 08:52:38 -05:00
|
|
|
area were printable, so this function will return the same rectangle as the page
|
|
|
|
rectangle.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxRect GetPaperRectPixels() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 18:04:29 -04:00
|
|
|
Returns the title of the printout.
|
|
|
|
|
|
|
|
@todo the python note here was wrong
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetTitle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Should be overridden to return @true if the document has this page, or @false
|
2008-04-10 17:16:38 -04:00
|
|
|
if not.
|
|
|
|
|
|
|
|
Returning @false signifies the end of the document. By default,
|
2008-03-08 08:52:38 -05:00
|
|
|
HasPage behaves as if the document has only one page.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool HasPage(int pageNum);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the printout is currently being used for previewing.
|
2010-05-05 08:19:59 -04:00
|
|
|
|
|
|
|
@see GetPreview()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsPreview() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2010-05-05 08:19:59 -04:00
|
|
|
/**
|
|
|
|
Returns the associated preview object if any.
|
|
|
|
|
|
|
|
If this printout object is used for previewing, returns the associated
|
|
|
|
wxPrintPreview. Otherwise returns @NULL.
|
|
|
|
|
|
|
|
The returned pointer is not owned by the printout and must not be
|
|
|
|
deleted.
|
|
|
|
|
|
|
|
@see IsPreview()
|
|
|
|
|
|
|
|
@since 2.9.1.
|
|
|
|
*/
|
|
|
|
wxPrintPreview *GetPreview() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Set the user scale and device origin of the wxDC associated with this wxPrintout
|
2008-04-10 17:16:38 -04:00
|
|
|
so that one screen pixel maps to one device pixel on the DC.
|
|
|
|
That is, the user scale is set to (1,1) and the device origin is set to (0,0).
|
|
|
|
|
|
|
|
Use this if you want to do your own scaling prior to calling wxDC drawing calls,
|
|
|
|
for example, if your underlying model is floating-point and you want to achieve
|
|
|
|
maximum drawing precision on high-resolution printers.
|
|
|
|
|
|
|
|
You can use the GetLogicalXXXRect() routines below to obtain the paper rectangle,
|
|
|
|
page rectangle, or page margins rectangle to perform your own scaling.
|
|
|
|
|
|
|
|
@note
|
|
|
|
While the underlying drawing model of Mac OS X is floating-point,
|
|
|
|
wxWidgets's drawing model scales from integer coordinates.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void MapScreenSizeToDevice();
|
|
|
|
|
|
|
|
/**
|
2011-04-03 16:31:32 -04:00
|
|
|
This sets the user scale of the wxDC associated with this wxPrintout to the same
|
2008-04-10 17:16:38 -04:00
|
|
|
scale as MapScreenSizeToPaper() but sets the logical origin to the top left corner
|
|
|
|
of the page rectangle.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void MapScreenSizeToPage();
|
|
|
|
|
|
|
|
/**
|
2011-04-03 16:31:32 -04:00
|
|
|
This sets the user scale of the wxDC associated with this wxPrintout to the same
|
2008-04-10 17:16:38 -04:00
|
|
|
scale as MapScreenSizeToPageMargins() but sets the logical origin to the top left
|
|
|
|
corner of the page margins specified by the given wxPageSetupDialogData object.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the user scale and device origin of the wxDC associated with this wxPrintout
|
|
|
|
so that the printed page matches the screen size as closely as possible
|
|
|
|
and the logical origin is in the top left corner of the paper rectangle.
|
2008-04-10 18:04:29 -04:00
|
|
|
|
|
|
|
That is, a 100-pixel object on screen should appear at the same size on the
|
|
|
|
printed page.
|
2008-04-10 17:16:38 -04:00
|
|
|
(It will, of course, be larger or smaller in the preview image, depending on the
|
|
|
|
zoom factor.)
|
|
|
|
|
2011-03-22 10:17:38 -04:00
|
|
|
Use this if you want WYSIWYG behaviour, e.g., in a text editor.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void MapScreenSizeToPaper();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Shift the device origin by an amount specified in logical coordinates.
|
|
|
|
*/
|
|
|
|
void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called by the framework at the start of document printing. Return @false from
|
2008-04-10 17:16:38 -04:00
|
|
|
this function cancels the print job.
|
|
|
|
|
|
|
|
OnBeginDocument() is called once for every copy printed.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
The base OnBeginDocument() must be called (and the return value
|
|
|
|
checked) from within the overridden function, since it calls wxDC::StartDoc().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool OnBeginDocument(int startPage, int endPage);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Called by the framework at the start of printing.
|
|
|
|
|
|
|
|
OnBeginPrinting() is called once for every print job
|
|
|
|
(regardless of how many copies are being printed).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void OnBeginPrinting();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Called by the framework at the end of document printing.
|
|
|
|
|
|
|
|
OnEndDocument() is called once for every copy printed.
|
|
|
|
|
|
|
|
@remarks
|
|
|
|
The base OnEndDocument() must be called from within the overridden function,
|
|
|
|
since it calls wxDC::EndDoc().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void OnEndDocument();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:16:38 -04:00
|
|
|
Called by the framework at the end of printing.
|
|
|
|
|
|
|
|
OnEndPrinting is called once for every print job
|
|
|
|
(regardless of how many copies are being printed).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void OnEndPrinting();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Called once by the framework before any other demands are made of the
|
2008-04-10 17:16:38 -04:00
|
|
|
wxPrintout object.
|
|
|
|
|
|
|
|
This gives the object an opportunity to calculate the number of pages
|
|
|
|
in the document, for example.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void OnPreparePrinting();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Called by the framework when a page should be printed. Returning @false cancels
|
2008-04-10 17:16:38 -04:00
|
|
|
the print job.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 09:24:43 -04:00
|
|
|
virtual bool OnPrintPage(int pageNum) = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the device origin of the associated wxDC so that the current logical point
|
|
|
|
becomes the new logical origin.
|
|
|
|
*/
|
|
|
|
void SetLogicalOrigin(wxCoord x, wxCoord y);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2012-08-09 12:47:48 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxPrintAbortDialog
|
|
|
|
|
|
|
|
The dialog created by default by the print framework that enables aborting
|
|
|
|
the printing process.
|
|
|
|
*/
|
|
|
|
class wxPrintAbortDialog: public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPrintAbortDialog(wxWindow *parent,
|
|
|
|
const wxString& documentTitle,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_DIALOG_STYLE,
|
2012-08-10 00:57:35 -04:00
|
|
|
const wxString& name = "dialog");
|
2012-08-09 12:47:48 -04:00
|
|
|
|
|
|
|
void SetProgress(int currentPage, int totalPages,
|
|
|
|
int currentCopy, int totalCopies);
|
|
|
|
};
|