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