X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a5c1223d2f95b9ac30f1ae3290a6751764e1f005..88932ec82d048d006cdc81bd309f5e59aee799ac:/src/msw/printwin.cpp?ds=sidebyside diff --git a/src/msw/printwin.cpp b/src/msw/printwin.cpp index 587a4749fc..0c8a2ed652 100644 --- a/src/msw/printwin.cpp +++ b/src/msw/printwin.cpp @@ -49,19 +49,16 @@ #include "wx/msw/printdlg.h" #include "wx/msw/private.h" #include "wx/msw/dcprint.h" -#include "wx/msw/enhmeta.h" - -#include - -#ifndef __WIN32__ - #include +#if wxUSE_ENH_METAFILE + #include "wx/msw/enhmeta.h" #endif +#include // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- -LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code); +BOOL CALLBACK wxAbortProc(HDC hdc, int error); // --------------------------------------------------------------------------- // wxWin macros @@ -81,16 +78,6 @@ LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code); wxWindowsPrinter::wxWindowsPrinter(wxPrintDialogData *data) : wxPrinterBase(data) { - m_lpAbortProc = (WXFARPROC)wxAbortProc; -} - -wxWindowsPrinter::~wxWindowsPrinter() -{ - // avoids warning about statement with no effect (FreeProcInstance - // doesn't do anything under Win32) -#if !defined(__WIN32__) && !defined(__NT__) - FreeProcInstance((FARPROC) m_lpAbortProc); -#endif } bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) @@ -104,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) @@ -182,27 +167,10 @@ 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(); -#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__GNUWIN32__) || !defined(__WIN32__) -#ifdef STRICT - ::SetAbortProc((HDC) impl->GetHDC(), (ABORTPROC) m_lpAbortProc); -#else - ::SetAbortProc((HDC) impl->GetHDC(), (FARPROC) m_lpAbortProc); -#endif -#else - ::SetAbortProc((HDC) impl->GetHDC(), (int (_stdcall *) - // cast it to right type only if required - // 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 -#ifdef STRICT - (HDC, int) -#else - () -#endif - )m_lpAbortProc); -#endif + ::SetAbortProc(GetHdcOf(*impl), wxAbortProc); if (!win) { @@ -228,10 +196,8 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt maxPageNum = m_printDialogData.GetToPage(); } - int copyCount; - for ( copyCount = 1; - copyCount <= m_printDialogData.GetNoCopies(); - copyCount++ ) + const int maxCopyCount = m_printDialogData.GetNoCopies(); + for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ ) { if ( !printout->OnBeginDocument(minPageNum, maxPageNum) ) { @@ -251,6 +217,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; @@ -276,8 +246,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; @@ -424,6 +393,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 @@ -469,17 +439,9 @@ bool wxWindowsPrintPreview::RenderPageIntoBitmap(wxBitmap& bmp, int pageNum) return true; } +#endif // wxUSE_ENH_METAFILE - -/**************************************************************************** - - FUNCTION: wxAbortProc() - - PURPOSE: Processes messages for the Abort Dialog box - -****************************************************************************/ - -LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code)) +BOOL CALLBACK wxAbortProc(HDC WXUNUSED(hdc), int WXUNUSED(error)) { MSG msg;