X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fadc2df6823d988f7a264b94e69a7e1bbcac1337..7344108e8a129a3f9b4df5ab0f98a1713db03b89:/interface/wx/print.h diff --git a/interface/wx/print.h b/interface/wx/print.h index b6f61dba8b..b0f5a70c52 100644 --- a/interface/wx/print.h +++ b/interface/wx/print.h @@ -3,9 +3,40 @@ // 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 @@ -117,7 +148,33 @@ public: 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 @@ -145,7 +202,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = "frame"); + const wxString& name = wxFrameNameStr); /** Destructor. @@ -169,15 +226,47 @@ public: virtual void CreateControlBar(); /** - 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. - This function should be called by the application prior to showing the frame. - */ + 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(); /** - Enables the other frames in the application, and deletes the print preview + 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. + + @param kind + The modality kind of preview frame. + + @since 2.9.2 + */ + virtual void InitializeWithModality(wxPreviewFrameModalityKind kind); + + /** + Enables any disabled frames in the application, and deletes the print preview object, implicitly deleting any printout objects associated with the print preview object. */ @@ -224,15 +313,18 @@ public: 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. @@ -240,7 +332,7 @@ public: 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. @@ -295,7 +387,7 @@ public: 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 @@ -321,7 +413,7 @@ public: /** 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 @@ -373,7 +465,7 @@ public: /** Creates the default printing abort window, with a cancel button. */ - void CreateAbortWindow(wxWindow* parent, wxPrintout* printout); + virtual wxWindow* CreateAbortWindow(wxWindow* parent, wxPrintout* printout); /** Returns @true if the user has aborted the print job. @@ -583,9 +675,10 @@ public: 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) const; @@ -598,9 +691,10 @@ public: 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) const; @@ -614,12 +708,6 @@ public: @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 */ virtual void GetPageInfo(int* minPage, int* maxPage, int* pageFrom, int* pageTo); @@ -627,9 +715,10 @@ public: /** 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) const; @@ -642,10 +731,6 @@ public: 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) const; @@ -688,9 +773,26 @@ public: /** Returns @true if the printout is currently being used for previewing. + + @see GetPreview() */ 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 so that one screen pixel maps to one device pixel on the DC. @@ -710,14 +812,14 @@ public: 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. */ @@ -733,7 +835,7 @@ public: (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(); @@ -751,11 +853,6 @@ public: @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 base_OnBeginDocument(startPage, endPage). - @endWxPythonOnly */ virtual bool OnBeginDocument(int startPage, int endPage);