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