]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/printdlg.cpp
guarding open combo box against AppDefined NSEvents issued by wxEventLoop::WakeUp...
[wxWidgets.git] / src / osx / carbon / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
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"
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 #include "wx/statline.h"
31 #include "wx/modalhook.h"
32
33 int wxMacPrintDialog::ShowModal()
34 {
35 WX_HOOK_MODAL_DIALOG();
36
37 m_printDialogData.GetPrintData().ConvertToNative();
38 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
39
40 int result = wxID_CANCEL;
41
42 OSErr err = noErr;
43 Boolean accepted;
44 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
45 wxDialog::OSXBeginModalDialog();
46 err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
47 nativeData->GetPageFormat(), &accepted );
48 wxDialog::OSXEndModalDialog();
49
50 if ((err == noErr) && !accepted)
51 {
52 // user clicked Cancel button
53 err = kPMCancel;
54 }
55
56 if (err == noErr)
57 {
58 result = wxID_OK;
59 }
60
61 if ((err != noErr) && (err != kPMCancel))
62 {
63 wxString message;
64
65 message.Printf( wxT("Print Error %d"), err );
66 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
67 dialog.ShowModal();
68 }
69
70 if (result == wxID_OK)
71 {
72 m_printDialogData.GetPrintData().ConvertFromNative();
73 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
74 }
75 return result;
76 }
77
78 int wxMacPageSetupDialog::ShowModal()
79 {
80 WX_HOOK_MODAL_DIALOG();
81
82 m_pageSetupData.GetPrintData().ConvertToNative();
83 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
84 nativeData->TransferFrom( &m_pageSetupData );
85
86 int result = wxID_CANCEL;
87 OSErr err = noErr;
88 Boolean accepted;
89
90 wxDialog::OSXBeginModalDialog();
91 err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
92 &accepted );
93 wxDialog::OSXEndModalDialog();
94
95 if ((err == noErr) && !accepted)
96 {
97 // user clicked Cancel button
98 err = kPMCancel;
99 }
100
101 // If the user did not cancel, flatten and save the PageFormat object
102 // with our document.
103 if (err == noErr)
104 {
105 result = wxID_OK;
106 }
107
108 if ((err != noErr) && (err != kPMCancel))
109 {
110 wxString message;
111
112 message.Printf( wxT("Print Error %d"), err );
113 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
114 dialog.ShowModal();
115 }
116
117 if (result == wxID_OK)
118 {
119 m_pageSetupData.GetPrintData().ConvertFromNative();
120 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
121 nativeData->TransferTo( &m_pageSetupData );
122 }
123 return result;
124 }
125
126 #endif