]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | ///////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/carbon/printdlg.cpp |
489468fe SC |
3 | // Purpose: wxPrintDialog, wxPageSetupDialog |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
489468fe 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" | |
16 | ||
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/object.h" | |
19 | #include "wx/dcprint.h" | |
20 | #include "wx/msgdlg.h" | |
21 | #include "wx/textctrl.h" | |
22 | #include "wx/sizer.h" | |
23 | #include "wx/stattext.h" | |
24 | #endif | |
25 | ||
1f0c8f31 SC |
26 | #include "wx/osx/printdlg.h" |
27 | #include "wx/osx/private/print.h" | |
28 | #include "wx/osx/private.h" | |
489468fe | 29 | #include "wx/statline.h" |
691745ab | 30 | #include "wx/modalhook.h" |
489468fe | 31 | |
489468fe SC |
32 | int wxMacPrintDialog::ShowModal() |
33 | { | |
691745ab | 34 | WX_HOOK_MODAL_DIALOG(); |
643e9cf9 | 35 | |
489468fe | 36 | m_printDialogData.GetPrintData().ConvertToNative(); |
c347101b | 37 | ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData ); |
489468fe SC |
38 | |
39 | int result = wxID_CANCEL; | |
03647350 | 40 | |
489468fe SC |
41 | OSErr err = noErr; |
42 | Boolean accepted; | |
c347101b | 43 | wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData(); |
445e564f | 44 | wxDialog::OSXBeginModalDialog(); |
c347101b SC |
45 | err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(), |
46 | nativeData->GetPageFormat(), &accepted ); | |
445e564f | 47 | wxDialog::OSXEndModalDialog(); |
489468fe SC |
48 | |
49 | if ((err == noErr) && !accepted) | |
50 | { | |
51 | // user clicked Cancel button | |
52 | err = kPMCancel; | |
53 | } | |
54 | ||
55 | if (err == noErr) | |
56 | { | |
57 | result = wxID_OK; | |
58 | } | |
59 | ||
60 | if ((err != noErr) && (err != kPMCancel)) | |
61 | { | |
62 | wxString message; | |
63 | ||
64 | message.Printf( wxT("Print Error %d"), err ); | |
65 | wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK ); | |
66 | dialog.ShowModal(); | |
67 | } | |
68 | ||
69 | if (result == wxID_OK) | |
70 | { | |
71 | m_printDialogData.GetPrintData().ConvertFromNative(); | |
c347101b | 72 | ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData ); |
489468fe | 73 | } |
489468fe SC |
74 | return result; |
75 | } | |
489468fe | 76 | |
489468fe SC |
77 | int wxMacPageSetupDialog::ShowModal() |
78 | { | |
691745ab | 79 | WX_HOOK_MODAL_DIALOG(); |
643e9cf9 | 80 | |
489468fe | 81 | m_pageSetupData.GetPrintData().ConvertToNative(); |
c347101b SC |
82 | wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData(); |
83 | nativeData->TransferFrom( &m_pageSetupData ); | |
489468fe SC |
84 | |
85 | int result = wxID_CANCEL; | |
489468fe SC |
86 | OSErr err = noErr; |
87 | Boolean accepted; | |
88 | ||
445e564f | 89 | wxDialog::OSXBeginModalDialog(); |
c347101b | 90 | err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(), |
489468fe | 91 | &accepted ); |
445e564f | 92 | wxDialog::OSXEndModalDialog(); |
489468fe SC |
93 | |
94 | if ((err == noErr) && !accepted) | |
95 | { | |
96 | // user clicked Cancel button | |
97 | err = kPMCancel; | |
98 | } | |
99 | ||
100 | // If the user did not cancel, flatten and save the PageFormat object | |
101 | // with our document. | |
102 | if (err == noErr) | |
103 | { | |
104 | result = wxID_OK; | |
105 | } | |
106 | ||
107 | if ((err != noErr) && (err != kPMCancel)) | |
108 | { | |
109 | wxString message; | |
110 | ||
111 | message.Printf( wxT("Print Error %d"), err ); | |
112 | wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK ); | |
113 | dialog.ShowModal(); | |
114 | } | |
115 | ||
116 | if (result == wxID_OK) | |
117 | { | |
118 | m_pageSetupData.GetPrintData().ConvertFromNative(); | |
119 | m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() ); | |
c347101b | 120 | nativeData->TransferTo( &m_pageSetupData ); |
489468fe | 121 | } |
489468fe SC |
122 | return result; |
123 | } | |
489468fe SC |
124 | |
125 | #endif |