+ OSStatus err = noErr ;
+
+ UInt32 copies ;
+ err = PMGetCopies( (PMPrintSettings) m_macPrintSettings , &copies ) ;
+ if ( err == noErr )
+ m_printNoCopies = copies ;
+
+ PMOrientation orientation ;
+ err = PMGetOrientation( (PMPageFormat) m_macPageFormat , &orientation ) ;
+ if ( err == noErr )
+ {
+ if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
+ m_printOrientation = wxPORTRAIT ;
+ else
+ m_printOrientation = wxLANDSCAPE ;
+ }
+
+ // collate cannot be set
+#if 0
+ {
+ wxMacCFStringHolder name ;
+ PMPrinter printer ;
+ PMSessionGetCurrentPrinter( (PMPrintSession) m_macPrintSession ,
+ &printer ) ;
+ m_printerName = name.AsString() ;
+ }
+#endif
+
+ PMColorMode color ;
+ err = PMGetColorMode( (PMPrintSettings) m_macPrintSettings, &color ) ;
+ if ( err == noErr )
+ m_colour = !(color == kPMBlackAndWhite) ;
+
+ // PMDuplexMode not yet accessible via API
+ // PMQualityMode not yet accessible via API
+ // todo paperSize
+ PMRect rPaper;
+ err = PMGetUnadjustedPaperRect((PMPageFormat) m_macPageFormat, &rPaper);
+ if ( err == noErr )
+ {
+ m_paperSize.x = (int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 );
+ m_paperSize.y = (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 );
+ }
+#else
+ m_printNoCopies = (**(THPrint)m_macPrintSettings).prJob.iCopies;
+
+ // paper size
+ m_paperSize.x = ((double) (**(THPrint)m_macPrintSettings).rPaper.right - (**(THPrint)m_macPrintSettings).rPaper.left ) * pt2mm;
+ m_paperSize.y = ((double) (**(THPrint)m_macPrintSettings).rPaper.bottom - (**(THPrint)m_macPrintSettings).rPaper.top ) * pt2mm;
+#endif
+}
+
+void wxPrintData::ValidateOrCreateNative()
+{
+#if TARGET_CARBON
+ OSStatus err = noErr ;
+ if ( m_macPrintSession == kPMNoReference )
+ {
+ err = PMCreateSession( (PMPrintSession *) &m_macPrintSession ) ;
+ }
+ // Set up a valid PageFormat object.
+ if ( m_macPageFormat == kPMNoPageFormat)
+ {
+ err = PMCreatePageFormat((PMPageFormat *) &m_macPageFormat);
+
+ // Note that PMPageFormat is not session-specific, but calling
+ // PMSessionDefaultPageFormat assigns values specific to the printer
+ // associated with the current printing session.
+ if ((err == noErr) &&
+ ( m_macPageFormat != kPMNoPageFormat))
+ {
+ err = PMSessionDefaultPageFormat((PMPrintSession) m_macPrintSession,
+ (PMPageFormat) m_macPageFormat);
+ }
+ }
+ else
+ {
+ err = PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession,
+ (PMPageFormat) m_macPageFormat,
+ kPMDontWantBoolean);
+ }
+
+ // Set up a valid PrintSettings object.
+ if ( m_macPrintSettings == kPMNoPrintSettings)
+ {
+ err = PMCreatePrintSettings((PMPrintSettings *) &m_macPrintSettings);
+
+ // Note that PMPrintSettings is not session-specific, but calling
+ // PMSessionDefaultPrintSettings assigns values specific to the printer
+ // associated with the current printing session.
+ if ((err == noErr) &&
+ ( m_macPrintSettings != kPMNoPrintSettings))
+ {
+ err = PMSessionDefaultPrintSettings((PMPrintSession) m_macPrintSession,
+ (PMPrintSettings) m_macPrintSettings);
+ }
+ }
+ else
+ {
+ err = PMSessionValidatePrintSettings((PMPrintSession) m_macPrintSession,
+ (PMPrintSettings) m_macPrintSettings,
+ kPMDontWantBoolean);
+ }