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