]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cmndata.cpp | |
3 | // Purpose: Common GDI data | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
55d99c7a | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
8826f46f VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8826f46f | 21 | #pragma implementation "cmndata.h" |
c801d85f KB |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
8826f46f | 28 | #pragma hdrstop |
c801d85f KB |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
8826f46f VZ |
32 | #include <stdio.h> |
33 | #include "wx/string.h" | |
34 | #include "wx/utils.h" | |
35 | #include "wx/app.h" | |
c801d85f KB |
36 | #endif |
37 | ||
38 | #include "wx/gdicmn.h" | |
39 | #include "wx/cmndata.h" | |
6776a0b2 | 40 | #include "wx/log.h" |
8850cbd3 RR |
41 | #include "wx/prntbase.h" |
42 | #include "wx/printdlg.h" | |
8826f46f | 43 | |
dbc65e27 VZ |
44 | #if wxUSE_FONTDLG |
45 | #include "wx/fontdlg.h" | |
46 | #endif // wxUSE_FONTDLG | |
47 | ||
88ac883a VZ |
48 | #if wxUSE_PRINTING_ARCHITECTURE |
49 | #include "wx/paper.h" | |
88ac883a | 50 | #endif // wxUSE_PRINTING_ARCHITECTURE |
7be1f0d9 | 51 | |
ffecfa5a | 52 | #if defined(__WXMSW__) && !defined(__PALMOS__) |
1c193821 | 53 | #include <windowsx.h> |
3096bd2f | 54 | #include "wx/msw/private.h" |
7be1f0d9 | 55 | |
0c44ec97 | 56 | #ifndef __SMARTPHONE__ /* of WinCE */ |
8826f46f | 57 | #include <commdlg.h> |
1c193821 | 58 | #endif |
8826f46f | 59 | |
2bdf7154 | 60 | #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__) |
8826f46f VZ |
61 | #include <windowsx.h> |
62 | #include <commdlg.h> | |
63 | #endif | |
64 | #endif // MSW | |
c801d85f | 65 | |
746d7582 SC |
66 | #ifdef __WXMAC__ |
67 | #include "wx/mac/private/print.h" | |
68 | #endif | |
69 | ||
88ac883a VZ |
70 | #if wxUSE_PRINTING_ARCHITECTURE |
71 | IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) | |
72 | IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) | |
73 | IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject) | |
74 | #endif // wxUSE_PRINTING_ARCHITECTURE | |
cd0b1709 | 75 | |
8826f46f VZ |
76 | IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) |
77 | IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) | |
c801d85f | 78 | |
83e72d5f GT |
79 | #ifndef DMPAPER_USER |
80 | #define DMPAPER_USER 256 | |
81 | #endif | |
82 | ||
8826f46f VZ |
83 | // ============================================================================ |
84 | // implementation | |
85 | // ============================================================================ | |
86 | ||
87 | // ---------------------------------------------------------------------------- | |
88 | // wxColourData | |
89 | // ---------------------------------------------------------------------------- | |
c801d85f | 90 | |
8bbe427f | 91 | wxColourData::wxColourData() |
c801d85f | 92 | { |
393c836c | 93 | m_chooseFull = false; |
ae500232 | 94 | m_dataColour.Set(0,0,0); |
393c836c | 95 | // m_custColours are wxNullColours initially |
7bcb11d3 | 96 | } |
c801d85f | 97 | |
7bcb11d3 | 98 | wxColourData::wxColourData(const wxColourData& data) |
5e472c1f | 99 | : wxObject() |
7bcb11d3 JS |
100 | { |
101 | (*this) = data; | |
8bbe427f | 102 | } |
c801d85f | 103 | |
8bbe427f | 104 | wxColourData::~wxColourData() |
c801d85f KB |
105 | { |
106 | } | |
107 | ||
cebf2fec | 108 | void wxColourData::SetCustomColour(int i, const wxColour& colour) |
c801d85f | 109 | { |
393c836c | 110 | wxCHECK_RET( (i >= 0 && i < 16), _T("custom colour index out of range") ); |
8826f46f | 111 | |
ae500232 | 112 | m_custColours[i] = colour; |
c801d85f KB |
113 | } |
114 | ||
115 | wxColour wxColourData::GetCustomColour(int i) | |
116 | { | |
393c836c VS |
117 | wxCHECK_MSG( (i >= 0 && i < 16), wxColour(0,0,0), |
118 | _T("custom colour index out of range") ); | |
8826f46f | 119 | |
ae500232 | 120 | return m_custColours[i]; |
c801d85f KB |
121 | } |
122 | ||
123 | void wxColourData::operator=(const wxColourData& data) | |
124 | { | |
7bcb11d3 JS |
125 | int i; |
126 | for (i = 0; i < 16; i++) | |
ae500232 | 127 | m_custColours[i] = data.m_custColours[i]; |
8826f46f | 128 | |
ae500232 JS |
129 | m_dataColour = (wxColour&)data.m_dataColour; |
130 | m_chooseFull = data.m_chooseFull; | |
c801d85f KB |
131 | } |
132 | ||
8826f46f VZ |
133 | // ---------------------------------------------------------------------------- |
134 | // Font data | |
135 | // ---------------------------------------------------------------------------- | |
c801d85f | 136 | |
8bbe427f | 137 | wxFontData::wxFontData() |
c801d85f | 138 | { |
7bcb11d3 | 139 | // Intialize colour to black. |
ae500232 | 140 | m_fontColour = wxNullColour; |
8826f46f | 141 | |
c9d59ee7 WS |
142 | m_showHelp = false; |
143 | m_allowSymbols = true; | |
144 | m_enableEffects = true; | |
ae500232 JS |
145 | m_minSize = 0; |
146 | m_maxSize = 0; | |
c801d85f | 147 | |
7beba2fc | 148 | m_encoding = wxFONTENCODING_SYSTEM; |
c801d85f KB |
149 | } |
150 | ||
8bbe427f | 151 | wxFontData::~wxFontData() |
c801d85f KB |
152 | { |
153 | } | |
154 | ||
dbc65e27 VZ |
155 | #if wxUSE_FONTDLG |
156 | ||
157 | wxFontDialogBase::~wxFontDialogBase() | |
158 | { | |
159 | } | |
160 | ||
161 | #endif // wxUSE_FONTDLG | |
162 | ||
88ac883a | 163 | #if wxUSE_PRINTING_ARCHITECTURE |
8826f46f VZ |
164 | // ---------------------------------------------------------------------------- |
165 | // Print data | |
166 | // ---------------------------------------------------------------------------- | |
c801d85f | 167 | |
8bbe427f | 168 | wxPrintData::wxPrintData() |
c801d85f | 169 | { |
8850cbd3 | 170 | #ifdef __WXMAC__ |
746d7582 | 171 | m_nativePrintData = wxNativePrintData::Create() ; |
c801d85f | 172 | #endif |
60090256 | 173 | m_bin = wxPRINTBIN_DEFAULT; |
6038ec8e | 174 | m_printMode = wxPRINT_MODE_PRINTER; |
7bcb11d3 JS |
175 | m_printOrientation = wxPORTRAIT; |
176 | m_printNoCopies = 1; | |
c9d59ee7 | 177 | m_printCollate = false; |
8826f46f | 178 | |
7bcb11d3 | 179 | // New, 24/3/99 |
2b5f62a0 | 180 | m_printerName = wxT(""); |
c9d59ee7 | 181 | m_colour = true; |
7bcb11d3 JS |
182 | m_duplexMode = wxDUPLEX_SIMPLEX; |
183 | m_printQuality = wxPRINT_QUALITY_HIGH; | |
184 | m_paperId = wxPAPER_A4; | |
185 | m_paperSize = wxSize(210, 297); | |
186 | ||
8850cbd3 | 187 | m_nativeData = wxPrintFactory::GetFactory()->CreatePrintNativeData(); |
7bcb11d3 JS |
188 | } |
189 | ||
190 | wxPrintData::wxPrintData(const wxPrintData& printData) | |
5e472c1f | 191 | : wxObject() |
7bcb11d3 JS |
192 | { |
193 | (*this) = printData; | |
c801d85f KB |
194 | } |
195 | ||
8bbe427f | 196 | wxPrintData::~wxPrintData() |
c801d85f | 197 | { |
8850cbd3 RR |
198 | m_nativeData->m_ref--; |
199 | if (m_nativeData->m_ref == 0) | |
200 | delete m_nativeData; | |
201 | ||
202 | #ifdef __WXMAC__ | |
746d7582 | 203 | delete m_nativePrintData ; |
c801d85f KB |
204 | #endif |
205 | } | |
206 | ||
51abe921 SC |
207 | void wxPrintData::ConvertToNative() |
208 | { | |
53fa663a | 209 | #ifdef __WXMAC__ |
746d7582 | 210 | m_nativePrintData->TransferFrom( this ) ; |
53fa663a RR |
211 | #else |
212 | m_nativeData->TransferFrom( *this ) ; | |
213 | #endif | |
51abe921 SC |
214 | } |
215 | ||
216 | void wxPrintData::ConvertFromNative() | |
217 | { | |
53fa663a | 218 | #ifdef __WXMAC__ |
746d7582 | 219 | m_nativePrintData->TransferTo( this ) ; |
53fa663a RR |
220 | #else |
221 | m_nativeData->TransferTo( *this ) ; | |
51abe921 | 222 | #endif |
53fa663a | 223 | } |
51abe921 | 224 | |
7bcb11d3 JS |
225 | void wxPrintData::operator=(const wxPrintData& data) |
226 | { | |
227 | m_printNoCopies = data.m_printNoCopies; | |
228 | m_printCollate = data.m_printCollate; | |
229 | m_printOrientation = data.m_printOrientation; | |
230 | m_printerName = data.m_printerName; | |
231 | m_colour = data.m_colour; | |
232 | m_duplexMode = data.m_duplexMode; | |
233 | m_printQuality = data.m_printQuality; | |
234 | m_paperId = data.m_paperId; | |
235 | m_paperSize = data.m_paperSize; | |
60090256 | 236 | m_bin = data.m_bin; |
6038ec8e | 237 | m_printMode = data.m_printMode; |
01b5396f | 238 | m_filename = data.m_filename; |
aac85509 RR |
239 | |
240 | // UnRef old m_nativeData | |
241 | m_nativeData->m_ref--; | |
242 | if (m_nativeData->m_ref == 0) | |
243 | delete m_nativeData; | |
244 | // Set Ref new one | |
8850cbd3 RR |
245 | m_nativeData = data.GetNativeData(); |
246 | m_nativeData->m_ref++; | |
247 | ||
248 | #ifdef __WXMAC__ | |
249 | m_nativePrintData->CopyFrom( data.m_nativePrintData ) ; | |
244e5e34 | 250 | #endif |
7bcb11d3 JS |
251 | } |
252 | ||
58cf0491 JS |
253 | // Is this data OK for showing the print dialog? |
254 | bool wxPrintData::Ok() const | |
255 | { | |
fd64de59 | 256 | m_nativeData->TransferFrom( *this ); |
8850cbd3 RR |
257 | |
258 | return m_nativeData->Ok(); | |
58cf0491 | 259 | } |
8826f46f | 260 | |
0ab2de15 RR |
261 | #if WXWIN_COMPATIBILITY_2_4 |
262 | ||
263 | #include "wx/generic/prntdlgg.h" | |
264 | ||
fd864f01 WS |
265 | #if wxUSE_POSTSCRIPT |
266 | #define WXUNUSED_WITHOUT_PS(name) name | |
267 | #else | |
268 | #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name) | |
269 | #endif | |
270 | ||
0ab2de15 RR |
271 | wxString wxPrintData::GetPrinterCommand() const |
272 | { | |
273 | #if wxUSE_POSTSCRIPT | |
274 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
275 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand(); | |
276 | #endif | |
277 | return wxT(""); | |
278 | } | |
279 | ||
280 | wxString wxPrintData::GetPrinterOptions() const | |
281 | { | |
282 | #if wxUSE_POSTSCRIPT | |
283 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
284 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions(); | |
285 | #endif | |
286 | return wxT(""); | |
287 | } | |
288 | ||
289 | wxString wxPrintData::GetPreviewCommand() const | |
290 | { | |
291 | #if wxUSE_POSTSCRIPT | |
292 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
293 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand(); | |
294 | #endif | |
295 | return wxT(""); | |
296 | } | |
297 | ||
298 | wxString wxPrintData::GetFontMetricPath() const | |
299 | { | |
300 | #if wxUSE_POSTSCRIPT | |
301 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
302 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath(); | |
303 | #endif | |
304 | return wxT(""); | |
305 | } | |
306 | ||
307 | double wxPrintData::GetPrinterScaleX() const | |
308 | { | |
309 | #if wxUSE_POSTSCRIPT | |
310 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
311 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX(); | |
312 | #endif | |
313 | return 1.0; | |
314 | } | |
315 | ||
316 | double wxPrintData::GetPrinterScaleY() const | |
317 | { | |
318 | #if wxUSE_POSTSCRIPT | |
319 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
320 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY(); | |
321 | #endif | |
322 | return 1.0; | |
323 | } | |
324 | ||
325 | long wxPrintData::GetPrinterTranslateX() const | |
326 | { | |
327 | #if wxUSE_POSTSCRIPT | |
328 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
329 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX(); | |
330 | #endif | |
331 | return 0; | |
332 | } | |
333 | ||
334 | long wxPrintData::GetPrinterTranslateY() const | |
335 | { | |
336 | #if wxUSE_POSTSCRIPT | |
337 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
338 | return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY(); | |
339 | #endif | |
340 | return 0; | |
341 | } | |
342 | ||
fd864f01 | 343 | void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) |
0ab2de15 RR |
344 | { |
345 | #if wxUSE_POSTSCRIPT | |
346 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
347 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command ); | |
348 | #endif | |
349 | } | |
350 | ||
fd864f01 | 351 | void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options)) |
0ab2de15 RR |
352 | { |
353 | #if wxUSE_POSTSCRIPT | |
354 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
355 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options ); | |
356 | #endif | |
357 | } | |
358 | ||
fd864f01 | 359 | void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command)) |
0ab2de15 RR |
360 | { |
361 | #if wxUSE_POSTSCRIPT | |
362 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
363 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command ); | |
364 | #endif | |
365 | } | |
366 | ||
fd864f01 | 367 | void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path)) |
0ab2de15 RR |
368 | { |
369 | #if wxUSE_POSTSCRIPT | |
370 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
371 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path ); | |
372 | #endif | |
373 | } | |
374 | ||
fd864f01 | 375 | void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x)) |
0ab2de15 RR |
376 | { |
377 | #if wxUSE_POSTSCRIPT | |
378 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
379 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x ); | |
380 | #endif | |
381 | } | |
382 | ||
fd864f01 | 383 | void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y)) |
0ab2de15 RR |
384 | { |
385 | #if wxUSE_POSTSCRIPT | |
386 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
387 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y ); | |
388 | #endif | |
389 | } | |
390 | ||
fd864f01 | 391 | void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y)) |
0ab2de15 RR |
392 | { |
393 | #if wxUSE_POSTSCRIPT | |
394 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
395 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y ); | |
396 | #endif | |
397 | } | |
398 | ||
fd864f01 | 399 | void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x)) |
0ab2de15 RR |
400 | { |
401 | #if wxUSE_POSTSCRIPT | |
402 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
403 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x ); | |
404 | #endif | |
405 | } | |
406 | ||
fd864f01 | 407 | void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y)) |
0ab2de15 RR |
408 | { |
409 | #if wxUSE_POSTSCRIPT | |
410 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
411 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y ); | |
412 | #endif | |
413 | } | |
414 | ||
fd864f01 | 415 | void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y)) |
0ab2de15 RR |
416 | { |
417 | #if wxUSE_POSTSCRIPT | |
418 | if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData)) | |
419 | ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y ); | |
420 | #endif | |
421 | } | |
422 | #endif | |
423 | ||
8826f46f VZ |
424 | // ---------------------------------------------------------------------------- |
425 | // Print dialog data | |
426 | // ---------------------------------------------------------------------------- | |
7bcb11d3 JS |
427 | |
428 | wxPrintDialogData::wxPrintDialogData() | |
429 | { | |
7bcb11d3 JS |
430 | m_printFromPage = 0; |
431 | m_printToPage = 0; | |
432 | m_printMinPage = 0; | |
433 | m_printMaxPage = 0; | |
434 | m_printNoCopies = 1; | |
c9d59ee7 WS |
435 | m_printAllPages = false; |
436 | m_printCollate = false; | |
437 | m_printToFile = false; | |
438 | m_printSelection = false; | |
439 | m_printEnableSelection = false; | |
440 | m_printEnablePageNumbers = true; | |
9f1316dc RR |
441 | |
442 | wxPrintFactory* factory = wxPrintFactory::GetFactory(); | |
443 | m_printEnablePrintToFile = ! factory->HasOwnPrintToFile(); | |
444 | ||
c9d59ee7 | 445 | m_printEnableHelp = false; |
b45dfd0a | 446 | #if WXWIN_COMPATIBILITY_2_4 |
c9d59ee7 | 447 | m_printSetupDialog = false; |
b45dfd0a | 448 | #endif |
7bcb11d3 JS |
449 | } |
450 | ||
451 | wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData) | |
5e472c1f | 452 | : wxObject() |
7bcb11d3 JS |
453 | { |
454 | (*this) = dialogData; | |
455 | } | |
456 | ||
457 | wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) | |
458 | { | |
d2b354f9 | 459 | m_printFromPage = 1; |
7bcb11d3 | 460 | m_printToPage = 0; |
d2b354f9 JS |
461 | m_printMinPage = 1; |
462 | m_printMaxPage = 9999; | |
7bcb11d3 | 463 | m_printNoCopies = 1; |
c9d59ee7 WS |
464 | m_printAllPages = false; |
465 | m_printCollate = false; | |
466 | m_printToFile = false; | |
467 | m_printSelection = false; | |
468 | m_printEnableSelection = false; | |
469 | m_printEnablePageNumbers = true; | |
470 | m_printEnablePrintToFile = true; | |
471 | m_printEnableHelp = false; | |
b45dfd0a | 472 | #if WXWIN_COMPATIBILITY_2_4 |
c9d59ee7 | 473 | m_printSetupDialog = false; |
b45dfd0a | 474 | #endif |
7bcb11d3 JS |
475 | m_printData = printData; |
476 | } | |
477 | ||
478 | wxPrintDialogData::~wxPrintDialogData() | |
479 | { | |
7bcb11d3 JS |
480 | } |
481 | ||
51abe921 | 482 | #ifdef __WXMAC__ |
cfb00da4 | 483 | |
51abe921 SC |
484 | void wxPrintDialogData::ConvertToNative() |
485 | { | |
cfb00da4 | 486 | m_printData.ConvertToNative(); |
746d7582 | 487 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
488 | } |
489 | ||
490 | void wxPrintDialogData::ConvertFromNative() | |
491 | { | |
cfb00da4 | 492 | m_printData.ConvertFromNative(); |
746d7582 | 493 | m_printData.m_nativePrintData->TransferTo( this ) ; |
51abe921 | 494 | } |
cfb00da4 | 495 | |
51abe921 SC |
496 | #endif |
497 | ||
498 | ||
7bcb11d3 | 499 | void wxPrintDialogData::operator=(const wxPrintDialogData& data) |
c801d85f | 500 | { |
7bcb11d3 JS |
501 | m_printFromPage = data.m_printFromPage; |
502 | m_printToPage = data.m_printToPage; | |
503 | m_printMinPage = data.m_printMinPage; | |
504 | m_printMaxPage = data.m_printMaxPage; | |
505 | m_printNoCopies = data.m_printNoCopies; | |
506 | m_printAllPages = data.m_printAllPages; | |
507 | m_printCollate = data.m_printCollate; | |
508 | m_printToFile = data.m_printToFile; | |
5360828d | 509 | m_printSelection = data.m_printSelection; |
7bcb11d3 JS |
510 | m_printEnableSelection = data.m_printEnableSelection; |
511 | m_printEnablePageNumbers = data.m_printEnablePageNumbers; | |
512 | m_printEnableHelp = data.m_printEnableHelp; | |
513 | m_printEnablePrintToFile = data.m_printEnablePrintToFile; | |
b45dfd0a | 514 | #if WXWIN_COMPATIBILITY_2_4 |
7bcb11d3 | 515 | m_printSetupDialog = data.m_printSetupDialog; |
b45dfd0a | 516 | #endif |
7bcb11d3 JS |
517 | m_printData = data.m_printData; |
518 | } | |
519 | ||
520 | void wxPrintDialogData::operator=(const wxPrintData& data) | |
521 | { | |
522 | m_printData = data; | |
c801d85f KB |
523 | } |
524 | ||
8826f46f VZ |
525 | // ---------------------------------------------------------------------------- |
526 | // wxPageSetupDialogData | |
527 | // ---------------------------------------------------------------------------- | |
c801d85f | 528 | |
7bcb11d3 | 529 | wxPageSetupDialogData::wxPageSetupDialogData() |
c801d85f | 530 | { |
7bcb11d3 JS |
531 | m_paperSize = wxSize(0, 0); |
532 | ||
533 | CalculatePaperSizeFromId(); | |
534 | ||
535 | m_minMarginTopLeft = wxPoint(0, 0); | |
536 | m_minMarginBottomRight = wxPoint(0, 0); | |
537 | m_marginTopLeft = wxPoint(0, 0); | |
538 | m_marginBottomRight = wxPoint(0, 0); | |
539 | ||
540 | // Flags | |
c9d59ee7 WS |
541 | m_defaultMinMargins = false; |
542 | m_enableMargins = true; | |
543 | m_enableOrientation = true; | |
544 | m_enablePaper = true; | |
545 | m_enablePrinter = true; | |
546 | m_enableHelp = false; | |
547 | m_getDefaultInfo = false; | |
7bcb11d3 | 548 | } |
c801d85f | 549 | |
7bcb11d3 | 550 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData) |
5e472c1f | 551 | : wxObject() |
7bcb11d3 JS |
552 | { |
553 | (*this) = dialogData; | |
554 | } | |
555 | ||
556 | wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData) | |
557 | { | |
7bcb11d3 JS |
558 | m_paperSize = wxSize(0, 0); |
559 | m_minMarginTopLeft = wxPoint(0, 0); | |
560 | m_minMarginBottomRight = wxPoint(0, 0); | |
561 | m_marginTopLeft = wxPoint(0, 0); | |
562 | m_marginBottomRight = wxPoint(0, 0); | |
563 | ||
564 | // Flags | |
c9d59ee7 WS |
565 | m_defaultMinMargins = false; |
566 | m_enableMargins = true; | |
567 | m_enableOrientation = true; | |
568 | m_enablePaper = true; | |
569 | m_enablePrinter = true; | |
570 | m_enableHelp = false; | |
571 | m_getDefaultInfo = false; | |
7bcb11d3 JS |
572 | |
573 | m_printData = printData; | |
574 | ||
575 | // The wxPrintData paper size overrides these values, unless the size cannot | |
576 | // be found. | |
577 | CalculatePaperSizeFromId(); | |
c801d85f KB |
578 | } |
579 | ||
7bcb11d3 | 580 | wxPageSetupDialogData::~wxPageSetupDialogData() |
c801d85f | 581 | { |
c801d85f KB |
582 | } |
583 | ||
5e472c1f | 584 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data) |
c801d85f | 585 | { |
7bcb11d3 JS |
586 | m_paperSize = data.m_paperSize; |
587 | m_minMarginTopLeft = data.m_minMarginTopLeft; | |
588 | m_minMarginBottomRight = data.m_minMarginBottomRight; | |
589 | m_marginTopLeft = data.m_marginTopLeft; | |
590 | m_marginBottomRight = data.m_marginBottomRight; | |
591 | m_defaultMinMargins = data.m_defaultMinMargins; | |
592 | m_enableMargins = data.m_enableMargins; | |
593 | m_enableOrientation = data.m_enableOrientation; | |
594 | m_enablePaper = data.m_enablePaper; | |
595 | m_enablePrinter = data.m_enablePrinter; | |
596 | m_getDefaultInfo = data.m_getDefaultInfo;; | |
597 | m_enableHelp = data.m_enableHelp; | |
598 | ||
599 | m_printData = data.m_printData; | |
5e472c1f GD |
600 | |
601 | return *this; | |
7bcb11d3 | 602 | } |
c801d85f | 603 | |
5e472c1f | 604 | wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data) |
7bcb11d3 JS |
605 | { |
606 | m_printData = data; | |
5e472c1f GD |
607 | |
608 | return *this; | |
c801d85f KB |
609 | } |
610 | ||
51abe921 | 611 | #ifdef __WXMAC__ |
7c74e7fe | 612 | void wxPageSetupDialogData::ConvertToNative() |
51abe921 | 613 | { |
161f4f73 | 614 | m_printData.ConvertToNative(); |
746d7582 | 615 | m_printData.m_nativePrintData->TransferFrom( this ) ; |
51abe921 SC |
616 | } |
617 | ||
7c74e7fe | 618 | void wxPageSetupDialogData::ConvertFromNative() |
51abe921 | 619 | { |
161f4f73 | 620 | m_printData.ConvertFromNative (); |
cfb00da4 SC |
621 | m_paperSize = m_printData.GetPaperSize() ; |
622 | CalculateIdFromPaperSize(); | |
746d7582 | 623 | m_printData.m_nativePrintData->TransferTo( this ) ; |
161f4f73 | 624 | // adjust minimal values |
161f4f73 VZ |
625 | |
626 | if ( m_marginTopLeft.x < m_minMarginTopLeft.x ) | |
627 | m_marginTopLeft.x = m_minMarginTopLeft.x; | |
628 | ||
629 | if ( m_marginBottomRight.x < m_minMarginBottomRight.x ) | |
630 | m_marginBottomRight.x = m_minMarginBottomRight.x; | |
631 | ||
632 | if ( m_marginTopLeft.y < m_minMarginTopLeft.y ) | |
633 | m_marginTopLeft.y = m_minMarginTopLeft.y; | |
634 | ||
635 | if ( m_marginBottomRight.y < m_minMarginBottomRight.y ) | |
636 | m_marginBottomRight.y = m_minMarginBottomRight.y; | |
51abe921 SC |
637 | } |
638 | #endif | |
639 | ||
640 | ||
7bcb11d3 JS |
641 | // If a corresponding paper type is found in the paper database, will set the m_printData |
642 | // paper size id member as well. | |
643 | void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) | |
644 | { | |
645 | m_paperSize = sz; | |
c801d85f | 646 | |
7bcb11d3 JS |
647 | CalculateIdFromPaperSize(); |
648 | } | |
c801d85f | 649 | |
7bcb11d3 JS |
650 | // Sets the wxPrintData id, plus the paper width/height if found in the paper database. |
651 | void wxPageSetupDialogData::SetPaperSize(wxPaperSize id) | |
652 | { | |
653 | m_printData.SetPaperId(id); | |
654 | ||
655 | CalculatePaperSizeFromId(); | |
c801d85f KB |
656 | } |
657 | ||
7bcb11d3 JS |
658 | // Use paper size defined in this object to set the wxPrintData |
659 | // paper id | |
660 | void wxPageSetupDialogData::CalculateIdFromPaperSize() | |
c801d85f | 661 | { |
8826f46f | 662 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 663 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
c801d85f | 664 | |
7bcb11d3 JS |
665 | wxSize sz = GetPaperSize(); |
666 | ||
667 | wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10)); | |
668 | if (id != wxPAPER_NONE) | |
c801d85f | 669 | { |
7bcb11d3 | 670 | m_printData.SetPaperId(id); |
c801d85f KB |
671 | } |
672 | } | |
8826f46f | 673 | |
7bcb11d3 JS |
674 | // Use paper id in wxPrintData to set this object's paper size |
675 | void wxPageSetupDialogData::CalculatePaperSizeFromId() | |
676 | { | |
8826f46f | 677 | wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL), |
fbdcff4a | 678 | wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") ); |
7bcb11d3 JS |
679 | |
680 | wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId()); | |
c801d85f | 681 | |
01cf2f95 VZ |
682 | // sz is in 10ths of a mm, while paper size is in mm |
683 | m_paperSize.x = sz.x / 10; | |
684 | m_paperSize.y = sz.y / 10; | |
7bcb11d3 | 685 | } |
8826f46f | 686 | |
88ac883a | 687 | #endif // wxUSE_PRINTING_ARCHITECTURE |