X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/18f3decb46a80b38801dd6590d08eb525d3a3963..3b5d20079c81e0106b3dead7cd8d7337bf3f36f4:/src/mac/classic/printmac.cpp diff --git a/src/mac/classic/printmac.cpp b/src/mac/classic/printmac.cpp index f179f5e7f6..3f4cbef6a8 100644 --- a/src/mac/classic/printmac.cpp +++ b/src/mac/classic/printmac.cpp @@ -21,6 +21,7 @@ #include "wx/dc.h" #include "wx/app.h" #include "wx/msgdlg.h" + #include "wx/dcprint.h" #endif #include "wx/mac/uma.h" @@ -31,7 +32,6 @@ #define mm2pt 2.83464566929 #define pt2mm 0.352777777778 -#include "wx/dcprint.h" #include "wx/printdlg.h" #include @@ -135,7 +135,7 @@ void wxMacCarbonPrintData::TransferFrom( wxPrintData* data ) kPMLandscape : kPMPortrait , false ) ; // collate cannot be set #if 0 // not yet tested - if ( m_printerName.Length() > 0 ) + if ( !m_printerName.empty() ) PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ; #endif PMColorMode color ; @@ -540,7 +540,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) m_printDialogData.SetMaxPage(9999); // Create a suitable device context - wxDC *dc = NULL; + wxPrinterDC *dc = NULL; if (prompt) { wxPrintDialog dialog(parent, & m_printDialogData); @@ -555,7 +555,6 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } - // May have pressed cancel. if (!dc || !dc->Ok()) { @@ -564,7 +563,6 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) } // on the mac we have always pixels as addressing mode with 72 dpi - printout->SetPPIScreen(72, 72); printout->SetPPIPrinter(72, 72); @@ -575,6 +573,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) wxCoord ww, hh; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); + printout->SetPaperRectPixels(dc->GetPaperRect()); dc->GetSizeMM(&ww, &hh); printout->SetPageSizeMM((int)ww, (int)hh); @@ -742,35 +741,42 @@ void wxMacPrintPreview::DetermineScaling(void) int screenWidth , screenHeight ; wxDisplaySize( &screenWidth , &screenHeight ) ; - m_previewPrintout->SetPPIScreen( 72 , 72 ) ; - m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; - m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); - m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ; - m_pageWidth = 8 * 72 ; - m_pageHeight = 11 * 72 ; - m_previewScale = 1 ; + wxSize ppiScreen( 72 , 72 ) ; + wxSize ppiPrinter( 72 , 72 ) ; + + m_previewPrintout->SetPPIScreen( ppiScreen.x , ppiScreen.y ) ; + + wxCoord w , h ; + wxCoord ww, hh; + wxRect paperRect; // Get a device context for the currently selected printer wxPrinterDC printerDC(m_printDialogData.GetPrintData()); if (printerDC.Ok()) { - int x , y ; - wxCoord ww, hh; printerDC.GetSizeMM(&ww, &hh); - printerDC.GetSize( &x , &y ) ; - m_previewPrintout->SetPageSizeMM((int)ww, (int)hh); - m_previewPrintout->SetPageSizePixels( x , y) ; - m_pageWidth = x ; - m_pageHeight = y ; + printerDC.GetSize( &w , &h ) ; + ppiPrinter = printerDC.GetPPI() ; + paperRect = printerDC.GetPaperRect(); m_isOk = true ; } else { + // use some defaults + w = 8 * 72 ; + h = 11 * 72 ; + ww = (wxCoord) (w * 25.4 / ppiPrinter.x) ; + hh = (wxCoord) (h * 25.4 / ppiPrinter.y) ; + paperRect = wxRect(0, 0, w, h); m_isOk = false ; } - // At 100%, the page should look about page-size on the screen. - // m_previewScale = (float)((float)screenWidth/(float)printerWidth); - // m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes); + m_previewPrintout->SetPageSizeMM(ww, hh); + m_previewPrintout->SetPageSizePixels(w , h) ; + m_previewPrintout->SetPaperRectPixels(paperRect); + m_pageWidth = w; + m_pageHeight = h; + m_previewPrintout->SetPPIPrinter( ppiPrinter.x , ppiPrinter.y ) ; - m_previewScale = 1 ; + m_previewScaleX = float(ppiScreen.x) / ppiPrinter.x; + m_previewScaleY = float(ppiScreen.y) / ppiPrinter.y; }