]> git.saurik.com Git - wxWidgets.git/blob - src/common/cmndata.cpp
Added __WXMAC_OSX__ guards around the CFRunLoop calls, CFRunLoop not available on...
[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 m_privData = NULL;
189 (*this) = printData;
190 }
191
192 void wxPrintData::SetPrivData( char *privData, int len )
193 {
194 if (m_privData)
195 {
196 delete [] m_privData;
197 m_privData = NULL;
198 }
199 m_privDataLen = len;
200 if (m_privDataLen > 0)
201 {
202 m_privData = new char[m_privDataLen];
203 memcpy( m_privData, privData, m_privDataLen );
204 }
205 }
206
207 wxPrintData::~wxPrintData()
208 {
209 m_nativeData->m_ref--;
210 if (m_nativeData->m_ref == 0)
211 delete m_nativeData;
212
213 if (m_privData)
214 delete [] m_privData;
215
216 #ifdef __WXMAC__
217 delete m_nativePrintData ;
218 #endif
219 }
220
221 void wxPrintData::ConvertToNative()
222 {
223 #ifdef __WXMAC__
224 m_nativePrintData->TransferFrom( this ) ;
225 #else
226 m_nativeData->TransferFrom( *this ) ;
227 #endif
228 }
229
230 void wxPrintData::ConvertFromNative()
231 {
232 #ifdef __WXMAC__
233 m_nativePrintData->TransferTo( this ) ;
234 #else
235 m_nativeData->TransferTo( *this ) ;
236 #endif
237 }
238
239 void wxPrintData::operator=(const wxPrintData& data)
240 {
241 m_printNoCopies = data.m_printNoCopies;
242 m_printCollate = data.m_printCollate;
243 m_printOrientation = data.m_printOrientation;
244 m_printerName = data.m_printerName;
245 m_colour = data.m_colour;
246 m_duplexMode = data.m_duplexMode;
247 m_printQuality = data.m_printQuality;
248 m_paperId = data.m_paperId;
249 m_paperSize = data.m_paperSize;
250 m_bin = data.m_bin;
251 m_printMode = data.m_printMode;
252 m_filename = data.m_filename;
253
254 // UnRef old m_nativeData
255 if (m_nativeData)
256 {
257 m_nativeData->m_ref--;
258 if (m_nativeData->m_ref == 0)
259 delete m_nativeData;
260 }
261 // Set Ref new one
262 m_nativeData = data.GetNativeData();
263 m_nativeData->m_ref++;
264
265 if (m_privData)
266 {
267 delete [] m_privData;
268 m_privData = NULL;
269 }
270 m_privDataLen = data.GetPrivDataLen();
271 if (m_privDataLen > 0)
272 {
273 m_privData = new char[m_privDataLen];
274 memcpy( m_privData, data.GetPrivData(), m_privDataLen );
275 }
276
277 #ifdef __WXMAC__
278 m_nativePrintData->CopyFrom( data.m_nativePrintData ) ;
279 #endif
280 }
281
282 // Is this data OK for showing the print dialog?
283 bool wxPrintData::Ok() const
284 {
285 m_nativeData->TransferFrom( *this );
286
287 return m_nativeData->Ok();
288 }
289
290 // What should happen here? wxPostScriptPrintNativeData is not
291 // defined unless all this is true on MSW.
292 #if WXWIN_COMPATIBILITY_2_4 && wxUSE_PRINTING_ARCHITECTURE && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW)
293
294 #include "wx/generic/prntdlgg.h"
295
296 #if wxUSE_POSTSCRIPT
297 #define WXUNUSED_WITHOUT_PS(name) name
298 #else
299 #define WXUNUSED_WITHOUT_PS(name) WXUNUSED(name)
300 #endif
301
302 wxString wxPrintData::GetPrinterCommand() const
303 {
304 #if wxUSE_POSTSCRIPT
305 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
306 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterCommand();
307 #endif
308 return wxEmptyString;
309 }
310
311 wxString wxPrintData::GetPrinterOptions() const
312 {
313 #if wxUSE_POSTSCRIPT
314 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
315 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterOptions();
316 #endif
317 return wxEmptyString;
318 }
319
320 wxString wxPrintData::GetPreviewCommand() const
321 {
322 #if wxUSE_POSTSCRIPT
323 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
324 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPreviewCommand();
325 #endif
326 return wxEmptyString;
327 }
328
329 wxString wxPrintData::GetFontMetricPath() const
330 {
331 #if wxUSE_POSTSCRIPT
332 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
333 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetFontMetricPath();
334 #endif
335 return wxEmptyString;
336 }
337
338 double wxPrintData::GetPrinterScaleX() const
339 {
340 #if wxUSE_POSTSCRIPT
341 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
342 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleX();
343 #endif
344 return 1.0;
345 }
346
347 double wxPrintData::GetPrinterScaleY() const
348 {
349 #if wxUSE_POSTSCRIPT
350 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
351 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterScaleY();
352 #endif
353 return 1.0;
354 }
355
356 long wxPrintData::GetPrinterTranslateX() const
357 {
358 #if wxUSE_POSTSCRIPT
359 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
360 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateX();
361 #endif
362 return 0;
363 }
364
365 long wxPrintData::GetPrinterTranslateY() const
366 {
367 #if wxUSE_POSTSCRIPT
368 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
369 return ((wxPostScriptPrintNativeData*)m_nativeData)->GetPrinterTranslateY();
370 #endif
371 return 0;
372 }
373
374 void wxPrintData::SetPrinterCommand(const wxString& WXUNUSED_WITHOUT_PS(command))
375 {
376 #if wxUSE_POSTSCRIPT
377 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
378 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterCommand( command );
379 #endif
380 }
381
382 void wxPrintData::SetPrinterOptions(const wxString& WXUNUSED_WITHOUT_PS(options))
383 {
384 #if wxUSE_POSTSCRIPT
385 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
386 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterOptions( options );
387 #endif
388 }
389
390 void wxPrintData::SetPreviewCommand(const wxString& WXUNUSED_WITHOUT_PS(command))
391 {
392 #if wxUSE_POSTSCRIPT
393 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
394 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPreviewCommand( command );
395 #endif
396 }
397
398 void wxPrintData::SetFontMetricPath(const wxString& WXUNUSED_WITHOUT_PS(path))
399 {
400 #if wxUSE_POSTSCRIPT
401 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
402 ((wxPostScriptPrintNativeData*)m_nativeData)->SetFontMetricPath( path );
403 #endif
404 }
405
406 void wxPrintData::SetPrinterScaleX(double WXUNUSED_WITHOUT_PS(x))
407 {
408 #if wxUSE_POSTSCRIPT
409 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
410 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleX( x );
411 #endif
412 }
413
414 void wxPrintData::SetPrinterScaleY(double WXUNUSED_WITHOUT_PS(y))
415 {
416 #if wxUSE_POSTSCRIPT
417 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
418 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaleY( y );
419 #endif
420 }
421
422 void wxPrintData::SetPrinterScaling(double WXUNUSED_WITHOUT_PS(x), double WXUNUSED_WITHOUT_PS(y))
423 {
424 #if wxUSE_POSTSCRIPT
425 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
426 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterScaling( x, y );
427 #endif
428 }
429
430 void wxPrintData::SetPrinterTranslateX(long WXUNUSED_WITHOUT_PS(x))
431 {
432 #if wxUSE_POSTSCRIPT
433 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
434 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateX( x );
435 #endif
436 }
437
438 void wxPrintData::SetPrinterTranslateY(long WXUNUSED_WITHOUT_PS(y))
439 {
440 #if wxUSE_POSTSCRIPT
441 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
442 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslateY( y );
443 #endif
444 }
445
446 void wxPrintData::SetPrinterTranslation(long WXUNUSED_WITHOUT_PS(x), long WXUNUSED_WITHOUT_PS(y))
447 {
448 #if wxUSE_POSTSCRIPT
449 if (m_nativeData && wxIsKindOf(m_nativeData,wxPostScriptPrintNativeData))
450 ((wxPostScriptPrintNativeData*)m_nativeData)->SetPrinterTranslation( x, y );
451 #endif
452 }
453 #endif
454
455 // ----------------------------------------------------------------------------
456 // Print dialog data
457 // ----------------------------------------------------------------------------
458
459 wxPrintDialogData::wxPrintDialogData()
460 {
461 m_printFromPage = 0;
462 m_printToPage = 0;
463 m_printMinPage = 0;
464 m_printMaxPage = 0;
465 m_printNoCopies = 1;
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
473 wxPrintFactory* factory = wxPrintFactory::GetFactory();
474 m_printEnablePrintToFile = ! factory->HasOwnPrintToFile();
475
476 m_printEnableHelp = false;
477 #if WXWIN_COMPATIBILITY_2_4
478 m_printSetupDialog = false;
479 #endif
480 }
481
482 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
483 : wxObject()
484 {
485 (*this) = dialogData;
486 }
487
488 wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
489 {
490 m_printFromPage = 1;
491 m_printToPage = 0;
492 m_printMinPage = 1;
493 m_printMaxPage = 9999;
494 m_printNoCopies = 1;
495 m_printAllPages = false;
496 m_printCollate = false;
497 m_printToFile = false;
498 m_printSelection = false;
499 m_printEnableSelection = false;
500 m_printEnablePageNumbers = true;
501 m_printEnablePrintToFile = true;
502 m_printEnableHelp = false;
503 #if WXWIN_COMPATIBILITY_2_4
504 m_printSetupDialog = false;
505 #endif
506 m_printData = printData;
507 }
508
509 wxPrintDialogData::~wxPrintDialogData()
510 {
511 }
512
513 #ifdef __WXMAC__
514
515 void wxPrintDialogData::ConvertToNative()
516 {
517 m_printData.ConvertToNative();
518 m_printData.m_nativePrintData->TransferFrom( this ) ;
519 }
520
521 void wxPrintDialogData::ConvertFromNative()
522 {
523 m_printData.ConvertFromNative();
524 m_printData.m_nativePrintData->TransferTo( this ) ;
525 }
526
527 #endif
528
529
530 void wxPrintDialogData::operator=(const wxPrintDialogData& data)
531 {
532 m_printFromPage = data.m_printFromPage;
533 m_printToPage = data.m_printToPage;
534 m_printMinPage = data.m_printMinPage;
535 m_printMaxPage = data.m_printMaxPage;
536 m_printNoCopies = data.m_printNoCopies;
537 m_printAllPages = data.m_printAllPages;
538 m_printCollate = data.m_printCollate;
539 m_printToFile = data.m_printToFile;
540 m_printSelection = data.m_printSelection;
541 m_printEnableSelection = data.m_printEnableSelection;
542 m_printEnablePageNumbers = data.m_printEnablePageNumbers;
543 m_printEnableHelp = data.m_printEnableHelp;
544 m_printEnablePrintToFile = data.m_printEnablePrintToFile;
545 #if WXWIN_COMPATIBILITY_2_4
546 m_printSetupDialog = data.m_printSetupDialog;
547 #endif
548 m_printData = data.m_printData;
549 }
550
551 void wxPrintDialogData::operator=(const wxPrintData& data)
552 {
553 m_printData = data;
554 }
555
556 // ----------------------------------------------------------------------------
557 // wxPageSetupDialogData
558 // ----------------------------------------------------------------------------
559
560 wxPageSetupDialogData::wxPageSetupDialogData()
561 {
562 m_paperSize = wxSize(0,0);
563
564 CalculatePaperSizeFromId();
565
566 m_minMarginTopLeft =
567 m_minMarginBottomRight =
568 m_marginTopLeft =
569 m_marginBottomRight = wxPoint(0,0);
570
571 // Flags
572 m_defaultMinMargins = false;
573 m_enableMargins = true;
574 m_enableOrientation = true;
575 m_enablePaper = true;
576 m_enablePrinter = true;
577 m_enableHelp = false;
578 m_getDefaultInfo = false;
579 }
580
581 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
582 : wxObject()
583 {
584 (*this) = dialogData;
585 }
586
587 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
588 {
589 m_paperSize = wxSize(0,0);
590 m_minMarginTopLeft =
591 m_minMarginBottomRight =
592 m_marginTopLeft =
593 m_marginBottomRight = wxPoint(0,0);
594
595 // Flags
596 m_defaultMinMargins = false;
597 m_enableMargins = true;
598 m_enableOrientation = true;
599 m_enablePaper = true;
600 m_enablePrinter = true;
601 m_enableHelp = false;
602 m_getDefaultInfo = false;
603
604 m_printData = printData;
605
606 // The wxPrintData paper size overrides these values, unless the size cannot
607 // be found.
608 CalculatePaperSizeFromId();
609 }
610
611 wxPageSetupDialogData::~wxPageSetupDialogData()
612 {
613 }
614
615 wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data)
616 {
617 m_paperSize = data.m_paperSize;
618 m_minMarginTopLeft = data.m_minMarginTopLeft;
619 m_minMarginBottomRight = data.m_minMarginBottomRight;
620 m_marginTopLeft = data.m_marginTopLeft;
621 m_marginBottomRight = data.m_marginBottomRight;
622 m_defaultMinMargins = data.m_defaultMinMargins;
623 m_enableMargins = data.m_enableMargins;
624 m_enableOrientation = data.m_enableOrientation;
625 m_enablePaper = data.m_enablePaper;
626 m_enablePrinter = data.m_enablePrinter;
627 m_getDefaultInfo = data.m_getDefaultInfo;;
628 m_enableHelp = data.m_enableHelp;
629
630 m_printData = data.m_printData;
631
632 return *this;
633 }
634
635 wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data)
636 {
637 m_printData = data;
638 CalculatePaperSizeFromId();
639
640 return *this;
641 }
642
643 #ifdef __WXMAC__
644 void wxPageSetupDialogData::ConvertToNative()
645 {
646 m_printData.ConvertToNative();
647 m_printData.m_nativePrintData->TransferFrom( this ) ;
648 }
649
650 void wxPageSetupDialogData::ConvertFromNative()
651 {
652 m_printData.ConvertFromNative ();
653 m_paperSize = m_printData.GetPaperSize() ;
654 CalculateIdFromPaperSize();
655 m_printData.m_nativePrintData->TransferTo( this ) ;
656 // adjust minimal values
657
658 if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
659 m_marginTopLeft.x = m_minMarginTopLeft.x;
660
661 if ( m_marginBottomRight.x < m_minMarginBottomRight.x )
662 m_marginBottomRight.x = m_minMarginBottomRight.x;
663
664 if ( m_marginTopLeft.y < m_minMarginTopLeft.y )
665 m_marginTopLeft.y = m_minMarginTopLeft.y;
666
667 if ( m_marginBottomRight.y < m_minMarginBottomRight.y )
668 m_marginBottomRight.y = m_minMarginBottomRight.y;
669 }
670 #endif
671
672
673 // If a corresponding paper type is found in the paper database, will set the m_printData
674 // paper size id member as well.
675 void wxPageSetupDialogData::SetPaperSize(const wxSize& sz)
676 {
677 m_paperSize = sz;
678
679 CalculateIdFromPaperSize();
680 }
681
682 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
683 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id)
684 {
685 m_printData.SetPaperId(id);
686
687 CalculatePaperSizeFromId();
688 }
689
690 void wxPageSetupDialogData::SetPrintData(const wxPrintData& printData)
691 {
692 m_printData = printData;
693 CalculatePaperSizeFromId();
694 }
695
696 // Use paper size defined in this object to set the wxPrintData
697 // paper id
698 void wxPageSetupDialogData::CalculateIdFromPaperSize()
699 {
700 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
701 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
702
703 wxSize sz = GetPaperSize();
704
705 wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
706 if (id != wxPAPER_NONE)
707 {
708 m_printData.SetPaperId(id);
709 }
710 }
711
712 // Use paper id in wxPrintData to set this object's paper size
713 void wxPageSetupDialogData::CalculatePaperSizeFromId()
714 {
715 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
716 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
717
718 wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
719
720 // sz is in 10ths of a mm, while paper size is in mm
721 m_paperSize.x = sz.x / 10;
722 m_paperSize.y = sz.y / 10;
723 }
724
725 #endif // wxUSE_PRINTING_ARCHITECTURE