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