X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5009cb6accf219ec5ce6010b9b1ea88bece64e03..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/msw/printwin.cpp diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 26aa924725..62abb589f6 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -49,8 +49,9 @@ #include "wx/msw/printdlg.h" #include "wx/msw/private.h" #include "wx/msw/dcprint.h" -#include "wx/msw/enhmeta.h" - +#if wxUSE_ENH_METAFILE + #include "wx/msw/enhmeta.h" +#endif #include // --------------------------------------------------------------------------- @@ -90,8 +91,6 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt return false; } - printout->SetIsPreview(false); - if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) @@ -168,7 +167,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); - wxWindow *win = CreateAbortWindow(parent, printout); + wxPrintAbortDialog *win = CreateAbortWindow(parent, printout); wxYield(); ::SetAbortProc(GetHdcOf(*impl), wxAbortProc); @@ -197,10 +196,15 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt maxPageNum = m_printDialogData.GetToPage(); } - int copyCount; - for ( copyCount = 1; - copyCount <= m_printDialogData.GetNoCopies(); - copyCount++ ) + // The dc we get from the PrintDialog will do multiple copies without help + // if the device supports it. Loop only if we have created a dc from our + // own m_printDialogData or the device does not support multiple copies. + // m_printDialogData.GetPrintData().GetNoCopies() is set from device + // devMode in printdlg.cpp/wxWindowsPrintDialog::ConvertFromNative() + const int maxCopyCount = !prompt || + !m_printDialogData.GetPrintData().GetNoCopies() + ? m_printDialogData.GetNoCopies() : 1; + for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ ) { if ( !printout->OnBeginDocument(minPageNum, maxPageNum) ) { @@ -220,6 +224,10 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt pn <= maxPageNum && printout->HasPage(pn); pn++ ) { + win->SetProgress(pn - minPageNum + 1, + maxPageNum - minPageNum + 1, + copyCount, maxCopyCount); + if ( sm_abortIt ) { sm_lastError = wxPRINTER_CANCELLED; @@ -245,8 +253,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt if (sm_abortWindow) { sm_abortWindow->Show(false); - delete sm_abortWindow; - sm_abortWindow = NULL; + wxDELETE(sm_abortWindow); } delete dc; @@ -393,6 +400,7 @@ void wxWindowsPrintPreview::DetermineScaling() m_previewScaleY = float(logPPIScreenY) / logPPIPrinterY; } +#if wxUSE_ENH_METAFILE bool wxWindowsPrintPreview::RenderPageIntoBitmap(wxBitmap& bmp, int pageNum) { // The preview, as implemented in wxPrintPreviewBase (and as used prior to @@ -438,7 +446,7 @@ bool wxWindowsPrintPreview::RenderPageIntoBitmap(wxBitmap& bmp, int pageNum) return true; } - +#endif // wxUSE_ENH_METAFILE BOOL CALLBACK wxAbortProc(HDC WXUNUSED(hdc), int WXUNUSED(error)) {