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