X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5be55d562f584025d966980f5fc4272db60c6eae..beedefb9401e8a0c2867aaf163ac6ea42e6dd6a7:/src/mac/carbon/printmac.cpp diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 1a0f8d5121..f7238e84ce 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -9,19 +9,19 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "printwin.h" #endif // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_PRINTING_ARCHITECTURE + #ifdef __BORLANDC__ #pragma hdrstop #endif -#include "wx/defs.h" - #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dc.h" @@ -29,16 +29,15 @@ #include "wx/msgdlg.h" #endif +#include "wx/math.h" #include "wx/mac/uma.h" #include "wx/mac/printmac.h" #include "wx/mac/private/print.h" -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - #include "wx/dcprint.h" #include "wx/printdlg.h" +#include "wx/mac/printdlg.h" #include @@ -144,7 +143,7 @@ void wxMacCarbonPrintData::TransferFrom( wxPrintData* data ) // collate cannot be set #if 0 // not yet tested if ( m_printerName.Length() > 0 ) - PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName ) ) ; + PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ; #endif PMColorMode color ; PMGetColorMode( (PMPrintSettings) m_macPrintSettings, &color ) ; @@ -261,7 +260,11 @@ void wxMacCarbonPrintData::TransferFrom( wxPrintDialogData* data ) PMSetPageRange( m_macPrintSettings , data->GetMinPage() , data->GetMaxPage() ) ; PMSetCopies( m_macPrintSettings , data->GetNoCopies() , false ) ; PMSetFirstPage( m_macPrintSettings , data->GetFromPage() , false ) ; - PMSetLastPage( m_macPrintSettings , data->GetToPage() , false ) ; + + int toPage = data->GetToPage(); + if (toPage < 1) + toPage = data->GetFromPage(); + PMSetLastPage( m_macPrintSettings , toPage , false ) ; } void wxMacCarbonPrintData::CopyFrom( wxNativePrintData* d ) @@ -443,8 +446,11 @@ void wxMacClassicPrintData::TransferTo( wxPageSetupData* data ) void wxMacClassicPrintData::TransferFrom( wxPrintDialogData* data ) { + int toPage = data->GetToPage(); + if (toPage < 1) + toPage = data->GetFromPage(); (**m_macPrintSettings).prJob.iFstPage = data->GetFromPage() ; - (**m_macPrintSettings).prJob.iLstPage = data->GetToPage() ; + (**m_macPrintSettings).prJob.iLstPage = toPage; } void wxMacClassicPrintData::TransferTo( wxPrintDialogData* data ) @@ -535,38 +541,11 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) return FALSE; printout->SetIsPreview(FALSE); - printout->OnPreparePrinting(); - - // Get some parameters from the printout, if defined - int fromPage, toPage; - int minPage, maxPage; - printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); - - if (maxPage == 0) - return FALSE; - - m_printDialogData.SetMinPage(minPage); - m_printDialogData.SetMaxPage(maxPage); - if (fromPage != 0) - m_printDialogData.SetFromPage(fromPage); - if (toPage != 0) - m_printDialogData.SetToPage(toPage); - - if (minPage != 0) - { - m_printDialogData.EnablePageNumbers(TRUE); - if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMinPage()); - else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage()); - if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMaxPage()); - else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMinPage()); - } - else - m_printDialogData.EnablePageNumbers(FALSE); - + if (m_printDialogData.GetMinPage() < 1) + m_printDialogData.SetMinPage(1); + if (m_printDialogData.GetMaxPage() < 1) + m_printDialogData.SetMaxPage(9999); + // Create a suitable device context wxDC *dc = NULL; if (prompt) @@ -575,7 +554,7 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) if (dialog.ShowModal() == wxID_OK) { dc = dialog.GetPrintDC(); - m_printDialogData = dialog.GetPrintData(); + m_printDialogData = dialog.GetPrintDialogData(); } } else @@ -609,6 +588,24 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) // Create an abort window wxBeginBusyCursor(); + printout->OnPreparePrinting(); + + // Get some parameters from the printout, if defined + int fromPage, toPage; + int minPage, maxPage; + printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); + + if (maxPage == 0) + { + wxEndBusyCursor(); + return FALSE; + } + + // Only set min and max, because from and to have been + // set by the user + m_printDialogData.SetMinPage(minPage); + m_printDialogData.SetMaxPage(maxPage); + wxWindow *win = CreateAbortWindow(parent, printout); wxSafeYield(win,true); @@ -650,12 +647,15 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) } else { -// #if !TARGET_CARBON - GrafPtr thePort ; - GetPort( &thePort ) ; - wxSafeYield(win,true); - SetPort( thePort ) ; -// #endif +#if TARGET_CARBON + if ( UMAGetSystemVersion() >= 0x1000 ) +#endif + { + GrafPtr thePort ; + GetPort( &thePort ) ; + wxSafeYield(win,true); + SetPort( thePort ) ; + } dc->StartPage(); keepGoing = printout->OnPrintPage(pn); dc->EndPage(); @@ -698,6 +698,7 @@ wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) bool wxMacPrinter::Setup(wxWindow *parent) { +#if 0 wxPrintDialog dialog(parent, & m_printDialogData); dialog.GetPrintDialogData().SetSetupDialog(TRUE); @@ -709,6 +710,8 @@ bool wxMacPrinter::Setup(wxWindow *parent) } return (ret == wxID_OK); +#endif + return wxID_CANCEL; } /* @@ -778,3 +781,5 @@ void wxMacPrintPreview::DetermineScaling(void) m_previewScale = 1 ; } + +#endif