]> git.saurik.com Git - wxWidgets.git/blame - src/common/cmndata.cpp
more wxPostEvent MT fixes
[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
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 91wxColourData::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 98wxColourData::wxColourData(const wxColourData& data)
5e472c1f 99 : wxObject()
7bcb11d3
JS
100{
101 (*this) = data;
8bbe427f 102}
c801d85f 103
8bbe427f 104wxColourData::~wxColourData()
c801d85f
KB
105{
106}
107
cebf2fec 108void 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
115wxColour 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
123void 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 137wxFontData::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 151wxFontData::~wxFontData()
c801d85f
KB
152{
153}
154
dbc65e27
VZ
155#if wxUSE_FONTDLG
156
157wxFontDialogBase::~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 168wxPrintData::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
190wxPrintData::wxPrintData(const wxPrintData& printData)
5e472c1f 191 : wxObject()
7bcb11d3
JS
192{
193 (*this) = printData;
c801d85f
KB
194}
195
8bbe427f 196wxPrintData::~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
207void 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
216void 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
225void 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?
254bool wxPrintData::Ok() const
255{
fd64de59 256 m_nativeData->TransferFrom( *this );
8850cbd3
RR
257
258 return m_nativeData->Ok();
58cf0491 259}
8826f46f 260
72259e00
RL
261// What should happen here? wxPostScriptPrintNativeData is not
262// defined unless all this is true on MSW.
263#if WXWIN_COMPATIBILITY_2_4 && wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
0ab2de15
RR
264
265#include "wx/generic/prntdlgg.h"
266
fd864f01
WS
267#if wxUSE_POSTSCRIPT
268 #define WXUNUSED_WITHOUT_PS(name) name
269#else
270 #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name)
271#endif
272
0ab2de15
RR
273wxString wxPrintData::GetPrinterCommand() const
274{
275#if wxUSE_POSTSCRIPT
276 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
277 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand();
278#endif
279 return wxT("");
280}
281
282wxString wxPrintData::GetPrinterOptions() const
283{
284#if wxUSE_POSTSCRIPT
285 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
286 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions();
287#endif
288 return wxT("");
289}
290
291wxString wxPrintData::GetPreviewCommand() const
292{
293#if wxUSE_POSTSCRIPT
294 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
295 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand();
296#endif
297 return wxT("");
298}
299
300wxString wxPrintData::GetFontMetricPath() const
301{
302#if wxUSE_POSTSCRIPT
303 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
304 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath();
305#endif
306 return wxT("");
307}
308
309double wxPrintData::GetPrinterScaleX() const
310{
311#if wxUSE_POSTSCRIPT
312 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
313 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX();
314#endif
315 return 1.0;
316}
317
318double wxPrintData::GetPrinterScaleY() const
319{
320#if wxUSE_POSTSCRIPT
321 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
322 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY();
323#endif
324 return 1.0;
325}
326
327long wxPrintData::GetPrinterTranslateX() const
328{
329#if wxUSE_POSTSCRIPT
330 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
331 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX();
332#endif
333 return 0;
334}
335
336long wxPrintData::GetPrinterTranslateY() const
337{
338#if wxUSE_POSTSCRIPT
339 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
340 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY();
341#endif
342 return 0;
343}
344
fd864f01 345void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command))
0ab2de15
RR
346{
347#if wxUSE_POSTSCRIPT
348 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
349 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command );
350#endif
351}
352
fd864f01 353void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options))
0ab2de15
RR
354{
355#if wxUSE_POSTSCRIPT
356 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
357 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options );
358#endif
359}
360
fd864f01 361void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command))
0ab2de15
RR
362{
363#if wxUSE_POSTSCRIPT
364 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
365 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command );
366#endif
367}
368
fd864f01 369void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path))
0ab2de15
RR
370{
371#if wxUSE_POSTSCRIPT
372 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
373 ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path );
374#endif
375}
376
fd864f01 377void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x))
0ab2de15
RR
378{
379#if wxUSE_POSTSCRIPT
380 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
381 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x );
382#endif
383}
384
fd864f01 385void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y))
0ab2de15
RR
386{
387#if wxUSE_POSTSCRIPT
388 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
389 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y );
390#endif
391}
392
fd864f01 393void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y))
0ab2de15
RR
394{
395#if wxUSE_POSTSCRIPT
396 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
397 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y );
398#endif
399}
400
fd864f01 401void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x))
0ab2de15
RR
402{
403#if wxUSE_POSTSCRIPT
404 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
405 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x );
406#endif
407}
408
fd864f01 409void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y))
0ab2de15
RR
410{
411#if wxUSE_POSTSCRIPT
412 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
413 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y );
414#endif
415}
416
fd864f01 417void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y))
0ab2de15
RR
418{
419#if wxUSE_POSTSCRIPT
420 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
421 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y );
422#endif
423}
424#endif
425
8826f46f
VZ
426// ----------------------------------------------------------------------------
427// Print dialog data
428// ----------------------------------------------------------------------------
7bcb11d3
JS
429
430wxPrintDialogData::wxPrintDialogData()
431{
7bcb11d3
JS
432 m_printFromPage = 0;
433 m_printToPage = 0;
434 m_printMinPage = 0;
435 m_printMaxPage = 0;
436 m_printNoCopies = 1;
c9d59ee7
WS
437 m_printAllPages = false;
438 m_printCollate = false;
439 m_printToFile = false;
440 m_printSelection = false;
441 m_printEnableSelection = false;
442 m_printEnablePageNumbers = true;
9f1316dc
RR
443
444 wxPrintFactory* factory = wxPrintFactory::GetFactory();
445 m_printEnablePrintToFile = ! factory->HasOwnPrintToFile();
446
c9d59ee7 447 m_printEnableHelp = false;
b45dfd0a 448#if WXWIN_COMPATIBILITY_2_4
c9d59ee7 449 m_printSetupDialog = false;
b45dfd0a 450#endif
7bcb11d3
JS
451}
452
453wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
5e472c1f 454 : wxObject()
7bcb11d3
JS
455{
456 (*this) = dialogData;
457}
458
459wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
460{
d2b354f9 461 m_printFromPage = 1;
7bcb11d3 462 m_printToPage = 0;
d2b354f9
JS
463 m_printMinPage = 1;
464 m_printMaxPage = 9999;
7bcb11d3 465 m_printNoCopies = 1;
c9d59ee7
WS
466 m_printAllPages = false;
467 m_printCollate = false;
468 m_printToFile = false;
469 m_printSelection = false;
470 m_printEnableSelection = false;
471 m_printEnablePageNumbers = true;
472 m_printEnablePrintToFile = true;
473 m_printEnableHelp = false;
b45dfd0a 474#if WXWIN_COMPATIBILITY_2_4
c9d59ee7 475 m_printSetupDialog = false;
b45dfd0a 476#endif
7bcb11d3
JS
477 m_printData = printData;
478}
479
480wxPrintDialogData::~wxPrintDialogData()
481{
7bcb11d3
JS
482}
483
51abe921 484#ifdef __WXMAC__
cfb00da4 485
51abe921
SC
486void wxPrintDialogData::ConvertToNative()
487{
cfb00da4 488 m_printData.ConvertToNative();
746d7582 489 m_printData.m_nativePrintData->TransferFrom( this ) ;
51abe921
SC
490}
491
492void wxPrintDialogData::ConvertFromNative()
493{
cfb00da4 494 m_printData.ConvertFromNative();
746d7582 495 m_printData.m_nativePrintData->TransferTo( this ) ;
51abe921 496}
cfb00da4 497
51abe921
SC
498#endif
499
500
7bcb11d3 501void wxPrintDialogData::operator=(const wxPrintDialogData& data)
c801d85f 502{
7bcb11d3
JS
503 m_printFromPage = data.m_printFromPage;
504 m_printToPage = data.m_printToPage;
505 m_printMinPage = data.m_printMinPage;
506 m_printMaxPage = data.m_printMaxPage;
507 m_printNoCopies = data.m_printNoCopies;
508 m_printAllPages = data.m_printAllPages;
509 m_printCollate = data.m_printCollate;
510 m_printToFile = data.m_printToFile;
5360828d 511 m_printSelection = data.m_printSelection;
7bcb11d3
JS
512 m_printEnableSelection = data.m_printEnableSelection;
513 m_printEnablePageNumbers = data.m_printEnablePageNumbers;
514 m_printEnableHelp = data.m_printEnableHelp;
515 m_printEnablePrintToFile = data.m_printEnablePrintToFile;
b45dfd0a 516#if WXWIN_COMPATIBILITY_2_4
7bcb11d3 517 m_printSetupDialog = data.m_printSetupDialog;
b45dfd0a 518#endif
7bcb11d3
JS
519 m_printData = data.m_printData;
520}
521
522void wxPrintDialogData::operator=(const wxPrintData& data)
523{
524 m_printData = data;
c801d85f
KB
525}
526
8826f46f
VZ
527// ----------------------------------------------------------------------------
528// wxPageSetupDialogData
529// ----------------------------------------------------------------------------
c801d85f 530
7bcb11d3 531wxPageSetupDialogData::wxPageSetupDialogData()
c801d85f 532{
7bcb11d3
JS
533 m_paperSize = wxSize(0, 0);
534
535 CalculatePaperSizeFromId();
536
537 m_minMarginTopLeft = wxPoint(0, 0);
538 m_minMarginBottomRight = wxPoint(0, 0);
539 m_marginTopLeft = wxPoint(0, 0);
540 m_marginBottomRight = wxPoint(0, 0);
541
542 // Flags
c9d59ee7
WS
543 m_defaultMinMargins = false;
544 m_enableMargins = true;
545 m_enableOrientation = true;
546 m_enablePaper = true;
547 m_enablePrinter = true;
548 m_enableHelp = false;
549 m_getDefaultInfo = false;
7bcb11d3 550}
c801d85f 551
7bcb11d3 552wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
5e472c1f 553 : wxObject()
7bcb11d3
JS
554{
555 (*this) = dialogData;
556}
557
558wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
559{
7bcb11d3
JS
560 m_paperSize = wxSize(0, 0);
561 m_minMarginTopLeft = wxPoint(0, 0);
562 m_minMarginBottomRight = wxPoint(0, 0);
563 m_marginTopLeft = wxPoint(0, 0);
564 m_marginBottomRight = wxPoint(0, 0);
565
566 // Flags
c9d59ee7
WS
567 m_defaultMinMargins = false;
568 m_enableMargins = true;
569 m_enableOrientation = true;
570 m_enablePaper = true;
571 m_enablePrinter = true;
572 m_enableHelp = false;
573 m_getDefaultInfo = false;
7bcb11d3
JS
574
575 m_printData = printData;
576
577 // The wxPrintData paper size overrides these values, unless the size cannot
578 // be found.
579 CalculatePaperSizeFromId();
c801d85f
KB
580}
581
7bcb11d3 582wxPageSetupDialogData::~wxPageSetupDialogData()
c801d85f 583{
c801d85f
KB
584}
585
5e472c1f 586wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data)
c801d85f 587{
7bcb11d3
JS
588 m_paperSize = data.m_paperSize;
589 m_minMarginTopLeft = data.m_minMarginTopLeft;
590 m_minMarginBottomRight = data.m_minMarginBottomRight;
591 m_marginTopLeft = data.m_marginTopLeft;
592 m_marginBottomRight = data.m_marginBottomRight;
593 m_defaultMinMargins = data.m_defaultMinMargins;
594 m_enableMargins = data.m_enableMargins;
595 m_enableOrientation = data.m_enableOrientation;
596 m_enablePaper = data.m_enablePaper;
597 m_enablePrinter = data.m_enablePrinter;
598 m_getDefaultInfo = data.m_getDefaultInfo;;
599 m_enableHelp = data.m_enableHelp;
600
601 m_printData = data.m_printData;
5e472c1f
GD
602
603 return *this;
7bcb11d3 604}
c801d85f 605
5e472c1f 606wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data)
7bcb11d3
JS
607{
608 m_printData = data;
5e472c1f
GD
609
610 return *this;
c801d85f
KB
611}
612
51abe921 613#ifdef __WXMAC__
7c74e7fe 614void wxPageSetupDialogData::ConvertToNative()
51abe921 615{
161f4f73 616 m_printData.ConvertToNative();
746d7582 617 m_printData.m_nativePrintData->TransferFrom( this ) ;
51abe921
SC
618}
619
7c74e7fe 620void wxPageSetupDialogData::ConvertFromNative()
51abe921 621{
161f4f73 622 m_printData.ConvertFromNative ();
cfb00da4
SC
623 m_paperSize = m_printData.GetPaperSize() ;
624 CalculateIdFromPaperSize();
746d7582 625 m_printData.m_nativePrintData->TransferTo( this ) ;
161f4f73 626 // adjust minimal values
161f4f73
VZ
627
628 if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
629 m_marginTopLeft.x = m_minMarginTopLeft.x;
630
631 if ( m_marginBottomRight.x < m_minMarginBottomRight.x )
632 m_marginBottomRight.x = m_minMarginBottomRight.x;
633
634 if ( m_marginTopLeft.y < m_minMarginTopLeft.y )
635 m_marginTopLeft.y = m_minMarginTopLeft.y;
636
637 if ( m_marginBottomRight.y < m_minMarginBottomRight.y )
638 m_marginBottomRight.y = m_minMarginBottomRight.y;
51abe921
SC
639}
640#endif
641
642
7bcb11d3
JS
643// If a corresponding paper type is found in the paper database, will set the m_printData
644// paper size id member as well.
645void wxPageSetupDialogData::SetPaperSize(const wxSize& sz)
646{
647 m_paperSize = sz;
c801d85f 648
7bcb11d3
JS
649 CalculateIdFromPaperSize();
650}
c801d85f 651
7bcb11d3
JS
652// Sets the wxPrintData id, plus the paper width/height if found in the paper database.
653void wxPageSetupDialogData::SetPaperSize(wxPaperSize id)
654{
655 m_printData.SetPaperId(id);
656
657 CalculatePaperSizeFromId();
c801d85f
KB
658}
659
7bcb11d3
JS
660// Use paper size defined in this object to set the wxPrintData
661// paper id
662void wxPageSetupDialogData::CalculateIdFromPaperSize()
c801d85f 663{
8826f46f 664 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
fbdcff4a 665 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
c801d85f 666
7bcb11d3
JS
667 wxSize sz = GetPaperSize();
668
669 wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
670 if (id != wxPAPER_NONE)
c801d85f 671 {
7bcb11d3 672 m_printData.SetPaperId(id);
c801d85f
KB
673 }
674}
8826f46f 675
7bcb11d3
JS
676// Use paper id in wxPrintData to set this object's paper size
677void wxPageSetupDialogData::CalculatePaperSizeFromId()
678{
8826f46f 679 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
fbdcff4a 680 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
7bcb11d3
JS
681
682 wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
c801d85f 683
01cf2f95
VZ
684 // sz is in 10ths of a mm, while paper size is in mm
685 m_paperSize.x = sz.x / 10;
686 m_paperSize.y = sz.y / 10;
7bcb11d3 687}
8826f46f 688
88ac883a 689#endif // wxUSE_PRINTING_ARCHITECTURE