]>
Commit | Line | Data |
---|---|---|
e158da36 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/osx/cocoa/printdlg.mm |
e158da36 SC |
3 | // Purpose: wxPrintDialog, wxPageSetupDialog |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
e158da36 SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #if wxUSE_PRINTING_ARCHITECTURE | |
14 | ||
15 | #include "wx/printdlg.h" | |
691745ab | 16 | #include "wx/modalhook.h" |
e158da36 SC |
17 | |
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/object.h" | |
20 | #include "wx/dcprint.h" | |
21 | #include "wx/msgdlg.h" | |
22 | #include "wx/textctrl.h" | |
23 | #include "wx/sizer.h" | |
24 | #include "wx/stattext.h" | |
25 | #endif | |
26 | ||
27 | #include "wx/osx/printdlg.h" | |
28 | #include "wx/osx/private/print.h" | |
29 | #include "wx/osx/private.h" | |
30 | ||
31 | IMPLEMENT_CLASS(wxOSXCocoaPrintData, wxOSXPrintData) | |
32 | ||
33 | wxOSXCocoaPrintData::wxOSXCocoaPrintData() | |
34 | { | |
35 | m_macPrintInfo = [[NSPrintInfo alloc] init]; | |
e158da36 SC |
36 | m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat]; |
37 | m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings]; | |
38 | m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ; | |
fc2f6088 | 39 | PMGetPageFormatPaper(m_macPageFormat, &m_macPaper); |
e158da36 SC |
40 | } |
41 | ||
42 | wxOSXCocoaPrintData::~wxOSXCocoaPrintData() | |
43 | { | |
44 | [m_macPrintInfo release]; | |
45 | } | |
46 | ||
47 | void wxOSXCocoaPrintData::UpdateFromPMState() | |
48 | { | |
e158da36 SC |
49 | [m_macPrintInfo updateFromPMPageFormat]; |
50 | [m_macPrintInfo updateFromPMPrintSettings]; | |
51 | } | |
52 | ||
53 | void wxOSXCocoaPrintData::UpdateToPMState() | |
54 | { | |
e158da36 SC |
55 | m_macPageFormat = (PMPageFormat) [m_macPrintInfo PMPageFormat]; |
56 | m_macPrintSettings = (PMPrintSettings) [m_macPrintInfo PMPrintSettings]; | |
57 | m_macPrintSession = (PMPrintSession) [m_macPrintInfo PMPrintSession] ; | |
58 | } | |
59 | ||
60 | int wxMacPrintDialog::ShowModal() | |
61 | { | |
691745ab | 62 | WX_HOOK_MODAL_DIALOG(); |
643e9cf9 | 63 | |
e158da36 SC |
64 | m_printDialogData.GetPrintData().ConvertToNative(); |
65 | ||
66 | int result = wxID_CANCEL; | |
03647350 | 67 | |
e158da36 SC |
68 | NSPrintPanel* panel = [NSPrintPanel printPanel]; |
69 | NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_printDialogData.GetPrintData().GetNativeData())->GetNSPrintInfo(); | |
f16170b0 VZ |
70 | |
71 | NSMutableDictionary* dict = [printInfo printSettings]; | |
72 | [dict setValue:[NSNumber numberWithInt:m_printDialogData.GetMinPage()] forKey:@"com_apple_print_PrintSettings_PMFirstPage"]; | |
73 | [dict setValue:[NSNumber numberWithInt:m_printDialogData.GetMaxPage()] forKey:@"com_apple_print_PrintSettings_PMLastPage"]; | |
74 | ||
9d5cfd0e | 75 | if ( (NSInteger)[panel runModalWithPrintInfo:printInfo] == NSOKButton ) |
e158da36 SC |
76 | { |
77 | result = wxID_OK; | |
78 | m_printDialogData.GetPrintData().ConvertFromNative(); | |
79 | ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData ); | |
80 | } | |
81 | ||
82 | return result; | |
83 | } | |
84 | ||
85 | int wxMacPageSetupDialog::ShowModal() | |
86 | { | |
691745ab | 87 | WX_HOOK_MODAL_DIALOG(); |
643e9cf9 | 88 | |
e158da36 SC |
89 | m_pageSetupData.GetPrintData().ConvertToNative(); |
90 | ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->TransferFrom( &m_pageSetupData ); | |
91 | ||
92 | int result = wxID_CANCEL; | |
93 | ||
94 | NSPageLayout *pageLayout = [NSPageLayout pageLayout]; | |
95 | NSPrintInfo* printInfo = ((wxOSXCocoaPrintData*)m_pageSetupData.GetPrintData().GetNativeData())->GetNSPrintInfo(); | |
96 | if ( [pageLayout runModalWithPrintInfo:printInfo] == NSOKButton ) | |
97 | { | |
98 | result = wxID_OK; | |
99 | m_pageSetupData.GetPrintData().ConvertFromNative(); | |
100 | m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() ); | |
101 | } | |
03647350 | 102 | |
e158da36 SC |
103 | return result; |
104 | } | |
105 | ||
106 | #endif |