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