1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/core/printmac.cpp
3 // Purpose: wxMacPrinter framework
4 // Author: Julian Smart, Stefan Csomor
8 // Copyright: (c) Julian Smart, Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if wxUSE_PRINTING_ARCHITECTURE
25 #include "wx/msgdlg.h"
26 #include "wx/dcprint.h"
30 #include "wx/osx/private.h"
32 #include "wx/osx/printmac.h"
33 #include "wx/osx/private/print.h"
35 #include "wx/printdlg.h"
37 #include "wx/osx/printdlg.h"
42 // move to print_osx.cpp
45 static int ResolutionSorter(const void *e1
, const void *e2
)
47 const PMResolution
*res1
= (const PMResolution
*)e1
;
48 const PMResolution
*res2
= (const PMResolution
*)e2
;
49 int area1
= res1
->hRes
* res1
->vRes
;
50 int area2
= res2
->hRes
* res2
->vRes
;
54 else if (area1
> area2
)
60 static PMResolution
*GetSupportedResolutions(PMPrinter printer
, UInt32
*count
)
62 PMResolution res
, *resolutions
= NULL
;
63 OSStatus status
= PMPrinterGetPrinterResolutionCount(printer
, count
);
64 if (status
== kPMNotImplemented
)
66 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
67 resolutions
= (PMResolution
*)malloc(sizeof(PMResolution
) * 4);
69 if (PMPrinterGetPrinterResolution(printer
, kPMMinRange
, &res
) == noErr
)
70 resolutions
[(*count
)++] = res
;
71 if (PMPrinterGetPrinterResolution(printer
, kPMMinSquareResolution
, &res
) == noErr
)
72 resolutions
[(*count
)++] = res
;
73 if (PMPrinterGetPrinterResolution(printer
, kPMMaxSquareResolution
, &res
) == noErr
)
74 resolutions
[(*count
)++] = res
;
75 if (PMPrinterGetPrinterResolution(printer
, kPMMaxRange
, &res
) == noErr
)
76 resolutions
[(*count
)++] = res
;
79 if (PMPrinterGetPrinterResolution(printer
, kPMDefaultResolution
, &res
) == noErr
)
80 resolutions
[(*count
)++] = res
;
84 else if (status
== noErr
)
86 resolutions
= (PMResolution
*)malloc(sizeof(PMResolution
) * (*count
));
88 for (UInt32 i
= 0; i
< *count
; i
++)
90 if (PMPrinterGetIndexedPrinterResolution(printer
, i
+ 1, &res
) == noErr
)
91 resolutions
[realCount
++] = res
;
93 qsort(resolutions
, realCount
, sizeof(PMResolution
), ResolutionSorter
);
97 if ((*count
== 0) && (resolutions
))
107 IMPLEMENT_DYNAMIC_CLASS(wxOSXPrintData
, wxPrintNativeDataBase
)
109 bool wxOSXPrintData::IsOk() const
111 return (m_macPageFormat
!= kPMNoPageFormat
) && (m_macPrintSettings
!= kPMNoPrintSettings
) && (m_macPrintSession
!= kPMNoReference
);
114 wxOSXPrintData::wxOSXPrintData()
116 m_macPageFormat
= kPMNoPageFormat
;
117 m_macPrintSettings
= kPMNoPrintSettings
;
118 m_macPrintSession
= kPMNoReference
;
119 m_macPaper
= kPMNoData
;
122 wxOSXPrintData::~wxOSXPrintData()
126 void wxOSXPrintData::UpdateFromPMState()
130 void wxOSXPrintData::UpdateToPMState()
134 bool wxOSXPrintData::TransferFrom( const wxPrintData
&data
)
136 CFArrayRef printerList
;
137 CFIndex index
, count
;
140 if (PMServerCreatePrinterList(kPMServerLocal
, &printerList
) == noErr
)
142 PMPrinter printer
= NULL
;
143 count
= CFArrayGetCount(printerList
);
144 for (index
= 0; index
< count
; index
++)
146 printer
= (PMPrinter
)CFArrayGetValueAtIndex(printerList
, index
);
147 if ((data
.GetPrinterName().empty()) && (PMPrinterIsDefault(printer
)))
151 name
= PMPrinterGetName(printer
);
153 if (data
.GetPrinterName() == wxCFStringRef(name
).AsString())
158 PMSessionSetCurrentPMPrinter(m_macPrintSession
, printer
);
159 CFRelease(printerList
);
163 PMSessionGetCurrentPrinter(m_macPrintSession
, &printer
);
165 wxSize papersize
= wxDefaultSize
;
166 const wxPaperSize paperId
= data
.GetPaperId();
167 if ( paperId
!= wxPAPER_NONE
&& wxThePrintPaperDatabase
)
169 papersize
= wxThePrintPaperDatabase
->GetSize(paperId
);
170 if ( papersize
!= wxDefaultSize
)
178 papersize
= data
.GetPaperSize();
181 if ( papersize
!= wxDefaultSize
)
183 papersize
.x
= (wxInt32
) (papersize
.x
* mm2pt
);
184 papersize
.y
= (wxInt32
) (papersize
.y
* mm2pt
);
186 double height
, width
;
187 PMPaperGetHeight(m_macPaper
, &height
);
188 PMPaperGetWidth(m_macPaper
, &width
);
190 if ( fabs( width
- papersize
.x
) >= 5 ||
191 fabs( height
- papersize
.y
) >= 5 )
193 // we have to change the current paper
194 CFArrayRef paperlist
= 0 ;
195 if ( PMPrinterGetPaperList( printer
, &paperlist
) == noErr
)
197 PMPaper bestPaper
= kPMNoData
;
198 CFIndex top
= CFArrayGetCount(paperlist
);
199 for ( CFIndex i
= 0 ; i
< top
; ++ i
)
201 PMPaper paper
= (PMPaper
) CFArrayGetValueAtIndex( paperlist
, i
);
202 PMPaperGetHeight(paper
, &height
);
203 PMPaperGetWidth(paper
, &width
);
204 if ( fabs( width
- papersize
.x
) < 5 &&
205 fabs( height
- papersize
.y
) < 5 )
207 // TODO test for duplicate hits and use additional
208 // criteria for best match
212 PMPaper paper
= kPMNoData
;
213 if ( bestPaper
== kPMNoData
)
215 const PMPaperMargins margins
= { 0.0, 0.0, 0.0, 0.0 };
216 wxString id
, name(wxT("Custom paper"));
217 id
.Printf(wxT("wxPaperCustom%dx%d"), papersize
.x
, papersize
.y
);
219 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
220 if ( PMPaperCreateCustom
!= NULL
)
222 PMPaperCreateCustom(printer
, wxCFStringRef( id
, wxFont::GetDefaultEncoding() ), wxCFStringRef( name
, wxFont::GetDefaultEncoding() ),
223 papersize
.x
, papersize
.y
, &margins
, &paper
);
226 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
227 if ( paper
== kPMNoData
)
229 PMPaperCreate(printer
, wxCFStringRef( id
, wxFont::GetDefaultEncoding() ), wxCFStringRef( name
, wxFont::GetDefaultEncoding() ),
230 papersize
.x
, papersize
.y
, &margins
, &paper
);
234 if ( bestPaper
!= kPMNoData
)
236 PMPageFormat pageFormat
;
237 PMCreatePageFormatWithPMPaper(&pageFormat
, bestPaper
);
238 PMCopyPageFormat( pageFormat
, m_macPageFormat
);
239 PMRelease(pageFormat
);
240 PMGetPageFormatPaper(m_macPageFormat
, &m_macPaper
);
247 PMSetCopies( m_macPrintSettings
, data
.GetNoCopies() , false ) ;
248 PMSetCollate(m_macPrintSettings
, data
.GetCollate());
249 if ( data
.IsOrientationReversed() )
250 PMSetOrientation( m_macPageFormat
, ( data
.GetOrientation() == wxLANDSCAPE
) ?
251 kPMReverseLandscape
: kPMReversePortrait
, false ) ;
253 PMSetOrientation( m_macPageFormat
, ( data
.GetOrientation() == wxLANDSCAPE
) ?
254 kPMLandscape
: kPMPortrait
, false ) ;
256 PMDuplexMode mode
= 0 ;
257 switch( data
.GetDuplex() )
259 case wxDUPLEX_HORIZONTAL
:
260 mode
= kPMDuplexNoTumble
;
262 case wxDUPLEX_VERTICAL
:
263 mode
= kPMDuplexTumble
;
265 case wxDUPLEX_SIMPLEX
:
267 mode
= kPMDuplexNone
;
270 PMSetDuplex( m_macPrintSettings
, mode
) ;
273 if ( data
.IsOrientationReversed() )
274 PMSetOrientation( m_macPageFormat
, ( data
.GetOrientation() == wxLANDSCAPE
) ?
275 kPMReverseLandscape
: kPMReversePortrait
, false ) ;
277 PMSetOrientation( m_macPageFormat
, ( data
.GetOrientation() == wxLANDSCAPE
) ?
278 kPMLandscape
: kPMPortrait
, false ) ;
281 PMResolution
*resolutions
= GetSupportedResolutions(printer
, &resCount
);
284 wxPrintQuality quality
= data
.GetQuality();
286 quality
= wxPRINT_QUALITY_HIGH
;
288 PMResolution res
= resolutions
[((quality
- wxPRINT_QUALITY_DRAFT
) * (resCount
- 1)) / 3];
289 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
290 if ( PMPrinterSetOutputResolution
!= NULL
)
291 PMPrinterSetOutputResolution(printer
, m_macPrintSettings
, &res
);
295 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
296 PMSetResolution( m_macPageFormat
, &res
);
302 // after setting the new resolution the format has to be updated, otherwise the page rect remains
303 // at the 'old' scaling
305 PMSessionValidatePageFormat(m_macPrintSession
,
306 m_macPageFormat
, kPMDontWantBoolean
);
307 PMSessionValidatePrintSettings(m_macPrintSession
,
308 m_macPrintSettings
, kPMDontWantBoolean
);
316 bool wxOSXPrintData::TransferTo( wxPrintData
&data
)
318 OSStatus err
= noErr
;
323 err
= PMGetCopies( m_macPrintSettings
, &copies
) ;
325 data
.SetNoCopies( copies
) ;
327 PMOrientation orientation
;
328 err
= PMGetOrientation( m_macPageFormat
, &orientation
) ;
331 if ( orientation
== kPMPortrait
|| orientation
== kPMReversePortrait
)
333 data
.SetOrientation( wxPORTRAIT
);
334 data
.SetOrientationReversed( orientation
== kPMReversePortrait
);
338 data
.SetOrientation( wxLANDSCAPE
);
339 data
.SetOrientationReversed( orientation
== kPMReverseLandscape
);
344 if (PMGetCollate(m_macPrintSettings
, &collate
) == noErr
)
345 data
.SetCollate(collate
);
349 PMSessionGetCurrentPrinter( m_macPrintSession
, &printer
);
350 if (PMPrinterIsDefault(printer
))
351 data
.SetPrinterName(wxEmptyString
);
354 name
= PMPrinterGetName(printer
);
356 data
.SetPrinterName(wxCFStringRef(name
).AsString());
359 PMDuplexMode mode
= 0 ;
360 PMGetDuplex( m_macPrintSettings
, &mode
) ;
363 case kPMDuplexNoTumble
:
364 data
.SetDuplex(wxDUPLEX_HORIZONTAL
);
366 case kPMDuplexTumble
:
367 data
.SetDuplex(wxDUPLEX_VERTICAL
);
371 data
.SetDuplex(wxDUPLEX_SIMPLEX
);
375 /* assume high quality, will change below if we are able to */
376 data
.SetQuality(wxPRINT_QUALITY_HIGH
);
378 PMResolution
*resolutions
;
380 resolutions
= GetSupportedResolutions(printer
, &resCount
);
385 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
386 if ( PMPrinterGetOutputResolution
!= NULL
)
388 if ( PMPrinterGetOutputResolution(printer
, m_macPrintSettings
, &res
) == noErr
)
392 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
393 if (PMPrinterGetPrinterResolution(printer
, kPMCurrentValue
, &res
) == noErr
)
399 for (i
= 0; i
< resCount
; i
++)
401 if ((resolutions
[i
].hRes
== res
.hRes
) && (resolutions
[i
].vRes
= res
.vRes
))
405 data
.SetQuality((((i
+ 1) * 3) / resCount
) + wxPRINT_QUALITY_DRAFT
);
410 double height
, width
;
411 PMPaperGetHeight(m_macPaper
, &height
);
412 PMPaperGetWidth(m_macPaper
, &width
);
414 wxSize
sz((int)(width
* pt2mm
+ 0.5 ) ,
415 (int)(height
* pt2mm
+ 0.5 ));
416 data
.SetPaperSize(sz
);
417 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
418 if (id
!= wxPAPER_NONE
)
425 void wxOSXPrintData::TransferFrom( wxPageSetupData
*WXUNUSED(data
) )
427 // should we setup the page rect here ?
428 // since MacOS sometimes has two same paper rects with different
429 // page rects we could make it roundtrip safe perhaps
432 void wxOSXPrintData::TransferTo( wxPageSetupData
* data
)
438 OSStatus err
= PMGetUnadjustedPaperRect(m_macPageFormat
, &rPaper
);
441 wxSize
sz((int)(( rPaper
.right
- rPaper
.left
) * pt2mm
+ 0.5 ) ,
442 (int)(( rPaper
.bottom
- rPaper
.top
) * pt2mm
+ 0.5 ));
443 data
->SetPaperSize(sz
);
446 err
= PMGetUnadjustedPageRect(m_macPageFormat
, &rPage
) ;
449 data
->SetMinMarginTopLeft( wxPoint (
450 (int)(((double) rPage
.left
- rPaper
.left
) * pt2mm
) ,
451 (int)(((double) rPage
.top
- rPaper
.top
) * pt2mm
) ) ) ;
453 data
->SetMinMarginBottomRight( wxPoint (
454 (wxCoord
)(((double) rPaper
.right
- rPage
.right
) * pt2mm
),
455 (wxCoord
)(((double) rPaper
.bottom
- rPage
.bottom
) * pt2mm
)) ) ;
457 if ( data
->GetMarginTopLeft().x
< data
->GetMinMarginTopLeft().x
)
458 data
->SetMarginTopLeft( wxPoint( data
->GetMinMarginTopLeft().x
,
459 data
->GetMarginTopLeft().y
) ) ;
461 if ( data
->GetMarginBottomRight().x
< data
->GetMinMarginBottomRight().x
)
462 data
->SetMarginBottomRight( wxPoint( data
->GetMinMarginBottomRight().x
,
463 data
->GetMarginBottomRight().y
) );
465 if ( data
->GetMarginTopLeft().y
< data
->GetMinMarginTopLeft().y
)
466 data
->SetMarginTopLeft( wxPoint( data
->GetMarginTopLeft().x
, data
->GetMinMarginTopLeft().y
) );
468 if ( data
->GetMarginBottomRight().y
< data
->GetMinMarginBottomRight().y
)
469 data
->SetMarginBottomRight( wxPoint( data
->GetMarginBottomRight().x
,
470 data
->GetMinMarginBottomRight().y
) );
475 void wxOSXPrintData::TransferTo( wxPrintDialogData
* data
)
480 UInt32 minPage
, maxPage
;
481 PMGetPageRange( m_macPrintSettings
, &minPage
, &maxPage
) ;
482 data
->SetMinPage( minPage
) ;
483 data
->SetMaxPage( maxPage
) ;
485 PMGetCopies( m_macPrintSettings
, &copies
) ;
486 data
->SetNoCopies( copies
) ;
488 PMGetFirstPage( m_macPrintSettings
, &from
) ;
489 PMGetLastPage( m_macPrintSettings
, &to
) ;
490 if ( to
>= 0x7FFFFFFF ) // due to an OS Bug we don't get back kPMPrintAllPages
492 data
->SetAllPages( true ) ;
493 // This means all pages, more or less
494 data
->SetFromPage(1);
495 data
->SetToPage(9999);
499 data
->SetFromPage( from
) ;
500 data
->SetToPage( to
) ;
501 data
->SetAllPages( false );
505 void wxOSXPrintData::TransferFrom( wxPrintDialogData
* data
)
507 // Respect the value of m_printAllPages
508 if ( data
->GetAllPages() )
509 PMSetPageRange( m_macPrintSettings
, data
->GetMinPage() , (UInt32
) kPMPrintAllPages
) ;
511 PMSetPageRange( m_macPrintSettings
, data
->GetMinPage() , data
->GetMaxPage() ) ;
512 PMSetCopies( m_macPrintSettings
, data
->GetNoCopies() , false ) ;
513 PMSetFirstPage( m_macPrintSettings
, data
->GetFromPage() , false ) ;
515 if (data
->GetAllPages() || data
->GetFromPage() == 0)
516 PMSetLastPage( m_macPrintSettings
, (UInt32
) kPMPrintAllPages
, true ) ;
518 PMSetLastPage( m_macPrintSettings
, (UInt32
) data
->GetToPage() , false ) ;
524 wxPrintNativeDataBase
* wxOSXCreatePrintData()
527 return new wxOSXCocoaPrintData();
528 #elif wxOSX_USE_CARBON
529 return new wxOSXCarbonPrintData();
539 IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter
, wxPrinterBase
)
541 wxMacPrinter::wxMacPrinter(wxPrintDialogData
*data
):
546 wxMacPrinter::~wxMacPrinter(void)
550 bool wxMacPrinter::Print(wxWindow
*parent
, wxPrintout
*printout
, bool prompt
)
553 sm_abortWindow
= NULL
;
557 sm_lastError
= wxPRINTER_ERROR
;
561 printout
->SetIsPreview(false);
563 if (m_printDialogData
.GetMinPage() < 1)
564 m_printDialogData
.SetMinPage(1);
565 if (m_printDialogData
.GetMaxPage() < 1)
566 m_printDialogData
.SetMaxPage(9999);
568 // Create a suitable device context
569 wxPrinterDC
*dc
= NULL
;
572 wxMacPrintDialog
dialog(parent
, & m_printDialogData
);
573 if (dialog
.ShowModal() == wxID_OK
)
575 dc
= wxDynamicCast(dialog
.GetPrintDC(), wxPrinterDC
);
577 m_printDialogData
= dialog
.GetPrintDialogData();
582 dc
= new wxPrinterDC( m_printDialogData
.GetPrintData() ) ;
585 // May have pressed cancel.
586 if (!dc
|| !dc
->IsOk())
592 // on the mac we have always pixels as addressing mode with 72 dpi
593 printout
->SetPPIScreen(72, 72);
597 wxOSXPrintData
* nativeData
= (wxOSXPrintData
*)
598 (m_printDialogData
.GetPrintData().GetNativeData());
600 if (PMSessionGetCurrentPrinter(nativeData
->GetPrintSession(), &printer
) == noErr
)
602 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
603 if ( PMPrinterGetOutputResolution
!= NULL
)
605 if (PMPrinterGetOutputResolution( printer
, nativeData
->GetPrintSettings(), &res
) == -9589 /* kPMKeyNotFound */ )
607 res
.hRes
= res
.vRes
= 300;
613 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
614 PMPrinterGetPrinterResolution(printer
, kPMCurrentValue
, &res
);
618 printout
->SetPPIPrinter(int(res
.hRes
), int(res
.vRes
));
620 // Set printout parameters
625 printout
->SetPageSizePixels((int)w
, (int)h
);
626 printout
->SetPaperRectPixels(dc
->GetPaperRect());
628 dc
->GetSizeMM(&mw
, &mh
);
629 printout
->SetPageSizeMM((int)mw
, (int)mh
);
631 // Create an abort window
634 printout
->OnPreparePrinting();
636 // Get some parameters from the printout, if defined
637 int fromPage
, toPage
;
638 int minPage
, maxPage
;
639 printout
->GetPageInfo(&minPage
, &maxPage
, &fromPage
, &toPage
);
643 sm_lastError
= wxPRINTER_ERROR
;
647 // Only set min and max, because from and to will be
649 m_printDialogData
.SetMinPage(minPage
);
650 m_printDialogData
.SetMaxPage(maxPage
);
652 printout
->OnBeginPrinting();
654 bool keepGoing
= true;
656 if (!printout
->OnBeginDocument(m_printDialogData
.GetFromPage(), m_printDialogData
.GetToPage()))
659 wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK
, parent
);
663 for (pn
= m_printDialogData
.GetFromPage();
664 keepGoing
&& (pn
<= m_printDialogData
.GetToPage()) && printout
->HasPage(pn
);
674 keepGoing
= printout
->OnPrintPage(pn
);
678 printout
->OnEndDocument();
680 printout
->OnEndPrinting();
684 sm_abortWindow
->Show(false);
685 delete sm_abortWindow
;
686 sm_abortWindow
= NULL
;
696 wxDC
* wxMacPrinter::PrintDialog(wxWindow
*parent
)
700 wxPrintDialog
dialog(parent
, & m_printDialogData
);
701 int ret
= dialog
.ShowModal();
705 dc
= dialog
.GetPrintDC();
706 m_printDialogData
= dialog
.GetPrintDialogData();
712 bool wxMacPrinter::Setup(wxWindow
*WXUNUSED(parent
))
715 wxPrintDialog
dialog(parent
, & m_printDialogData
);
716 dialog
.GetPrintDialogData().SetSetupDialog(true);
718 int ret
= dialog
.ShowModal();
721 m_printDialogData
= dialog
.GetPrintDialogData();
723 return (ret
== wxID_OK
);
733 IMPLEMENT_CLASS(wxMacPrintPreview
, wxPrintPreviewBase
)
735 wxMacPrintPreview::wxMacPrintPreview(wxPrintout
*printout
,
736 wxPrintout
*printoutForPrinting
,
737 wxPrintDialogData
*data
)
738 : wxPrintPreviewBase(printout
, printoutForPrinting
, data
)
743 wxMacPrintPreview::wxMacPrintPreview(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
, wxPrintData
*data
):
744 wxPrintPreviewBase(printout
, printoutForPrinting
, data
)
749 wxMacPrintPreview::~wxMacPrintPreview(void)
753 bool wxMacPrintPreview::Print(bool interactive
)
755 if (!m_printPrintout
)
758 wxMacPrinter
printer(&m_printDialogData
);
759 return printer
.Print(m_previewFrame
, m_printPrintout
, interactive
);
762 void wxMacPrintPreview::DetermineScaling(void)
764 int screenWidth
, screenHeight
;
765 wxDisplaySize( &screenWidth
, &screenHeight
) ;
767 wxSize
ppiScreen( 72 , 72 ) ;
768 wxSize
ppiPrinter( 72 , 72 ) ;
770 // Note that with Leopard, screen dpi=72 is no longer a given
771 m_previewPrintout
->SetPPIScreen( ppiScreen
.x
, ppiScreen
.y
) ;
777 // Get a device context for the currently selected printer
778 wxPrinterDC
printerDC(m_printDialogData
.GetPrintData());
779 if (printerDC
.IsOk())
781 printerDC
.GetSizeMM(&ww
, &hh
);
782 printerDC
.GetSize( &w
, &h
) ;
783 ppiPrinter
= printerDC
.GetPPI() ;
784 paperRect
= printerDC
.GetPaperRect();
792 ww
= (wxCoord
) (w
* 25.4 / ppiPrinter
.x
) ;
793 hh
= (wxCoord
) (h
* 25.4 / ppiPrinter
.y
) ;
794 paperRect
= wxRect(0, 0, w
, h
);
800 m_previewPrintout
->SetPageSizePixels(w
, h
) ;
801 m_previewPrintout
->SetPageSizeMM(ww
, hh
);
802 m_previewPrintout
->SetPaperRectPixels(paperRect
);
803 m_previewPrintout
->SetPPIPrinter( ppiPrinter
.x
, ppiPrinter
.y
) ;
805 m_previewScaleX
= float(ppiScreen
.x
) / ppiPrinter
.x
;
806 m_previewScaleY
= float(ppiScreen
.y
) / ppiPrinter
.y
;
810 // end of print_osx.cpp
815 IMPLEMENT_DYNAMIC_CLASS(wxOSXCarbonPrintData
, wxOSXPrintData
)
817 wxOSXCarbonPrintData::wxOSXCarbonPrintData()
819 if ( PMCreateSession( &m_macPrintSession
) == noErr
)
821 if ( PMCreatePageFormat(&m_macPageFormat
) == noErr
)
823 PMSessionDefaultPageFormat(m_macPrintSession
,
825 PMGetPageFormatPaper(m_macPageFormat
, &m_macPaper
);
828 if ( PMCreatePrintSettings(&m_macPrintSettings
) == noErr
)
830 PMSessionDefaultPrintSettings(m_macPrintSession
,
836 wxOSXCarbonPrintData::~wxOSXCarbonPrintData()
838 (void)PMRelease(m_macPageFormat
);
839 (void)PMRelease(m_macPrintSettings
);
840 (void)PMRelease(m_macPrintSession
);