{
}
-bool wxOSXPrintData::TransferFrom( const wxPrintData &data )
+void wxOSXPrintData::TransferPrinterNameFrom( const wxPrintData &data )
{
CFArrayRef printerList;
CFIndex index, count;
PMSessionSetCurrentPMPrinter(m_macPrintSession, printer);
CFRelease(printerList);
}
+}
+void wxOSXPrintData::TransferPaperInfoFrom( const wxPrintData &data )
+{
PMPrinter printer;
PMSessionGetCurrentPrinter(m_macPrintSession, &printer);
-
+
wxSize papersize = wxDefaultSize;
const wxPaperSize paperId = data.GetPaperId();
if ( paperId != wxPAPER_NONE && wxThePrintPaperDatabase )
{
papersize = data.GetPaperSize();
}
-
+
if ( papersize != wxDefaultSize )
{
papersize.x = (wxInt32) (papersize.x * mm2pt);
papersize.y = (wxInt32) (papersize.y * mm2pt);
-
+
double height, width;
PMPaperGetHeight(m_macPaper, &height);
PMPaperGetWidth(m_macPaper, &width);
-
+
if ( fabs( width - papersize.x ) >= 5 ||
fabs( height - papersize.y ) >= 5 )
{
const PMPaperMargins margins = { 0.0, 0.0, 0.0, 0.0 };
wxString id, name(wxT("Custom paper"));
id.Printf(wxT("wxPaperCustom%dx%d"), papersize.x, papersize.y);
-
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if ( PMPaperCreateCustom != NULL)
{
PMPaperCreateCustom(printer, wxCFStringRef( id, wxFont::GetDefaultEncoding() ), wxCFStringRef( name, wxFont::GetDefaultEncoding() ),
- papersize.x, papersize.y, &margins, &paper);
+ papersize.x, papersize.y, &margins, &paper);
}
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if ( paper == kPMNoData )
{
PMPaperCreate(printer, wxCFStringRef( id, wxFont::GetDefaultEncoding() ), wxCFStringRef( name, wxFont::GetDefaultEncoding() ),
- papersize.x, papersize.y, &margins, &paper);
+ papersize.x, papersize.y, &margins, &paper);
}
#endif
}
}
}
}
-
+
PMSetCopies( m_macPrintSettings , data.GetNoCopies() , false ) ;
PMSetCollate(m_macPrintSettings, data.GetCollate());
if ( data.IsOrientationReversed() )
PMSetOrientation( m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
- kPMReverseLandscape : kPMReversePortrait , false ) ;
+ kPMReverseLandscape : kPMReversePortrait , false ) ;
else
PMSetOrientation( m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
- kPMLandscape : kPMPortrait , false ) ;
-
+ kPMLandscape : kPMPortrait , false ) ;
+
PMDuplexMode mode = 0 ;
switch( data.GetDuplex() )
{
break ;
}
PMSetDuplex( m_macPrintSettings, mode ) ;
-
-
+
+
if ( data.IsOrientationReversed() )
PMSetOrientation( m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
- kPMReverseLandscape : kPMReversePortrait , false ) ;
+ kPMReverseLandscape : kPMReversePortrait , false ) ;
else
PMSetOrientation( m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
- kPMLandscape : kPMPortrait , false ) ;
+ kPMLandscape : kPMPortrait , false ) ;
+}
+
+void wxOSXPrintData::TransferResolutionFrom( const wxPrintData &data )
+{
+ PMPrinter printer;
+ PMSessionGetCurrentPrinter(m_macPrintSession, &printer);
UInt32 resCount;
PMResolution *resolutions = GetSupportedResolutions(printer, &resCount);
PMSetResolution( m_macPageFormat, &res);
#endif
}
-
+
free(resolutions);
}
+}
+
+bool wxOSXPrintData::TransferFrom( const wxPrintData &data )
+{
+ TransferPrinterNameFrom(data);
+ TransferPaperInfoFrom(data);
+ TransferResolutionFrom(data);
+
// after setting the new resolution the format has to be updated, otherwise the page rect remains
// at the 'old' scaling
-
+
PMSessionValidatePageFormat(m_macPrintSession,
- m_macPageFormat, kPMDontWantBoolean);
+ m_macPageFormat, kPMDontWantBoolean);
PMSessionValidatePrintSettings(m_macPrintSession,
- m_macPrintSettings, kPMDontWantBoolean);
+ m_macPrintSettings, kPMDontWantBoolean);
+
#if wxOSX_USE_COCOA
UpdateFromPMState();
#endif
return true ;
}
-bool wxOSXPrintData::TransferTo( wxPrintData &data )
+void wxOSXPrintData::TransferPrinterNameTo( wxPrintData &data )
{
+ CFStringRef name;
+ PMPrinter printer ;
+ PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
+ if (PMPrinterIsDefault(printer))
+ data.SetPrinterName(wxEmptyString);
+ else
+ {
+ name = PMPrinterGetName(printer);
+ CFRetain(name);
+ data.SetPrinterName(wxCFStringRef(name).AsString());
+ }
+}
+
+void wxOSXPrintData::TransferPaperInfoTo( wxPrintData &data )
+{
+ PMPrinter printer ;
+ PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
OSStatus err = noErr ;
-#if wxOSX_USE_COCOA
- UpdateToPMState();
-#endif
UInt32 copies ;
err = PMGetCopies( m_macPrintSettings , &copies ) ;
if ( err == noErr )
data.SetNoCopies( copies ) ;
-
+
PMOrientation orientation ;
err = PMGetOrientation( m_macPageFormat , &orientation ) ;
if ( err == noErr )
data.SetOrientationReversed( orientation == kPMReverseLandscape );
}
}
-
+
Boolean collate;
if (PMGetCollate(m_macPrintSettings, &collate) == noErr)
data.SetCollate(collate);
-
- CFStringRef name;
- PMPrinter printer ;
- PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
- if (PMPrinterIsDefault(printer))
- data.SetPrinterName(wxEmptyString);
- else
- {
- name = PMPrinterGetName(printer);
- CFRetain(name);
- data.SetPrinterName(wxCFStringRef(name).AsString());
- }
-
+
+
PMDuplexMode mode = 0 ;
PMGetDuplex( m_macPrintSettings, &mode ) ;
switch( mode )
data.SetDuplex(wxDUPLEX_SIMPLEX);
break ;
}
+
+ double height, width;
+ PMPaperGetHeight(m_macPaper, &height);
+ PMPaperGetWidth(m_macPaper, &width);
+
+ wxSize sz((int)(width * pt2mm + 0.5 ) ,
+ (int)(height * pt2mm + 0.5 ));
+ data.SetPaperSize(sz);
+ wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
+ if (id != wxPAPER_NONE)
+ {
+ data.SetPaperId(id);
+ }
+}
+
+void wxOSXPrintData::TransferResolutionTo( wxPrintData &data )
+{
+ PMPrinter printer ;
+ PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
/* assume high quality, will change below if we are able to */
data.SetQuality(wxPRINT_QUALITY_HIGH);
data.SetQuality((((i + 1) * 3) / resCount) + wxPRINT_QUALITY_DRAFT);
}
free(resolutions);
- }
+ }
+}
- double height, width;
- PMPaperGetHeight(m_macPaper, &height);
- PMPaperGetWidth(m_macPaper, &width);
+bool wxOSXPrintData::TransferTo( wxPrintData &data )
+{
+#if wxOSX_USE_COCOA
+ UpdateToPMState();
+#endif
- wxSize sz((int)(width * pt2mm + 0.5 ) ,
- (int)(height * pt2mm + 0.5 ));
- data.SetPaperSize(sz);
- wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
- if (id != wxPAPER_NONE)
- {
- data.SetPaperId(id);
- }
+ TransferPrinterNameTo(data);
+ TransferPaperInfoTo(data);
+ TransferResolutionTo(data);
return true ;
}