]>
Commit | Line | Data |
---|---|---|
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 | #if __UNIX__ | |
95 | #warning "TODO:Printing for carbon" | |
96 | #else | |
97 | #pragma warning "TODO:Printing for carbon" | |
98 | #endif | |
99 | #endif | |
100 | return result ; | |
101 | } | |
102 | ||
103 | wxDC *wxPrintDialog::GetPrintDC() | |
104 | { | |
105 | return new wxPrinterDC( m_printDialogData.GetPrintData() ) ; | |
106 | } | |
107 | ||
108 | /* | |
109 | * wxPageSetupDialog | |
110 | */ | |
111 | ||
112 | wxPageSetupDialog::wxPageSetupDialog(): | |
113 | wxDialog() | |
114 | { | |
115 | m_dialogParent = NULL; | |
116 | } | |
117 | ||
118 | wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): | |
119 | wxDialog() | |
120 | { | |
121 | Create(p, data); | |
122 | } | |
123 | ||
124 | bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) | |
125 | { | |
126 | m_dialogParent = p; | |
127 | ||
128 | if (data) | |
129 | m_pageSetupData = (*data); | |
130 | ||
131 | return TRUE; | |
132 | } | |
133 | ||
134 | wxPageSetupDialog::~wxPageSetupDialog() | |
135 | { | |
136 | } | |
137 | ||
138 | int wxPageSetupDialog::ShowModal() | |
139 | { | |
140 | int result = wxID_CANCEL ; | |
141 | #if !TARGET_CARBON | |
142 | ||
143 | OSErr err ; | |
144 | wxString message ; | |
145 | ::UMAPrOpen() ; | |
146 | err = PrError() ; | |
147 | ||
148 | if ( !err ) | |
149 | { | |
150 | m_pageSetupData.ConvertToNative() ; | |
151 | if ( ::PrStlDialog( m_pageSetupData.GetPrintData().m_macPrintInfo ) ) | |
152 | { | |
153 | m_pageSetupData.ConvertFromNative() ; | |
154 | result = wxID_OK ; | |
155 | } | |
156 | ||
157 | } | |
158 | else | |
159 | { | |
160 | message.Printf( "Print Error %d", err ) ; | |
161 | wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; | |
162 | } | |
163 | ::UMAPrClose() ; | |
164 | #else | |
165 | #if __UNIX__ | |
166 | #warning "TODO:Printing for carbon" | |
167 | #else | |
168 | #pragma warning "TODO:Printing for carbon" | |
169 | #endif | |
170 | #endif | |
171 | return result ; | |
172 | } | |
173 |