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