コード例 #1
0
ファイル: printmac.cpp プロジェクト: BloodRedd/gamekit
void wxOSXPrintData::TransferPaperInfoTo( wxPrintData &data )
{
    PMPrinter printer ;
    PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
    OSStatus err = noErr ;
    UInt32 copies ;
    err = PMGetCopies( m_macPrintSettings , &copies ) ;
    if ( err == noErr )
        data.SetNoCopies( copies ) ;
    
    PMOrientation orientation ;
    err = PMGetOrientation(  m_macPageFormat , &orientation ) ;
    if ( err == noErr )
    {
        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
        {
            data.SetOrientation( wxPORTRAIT  );
            data.SetOrientationReversed( orientation == kPMReversePortrait );
        }
        else
        {
            data.SetOrientation( wxLANDSCAPE );
            data.SetOrientationReversed( orientation == kPMReverseLandscape );
        }
    }
    
    Boolean collate;
    if (PMGetCollate(m_macPrintSettings, &collate) == noErr)
        data.SetCollate(collate);
    
    
    PMDuplexMode mode = 0 ;
    PMGetDuplex(  m_macPrintSettings, &mode ) ;
    switch( mode )
    {
        case kPMDuplexNoTumble :
            data.SetDuplex(wxDUPLEX_HORIZONTAL);
            break ;
        case kPMDuplexTumble :
            data.SetDuplex(wxDUPLEX_VERTICAL);
            break ;
        case kPMDuplexNone :
        default :
            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);
    }
}
コード例 #2
0
ファイル: printmac.cpp プロジェクト: CodeSmithyIDE/wxWidgets
void wxOSXPrintData::TransferTo( wxPrintDialogData* data )
{
#if wxOSX_USE_COCOA
    UpdateToPMState();
#endif
    UInt32 minPage , maxPage ;
    PMGetPageRange( m_macPrintSettings , &minPage , &maxPage ) ;
    data->SetMinPage( minPage ) ;
    data->SetMaxPage( maxPage ) ;
    UInt32 copies ;
    PMGetCopies( m_macPrintSettings , &copies ) ;
    data->SetNoCopies( copies ) ;
    UInt32 from , to ;
    PMGetFirstPage( m_macPrintSettings , &from ) ;
    PMGetLastPage( m_macPrintSettings , &to ) ;
    if ( to >= 0x7FFFFFFF ) //  due to an OS Bug we don't get back kPMPrintAllPages
    {
        data->SetAllPages( true ) ;
        // This means all pages, more or less
        data->SetFromPage(1);
        data->SetToPage(9999);
    }
    else
    {
        data->SetFromPage( from ) ;
        data->SetToPage( to ) ;
        data->SetAllPages( false );
    }
}
コード例 #3
0
ファイル: printmac.cpp プロジェクト: EdgarTx/wx
void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data )
{
    UInt32 minPage , maxPage ;
    PMGetPageRange( m_macPrintSettings , &minPage , &maxPage ) ;
    data->SetMinPage( minPage ) ;
    data->SetMaxPage( maxPage ) ;
    UInt32 copies ;
    PMGetCopies( m_macPrintSettings , &copies ) ;
    data->SetNoCopies( copies ) ;
    UInt32 from , to ;
    PMGetFirstPage( m_macPrintSettings , &from ) ;
    PMGetLastPage( m_macPrintSettings , &to ) ;
    data->SetFromPage( from ) ;
    data->SetToPage( to ) ;
}
コード例 #4
0
ファイル: printmac.cpp プロジェクト: Duion/Torsion
bool wxMacCarbonPrintData::TransferTo( wxPrintData &data )
{
    OSStatus err = noErr ;
    
    UInt32 copies ;
    err = PMGetCopies( m_macPrintSettings , &copies ) ;
    if ( err == noErr )
        data.SetNoCopies( copies ) ; 
          
    PMOrientation orientation ;
    err = PMGetOrientation(  m_macPageFormat , &orientation ) ;
    if ( err == noErr )
    {
        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
            data.SetOrientation( wxPORTRAIT  );
        else
            data.SetOrientation( wxLANDSCAPE );
    }

    // collate cannot be set
#if 0
    {
        wxMacCFStringHolder name ;
        PMPrinter printer ;
        PMSessionGetCurrentPrinter( m_macPrintSession ,
            &printer ) ;
        m_printerName = name.AsString() ;
    }
#endif
    
    PMColorMode color ;
    err = PMGetColorMode( m_macPrintSettings, &color ) ;
    if ( err == noErr )
        data.SetColour( !(color == kPMBlackAndWhite) ) ;
        
    // PMDuplexMode not yet accessible via API
    // PMQualityMode not yet accessible via API
    // todo paperSize
	PMRect rPaper;
    err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper);
    if ( err == noErr )
    {
        data.SetPaperSize( wxSize (
            (int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) ,
             (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 ) ) );
    }
    return true ;
}
コード例 #5
0
ファイル: qprinter_mac.cpp プロジェクト: gestiweb/eneboo
void QPrinter::interpret(PMPrintSettings *s)
{
  //get values
  UInt32 from, to;
  if (PMGetFirstPage(*s, &from) == noErr && PMGetLastPage(*s, &to) == noErr) {
    if (to == INT_MAX) //this means all pages!
      from = to = 0;
    setFromTo(from, to);
  }

  UInt32 copies;
  if (PMGetCopies(*s, &copies) == noErr)
    setNumCopies(copies);

  UInt32 max, min;
  if (PMGetPageRange(*s, &min, &max) == noErr) {
    // The problem here is that Apple's print dialog will always show a one even when you pass
    // it a zero. So take care of that. The other problem is that we can also call this because
    // we need to interpret the default settings, in that case, the min and max will both be
    // zero. In that case, leave them "as is" as some other functions will reset the max and
    // make everything OK when the dialog is actually called.
    int newMin = min;
    int newMax = max;

    if (newMin < 1 && newMax != 0)
      newMin = 1;
    setMinMax(newMin, newMax);
  }

  PMColorMode cm;
  if (PMGetColorMode(*s, &cm) == noErr)
    setColorMode(cm == kPMGray ? GrayScale : Color);
  // Get the current Printer Name
  CFIndex currPrinterIndex;
  PMPrinter currPrinter;
  CFArrayRef printerArray;
  OSStatus err = PMSessionCreatePrinterList(psession, &printerArray,
                                            &currPrinterIndex, &currPrinter);
  if (err != noErr)
    qWarning("Qt: QPrinter::interpret problem creating printer list %ld", err);
  if (printerArray) {
    setPrinterName(cfstring2qstring((CFStringRef)CFArrayGetValueAtIndex(printerArray,
                                                                        currPrinterIndex)));
    CFRelease(printerArray);
  }
}
コード例 #6
0
ファイル: printmac.cpp プロジェクト: EdgarTx/wx
bool wxMacCarbonPrintData::TransferTo( wxPrintData &data )
{
    OSStatus err = noErr ;

    UInt32 copies ;
    err = PMGetCopies( m_macPrintSettings , &copies ) ;
    if ( err == noErr )
        data.SetNoCopies( copies ) ;

    PMOrientation orientation ;
    err = PMGetOrientation(  m_macPageFormat , &orientation ) ;
    if ( err == noErr )
    {
        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
        {
            data.SetOrientation( wxPORTRAIT  );
            data.SetOrientationReversed( orientation == kPMReversePortrait );
        }
        else
        {
            data.SetOrientation( wxLANDSCAPE );
            data.SetOrientationReversed( orientation == kPMReverseLandscape );
        }
    }

    // collate cannot be set
#if 0
    {
        wxMacCFStringHolder name ;
        PMPrinter printer ;
        PMSessionGetCurrentPrinter( m_macPrintSession ,
            &printer ) ;
        m_printerName = name.AsString() ;
    }
#endif

#ifndef __LP64__
    PMColorMode color ;
    err = PMGetColorMode( m_macPrintSettings, &color ) ;
    if ( err == noErr )
        data.SetColour( !(color == kPMBlackAndWhite) ) ;
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    if ( &PMGetDuplex!=NULL )
    {
        PMDuplexMode mode = 0 ;
        PMGetDuplex( (PMPrintSettings) m_macPrintSettings, &mode ) ;
        switch( mode )
        {
            case kPMDuplexNoTumble :
                data.SetDuplex(wxDUPLEX_HORIZONTAL);
                break ;
            case kPMDuplexTumble :
                data.SetDuplex(wxDUPLEX_VERTICAL);
                break ;
            case kPMDuplexNone :
            default :
                data.SetDuplex(wxDUPLEX_SIMPLEX);
                break ;
        }
    }
#endif
    // PMQualityMode not yet accessible via API
    
    PMPaper paper ;
    PMGetPageFormatPaper( m_macPageFormat, &paper );
    
    PMRect rPaper;
    err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper);
    if ( err == noErr )
    {
        wxSize sz((int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) ,
             (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 ));
        data.SetPaperSize(sz);
        wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
        if (id != wxPAPER_NONE)
        {
            data.SetPaperId(id);
        }
    }
    return true ;
}
コード例 #7
0
ファイル: printmac.cpp プロジェクト: czxxjtu/wxPython-1
bool wxOSXPrintData::TransferTo( wxPrintData &data )
{
    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 )
    {
        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
        {
            data.SetOrientation( wxPORTRAIT  );
            data.SetOrientationReversed( orientation == kPMReversePortrait );
        }
        else
        {
            data.SetOrientation( wxLANDSCAPE );
            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 )
    {
        case kPMDuplexNoTumble :
            data.SetDuplex(wxDUPLEX_HORIZONTAL);
            break ;
        case kPMDuplexTumble :
            data.SetDuplex(wxDUPLEX_VERTICAL);
            break ;
        case kPMDuplexNone :
        default :
            data.SetDuplex(wxDUPLEX_SIMPLEX);
            break ;
    }
    // PMQualityMode not yet accessible via API
    
    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);
    }
    return true ;
}