1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/printdlg.mm
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #if wxUSE_PRINTING_ARCHITECTURE
16 #include "wx/printdlg.h"
19 #include "wx/object.h"
20 #include "wx/dcprint.h"
21 #include "wx/msgdlg.h"
22 #include "wx/textctrl.h"
24 #include "wx/stattext.h"
27 #include "wx/osx/printdlg.h"
28 #include "wx/osx/private/print.h"
29 #include "wx/osx/private.h"
31 IMPLEMENT_CLASS(wxOSXCocoaPrintData, wxOSXPrintData)
33 wxOSXCocoaPrintData::wxOSXCocoaPrintData()
35 m_macPrintInfo = [[NSPrintInfo alloc] init];
37 m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
38 m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
39 m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
40 PMGetPageFormatPaper(m_macPageFormat, &m_macPaper);
43 wxOSXCocoaPrintData::~wxOSXCocoaPrintData()
45 [m_macPrintInfo release];
48 void wxOSXCocoaPrintData::UpdateFromPMState()
51 [m_macPrintInfo updateFromPMPageFormat];
52 [m_macPrintInfo updateFromPMPrintSettings];
55 void wxOSXCocoaPrintData::UpdateToPMState()
58 m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat];
59 m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings];
60 m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ;
63 int wxMacPrintDialog::ShowModal()
65 m_printDialogData.GetPrintData().ConvertToNative();
67 int result = wxID_CANCEL;
69 NSPrintPanel* panel = [NSPrintPanel printPanel];
70 NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_printDialogData.GetPrintData().GetNativeData())->GetNSPrintInfo();
71 if ( (NSInteger)[panel runModalWithPrintInfo:printInfo] == NSOKButton )
74 m_printDialogData.GetPrintData().ConvertFromNative();
75 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
81 int wxMacPageSetupDialog::ShowModal()
83 m_pageSetupData.GetPrintData().ConvertToNative();
84 ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData );
86 int result = wxID_CANCEL;
88 NSPageLayout *pageLayout = [NSPageLayout pageLayout];
89 NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->GetNSPrintInfo();
90 if ( [pageLayout runModalWithPrintInfo:printInfo] == NSOKButton )
93 m_pageSetupData.GetPrintData().ConvertFromNative();
94 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );