1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-10-30 11:56:12 +00:00
|
|
|
// Name: wx/prntbase.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose: Base classes for printing framework
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
2003-03-17 10:34:04 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_PRNTBASEH__
|
|
|
|
#define _WX_PRNTBASEH__
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
#include "wx/defs.h"
|
1999-06-13 22:54:04 +00:00
|
|
|
|
|
|
|
#if wxUSE_PRINTING_ARCHITECTURE
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#include "wx/event.h"
|
|
|
|
#include "wx/cmndata.h"
|
|
|
|
#include "wx/panel.h"
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/dialog.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#include "wx/frame.h"
|
2007-11-30 13:48:22 +00:00
|
|
|
#include "wx/dc.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDC;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxButton;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxChoice;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintout;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrinterBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintDialogBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintDialog;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPageSetupDialogBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPageSetupDialog;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintPreviewBase;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPreviewCanvas;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPreviewControlBar;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPreviewFrame;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintFactory;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
|
2010-05-05 12:19:59 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintPreview;
|
2012-08-09 15:52:08 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog;
|
2012-08-09 15:52:15 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxStaticText;
|
2011-04-23 10:49:48 +00:00
|
|
|
class wxPrintPageMaxCtrl;
|
2011-01-03 15:57:21 +00:00
|
|
|
class wxPrintPageTextCtrl;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// error consts
|
|
|
|
//----------------------------------------------------------------------------
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
enum wxPrinterError
|
|
|
|
{
|
|
|
|
wxPRINTER_NO_ERROR = 0,
|
|
|
|
wxPRINTER_CANCELLED,
|
|
|
|
wxPRINTER_ERROR
|
|
|
|
};
|
|
|
|
|
2011-04-26 22:57:27 +00:00
|
|
|
// Preview frame modality kind used with wxPreviewFrame::Initialize()
|
|
|
|
enum wxPreviewFrameModalityKind
|
|
|
|
{
|
|
|
|
// Disable all the other top level windows while the preview is shown.
|
|
|
|
wxPreviewFrame_AppModal,
|
|
|
|
|
|
|
|
// Disable only the parent window while the preview is shown.
|
|
|
|
wxPreviewFrame_WindowModal,
|
|
|
|
|
|
|
|
// Don't disable any windows.
|
|
|
|
wxPreviewFrame_NonModal
|
|
|
|
};
|
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintFactory
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintFactory
|
2004-10-12 21:07:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPrintFactory() {}
|
|
|
|
virtual ~wxPrintFactory() {}
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual wxPrinterBase *CreatePrinter( wxPrintDialogData* data ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
|
|
|
virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
|
|
|
|
wxPrintout *printout = NULL,
|
2004-10-12 21:07:42 +00:00
|
|
|
wxPrintDialogData *data = NULL ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
|
|
|
|
wxPrintout *printout,
|
2004-10-12 21:07:42 +00:00
|
|
|
wxPrintData *data ) = 0;
|
2004-10-16 22:11:48 +00:00
|
|
|
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
|
2004-10-16 22:11:48 +00:00
|
|
|
wxPrintDialogData *data = NULL ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
|
2004-10-16 22:11:48 +00:00
|
|
|
wxPrintData *data ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-11-20 14:46:25 +00:00
|
|
|
virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
|
|
|
|
wxPageSetupDialogData * data = NULL ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2007-11-30 13:48:22 +00:00
|
|
|
virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) = 0;
|
2006-10-24 15:41:39 +00:00
|
|
|
|
2004-10-26 19:49:59 +00:00
|
|
|
// What to do and what to show in the wxPrintDialog
|
|
|
|
// a) Use the generic print setup dialog or a native one?
|
|
|
|
virtual bool HasPrintSetupDialog() = 0;
|
|
|
|
virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) = 0;
|
|
|
|
// b) Provide the "print to file" option ourselves or via print setup?
|
|
|
|
virtual bool HasOwnPrintToFile() = 0;
|
|
|
|
// c) Show current printer
|
|
|
|
virtual bool HasPrinterLine() = 0;
|
|
|
|
virtual wxString CreatePrinterLine() = 0;
|
|
|
|
// d) Show Status line for current printer?
|
|
|
|
virtual bool HasStatusLine() = 0;
|
|
|
|
virtual wxString CreateStatusLine() = 0;
|
|
|
|
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-17 17:25:40 +00:00
|
|
|
virtual wxPrintNativeDataBase *CreatePrintNativeData() = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
static void SetPrintFactory( wxPrintFactory *factory );
|
|
|
|
static wxPrintFactory *GetFactory();
|
2005-09-25 14:22:16 +00:00
|
|
|
private:
|
2004-10-12 21:07:42 +00:00
|
|
|
static wxPrintFactory *m_factory;
|
|
|
|
};
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxNativePrintFactory: public wxPrintFactory
|
2004-10-12 21:07:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
|
|
|
virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
|
|
|
|
wxPrintout *printout = NULL,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPrintDialogData *data = NULL ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
|
2004-10-12 21:07:42 +00:00
|
|
|
wxPrintout *printout,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPrintData *data ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
|
|
|
virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPrintDialogData *data = NULL ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPrintData *data ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-11-20 14:46:25 +00:00
|
|
|
virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxPageSetupDialogData * data = NULL ) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) wxOVERRIDE;
|
2006-10-24 15:41:39 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HasPrintSetupDialog() wxOVERRIDE;
|
|
|
|
virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) wxOVERRIDE;
|
|
|
|
virtual bool HasOwnPrintToFile() wxOVERRIDE;
|
|
|
|
virtual bool HasPrinterLine() wxOVERRIDE;
|
|
|
|
virtual wxString CreatePrinterLine() wxOVERRIDE;
|
|
|
|
virtual bool HasStatusLine() wxOVERRIDE;
|
|
|
|
virtual wxString CreateStatusLine() wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPrintNativeDataBase *CreatePrintNativeData() wxOVERRIDE;
|
2004-10-17 17:25:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintNativeDataBase
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintNativeDataBase: public wxObject
|
2004-10-17 17:25:40 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPrintNativeDataBase();
|
|
|
|
virtual ~wxPrintNativeDataBase() {}
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-17 23:00:41 +00:00
|
|
|
virtual bool TransferTo( wxPrintData &data ) = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
virtual bool TransferFrom( const wxPrintData &data ) = 0;
|
|
|
|
|
2006-10-08 21:56:55 +00:00
|
|
|
virtual bool Ok() const { return IsOk(); }
|
|
|
|
virtual bool IsOk() const = 0;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-17 17:25:40 +00:00
|
|
|
int m_ref;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-17 17:25:40 +00:00
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxPrintNativeDataBase)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrintNativeDataBase);
|
2004-10-12 21:07:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrinterBase
|
|
|
|
//----------------------------------------------------------------------------
|
2000-07-15 19:51:35 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* Represents the printer: manages printing a wxPrintout object
|
|
|
|
*/
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrinterBase: public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
2009-01-19 13:55:27 +00:00
|
|
|
wxPrinterBase(wxPrintDialogData *data = NULL);
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual ~wxPrinterBase();
|
|
|
|
|
2012-08-09 15:52:08 +00:00
|
|
|
virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
|
2001-06-03 02:58:56 +00:00
|
|
|
virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-10-16 22:11:48 +00:00
|
|
|
virtual wxPrintDialogData& GetPrintDialogData() const;
|
1999-03-29 20:49:05 +00:00
|
|
|
bool GetAbort() const { return sm_abortIt; }
|
2004-09-20 11:31:49 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
static wxPrinterError GetLastError() { return sm_lastError; }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// OVERRIDES
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual bool Setup(wxWindow *parent) = 0;
|
2004-09-20 11:31:49 +00:00
|
|
|
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) = 0;
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual wxDC* PrintDialog(wxWindow *parent) = 0;
|
1998-08-28 11:00:50 +00:00
|
|
|
|
|
|
|
protected:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintDialogData m_printDialogData;
|
|
|
|
wxPrintout* m_currentPrintout;
|
2004-09-20 11:31:49 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
static wxPrinterError sm_lastError;
|
2004-09-20 11:31:49 +00:00
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
static wxWindow* sm_abortWindow;
|
|
|
|
static bool sm_abortIt;
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxPrinterBase)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrinterBase);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrinter
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrinter: public wxPrinterBase
|
2004-10-12 21:07:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-01-19 13:55:27 +00:00
|
|
|
wxPrinter(wxPrintDialogData *data = NULL);
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual ~wxPrinter();
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout) wxOVERRIDE;
|
|
|
|
virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message) wxOVERRIDE;
|
2004-10-12 21:07:42 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool Setup(wxWindow *parent) wxOVERRIDE;
|
|
|
|
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) wxOVERRIDE;
|
|
|
|
virtual wxDC* PrintDialog(wxWindow *parent) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPrintDialogData& GetPrintDialogData() const wxOVERRIDE;
|
2004-10-12 21:07:42 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
wxPrinterBase *m_pimpl;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxPrinter)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrinter);
|
2004-10-12 21:07:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintout
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* Represents an object via which a document may be printed.
|
|
|
|
* The programmer derives from this, overrides (at least) OnPrintPage,
|
|
|
|
* and passes it to a wxPrinter object for printing, or a wxPrintPreview
|
|
|
|
* object for previewing.
|
|
|
|
*/
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintout: public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
2013-09-15 00:15:02 +00:00
|
|
|
wxPrintout(const wxString& title = wxGetTranslation("Printout"));
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual ~wxPrintout();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual bool OnBeginDocument(int startPage, int endPage);
|
|
|
|
virtual void OnEndDocument();
|
|
|
|
virtual void OnBeginPrinting();
|
|
|
|
virtual void OnEndPrinting();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// Guaranteed to be before any other functions are called
|
|
|
|
virtual void OnPreparePrinting() { }
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual bool HasPage(int page);
|
|
|
|
virtual bool OnPrintPage(int page) = 0;
|
|
|
|
virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual wxString GetTitle() const { return m_printoutTitle; }
|
1998-08-28 11:00:50 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
wxDC *GetDC() const { return m_printoutDC; }
|
|
|
|
void SetDC(wxDC *dc) { m_printoutDC = dc; }
|
2006-10-27 13:07:40 +00:00
|
|
|
|
|
|
|
void FitThisSizeToPaper(const wxSize& imageSize);
|
|
|
|
void FitThisSizeToPage(const wxSize& imageSize);
|
|
|
|
void FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageSetupDialogData& pageSetupData);
|
|
|
|
void MapScreenSizeToPaper();
|
|
|
|
void MapScreenSizeToPage();
|
|
|
|
void MapScreenSizeToPageMargins(const wxPageSetupDialogData& pageSetupData);
|
|
|
|
void MapScreenSizeToDevice();
|
|
|
|
|
|
|
|
wxRect GetLogicalPaperRect() const;
|
|
|
|
wxRect GetLogicalPageRect() const;
|
|
|
|
wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
|
|
|
|
|
|
|
|
void SetLogicalOrigin(wxCoord x, wxCoord y);
|
|
|
|
void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; }
|
|
|
|
void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; }
|
|
|
|
void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; }
|
|
|
|
void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
|
1998-08-28 11:00:50 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
|
2008-09-21 09:35:49 +00:00
|
|
|
void SetPPIScreen(const wxSize& ppi) { SetPPIScreen(ppi.x, ppi.y); }
|
1999-03-29 20:49:05 +00:00
|
|
|
void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
|
|
|
|
void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
|
2008-09-21 09:35:49 +00:00
|
|
|
void SetPPIPrinter(const wxSize& ppi) { SetPPIPrinter(ppi.x, ppi.y); }
|
1999-03-29 20:49:05 +00:00
|
|
|
void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; }
|
|
|
|
wxRect GetPaperRectPixels() const { return m_paperRectPixels; }
|
|
|
|
|
2010-05-05 12:19:59 +00:00
|
|
|
// This must be called by wxPrintPreview to associate itself with the
|
|
|
|
// printout it uses.
|
|
|
|
virtual void SetPreview(wxPrintPreview *preview) { m_preview = preview; }
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2010-05-05 12:19:59 +00:00
|
|
|
wxPrintPreview *GetPreview() const { return m_preview; }
|
|
|
|
virtual bool IsPreview() const { return GetPreview() != NULL; }
|
1998-08-28 11:00:50 +00:00
|
|
|
|
|
|
|
private:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxString m_printoutTitle;
|
|
|
|
wxDC* m_printoutDC;
|
2010-05-05 12:19:59 +00:00
|
|
|
wxPrintPreview *m_preview;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
int m_pageWidthPixels;
|
|
|
|
int m_pageHeightPixels;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
int m_pageWidthMM;
|
|
|
|
int m_pageHeightMM;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
int m_PPIScreenX;
|
|
|
|
int m_PPIScreenY;
|
|
|
|
int m_PPIPrinterX;
|
|
|
|
int m_PPIPrinterY;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
wxRect m_paperRectPixels;
|
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
private:
|
|
|
|
DECLARE_ABSTRACT_CLASS(wxPrintout)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrintout);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPreviewCanvas
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* Canvas upon which a preview is drawn.
|
|
|
|
*/
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPreviewCanvas: public wxScrolledWindow
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPreviewCanvas(wxPrintPreviewBase *preview,
|
|
|
|
wxWindow *parent,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
2002-12-04 14:11:26 +00:00
|
|
|
const wxString& name = wxT("canvas"));
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxPreviewCanvas();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2008-06-11 20:56:41 +00:00
|
|
|
void SetPreview(wxPrintPreviewBase *preview) { m_printPreview = preview; }
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
void OnPaint(wxPaintEvent& event);
|
2003-07-23 20:30:19 +00:00
|
|
|
void OnChar(wxKeyEvent &event);
|
1999-03-29 20:49:05 +00:00
|
|
|
// Responds to colour changes
|
|
|
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
private:
|
2005-07-28 22:20:06 +00:00
|
|
|
#if wxUSE_MOUSEWHEEL
|
|
|
|
void OnMouseWheel(wxMouseEvent& event);
|
|
|
|
#endif // wxUSE_MOUSEWHEEL
|
2008-06-11 20:56:41 +00:00
|
|
|
void OnIdle(wxIdleEvent& event);
|
2005-07-28 22:20:06 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintPreviewBase* m_printPreview;
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
DECLARE_CLASS(wxPreviewCanvas)
|
1999-03-29 20:49:05 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPreviewCanvas);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPreviewFrame
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* Default frame for showing preview.
|
|
|
|
*/
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPreviewFrame: public wxFrame
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPreviewFrame(wxPrintPreviewBase *preview,
|
2003-05-26 09:55:28 +00:00
|
|
|
wxWindow *parent,
|
2013-09-15 00:15:02 +00:00
|
|
|
const wxString& title = wxGetTranslation("Print Preview"),
|
1999-03-29 20:49:05 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-01-16 18:49:04 +00:00
|
|
|
long style = wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT,
|
2008-11-08 15:01:00 +00:00
|
|
|
const wxString& name = wxFrameNameStr);
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxPreviewFrame();
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2011-06-22 22:58:07 +00:00
|
|
|
// Either Initialize() or InitializeWithModality() must be called before
|
|
|
|
// showing the preview frame, the former being just a particular case of
|
|
|
|
// the latter initializing the frame for being showing app-modally.
|
|
|
|
|
|
|
|
// Notice that we must keep Initialize() with its existing signature to
|
|
|
|
// avoid breaking the old code that overrides it and we can't reuse the
|
|
|
|
// same name for the other functions to avoid virtual function hiding
|
|
|
|
// problem and the associated warnings given by some compilers (e.g. from
|
|
|
|
// g++ with -Woverloaded-virtual).
|
|
|
|
virtual void Initialize()
|
|
|
|
{
|
|
|
|
InitializeWithModality(wxPreviewFrame_AppModal);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also note that this method is not virtual as it doesn't need to be
|
|
|
|
// overridden: it's never called by wxWidgets (of course, the same is true
|
|
|
|
// for Initialize() but, again, it must remain virtual for compatibility).
|
|
|
|
void InitializeWithModality(wxPreviewFrameModalityKind kind);
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
virtual void CreateCanvas();
|
|
|
|
virtual void CreateControlBar();
|
2003-07-23 20:30:19 +00:00
|
|
|
|
|
|
|
inline wxPreviewControlBar* GetControlBar() const { return m_controlBar; }
|
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
protected:
|
2003-07-23 20:30:19 +00:00
|
|
|
wxPreviewCanvas* m_previewCanvas;
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPreviewControlBar* m_controlBar;
|
|
|
|
wxPrintPreviewBase* m_printPreview;
|
2004-07-25 17:09:30 +00:00
|
|
|
wxWindowDisabler* m_windowDisabler;
|
1999-02-05 23:55:04 +00:00
|
|
|
|
2011-04-26 22:57:27 +00:00
|
|
|
wxPreviewFrameModalityKind m_modalityKind;
|
|
|
|
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
private:
|
2007-09-20 23:11:22 +00:00
|
|
|
void OnChar(wxKeyEvent& event);
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-09-20 23:11:22 +00:00
|
|
|
DECLARE_CLASS(wxPreviewFrame)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPreviewFrame);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPreviewControlBar
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* A panel with buttons for controlling a print preview.
|
|
|
|
* The programmer may wish to use other means for controlling
|
|
|
|
* the print preview.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define wxPREVIEW_PRINT 1
|
|
|
|
#define wxPREVIEW_PREVIOUS 2
|
|
|
|
#define wxPREVIEW_NEXT 4
|
|
|
|
#define wxPREVIEW_ZOOM 8
|
2002-08-16 16:18:28 +00:00
|
|
|
#define wxPREVIEW_FIRST 16
|
|
|
|
#define wxPREVIEW_LAST 32
|
|
|
|
#define wxPREVIEW_GOTO 64
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2005-06-13 12:19:33 +00:00
|
|
|
#define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
|
|
|
|
|wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
// 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
|
2002-08-16 16:18:28 +00:00
|
|
|
#define wxID_PREVIEW_FIRST 6
|
|
|
|
#define wxID_PREVIEW_LAST 7
|
|
|
|
#define wxID_PREVIEW_GOTO 8
|
2011-01-03 15:57:21 +00:00
|
|
|
#define wxID_PREVIEW_ZOOM_IN 9
|
|
|
|
#define wxID_PREVIEW_ZOOM_OUT 10
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPreviewControlBar: public wxPanel
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1999-03-29 20:49:05 +00:00
|
|
|
DECLARE_CLASS(wxPreviewControlBar)
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPreviewControlBar(wxPrintPreviewBase *preview,
|
|
|
|
long buttons,
|
|
|
|
wxWindow *parent,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2003-07-23 20:30:19 +00:00
|
|
|
long style = wxTAB_TRAVERSAL,
|
2002-12-04 14:11:26 +00:00
|
|
|
const wxString& name = wxT("panel"));
|
2006-09-05 20:47:48 +00:00
|
|
|
virtual ~wxPreviewControlBar();
|
1999-03-29 20:49:05 +00:00
|
|
|
|
|
|
|
virtual void CreateButtons();
|
2011-04-23 10:49:48 +00:00
|
|
|
virtual void SetPageInfo(int minPage, int maxPage);
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual void SetZoomControl(int zoom);
|
|
|
|
virtual int GetZoomControl();
|
|
|
|
virtual wxPrintPreviewBase *GetPrintPreview() const
|
|
|
|
{ return m_printPreview; }
|
|
|
|
|
2011-01-03 15:57:21 +00:00
|
|
|
|
|
|
|
// Implementation only from now on.
|
1999-03-29 20:49:05 +00:00
|
|
|
void OnWindowClose(wxCommandEvent& event);
|
1999-06-21 21:00:36 +00:00
|
|
|
void OnNext();
|
|
|
|
void OnPrevious();
|
2002-08-16 16:18:28 +00:00
|
|
|
void OnFirst();
|
|
|
|
void OnLast();
|
2011-01-03 15:57:21 +00:00
|
|
|
void OnGotoPage();
|
2003-07-24 10:07:43 +00:00
|
|
|
void OnPrint();
|
2011-01-03 15:57:21 +00:00
|
|
|
|
2003-07-24 20:06:02 +00:00
|
|
|
void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); }
|
1999-09-18 16:49:30 +00:00
|
|
|
void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); }
|
|
|
|
void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); }
|
2002-08-16 16:18:28 +00:00
|
|
|
void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); }
|
|
|
|
void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); }
|
1999-03-29 20:49:05 +00:00
|
|
|
void OnPaint(wxPaintEvent& event);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2011-01-03 15:57:21 +00:00
|
|
|
void OnUpdateNextButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsNextEnabled()); }
|
|
|
|
void OnUpdatePreviousButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsPreviousEnabled()); }
|
|
|
|
void OnUpdateFirstButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsFirstEnabled()); }
|
|
|
|
void OnUpdateLastButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsLastEnabled()); }
|
|
|
|
void OnUpdateZoomInButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsZoomInEnabled()); }
|
|
|
|
void OnUpdateZoomOutButton(wxUpdateUIEvent& event)
|
|
|
|
{ event.Enable(IsZoomOutEnabled()); }
|
|
|
|
|
|
|
|
// These methods are not private because they are called by wxPreviewCanvas.
|
|
|
|
void DoZoomIn();
|
|
|
|
void DoZoomOut();
|
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
protected:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintPreviewBase* m_printPreview;
|
|
|
|
wxButton* m_closeButton;
|
|
|
|
wxChoice* m_zoomControl;
|
2011-04-23 10:49:48 +00:00
|
|
|
wxPrintPageTextCtrl* m_currentPageText;
|
|
|
|
wxPrintPageMaxCtrl* m_maxPageText;
|
2011-01-03 15:57:21 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
long m_buttonFlags;
|
|
|
|
|
|
|
|
private:
|
2011-01-03 15:57:21 +00:00
|
|
|
void DoGotoPage(int page);
|
|
|
|
|
|
|
|
void DoZoom();
|
|
|
|
|
|
|
|
bool IsNextEnabled() const;
|
|
|
|
bool IsPreviousEnabled() const;
|
|
|
|
bool IsFirstEnabled() const;
|
|
|
|
bool IsLastEnabled() const;
|
|
|
|
bool IsZoomInEnabled() const;
|
|
|
|
bool IsZoomOutEnabled() const;
|
|
|
|
|
|
|
|
void OnZoomInButton(wxCommandEvent & WXUNUSED(event)) { DoZoomIn(); }
|
|
|
|
void OnZoomOutButton(wxCommandEvent & WXUNUSED(event)) { DoZoomOut(); }
|
|
|
|
void OnZoomChoice(wxCommandEvent& WXUNUSED(event)) { DoZoom(); }
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPreviewControlBar);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintPreviewBase
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
/*
|
|
|
|
* Programmer creates an object of this class to preview a wxPrintout.
|
|
|
|
*/
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintPreviewBase: public wxObject
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-08-28 11:00:50 +00:00
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintPreviewBase(wxPrintout *printout,
|
2009-01-19 13:55:27 +00:00
|
|
|
wxPrintout *printoutForPrinting = NULL,
|
|
|
|
wxPrintDialogData *data = NULL);
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintPreviewBase(wxPrintout *printout,
|
|
|
|
wxPrintout *printoutForPrinting,
|
|
|
|
wxPrintData *data);
|
|
|
|
virtual ~wxPrintPreviewBase();
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual bool SetCurrentPage(int pageNum);
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual int GetCurrentPage() const;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual void SetPrintout(wxPrintout *printout);
|
|
|
|
virtual wxPrintout *GetPrintout() const;
|
|
|
|
virtual wxPrintout *GetPrintoutForPrinting() const;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual void SetFrame(wxFrame *frame);
|
|
|
|
virtual void SetCanvas(wxPreviewCanvas *canvas);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual wxFrame *GetFrame() const;
|
|
|
|
virtual wxPreviewCanvas *GetCanvas() const;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2006-10-27 13:07:40 +00:00
|
|
|
// This is a helper routine, used by the next 4 routines.
|
|
|
|
|
|
|
|
virtual void CalcRects(wxPreviewCanvas *canvas, wxRect& printableAreaRect, wxRect& paperRect);
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// The preview canvas should call this from OnPaint
|
2003-07-23 20:30:19 +00:00
|
|
|
virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2008-06-11 20:56:41 +00:00
|
|
|
// Updates rendered page by calling RenderPage() if needed, returns true
|
|
|
|
// if there was some change. Preview canvas should call it at idle time
|
|
|
|
virtual bool UpdatePageRendering();
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// This draws a blank page onto the preview canvas
|
2003-07-23 20:30:19 +00:00
|
|
|
virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
|
|
|
|
|
|
|
|
// Adjusts the scrollbars for the current scale
|
|
|
|
virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// This is called by wxPrintPreview to render a page into a wxMemoryDC.
|
|
|
|
virtual bool RenderPage(int pageNum);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
virtual void SetZoom(int percent);
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual int GetZoom() const;
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual wxPrintDialogData& GetPrintDialogData();
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual int GetMaxPage() const;
|
|
|
|
virtual int GetMinPage() const;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2006-10-08 21:56:55 +00:00
|
|
|
virtual bool Ok() const { return IsOk(); }
|
|
|
|
virtual bool IsOk() const;
|
2004-10-12 21:07:42 +00:00
|
|
|
virtual void SetOk(bool ok);
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// OVERRIDES
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// If we own a wxPrintout that can be used for printing, this
|
|
|
|
// will invoke the actual printing procedure. Called
|
|
|
|
// by the wxPreviewControlBar.
|
|
|
|
virtual bool Print(bool interactive) = 0;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
// Calculate scaling that needs to be done to get roughly
|
|
|
|
// the right scaling for the screen pretending to be
|
|
|
|
// the currently selected printer.
|
|
|
|
virtual void DetermineScaling() = 0;
|
1998-08-28 11:00:50 +00:00
|
|
|
|
2008-06-16 07:43:59 +00:00
|
|
|
protected:
|
2008-06-16 08:41:51 +00:00
|
|
|
// helpers for RenderPage():
|
|
|
|
virtual bool RenderPageIntoDC(wxDC& dc, int pageNum);
|
|
|
|
// renders preview into m_previewBitmap
|
|
|
|
virtual bool RenderPageIntoBitmap(wxBitmap& bmp, int pageNum);
|
|
|
|
|
2008-06-16 07:43:59 +00:00
|
|
|
void InvalidatePreviewBitmap();
|
|
|
|
|
1998-08-28 11:00:50 +00:00
|
|
|
protected:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintDialogData m_printDialogData;
|
2003-07-23 20:30:19 +00:00
|
|
|
wxPreviewCanvas* m_previewCanvas;
|
1999-03-29 20:49:05 +00:00
|
|
|
wxFrame* m_previewFrame;
|
|
|
|
wxBitmap* m_previewBitmap;
|
2008-06-16 07:43:59 +00:00
|
|
|
bool m_previewFailed;
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintout* m_previewPrintout;
|
|
|
|
wxPrintout* m_printPrintout;
|
|
|
|
int m_currentPage;
|
|
|
|
int m_currentZoom;
|
2006-10-27 13:07:40 +00:00
|
|
|
float m_previewScaleX;
|
|
|
|
float m_previewScaleY;
|
1999-03-29 20:49:05 +00:00
|
|
|
int m_topMargin;
|
|
|
|
int m_leftMargin;
|
|
|
|
int m_pageWidth;
|
|
|
|
int m_pageHeight;
|
|
|
|
int m_minPage;
|
|
|
|
int m_maxPage;
|
|
|
|
|
|
|
|
bool m_isOk;
|
1999-09-05 15:14:50 +00:00
|
|
|
bool m_printingPrepared; // Called OnPreparePrinting?
|
1999-03-29 20:49:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
|
2003-01-02 23:38:11 +00:00
|
|
|
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrintPreviewBase);
|
2004-10-12 21:07:42 +00:00
|
|
|
DECLARE_CLASS(wxPrintPreviewBase)
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintPreview
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintPreview: public wxPrintPreviewBase
|
2004-10-12 21:07:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPrintPreview(wxPrintout *printout,
|
2009-01-19 13:55:27 +00:00
|
|
|
wxPrintout *printoutForPrinting = NULL,
|
|
|
|
wxPrintDialogData *data = NULL);
|
2004-10-12 21:07:42 +00:00
|
|
|
wxPrintPreview(wxPrintout *printout,
|
|
|
|
wxPrintout *printoutForPrinting,
|
|
|
|
wxPrintData *data);
|
|
|
|
virtual ~wxPrintPreview();
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool SetCurrentPage(int pageNum) wxOVERRIDE;
|
|
|
|
virtual int GetCurrentPage() const wxOVERRIDE;
|
|
|
|
virtual void SetPrintout(wxPrintout *printout) wxOVERRIDE;
|
|
|
|
virtual wxPrintout *GetPrintout() const wxOVERRIDE;
|
|
|
|
virtual wxPrintout *GetPrintoutForPrinting() const wxOVERRIDE;
|
|
|
|
virtual void SetFrame(wxFrame *frame) wxOVERRIDE;
|
|
|
|
virtual void SetCanvas(wxPreviewCanvas *canvas) wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual wxFrame *GetFrame() const wxOVERRIDE;
|
|
|
|
virtual wxPreviewCanvas *GetCanvas() const wxOVERRIDE;
|
|
|
|
virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc) wxOVERRIDE;
|
|
|
|
virtual bool UpdatePageRendering() wxOVERRIDE;
|
|
|
|
virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc) wxOVERRIDE;
|
|
|
|
virtual void AdjustScrollbars(wxPreviewCanvas *canvas) wxOVERRIDE;
|
|
|
|
virtual bool RenderPage(int pageNum) wxOVERRIDE;
|
|
|
|
virtual void SetZoom(int percent) wxOVERRIDE;
|
|
|
|
virtual int GetZoom() const wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual bool Print(bool interactive) wxOVERRIDE;
|
|
|
|
virtual void DetermineScaling() wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual wxPrintDialogData& GetPrintDialogData() wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual int GetMaxPage() const wxOVERRIDE;
|
|
|
|
virtual int GetMinPage() const wxOVERRIDE;
|
|
|
|
|
|
|
|
virtual bool Ok() const wxOVERRIDE { return IsOk(); }
|
|
|
|
virtual bool IsOk() const wxOVERRIDE;
|
|
|
|
virtual void SetOk(bool ok) wxOVERRIDE;
|
2005-06-13 12:19:33 +00:00
|
|
|
|
2004-10-12 21:07:42 +00:00
|
|
|
private:
|
|
|
|
wxPrintPreviewBase *m_pimpl;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxPrintPreview)
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrintPreview);
|
2004-10-12 21:07:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// wxPrintAbortDialog
|
|
|
|
//----------------------------------------------------------------------------
|
1998-05-20 14:01:55 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxPrintAbortDialog: public wxDialog
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
|
|
|
public:
|
1999-03-29 20:49:05 +00:00
|
|
|
wxPrintAbortDialog(wxWindow *parent,
|
2012-08-09 15:52:04 +00:00
|
|
|
const wxString& documentTitle,
|
1999-03-29 20:49:05 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2012-08-09 15:52:04 +00:00
|
|
|
long style = wxDEFAULT_DIALOG_STYLE,
|
|
|
|
const wxString& name = wxT("dialog"));
|
1999-03-29 20:49:05 +00:00
|
|
|
|
2012-08-09 15:52:15 +00:00
|
|
|
void SetProgress(int currentPage, int totalPages,
|
|
|
|
int currentCopy, int totalCopies);
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
void OnCancel(wxCommandEvent& event);
|
1998-08-28 11:00:50 +00:00
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
private:
|
2012-08-09 15:52:15 +00:00
|
|
|
wxStaticText *m_progress;
|
|
|
|
|
1999-03-29 20:49:05 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
1999-06-13 22:54:04 +00:00
|
|
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_PRNTBASEH__
|