]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/printdlg.cpp
wxMSW: Use TBSTYLE_AUTOSIZE for toolbar buttons with horizontal text.
[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
32 int wxMacPrintDialog::ShowModal()
33 {
34 m_printDialogData.GetPrintData().ConvertToNative();
35 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferFrom( &m_printDialogData );
36
37 int result = wxID_CANCEL;
38
39 OSErr err = noErr;
40 Boolean accepted;
41 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData();
42 wxDialog::OSXBeginModalDialog();
43 err = PMSessionPrintDialog(nativeData->GetPrintSession(), nativeData->GetPrintSettings(),
44 nativeData->GetPageFormat(), &accepted );
45 wxDialog::OSXEndModalDialog();
46
47 if ((err == noErr) && !accepted)
48 {
49 // user clicked Cancel button
50 err = kPMCancel;
51 }
52
53 if (err == noErr)
54 {
55 result = wxID_OK;
56 }
57
58 if ((err != noErr) && (err != kPMCancel))
59 {
60 wxString message;
61
62 message.Printf( wxT("Print Error %d"), err );
63 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
64 dialog.ShowModal();
65 }
66
67 if (result == wxID_OK)
68 {
69 m_printDialogData.GetPrintData().ConvertFromNative();
70 ((wxOSXPrintData*)m_printDialogData.GetPrintData().GetNativeData())->TransferTo( &m_printDialogData );
71 }
72 return result;
73 }
74
75 int wxMacPageSetupDialog::ShowModal()
76 {
77 m_pageSetupData.GetPrintData().ConvertToNative();
78 wxOSXPrintData* nativeData = (wxOSXPrintData*)m_pageSetupData.GetPrintData().GetNativeData();
79 nativeData->TransferFrom( &m_pageSetupData );
80
81 int result = wxID_CANCEL;
82 OSErr err = noErr;
83 Boolean accepted;
84
85 wxDialog::OSXBeginModalDialog();
86 err = PMSessionPageSetupDialog( nativeData->GetPrintSession(), nativeData->GetPageFormat(),
87 &accepted );
88 wxDialog::OSXEndModalDialog();
89
90 if ((err == noErr) && !accepted)
91 {
92 // user clicked Cancel button
93 err = kPMCancel;
94 }
95
96 // If the user did not cancel, flatten and save the PageFormat object
97 // with our document.
98 if (err == noErr)
99 {
100 result = wxID_OK;
101 }
102
103 if ((err != noErr) && (err != kPMCancel))
104 {
105 wxString message;
106
107 message.Printf( wxT("Print Error %d"), err );
108 wxMessageDialog dialog( NULL, message, wxEmptyString, wxICON_HAND | wxOK );
109 dialog.ShowModal();
110 }
111
112 if (result == wxID_OK)
113 {
114 m_pageSetupData.GetPrintData().ConvertFromNative();
115 m_pageSetupData.SetPaperSize( m_pageSetupData.GetPrintData().GetPaperSize() );
116 nativeData->TransferTo( &m_pageSetupData );
117 }
118 return result;
119 }
120
121 #endif