Exemple #1
0
bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data )
{
    ValidateOrCreate() ;
    PMSetCopies( (PMPrintSettings) m_macPrintSettings , data.GetNoCopies() , false ) ;
    PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
        kPMLandscape : kPMPortrait , false ) ;
    // collate cannot be set
#if 0 // not yet tested
    if ( m_printerName.Length() > 0 )
        PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ;
#endif
    PMColorMode color ;
    PMGetColorMode(  (PMPrintSettings) m_macPrintSettings, &color ) ;
    if ( data.GetColour() )
    {
        if ( color == kPMBlackAndWhite )
            PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ;
    }
    else
        PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
    
    // PMDuplexMode not yet accessible via API
    // PMQualityMode not yet accessible via API
    // todo paperSize
    PMResolution res;
    PMPrinter printer;
    PMTag tag = kPMMaxSquareResolution;
    PMSessionGetCurrentPrinter(m_macPrintSession, &printer);
    PMPrinterGetPrinterResolution(printer, tag, &res);
    PMSetResolution((PMPageFormat) m_macPageFormat, &res);

    return true ;
}
Exemple #2
0
void wxMacCarbonPrintData::TransferFrom( wxPrintData* data )
{
    ValidateOrCreate() ;
    PMSetCopies( (PMPrintSettings) m_macPrintSettings , data->GetNoCopies() , false ) ;
    PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data->GetOrientation() == wxLANDSCAPE ) ?
        kPMLandscape : kPMPortrait , false ) ;
    // collate cannot be set
#if 0 // not yet tested
    if ( !m_printerName.empty() )
        PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ;
#endif
    PMColorMode color ;
    PMGetColorMode(  (PMPrintSettings) m_macPrintSettings, &color ) ;
    if ( data->GetColour() )
    {
        if ( color == kPMBlackAndWhite )
            PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ;
    }
    else
        PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;

    // PMDuplexMode not yet accessible via API
    // PMQualityMode not yet accessible via API
    // todo paperSize
}
Exemple #3
0
bool
QPrinter::prepare(PMPrintSettings *s)
{
  if (!psession && PMCreateSession(&psession) != noErr)
    return FALSE;
  if (*s == kPMNoPrintSettings) {
    if (PMCreatePrintSettings(s) != noErr)
      return FALSE;
    if (PMSessionDefaultPrintSettings(psession, *s) != noErr)
      return FALSE;
  } else {
    if (PMSessionValidatePrintSettings(psession, *s, kPMDontWantBoolean) != noErr)
      return FALSE;
  }
  if (minPage() != 0 || maxPage() != 0)
    PMSetPageRange(*s, minPage(), maxPage());
  if (d->printRange != AllPages) {
    PMSetFirstPage(*s, fromPage(), TRUE);
    PMSetLastPage(*s, toPage(), TRUE);
  }
  PMSetColorMode(*s, colorMode() == GrayScale ? kPMGray : kPMColor);
  PMSetCopies(*s, numCopies(), TRUE);
  if (outputToFile()) {
    CFStringRef cfstring = qstring2cfstring(outputFileName());
    CFURLRef outFile = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, cfstring,
                                                     kCFURLPOSIXPathStyle, false);
    PMSessionSetDestination(psession, *s, kPMDestinationFile, kPMDocumentFormatPDF, outFile);
    CFRelease(outFile);
    CFRelease(cfstring);
  }

  QString printName = printerName();
  if (!printName.isEmpty()) {
    CFStringRef pname = qstring2cfstring(printName);
    PMSessionSetCurrentPrinter(psession, pname);
    CFRelease(pname);
  }
  return TRUE;
}
Exemple #4
0
bool wxMacCarbonPrintData::TransferFrom( const wxPrintData &data )
{
    ValidateOrCreate() ;
    PMSetCopies( (PMPrintSettings) m_macPrintSettings , data.GetNoCopies() , false ) ;
    if ( data.IsOrientationReversed() )
        PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
            kPMReverseLandscape : kPMReversePortrait , false ) ;
    else
        PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data.GetOrientation() == wxLANDSCAPE ) ?
            kPMLandscape : kPMPortrait , false ) ;
    // collate cannot be set
#if 0 // not yet tested
    if ( !m_printerName.empty() )
        PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ;
#endif
#ifndef __LP64__
    PMColorMode color ;
    PMGetColorMode(  (PMPrintSettings) m_macPrintSettings, &color ) ;
    if ( data.GetColour() )
    {
        if ( color == kPMBlackAndWhite )
            PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ;
    }
    else
        PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
#endif

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    if ( &PMSetDuplex!=NULL )
    {
        PMDuplexMode mode = 0 ;
        switch( data.GetDuplex() )
        {
            case wxDUPLEX_HORIZONTAL :
                mode = kPMDuplexNoTumble ;
                break ;
            case wxDUPLEX_VERTICAL :
                mode = kPMDuplexTumble ;
                break ;
            case wxDUPLEX_SIMPLEX :
            default :
                mode = kPMDuplexNone ;
                break ;
        }
        PMSetDuplex( (PMPrintSettings) m_macPrintSettings, mode ) ;
    }
#endif
    // PMQualityMode not yet accessible via API
    // todo paperSize

    PMResolution res;
    PMPrinter printer;
    PMSessionGetCurrentPrinter(m_macPrintSession, &printer);
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 
    PMPrinterGetOutputResolution( printer,  
        (PMPrintSettings) m_macPrintSettings,  &res) ;
    // TODO transfer ? into page format ?
#else
    PMTag tag = kPMMaxSquareResolution;
    PMPrinterGetPrinterResolution(printer, tag, &res);
    PMSetResolution((PMPageFormat) m_macPageFormat, &res);
#endif
    // after setting the new resolution the format has to be updated, otherwise the page rect remains 
    // at the 'old' scaling
    PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession,
            (PMPageFormat) m_macPageFormat,
            kPMDontWantBoolean) ;

    return true ;
}