more backwards compatibility for printing
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_PRINTDLG_H_
|
#ifndef _WX_PRINTDLG_H_
|
||||||
@@ -19,51 +19,53 @@
|
|||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/cmndata.h"
|
#include "wx/cmndata.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* wxPrinterDialog
|
|
||||||
* The common dialog for printing.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxDC;
|
class WXDLLEXPORT wxDC;
|
||||||
class WXDLLEXPORT wxPrintDialog: public wxDialog
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxPrinterDialog: the common dialog for printing.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxPrintDialog : public wxDialog
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxPrintDialog)
|
DECLARE_DYNAMIC_CLASS(wxPrintDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxPrintDialog(void);
|
wxPrintDialog();
|
||||||
wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
|
wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
|
||||||
~wxPrintDialog(void);
|
wxPrintDialog(wxWindow *parent, wxPrintData* data);
|
||||||
|
virtual ~wxPrintDialog();
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
|
bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
|
||||||
virtual int ShowModal(void);
|
virtual int ShowModal();
|
||||||
|
|
||||||
inline wxPrintDialogData& GetPrintDialogData(void) { return m_printDialogData; }
|
wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
|
||||||
inline wxPrintData& GetPrintData(void) { return m_printDialogData.GetPrintData(); }
|
wxPrintData& GetPrintData() { return m_printDialogData.GetPrintData(); }
|
||||||
virtual wxDC *GetPrintDC(void);
|
virtual wxDC *GetPrintDC();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxPrintDialogData m_printDialogData;
|
wxPrintDialogData m_printDialogData;
|
||||||
wxDC* m_printerDC;
|
wxDC* m_printerDC;
|
||||||
bool m_destroyDC;
|
bool m_destroyDC;
|
||||||
wxWindow* m_dialogParent;
|
wxWindow* m_dialogParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxPageSetupDialog: public wxDialog
|
class WXDLLEXPORT wxPageSetupDialog: public wxDialog
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
|
DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
|
||||||
|
|
||||||
private:
|
public:
|
||||||
wxPageSetupData m_pageSetupData;
|
wxPageSetupDialog();
|
||||||
wxWindow* m_dialogParent;
|
wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
|
||||||
public:
|
virtual ~wxPageSetupDialog();
|
||||||
wxPageSetupDialog(void);
|
|
||||||
wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
|
|
||||||
~wxPageSetupDialog(void);
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxPageSetupData *data = NULL);
|
bool Create(wxWindow *parent, wxPageSetupData *data = NULL);
|
||||||
virtual int ShowModal(void);
|
virtual int ShowModal();
|
||||||
|
|
||||||
inline wxPageSetupData& GetPageSetupData(void) { return m_pageSetupData; }
|
wxPageSetupData& GetPageSetupData() { return m_pageSetupData; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxPageSetupData m_pageSetupData;
|
||||||
|
wxWindow* m_dialogParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -6,54 +6,61 @@
|
|||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_PRINTWIN_H_
|
#ifndef _WX_PRINTWIN_H_
|
||||||
#define _WX_PRINTWIN_H_
|
#define _WX_PRINTWIN_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "printwin.h"
|
#pragma interface "printwin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/prntbase.h"
|
#include "wx/prntbase.h"
|
||||||
|
|
||||||
/*
|
// ---------------------------------------------------------------------------
|
||||||
* Represents the printer: manages printing a wxPrintout object
|
// Represents the printer: manages printing a wxPrintout object
|
||||||
*/
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxWindowsPrinter: public wxPrinterBase
|
class WXDLLEXPORT wxWindowsPrinter : public wxPrinterBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
|
DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxWindowsPrinter(wxPrintDialogData *data = NULL);
|
wxWindowsPrinter(wxPrintDialogData *data = NULL);
|
||||||
~wxWindowsPrinter(void);
|
virtual ~wxWindowsPrinter();
|
||||||
|
|
||||||
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
|
virtual bool Print(wxWindow *parent,
|
||||||
virtual wxDC* PrintDialog(wxWindow *parent);
|
wxPrintout *printout,
|
||||||
virtual bool Setup(wxWindow *parent);
|
bool prompt = TRUE);
|
||||||
|
virtual wxDC* PrintDialog(wxWindow *parent);
|
||||||
|
virtual bool Setup(wxWindow *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WXFARPROC m_lpAbortProc;
|
WXFARPROC m_lpAbortProc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
// ---------------------------------------------------------------------------
|
||||||
* wxPrintPreview
|
// wxPrintPreview: programmer creates an object of this class to preview a
|
||||||
* Programmer creates an object of this class to preview a wxPrintout.
|
// wxPrintout.
|
||||||
*/
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxWindowsPrintPreview: public wxPrintPreviewBase
|
class WXDLLEXPORT wxWindowsPrintPreview : public wxPrintPreviewBase
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(wxWindowsPrintPreview)
|
DECLARE_CLASS(wxWindowsPrintPreview)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintDialogData *data = NULL);
|
wxWindowsPrintPreview(wxPrintout *printout,
|
||||||
~wxWindowsPrintPreview(void);
|
wxPrintout *printoutForPrinting = NULL,
|
||||||
|
wxPrintDialogData *data = NULL);
|
||||||
|
wxWindowsPrintPreview(wxPrintout *printout,
|
||||||
|
wxPrintout *printoutForPrinting,
|
||||||
|
wxPrintData *data);
|
||||||
|
virtual ~wxWindowsPrintPreview();
|
||||||
|
|
||||||
virtual bool Print(bool interactive);
|
virtual bool Print(bool interactive);
|
||||||
virtual void DetermineScaling(void);
|
virtual void DetermineScaling();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_PRINTWIN_H_
|
// _WX_PRINTWIN_H_
|
||||||
|
@@ -6,21 +6,26 @@
|
|||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// declarations
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "printdlg.h"
|
#pragma implementation "printdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/printdlg.h"
|
#include "wx/printdlg.h"
|
||||||
@@ -28,7 +33,7 @@
|
|||||||
|
|
||||||
// Have to emulate page setup dialog for Win16
|
// Have to emulate page setup dialog for Win16
|
||||||
#if !defined(__WIN95__)
|
#if !defined(__WIN95__)
|
||||||
#include "wx/generic/prntdlgg.h"
|
#include "wx/generic/prntdlgg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -36,7 +41,7 @@
|
|||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <print.h>
|
#include <print.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Clash with Windows header files
|
// Clash with Windows header files
|
||||||
@@ -44,25 +49,44 @@
|
|||||||
#undef StartDoc
|
#undef StartDoc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
|
IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
|
||||||
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog(void):
|
// ===========================================================================
|
||||||
wxDialog()
|
// implementation
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxPrintDialog
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxPrintDialog::wxPrintDialog()
|
||||||
{
|
{
|
||||||
m_dialogParent = NULL;
|
m_dialogParent = NULL;
|
||||||
m_printerDC = NULL;
|
m_printerDC = NULL;
|
||||||
m_destroyDC = TRUE;
|
m_destroyDC = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data):
|
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
Create(p, data);
|
Create(p, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
|
||||||
|
{
|
||||||
|
wxPrintDialogData data2;
|
||||||
|
if ( data )
|
||||||
|
data2 = *data;
|
||||||
|
|
||||||
|
Create(p, &data2);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
|
bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
|
||||||
{
|
{
|
||||||
m_dialogParent = p;
|
m_dialogParent = p;
|
||||||
@@ -71,22 +95,22 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
|
|||||||
|
|
||||||
if ( data )
|
if ( data )
|
||||||
m_printDialogData = *data;
|
m_printDialogData = *data;
|
||||||
|
|
||||||
m_printDialogData.SetOwnerWindow(p);
|
m_printDialogData.SetOwnerWindow(p);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::~wxPrintDialog(void)
|
wxPrintDialog::~wxPrintDialog()
|
||||||
{
|
{
|
||||||
if (m_destroyDC && m_printerDC)
|
if (m_destroyDC && m_printerDC)
|
||||||
delete m_printerDC;
|
delete m_printerDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPrintDialog::ShowModal(void)
|
int wxPrintDialog::ShowModal()
|
||||||
{
|
{
|
||||||
m_printDialogData.ConvertToNative();
|
m_printDialogData.ConvertToNative();
|
||||||
|
|
||||||
bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
|
bool ret = (PrintDlg( (PRINTDLG *)m_printDialogData.GetNativeData() ) != 0);
|
||||||
if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
|
if ( ret != FALSE && ((PRINTDLG *)m_printDialogData.GetNativeData())->hDC)
|
||||||
{
|
{
|
||||||
@@ -97,17 +121,11 @@ int wxPrintDialog::ShowModal(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
char buf[256];
|
|
||||||
DWORD exError = CommDlgExtendedError();
|
|
||||||
sprintf(buf, "ret = %d, ex error = %d", (int) ret, (int) exError);
|
|
||||||
wxMessageBox(buf);
|
|
||||||
*/
|
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDC *wxPrintDialog::GetPrintDC(void)
|
wxDC *wxPrintDialog::GetPrintDC()
|
||||||
{
|
{
|
||||||
if (m_printerDC)
|
if (m_printerDC)
|
||||||
{
|
{
|
||||||
@@ -118,18 +136,16 @@ wxDC *wxPrintDialog::GetPrintDC(void)
|
|||||||
return (wxDC*) NULL;
|
return (wxDC*) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// ---------------------------------------------------------------------------
|
||||||
* wxPageSetupDialog
|
// wxPageSetupDialog
|
||||||
*/
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
wxPageSetupDialog::wxPageSetupDialog(void):
|
wxPageSetupDialog::wxPageSetupDialog()
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
m_dialogParent = NULL;
|
m_dialogParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
|
wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
Create(p, data);
|
Create(p, data);
|
||||||
}
|
}
|
||||||
@@ -137,21 +153,21 @@ wxDialog()
|
|||||||
bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
|
bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
|
||||||
{
|
{
|
||||||
m_dialogParent = p;
|
m_dialogParent = p;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
m_pageSetupData = (*data);
|
m_pageSetupData = (*data);
|
||||||
|
|
||||||
#if defined(__WIN95__)
|
#if defined(__WIN95__)
|
||||||
m_pageSetupData.SetOwnerWindow(p);
|
m_pageSetupData.SetOwnerWindow(p);
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPageSetupDialog::~wxPageSetupDialog(void)
|
wxPageSetupDialog::~wxPageSetupDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPageSetupDialog::ShowModal(void)
|
int wxPageSetupDialog::ShowModal()
|
||||||
{
|
{
|
||||||
#ifdef __WIN95__
|
#ifdef __WIN95__
|
||||||
m_pageSetupData.ConvertToNative();
|
m_pageSetupData.ConvertToNative();
|
||||||
|
@@ -6,27 +6,35 @@
|
|||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// declarations
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "printwin.h"
|
#pragma implementation "printwin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/msgdlg.h"
|
#include "wx/msgdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/printwin.h"
|
#include "wx/msw/printwin.h"
|
||||||
@@ -40,31 +48,43 @@
|
|||||||
|
|
||||||
// Clash with Windows header files
|
// Clash with Windows header files
|
||||||
#ifdef StartDoc
|
#ifdef StartDoc
|
||||||
#undef StartDoc
|
#undef StartDoc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
#include <print.h>
|
#include <print.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code);
|
LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowsPrinter, wxPrinterBase)
|
IMPLEMENT_DYNAMIC_CLASS(wxWindowsPrinter, wxPrinterBase)
|
||||||
IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
|
IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// ===========================================================================
|
||||||
* Printer
|
// implementation
|
||||||
*/
|
// ===========================================================================
|
||||||
|
|
||||||
wxWindowsPrinter::wxWindowsPrinter(wxPrintDialogData *data):
|
// ---------------------------------------------------------------------------
|
||||||
wxPrinterBase(data)
|
// Printer
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxWindowsPrinter::wxWindowsPrinter(wxPrintDialogData *data)
|
||||||
|
: wxPrinterBase(data)
|
||||||
{
|
{
|
||||||
m_lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
|
m_lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowsPrinter::~wxWindowsPrinter(void)
|
wxWindowsPrinter::~wxWindowsPrinter()
|
||||||
{
|
{
|
||||||
FreeProcInstance((FARPROC) m_lpAbortProc);
|
FreeProcInstance((FARPROC) m_lpAbortProc);
|
||||||
}
|
}
|
||||||
@@ -73,28 +93,28 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
{
|
{
|
||||||
sm_abortIt = FALSE;
|
sm_abortIt = FALSE;
|
||||||
sm_abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
|
|
||||||
if (!printout)
|
if (!printout)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
printout->SetIsPreview(FALSE);
|
printout->SetIsPreview(FALSE);
|
||||||
printout->OnPreparePrinting();
|
printout->OnPreparePrinting();
|
||||||
|
|
||||||
// Get some parameters from the printout, if defined
|
// Get some parameters from the printout, if defined
|
||||||
int fromPage, toPage;
|
int fromPage, toPage;
|
||||||
int minPage, maxPage;
|
int minPage, maxPage;
|
||||||
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
|
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
|
||||||
|
|
||||||
if (maxPage == 0)
|
if (maxPage == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
m_printDialogData.SetMinPage(minPage);
|
m_printDialogData.SetMinPage(minPage);
|
||||||
m_printDialogData.SetMaxPage(maxPage);
|
m_printDialogData.SetMaxPage(maxPage);
|
||||||
if (fromPage != 0)
|
if (fromPage != 0)
|
||||||
m_printDialogData.SetFromPage(fromPage);
|
m_printDialogData.SetFromPage(fromPage);
|
||||||
if (toPage != 0)
|
if (toPage != 0)
|
||||||
m_printDialogData.SetToPage(toPage);
|
m_printDialogData.SetToPage(toPage);
|
||||||
|
|
||||||
if (minPage != 0)
|
if (minPage != 0)
|
||||||
{
|
{
|
||||||
m_printDialogData.EnablePageNumbers(TRUE);
|
m_printDialogData.EnablePageNumbers(TRUE);
|
||||||
@@ -110,7 +130,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
else
|
else
|
||||||
m_printDialogData.EnablePageNumbers(FALSE);
|
m_printDialogData.EnablePageNumbers(FALSE);
|
||||||
|
|
||||||
// Create a suitable device context
|
// Create a suitable device context
|
||||||
wxDC *dc = NULL;
|
wxDC *dc = NULL;
|
||||||
if (prompt)
|
if (prompt)
|
||||||
{
|
{
|
||||||
@@ -123,24 +143,24 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
// dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
|
// dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
|
||||||
dc = new wxPrinterDC(m_printDialogData.GetPrintData());
|
dc = new wxPrinterDC(m_printDialogData.GetPrintData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// May have pressed cancel.
|
// May have pressed cancel.
|
||||||
if (!dc || !dc->Ok())
|
if (!dc || !dc->Ok())
|
||||||
{
|
{
|
||||||
if (dc) delete dc;
|
if (dc) delete dc;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logPPIScreenX = 0;
|
int logPPIScreenX = 0;
|
||||||
int logPPIScreenY = 0;
|
int logPPIScreenY = 0;
|
||||||
int logPPIPrinterX = 0;
|
int logPPIPrinterX = 0;
|
||||||
int logPPIPrinterY = 0;
|
int logPPIPrinterY = 0;
|
||||||
|
|
||||||
HDC hdc = ::GetDC(NULL);
|
HDC hdc = ::GetDC(NULL);
|
||||||
logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
|
logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
|
logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
|
||||||
::ReleaseDC(NULL, hdc);
|
::ReleaseDC(NULL, hdc);
|
||||||
|
|
||||||
logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
|
logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
|
||||||
logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
|
logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
|
||||||
if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
|
if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
|
||||||
@@ -148,33 +168,33 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
delete dc;
|
delete dc;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
||||||
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
||||||
|
|
||||||
// Set printout parameters
|
// Set printout parameters
|
||||||
printout->SetDC(dc);
|
printout->SetDC(dc);
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
dc->GetSize(&w, &h);
|
dc->GetSize(&w, &h);
|
||||||
printout->SetPageSizePixels((int)w, (int)h);
|
printout->SetPageSizePixels((int)w, (int)h);
|
||||||
|
|
||||||
dc->GetSizeMM(&w, &h);
|
dc->GetSizeMM(&w, &h);
|
||||||
printout->SetPageSizeMM((int)w, (int)h);
|
printout->SetPageSizeMM((int)w, (int)h);
|
||||||
|
|
||||||
// Create an abort window
|
// Create an abort window
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
wxWindow *win = CreateAbortWindow(parent, printout);
|
wxWindow *win = CreateAbortWindow(parent, printout);
|
||||||
wxYield();
|
wxYield();
|
||||||
|
|
||||||
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
|
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || defined(__SALFORDC__) || !defined(__WIN32__)
|
||||||
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
|
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
|
||||||
#else
|
#else
|
||||||
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
|
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
|
||||||
// cast it to right type only if required
|
// cast it to right type only if required
|
||||||
// @@@ it's really cdecl and we're casting it to stdcall - either there is
|
// FIXME it's really cdecl and we're casting it to stdcall - either there is
|
||||||
// something I don't understand or it will crash at first usage
|
// something I don't understand or it will crash at first usage
|
||||||
#ifdef STRICT
|
#ifdef STRICT
|
||||||
(HDC, int)
|
(HDC, int)
|
||||||
#else
|
#else
|
||||||
@@ -182,33 +202,34 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
#endif
|
#endif
|
||||||
)m_lpAbortProc);
|
)m_lpAbortProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!win)
|
if (!win)
|
||||||
{
|
{
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
|
wxLogDebug("Could not create an abort dialog.");
|
||||||
|
|
||||||
delete dc;
|
delete dc;
|
||||||
}
|
}
|
||||||
sm_abortWindow = win;
|
sm_abortWindow = win;
|
||||||
sm_abortWindow->Show(TRUE);
|
sm_abortWindow->Show(TRUE);
|
||||||
wxYield();
|
wxSafeYield();
|
||||||
|
|
||||||
printout->OnBeginPrinting();
|
printout->OnBeginPrinting();
|
||||||
|
|
||||||
bool keepGoing = TRUE;
|
bool keepGoing = TRUE;
|
||||||
|
|
||||||
int copyCount;
|
int copyCount;
|
||||||
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
|
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
|
||||||
{
|
{
|
||||||
if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
|
if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
|
||||||
{
|
{
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
|
wxLogError(_("Could not start printing."));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sm_abortIt)
|
if (sm_abortIt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int pn;
|
int pn;
|
||||||
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
|
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
|
||||||
pn++)
|
pn++)
|
||||||
@@ -227,20 +248,20 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
}
|
}
|
||||||
printout->OnEndDocument();
|
printout->OnEndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
printout->OnEndPrinting();
|
printout->OnEndPrinting();
|
||||||
|
|
||||||
if (sm_abortWindow)
|
if (sm_abortWindow)
|
||||||
{
|
{
|
||||||
sm_abortWindow->Show(FALSE);
|
sm_abortWindow->Show(FALSE);
|
||||||
delete sm_abortWindow;
|
delete sm_abortWindow;
|
||||||
sm_abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
|
|
||||||
delete dc;
|
delete dc;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,13 +300,23 @@ bool wxWindowsPrinter::Setup(wxWindow *parent)
|
|||||||
* Print preview
|
* Print preview
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintDialogData *data):
|
wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout,
|
||||||
wxPrintPreviewBase(printout, printoutForPrinting, data)
|
wxPrintout *printoutForPrinting,
|
||||||
|
wxPrintDialogData *data)
|
||||||
|
: wxPrintPreviewBase(printout, printoutForPrinting, data)
|
||||||
{
|
{
|
||||||
DetermineScaling();
|
DetermineScaling();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowsPrintPreview::~wxWindowsPrintPreview(void)
|
wxWindowsPrintPreview::wxWindowsPrintPreview(wxPrintout *printout,
|
||||||
|
wxPrintout *printoutForPrinting,
|
||||||
|
wxPrintData *data)
|
||||||
|
: wxPrintPreviewBase(printout, printoutForPrinting, data)
|
||||||
|
{
|
||||||
|
DetermineScaling();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWindowsPrintPreview::~wxWindowsPrintPreview()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +328,7 @@ bool wxWindowsPrintPreview::Print(bool interactive)
|
|||||||
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowsPrintPreview::DetermineScaling(void)
|
void wxWindowsPrintPreview::DetermineScaling()
|
||||||
{
|
{
|
||||||
HDC dc = ::GetDC(NULL);
|
HDC dc = ::GetDC(NULL);
|
||||||
int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
|
int screenWidth = ::GetDeviceCaps(dc, HORZSIZE);
|
||||||
@@ -307,39 +338,39 @@ void wxWindowsPrintPreview::DetermineScaling(void)
|
|||||||
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
|
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
|
||||||
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
|
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
||||||
|
|
||||||
::ReleaseDC(NULL, dc);
|
::ReleaseDC(NULL, dc);
|
||||||
|
|
||||||
// Get a device context for the currently selected printer
|
// Get a device context for the currently selected printer
|
||||||
wxPrinterDC printerDC(m_printDialogData.GetPrintData());
|
wxPrinterDC printerDC(m_printDialogData.GetPrintData());
|
||||||
|
|
||||||
int printerWidth = 150;
|
int printerWidth = 150;
|
||||||
int printerHeight = 250;
|
int printerHeight = 250;
|
||||||
int printerXRes = 1500;
|
int printerXRes = 1500;
|
||||||
int printerYRes = 2500;
|
int printerYRes = 2500;
|
||||||
|
|
||||||
if (printerDC.GetHDC())
|
if (printerDC.GetHDC())
|
||||||
{
|
{
|
||||||
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
|
printerWidth = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZSIZE);
|
||||||
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
|
printerHeight = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTSIZE);
|
||||||
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
|
printerXRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), HORZRES);
|
||||||
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
|
printerYRes = ::GetDeviceCaps((HDC) printerDC.GetHDC(), VERTRES);
|
||||||
|
|
||||||
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
|
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
|
||||||
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
|
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
|
||||||
|
|
||||||
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
||||||
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
||||||
|
|
||||||
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
||||||
m_isOk = FALSE;
|
m_isOk = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_isOk = FALSE;
|
m_isOk = FALSE;
|
||||||
|
|
||||||
m_pageWidth = printerXRes;
|
m_pageWidth = printerXRes;
|
||||||
m_pageHeight = printerYRes;
|
m_pageHeight = printerYRes;
|
||||||
|
|
||||||
// At 100%, the page should look about page-size on the screen.
|
// At 100%, the page should look about page-size on the screen.
|
||||||
m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
||||||
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes);
|
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes);
|
||||||
@@ -348,28 +379,28 @@ void wxWindowsPrintPreview::DetermineScaling(void)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
||||||
FUNCTION: wxAbortProc()
|
FUNCTION: wxAbortProc()
|
||||||
|
|
||||||
PURPOSE: Processes messages for the Abort Dialog box
|
PURPOSE: Processes messages for the Abort Dialog box
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code))
|
LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code))
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
if (!wxPrinterBase::sm_abortWindow) /* If the abort dialog isn't up yet */
|
if (!wxPrinterBase::sm_abortWindow) /* If the abort dialog isn't up yet */
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
||||||
/* Process messages intended for the abort dialog box */
|
/* Process messages intended for the abort dialog box */
|
||||||
|
|
||||||
while (!wxPrinterBase::sm_abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
|
while (!wxPrinterBase::sm_abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
|
||||||
if (!IsDialogMessage((HWND) wxPrinterBase::sm_abortWindow->GetHWND(), &msg)) {
|
if (!IsDialogMessage((HWND) wxPrinterBase::sm_abortWindow->GetHWND(), &msg)) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bAbort is TRUE (return is FALSE) if the user has aborted */
|
/* bAbort is TRUE (return is FALSE) if the user has aborted */
|
||||||
|
|
||||||
return (!wxPrinterBase::sm_abortIt);
|
return (!wxPrinterBase::sm_abortIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user