// Name: print.h
// Purpose: interface of wxPreviewControlBar
// Author: wxWidgets team
-// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+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
+
+
/**
@class wxPreviewControlBar
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.
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see wxPreviewFrame, wxPreviewCanvas, wxPrintPreview
/**
Destructor.
*/
- ~wxPreviewControlBar();
+ virtual ~wxPreviewControlBar();
/**
Creates buttons, according to value of the button style flags.
@todo which flags??
*/
- void CreateButtons();
+ virtual void CreateButtons();
/**
Gets the print preview object associated with the control bar.
*/
- wxPrintPreview* GetPrintPreview();
+ virtual wxPrintPreviewBase* GetPrintPreview() const;
/**
Gets the current zoom setting in percent.
*/
- int GetZoomControl();
+ virtual int GetZoomControl();
/**
Sets the zoom control.
*/
- void SetZoomControl(int percent);
+ virtual void SetZoomControl(int percent);
};
A preview canvas is the default canvas used by the print preview
system to display the preview.
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see wxPreviewFrame, wxPreviewControlBar, wxPrintPreview
/**
Destructor.
*/
- ~wxPreviewCanvas();
+ virtual ~wxPreviewCanvas();
/**
Calls wxPrintPreview::PaintPage() to refresh the canvas.
void OnPaint(wxPaintEvent& event);
};
+/**
+ Preview frame modality kind.
+
+ 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
+};
/**
@class wxPreviewFrame
Member functions may be overridden to replace functionality, or the
class may be used without derivation.
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see wxPreviewCanvas, wxPreviewControlBar, wxPrintPreview
Pass a print preview object plus other normal frame arguments.
The print preview object will be destroyed by the frame when it closes.
*/
- wxPreviewFrame(wxPrintPreview* preview, wxWindow* parent,
- const wxString& title,
+ wxPreviewFrame(wxPrintPreviewBase* preview, wxWindow* parent,
+ const wxString& title = "Print Preview",
const wxPoint& pos = wxDefaultPosition,
- const wxSize& size size = wxDefaultSize,
+ const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = "frame");
+ const wxString& name = wxFrameNameStr);
/**
Destructor.
*/
- ~wxPreviewFrame();
+ virtual ~wxPreviewFrame();
/**
Creates a wxPreviewCanvas.
Override this function to allow a user-defined preview canvas object
to be created.
*/
- void CreateCanvas();
+ virtual void CreateCanvas();
/**
Creates a wxPreviewControlBar.
Override this function to allow a user-defined preview control bar object
to be created.
*/
- void CreateControlBar();
+ virtual void CreateControlBar();
+
+ /**
+ Initializes the frame elements and prepares for showing it.
+
+ Calling this method is equivalent to calling InitializeWithModality()
+ with wxPreviewFrame_AppModal argument, please see its documentation for
+ more details.
+
+ 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();
/**
- Creates the preview canvas and control bar, and calls wxWindow::MakeModal(@true)
- to disable other top-level windows in the application.
+ Initializes the frame elements and prepares for showing it with the
+ given modality kind.
- This function should be called by the application prior to showing the frame.
+ 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.
+
+ @param kind
+ The modality kind of preview frame.
+
+ @since 2.9.2
*/
- void Initialize();
+ virtual void InitializeWithModality(wxPreviewFrameModalityKind kind);
/**
- Enables the other frames in the application, and deletes the print preview
+ Enables any disabled frames in the application, and deletes the print preview
object, implicitly deleting any printout objects associated with the print
preview object.
*/
affected. It is recommended to use native preview functionality on
platforms that offer it (OS X, GTK+).
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrinter,
the preview frame so that the user can print directly from the preview interface.
@remarks
- Do not explicitly delete the printout objects once this destructor has been
- called, since they will be deleted in the wxPrintPreview constructor.
+ Do not explicitly delete the printout objects once this constructor has been
+ called, since they will be deleted in the wxPrintPreview destructor.
The same does not apply to the @a data argument.
Use IsOk() to check whether the wxPrintPreview object was created correctly.
*/
+ wxPrintPreview(wxPrintout* printout,
+ wxPrintout* printoutForPrinting = NULL,
+ wxPrintDialogData* data = NULL);
wxPrintPreview(wxPrintout* printout,
wxPrintout* printoutForPrinting,
- wxPrintData* data = NULL);
+ wxPrintData* data);
/**
Destructor.
Deletes both print preview objects, so do not destroy these objects
in your application.
*/
- ~wxPrinter();
+ ~wxPrintPreview();
/**
Gets the preview window used for displaying the print preview image.
*/
- wxPreviewCanvas* GetCanvas();
+ virtual wxPreviewCanvas* GetCanvas() const;
/**
Gets the page currently being previewed.
*/
- int GetCurrentPage();
+ virtual int GetCurrentPage() const;
/**
Gets the frame used for displaying the print preview canvas
and control bar.
*/
- wxFrame* GetFrame();
+ virtual wxFrame* GetFrame() const;
/**
Returns the maximum page number.
*/
- int GetMaxPage();
+ virtual int GetMaxPage() const;
/**
Returns the minimum page number.
*/
- int GetMinPage();
+ virtual int GetMinPage() const;
/**
Gets the preview printout object associated with the wxPrintPreview object.
*/
- wxPrintout* GetPrintout();
+ virtual wxPrintout* GetPrintout() const;
/**
Gets the printout object to be used for printing from within the preview
interface,
or @NULL if none exists.
*/
- wxPrintout* GetPrintoutForPrinting();
+ virtual wxPrintout* GetPrintoutForPrinting() const;
/**
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).
*/
- bool IsOk();
+ virtual bool IsOk() const;
/**
This refreshes the preview window with the preview image.
The implementation simply blits the preview bitmap onto
the canvas, creating a new preview bitmap if none exists.
*/
- bool PaintPage(wxPreviewCanvas* canvas, wxDC dc);
+ virtual bool PaintPage(wxPreviewCanvas* canvas, wxDC& dc);
/**
Invokes the print process using the second wxPrintout object
Returns @false in case of error -- call wxPrinter::GetLastError()
to get detailed information about the kind of the error.
*/
- bool Print(bool prompt);
+ virtual bool Print(bool prompt);
/**
Renders a page into a wxMemoryDC. Used internally by wxPrintPreview.
*/
- bool RenderPage(int pageNum);
+ virtual bool RenderPage(int pageNum);
/**
Sets the window to be used for displaying the print preview image.
*/
- void SetCanvas(wxPreviewCanvas* window);
+ virtual void SetCanvas(wxPreviewCanvas* window);
/**
Sets the current page to be previewed.
*/
- void SetCurrentPage(int pageNum);
+ virtual bool SetCurrentPage(int pageNum);
/**
Sets the frame to be used for displaying the print preview canvas
and control bar.
*/
- void SetFrame(wxFrame* frame);
+ virtual void SetFrame(wxFrame* frame);
/**
Associates a printout object with the wxPrintPreview object.
*/
- void SetPrintout(wxPrintout* printout);
+ virtual void SetPrintout(wxPrintout* printout);
/**
Sets the percentage preview zoom, and refreshes the preview canvas accordingly.
*/
- void SetZoom(int percent);
+ virtual void SetZoom(int percent);
};
but this and associated classes provide a more convenient and general method
of printing.
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPrintout, wxPrintPreview
/**
Creates the default printing abort window, with a cancel button.
*/
- void CreateAbortWindow(wxWindow* parent, wxPrintout* printout);
+ virtual wxPrintAbortDialog* CreateAbortWindow(wxWindow* parent, wxPrintout* printout);
/**
Returns @true if the user has aborted the print job.
*/
- bool GetAbort();
+ bool GetAbort() const;
/**
Return last error. Valid after calling Print(), PrintDialog() or
Returns the @ref overview_printing_printdata "print data" associated with
the printer object.
*/
- wxPrintDialogData& GetPrintDialogData();
+ virtual wxPrintDialogData& GetPrintDialogData() const;
/**
Starts the printing process. Provide a parent window, a user-defined wxPrintout
context (current printer not set, for example) or the user cancelled printing.
Call GetLastError() to get detailed information about the kind of the error.
*/
- bool Print(wxWindow* parent, wxPrintout* printout,
- bool prompt = true);
+ virtual bool Print(wxWindow* parent, wxPrintout* printout,
+ bool prompt = true);
/**
Invokes the print dialog.
@remarks
The application must delete this device context to avoid a memory leak.
*/
- wxDC* PrintDialog(wxWindow* parent);
+ virtual wxDC* PrintDialog(wxWindow* parent);
/**
Default error-reporting function.
*/
- void ReportError(wxWindow* parent, wxPrintout* printout,
- const wxString& message);
+ virtual void ReportError(wxWindow* parent, wxPrintout* printout,
+ const wxString& message);
/**
Invokes the print setup dialog.
The setup dialog is obsolete from Windows 95, though retained
for backward compatibility.
*/
- bool Setup(wxWindow* parent);
+ virtual bool Setup(wxWindow* parent);
};
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.
- @library{wxbase}
+ @library{wxcore}
@category{printing}
@see @ref overview_printing, wxPrinterDC, wxPrintDialog, wxPageSetupDialog,
/**
Destructor.
*/
- ~wxPrintout();
+ virtual ~wxPrintout();
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
This will be a wxPrinterDC if printing under Windows or Mac, a wxPostScriptDC
if printing on other platforms, and a wxMemoryDC if previewing.
*/
- wxDC* GetDC();
+ wxDC* GetDC() const;
/**
Return the rectangle corresponding to the page margins specified by the given
The page margins are specified with respect to the edges of the paper on all
platforms.
*/
- wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData);
+ wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
/**
Return the rectangle corresponding to the page in the associated wxDC 's
On other platforms and PostScript printing, this will be the full paper
rectangle.
*/
- wxRect GetLogicalPageRect();
+ wxRect GetLogicalPageRect() const;
/**
Return the rectangle corresponding to the paper in the associated wxDC 's
logical coordinates for the current user scale and device origin.
*/
- wxRect GetLogicalPaperRect();
+ wxRect GetLogicalPaperRect() const;
/**
Returns the number of pixels per logical inch of the printer device context.
Or you can just use the FitThisSizeToXXX() and MapScreenSizeToXXX routines below,
which do most of the scaling calculations for you.
- @beginWxPythonOnly
- This method returns the output-only parameters as a tuple.
- @endWxPythonOnly
+ @beginWxPerlOnly
+ In wxPerl this method takes no arguments and returns a
+ 2-element list (w, h).
+ @endWxPerlOnly
*/
- void GetPPIPrinter(int* w, int* h);
+ void GetPPIPrinter(int* w, int* h) const;
/**
Returns the number of pixels per logical inch of the screen device context.
If you are doing your own scaling, remember to multiply this by a scaling
factor to take the preview DC size into account.
- @beginWxPythonOnly
- This method returns the output-only parameters as a tuple.
- @endWxPythonOnly
+ @beginWxPerlOnly
+ In wxPerl this method takes no arguments and returns a
+ 2-element list (w, h).
+ @endWxPerlOnly
*/
- void GetPPIScreen(int* w, int* h);
+ void GetPPIScreen(int* w, int* h) const;
/**
Called by the framework to obtain information from the application about minimum
@a minPage must be greater than zero and @a maxPage must be greater
than @a minPage.
-
- @beginWxPythonOnly
- When this method is implemented in a derived Python class, it should be designed
- to take no parameters (other than the self reference) and to return a tuple of
- four integers.
- @endWxPythonOnly
*/
- void GetPageInfo(int* minPage, int* maxPage, int* pageFrom,
- int* pageTo);
+ virtual void GetPageInfo(int* minPage, int* maxPage, int* pageFrom,
+ int* pageTo);
/**
Returns the size of the printer page in millimetres.
- @beginWxPythonOnly
- This method returns the output-only parameters as a tuple.
- @endWxPythonOnly
+ @beginWxPerlOnly
+ In wxPerl this method takes no arguments and returns a
+ 2-element list (w, h).
+ @endWxPerlOnly
*/
- void GetPageSizeMM(int* w, int* h);
+ void GetPageSizeMM(int* w, int* h) const;
/**
Returns the size of the printer page in pixels, called the page rectangle.
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.
-
- @beginWxPythonOnly
- This method returns the output-only parameters as a tuple.
- @endWxPythonOnly
*/
- void GetPageSizePixels(int* w, int* h);
+ void GetPageSizePixels(int* w, int* h) const;
/**
Returns the rectangle that corresponds to the entire paper in pixels, called the
area were printable, so this function will return the same rectangle as the page
rectangle.
*/
- wxRect GetPaperRectPixels();
+ wxRect GetPaperRectPixels() const;
/**
Returns the title of the printout.
@todo the python note here was wrong
*/
- wxString GetTitle();
+ virtual wxString GetTitle() const;
/**
Should be overridden to return @true if the document has this page, or @false
Returning @false signifies the end of the document. By default,
HasPage behaves as if the document has only one page.
*/
- bool HasPage(int pageNum);
+ virtual bool HasPage(int pageNum);
/**
Returns @true if the printout is currently being used for previewing.
+
+ @see GetPreview()
*/
- bool IsPreview();
+ virtual bool IsPreview() const;
+
+ /**
+ 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;
/**
Set the user scale and device origin of the wxDC associated with this wxPrintout
void MapScreenSizeToDevice();
/**
- This sets the user scale of the wxDC assocated with this wxPrintout to the same
+ This sets the user scale of the wxDC associated with this wxPrintout to the same
scale as MapScreenSizeToPaper() but sets the logical origin to the top left corner
of the page rectangle.
*/
void MapScreenSizeToPage();
/**
- This sets the user scale of the wxDC assocated with this wxPrintout to the same
+ This sets the user scale of the wxDC associated with this wxPrintout to the same
scale as MapScreenSizeToPageMargins() but sets the logical origin to the top left
corner of the page margins specified by the given wxPageSetupDialogData object.
*/
(It will, of course, be larger or smaller in the preview image, depending on the
zoom factor.)
- Use this if you want WYSIWYG behavior, e.g., in a text editor.
+ Use this if you want WYSIWYG behaviour, e.g., in a text editor.
*/
void MapScreenSizeToPaper();
@remarks
The base OnBeginDocument() must be called (and the return value
checked) from within the overridden function, since it calls wxDC::StartDoc().
-
- @beginWxPythonOnly
- If this method is overridden in a Python class then the base class version can
- be called by using the method <tt>base_OnBeginDocument(startPage, endPage)</tt>.
- @endWxPythonOnly
*/
- bool OnBeginDocument(int startPage, int endPage);
+ virtual bool OnBeginDocument(int startPage, int endPage);
/**
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).
*/
- void OnBeginPrinting();
+ virtual void OnBeginPrinting();
/**
Called by the framework at the end of document printing.
The base OnEndDocument() must be called from within the overridden function,
since it calls wxDC::EndDoc().
*/
- void OnEndDocument();
+ virtual void OnEndDocument();
/**
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).
*/
- void OnEndPrinting();
+ virtual void OnEndPrinting();
/**
Called once by the framework before any other demands are made of the
This gives the object an opportunity to calculate the number of pages
in the document, for example.
*/
- void OnPreparePrinting();
+ virtual void OnPreparePrinting();
/**
Called by the framework when a page should be printed. Returning @false cancels
the print job.
*/
- bool OnPrintPage(int pageNum);
+ virtual bool OnPrintPage(int pageNum) = 0;
/**
Set the device origin of the associated wxDC so that the current logical point
void SetLogicalOrigin(wxCoord x, wxCoord y);
};
+
+/**
+ @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,
+ const wxString& name = "dialog");
+
+ void SetProgress(int currentPage, int totalPages,
+ int currentCopy, int totalCopies);
+};