]> git.saurik.com Git - wxWidgets.git/blob - src/mac/printdlg.cpp
Readded wxPlotWindow as external lib.
[wxWidgets.git] / src / mac / printdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: printdlg.cpp
3 // Purpose: wxPrintDialog, wxPageSetupDialog
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "printdlg.h"
14 #endif
15
16 #include "wx/object.h"
17 #include "wx/printdlg.h"
18 #include "wx/dcprint.h"
19 #include "wx/mac/uma.h"
20
21 // Use generic page setup dialog: use your own native one if one exists.
22
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
25 IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
26 #endif
27
28 wxPrintDialog::wxPrintDialog()
29 {
30 m_dialogParent = NULL;
31 m_printerDC = NULL;
32 m_destroyDC = TRUE;
33 }
34
35 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
36 {
37 Create(p, data);
38 }
39
40 wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
41 {
42 wxPrintDialogData data2;
43 if ( data )
44 data2 = *data;
45
46 Create(p, &data2);
47 }
48
49 bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
50 {
51 m_dialogParent = p;
52 m_printerDC = NULL;
53 m_destroyDC = TRUE;
54
55 if ( data )
56 m_printDialogData = *data;
57
58 return TRUE;
59 }
60
61 wxPrintDialog::~wxPrintDialog()
62 {
63 if (m_destroyDC && m_printerDC)
64 delete m_printerDC;
65 }
66
67 int wxPrintDialog::ShowModal()
68 {
69 int result = wxID_CANCEL ;
70 #if !TARGET_CARBON
71
72 OSErr err ;
73 wxString message ;
74 ::UMAPrOpen() ;
75 err = PrError() ;
76
77 if ( !err )
78 {
79 m_printDialogData.ConvertToNative() ;
80 if ( ::PrJobDialog( m_printDialogData.GetPrintData().m_macPrintInfo ) )
81 {
82 m_printDialogData.ConvertFromNative() ;
83 result = wxID_OK ;
84 }
85
86 }
87 else
88 {
89 message.Printf( "Print Error %d", err ) ;
90 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
91 }
92 ::UMAPrClose() ;
93 #else
94 #pragma warning "TODO:Printing for carbon"
95 #endif
96 return result ;
97 }
98
99 wxDC *wxPrintDialog::GetPrintDC()
100 {
101 return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
102 }
103
104 /*
105 * wxPageSetupDialog
106 */
107
108 wxPageSetupDialog::wxPageSetupDialog():
109 wxDialog()
110 {
111 m_dialogParent = NULL;
112 }
113
114 wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
115 wxDialog()
116 {
117 Create(p, data);
118 }
119
120 bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
121 {
122 m_dialogParent = p;
123
124 if (data)
125 m_pageSetupData = (*data);
126
127 return TRUE;
128 }
129
130 wxPageSetupDialog::~wxPageSetupDialog()
131 {
132 }
133
134 int wxPageSetupDialog::ShowModal()
135 {
136 int result = wxID_CANCEL ;
137 #if !TARGET_CARBON
138
139 OSErr err ;
140 wxString message ;
141 ::UMAPrOpen() ;
142 err = PrError() ;
143
144 if ( !err )
145 {
146 m_pageSetupData.ConvertToNative() ;
147 if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) )
148 {
149 m_pageSetupData.ConvertFromNative() ;
150 result = wxID_OK ;
151 }
152
153 }
154 else
155 {
156 message.Printf( "Print Error %d", err ) ;
157 wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ;
158 }
159 ::UMAPrClose() ;
160 #else
161 #pragma warning "TODO:printing for carbon"
162 #endif
163 return result ;
164 }
165