]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/cmndata.cpp
Quick fix up for __WXPM__
[wxWidgets.git] / src / common / cmndata.cpp
... / ...
CommitLineData
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 and Markus Holzem
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
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
42// For compatibility
43#if (defined(__WXMOTIF__) || defined(__WXGTK__)) && wxUSE_POSTSCRIPT
44 #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
45#endif
46
47#if wxUSE_PRINTING_ARCHITECTURE
48 #include "wx/paper.h"
49
50 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
51 #include "wx/generic/dcpsg.h"
52 #endif
53#endif // wxUSE_PRINTING_ARCHITECTURE
54
55#ifdef __WXMSW__
56 #include <windows.h>
57 #include "wx/msw/private.h"
58
59 #if !defined(__WIN32__)
60 #include <print.h>
61 #include <commdlg.h>
62 #endif // Win16
63
64 #ifdef __WXWINE__
65 #include <cderr.h>
66 #include <commdlg.h>
67 #endif
68
69 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
70 #include <windowsx.h>
71 #include <commdlg.h>
72 #endif
73#endif // MSW
74
75#if !USE_SHARED_LIBRARY
76 #if wxUSE_PRINTING_ARCHITECTURE
77 IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject)
78 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject)
79 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData, wxObject)
80 #endif // wxUSE_PRINTING_ARCHITECTURE
81 IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject)
82 IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
83#endif
84
85#ifdef __WXMAC__
86#define mm2pt 2.83464566929
87#define pt2mm 0.352777777778
88#endif
89
90// ============================================================================
91// implementation
92// ============================================================================
93
94// ----------------------------------------------------------------------------
95// wxColourData
96// ----------------------------------------------------------------------------
97
98wxColourData::wxColourData()
99{
100 int i;
101 for (i = 0; i < 16; i++)
102 custColours[i].Set(255, 255, 255);
103
104 chooseFull = FALSE;
105 dataColour.Set(0,0,0);
106}
107
108wxColourData::wxColourData(const wxColourData& data)
109{
110 (*this) = data;
111}
112
113wxColourData::~wxColourData()
114{
115}
116
117void wxColourData::SetCustomColour(int i, wxColour& colour)
118{
119 if (i > 15 || i < 0)
120 return;
121
122 custColours[i] = colour;
123}
124
125wxColour wxColourData::GetCustomColour(int i)
126{
127 if (i > 15 || i < 0)
128 return wxColour(0,0,0);
129
130 return custColours[i];
131}
132
133void wxColourData::operator=(const wxColourData& data)
134{
135 int i;
136 for (i = 0; i < 16; i++)
137 custColours[i] = data.custColours[i];
138
139 dataColour = (wxColour&)data.dataColour;
140 chooseFull = data.chooseFull;
141}
142
143// ----------------------------------------------------------------------------
144// Font data
145// ----------------------------------------------------------------------------
146
147wxFontData::wxFontData()
148{
149 // Intialize colour to black.
150 fontColour.Set(0, 0, 0);
151
152 showHelp = FALSE;
153 allowSymbols = TRUE;
154 enableEffects = TRUE;
155 minSize = 0;
156 maxSize = 0;
157
158 m_encoding = wxFONTENCODING_SYSTEM;
159}
160
161wxFontData::~wxFontData()
162{
163}
164
165#if wxUSE_PRINTING_ARCHITECTURE
166// ----------------------------------------------------------------------------
167// Print data
168// ----------------------------------------------------------------------------
169
170wxPrintData::wxPrintData()
171{
172#ifdef __WXMSW__
173 m_devMode = NULL;
174#elif defined( __WXMAC__ )
175 m_macPrintInfo = NULL ;
176#endif
177 m_printOrientation = wxPORTRAIT;
178 m_printNoCopies = 1;
179 m_printCollate = FALSE;
180
181 // New, 24/3/99
182 m_printerName = "";
183 m_colour = TRUE;
184 m_duplexMode = wxDUPLEX_SIMPLEX;
185 m_printQuality = wxPRINT_QUALITY_HIGH;
186 m_paperId = wxPAPER_A4;
187 m_paperSize = wxSize(210, 297);
188
189 // PostScript-specific data
190 m_printerCommand = "";
191 m_previewCommand = "";
192 m_printerOptions = "";
193 m_filename = "";
194 m_afmPath = "";
195 m_printerScaleX = 1.0;
196 m_printerScaleY = 1.0;
197 m_printerTranslateX = 0;
198 m_printerTranslateY = 0;
199 m_printMode = wxPRINT_MODE_FILE;
200}
201
202wxPrintData::wxPrintData(const wxPrintData& printData)
203{
204#ifdef __WXMSW__
205 m_devMode = NULL;
206#endif
207
208 (*this) = printData;
209}
210
211wxPrintData::~wxPrintData()
212{
213#ifdef __WXMSW__
214 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
215 if (hDevMode )
216 GlobalFree(hDevMode);
217#elif defined(__WXMAC__)
218 if ( m_macPrintInfo )
219 ::DisposeHandle( (Handle) m_macPrintInfo ) ;
220#endif
221}
222
223#if defined(__WXMSW__) // && defined(__WIN32__)
224
225#ifdef __WIN32__
226static wxString wxGetPrintDlgError()
227{
228 DWORD err = CommDlgExtendedError();
229 wxString msg = wxT("Unknown");
230 switch (err)
231 {
232 case CDERR_FINDRESFAILURE: msg = wxT("CDERR_FINDRESFAILURE"); break;
233 case CDERR_INITIALIZATION: msg = wxT("CDERR_INITIALIZATION"); break;
234 case CDERR_LOADRESFAILURE: msg = wxT("CDERR_LOADRESFAILURE"); break;
235 case CDERR_LOADSTRFAILURE: msg = wxT("CDERR_LOADSTRFAILURE"); break;
236 case CDERR_LOCKRESFAILURE: msg = wxT("CDERR_LOCKRESFAILURE"); break;
237 case CDERR_MEMALLOCFAILURE: msg = wxT("CDERR_MEMALLOCFAILURE"); break;
238 case CDERR_MEMLOCKFAILURE: msg = wxT("CDERR_MEMLOCKFAILURE"); break;
239 case CDERR_NOHINSTANCE: msg = wxT("CDERR_NOHINSTANCE"); break;
240 case CDERR_NOHOOK: msg = wxT("CDERR_NOHOOK"); break;
241 case CDERR_NOTEMPLATE: msg = wxT("CDERR_NOTEMPLATE"); break;
242 case CDERR_STRUCTSIZE: msg = wxT("CDERR_STRUCTSIZE"); break;
243 case PDERR_RETDEFFAILURE: msg = wxT("PDERR_RETDEFFAILURE"); break;
244 case PDERR_PRINTERNOTFOUND: msg = wxT("PDERR_PRINTERNOTFOUND"); break;
245 case PDERR_PARSEFAILURE: msg = wxT("PDERR_PARSEFAILURE"); break;
246 case PDERR_NODEVICES: msg = wxT("PDERR_NODEVICES"); break;
247 case PDERR_NODEFAULTPRN: msg = wxT("PDERR_NODEFAULTPRN"); break;
248 case PDERR_LOADDRVFAILURE: msg = wxT("PDERR_LOADDRVFAILURE"); break;
249 case PDERR_INITFAILURE: msg = wxT("PDERR_INITFAILURE"); break;
250 case PDERR_GETDEVMODEFAIL: msg = wxT("PDERR_GETDEVMODEFAIL"); break;
251 case PDERR_DNDMMISMATCH: msg = wxT("PDERR_DNDMMISMATCH"); break;
252 case PDERR_DEFAULTDIFFERENT: msg = wxT("PDERR_DEFAULTDIFFERENT"); break;
253 case PDERR_CREATEICFAILURE: msg = wxT("PDERR_CREATEICFAILURE"); break;
254 default: break;
255 }
256 return msg;
257}
258#endif
259
260void wxPrintData::ConvertToNative()
261{
262 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
263 if (!hDevMode)
264 {
265 // Use PRINTDLG as a way of creating a DEVMODE object
266 PRINTDLG *pd = new PRINTDLG;
267
268 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
269#ifdef __GNUWIN32__
270 memset(pd, 0, 66);
271 pd->lStructSize = 66 ;
272#else
273 memset(pd, 0, sizeof(PRINTDLG));
274 pd->lStructSize = sizeof(PRINTDLG);
275#endif
276
277 pd->hwndOwner = (HWND)NULL;
278 pd->hDevMode = NULL; // Will be created by PrintDlg
279 pd->hDevNames = NULL; // Ditto
280 pd->hInstance = (HINSTANCE) wxGetInstance();
281
282 pd->Flags = PD_RETURNDEFAULT;
283 pd->nCopies = 1;
284
285 // Fill out the DEVMODE structure
286 // so we can use it as input in the 'real' PrintDlg
287 if (!PrintDlg(pd))
288 {
289 if ( pd->hDevMode )
290 GlobalFree(pd->hDevMode);
291 if ( pd->hDevNames )
292 GlobalFree(pd->hDevNames);
293 pd->hDevMode = NULL;
294 pd->hDevNames = NULL;
295
296#if defined(__WXDEBUG__) && defined(__WIN32__)
297 wxString str(wxT("Printing error: "));
298 str += wxGetPrintDlgError();
299 wxLogDebug(str);
300#endif
301 }
302 else
303 {
304 if ( pd->hDevNames )
305 GlobalFree(pd->hDevNames);
306 pd->hDevNames = NULL;
307
308 hDevMode = pd->hDevMode;
309 m_devMode = (void*)(long) hDevMode;
310 pd->hDevMode = NULL;
311 }
312
313 delete pd;
314 }
315
316 if ( hDevMode )
317 {
318 DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode);
319
320 //// Orientation
321
322#ifndef __WXWINE__
323 devMode->dmOrientation = m_printOrientation;
324#endif
325 devMode->dmFields = DM_ORIENTATION;
326
327 //// Collation
328
329#ifndef __WIN16__
330 devMode->dmCollate = (m_printCollate ? DMCOLLATE_TRUE : DMCOLLATE_FALSE);
331 devMode->dmFields |= DM_COLLATE;
332#endif
333
334 //// Number of copies
335
336 devMode->dmCopies = m_printNoCopies;
337 devMode->dmFields |= DM_COPIES;
338
339 //// Printer name
340
341 if (m_printerName != wxT(""))
342 {
343 // TODO: make this Unicode compatible
344 int len = wxMin(31, m_printerName.Len());
345 int i;
346 for (i = 0; i < len; i++)
347 devMode->dmDeviceName[i] = m_printerName.GetChar(i);
348 devMode->dmDeviceName[i] = 0;
349 }
350
351 //// Colour
352
353 if (m_colour)
354 devMode->dmColor = DMCOLOR_COLOR;
355 else
356 devMode->dmColor = DMCOLOR_MONOCHROME;
357
358 devMode->dmFields |= DM_COLOR;
359
360#ifndef __WXWINE__
361 //// Paper size
362
363 if (m_paperId == wxPAPER_NONE)
364 {
365 devMode->dmPaperWidth = m_paperSize.x * 10;
366 devMode->dmPaperLength = m_paperSize.y * 10;
367 devMode->dmFields |= DM_PAPERWIDTH;
368 devMode->dmFields |= DM_PAPERLENGTH;
369 }
370 else
371 {
372 if (wxThePrintPaperDatabase)
373 {
374 wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperType(m_paperId);
375 if (paper)
376 {
377 devMode->dmPaperSize = paper->GetPlatformId();
378 devMode->dmFields |= DM_PAPERSIZE;
379 }
380 }
381 }
382#endif
383
384 //// Duplex
385
386 int duplex;
387 switch (m_duplexMode)
388 {
389 case wxDUPLEX_HORIZONTAL: {
390 duplex = DMDUP_HORIZONTAL; break;
391 }
392 case wxDUPLEX_VERTICAL: {
393 duplex = DMDUP_VERTICAL; break;
394 }
395 default:
396 case wxDUPLEX_SIMPLEX: {
397 duplex = DMDUP_SIMPLEX; break;
398 }
399 }
400 devMode->dmDuplex = duplex;
401 devMode->dmFields |= DM_DUPLEX;
402
403 //// Quality
404
405 int quality;
406 switch (m_printQuality)
407 {
408 case wxPRINT_QUALITY_MEDIUM: {
409 quality = DMRES_MEDIUM; break;
410 }
411 case wxPRINT_QUALITY_LOW: {
412 quality = DMRES_LOW; break;
413 }
414 case wxPRINT_QUALITY_DRAFT: {
415 quality = DMRES_DRAFT; break;
416 }
417 case wxPRINT_QUALITY_HIGH: {
418 quality = DMRES_HIGH; break;
419 }
420 default: {
421 quality = m_printQuality; break;
422 }
423 }
424 devMode->dmPrintQuality = quality;
425 devMode->dmFields |= DM_PRINTQUALITY;
426
427 GlobalUnlock(hDevMode);
428 }
429}
430
431void wxPrintData::ConvertFromNative()
432{
433 HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
434
435 if (!hDevMode)
436 return;
437
438 if ( hDevMode )
439 {
440 DEVMODE *devMode = (DEVMODE*) GlobalLock(hDevMode);
441
442#ifndef __WXWINE__
443 //// Orientation
444
445 if (devMode->dmFields & DM_ORIENTATION)
446 m_printOrientation = devMode->dmOrientation;
447#endif
448
449 //// Collation
450
451#ifndef __WIN16__
452 if (devMode->dmFields & DM_COLLATE)
453 {
454 if (devMode->dmCollate == DMCOLLATE_TRUE)
455 m_printCollate = TRUE;
456 else
457 m_printCollate = FALSE;
458 }
459#endif
460
461 //// Number of copies
462
463 if (devMode->dmFields & DM_COPIES)
464 {
465 m_printNoCopies = devMode->dmCopies;
466 }
467
468 //// Printer name
469
470 if (devMode->dmDeviceName[0] != 0)
471 {
472 // TODO: make this Unicode compatible
473 char buf[32];
474 int i = 0;
475 while (devMode->dmDeviceName[i] != 0)
476 {
477 buf[i] = devMode->dmDeviceName[i];
478 i ++;
479 }
480 buf[i] = 0;
481
482 m_printerName = buf;
483 }
484
485 //// Colour
486
487 if (devMode->dmFields & DM_COLOR)
488 {
489 if (devMode->dmColor == DMCOLOR_COLOR)
490 m_colour = TRUE;
491 else
492 m_colour = FALSE;
493 }
494 else
495 m_colour = TRUE;
496
497#ifndef __WXWINE__
498 //// Paper size
499
500 if (devMode->dmFields & DM_PAPERSIZE)
501 {
502 if (wxThePrintPaperDatabase)
503 {
504 wxPrintPaperType* paper = wxThePrintPaperDatabase->FindPaperTypeByPlatformId(devMode->dmPaperSize);
505 if (paper)
506 {
507 m_paperId = paper->GetId();
508 m_paperSize.x = paper->GetWidth() / 10 ;
509 m_paperSize.y = paper->GetHeight() / 10 ;
510 }
511 else
512 {
513 // Shouldn't really get here
514 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
515
516 m_paperId = wxPAPER_NONE;
517 m_paperSize.x = 0;
518 m_paperSize.y = 0;
519 }
520 }
521 else
522 {
523 // Shouldn't really get here
524 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
525
526 m_paperId = wxPAPER_NONE;
527 m_paperSize.x = 0;
528 m_paperSize.y = 0;
529 }
530 }
531 else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH))
532 {
533 m_paperSize.x = devMode->dmPaperWidth / 10;
534 m_paperSize.y = devMode->dmPaperLength / 10;
535 m_paperId = wxPAPER_NONE;
536 }
537 else
538 {
539 // Shouldn't really get here
540 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
541
542 m_paperSize.x = 0;
543 m_paperSize.y = 0;
544 m_paperId = wxPAPER_NONE;
545 }
546#endif
547
548 //// Duplex
549
550 if (devMode->dmFields & DM_DUPLEX)
551 {
552 switch (devMode->dmDuplex)
553 {
554 case DMDUP_HORIZONTAL: {
555 m_duplexMode = wxDUPLEX_HORIZONTAL; break;
556 }
557 case DMDUP_VERTICAL: {
558 m_duplexMode = wxDUPLEX_VERTICAL; break;
559 }
560 default:
561 case DMDUP_SIMPLEX: {
562 m_duplexMode = wxDUPLEX_SIMPLEX; break;
563 }
564 }
565 }
566 else
567 m_duplexMode = wxDUPLEX_SIMPLEX;
568
569 //// Quality
570
571 if (devMode->dmFields & DM_PRINTQUALITY)
572 {
573 switch (devMode->dmPrintQuality)
574 {
575 case DMRES_MEDIUM: {
576 m_printQuality = wxPRINT_QUALITY_MEDIUM; break;
577 }
578 case DMRES_LOW: {
579 m_printQuality = wxPRINT_QUALITY_LOW; break;
580 }
581 case DMRES_DRAFT: {
582 m_printQuality = wxPRINT_QUALITY_DRAFT; break;
583 }
584 case DMRES_HIGH: {
585 m_printQuality = wxPRINT_QUALITY_HIGH; break;
586 }
587 default:
588 {
589 // TODO: if the printer fills in the resolution in DPI, how
590 // will the application know if it's high, low, draft etc.??
591 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
592 m_printQuality = devMode->dmPrintQuality; break;
593
594 }
595 }
596 }
597 else
598 m_printQuality = wxPRINT_QUALITY_HIGH;
599
600 GlobalUnlock(hDevMode);
601 }
602}
603
604#endif
605
606#ifdef __WXMAC__
607void wxPrintData::ConvertToNative()
608{
609 if ( !m_macPrintInfo )
610 {
611 m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
612 if ( m_macPrintInfo )
613 {
614 ::PrintDefault( m_macPrintInfo ) ;
615 // todo setup the global pagesetup ?
616 }
617 }
618 if ( m_macPrintInfo )
619 {
620 (**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
621 (**m_macPrintInfo).prJob.iFstPage = 0 ;
622 (**m_macPrintInfo).prJob.iLstPage = 0 ;
623 }
624}
625
626void wxPrintData::ConvertFromNative()
627{
628 if ( m_macPrintInfo )
629 {
630 m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
631 }
632}
633#endif
634
635void wxPrintData::operator=(const wxPrintData& data)
636{
637 m_printNoCopies = data.m_printNoCopies;
638 m_printCollate = data.m_printCollate;
639 m_printOrientation = data.m_printOrientation;
640 m_printerName = data.m_printerName;
641 m_colour = data.m_colour;
642 m_duplexMode = data.m_duplexMode;
643 m_printQuality = data.m_printQuality;
644 m_paperId = data.m_paperId;
645 m_paperSize = data.m_paperSize;
646
647 // PostScript-specific data
648 m_printerCommand = data.m_printerCommand;
649 m_previewCommand = data.m_previewCommand;
650 m_printerOptions = data.m_printerOptions;
651 m_filename = data.m_filename;
652 m_afmPath = data.m_afmPath;
653 m_printerScaleX = data.m_printerScaleX;
654 m_printerScaleY = data.m_printerScaleY;
655 m_printerTranslateX = data.m_printerTranslateX;
656 m_printerTranslateY = data.m_printerTranslateY;
657 m_printMode = data.m_printMode;
658}
659
660// For compatibility
661#if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
662void wxPrintData::operator=(const wxPrintSetupData& setupData)
663{
664 SetPrinterCommand(setupData.GetPrinterCommand());
665 SetPreviewCommand(setupData.GetPrintPreviewCommand());
666 SetPrinterOptions(setupData.GetPrinterOptions());
667
668 long xt, yt;
669 setupData.GetPrinterTranslation(& xt, & yt);
670 SetPrinterTranslation(xt, yt);
671
672 double xs, ys;
673 setupData.GetPrinterScaling(& xs, & ys);
674 SetPrinterScaling(xs, ys);
675
676 SetOrientation(setupData.GetPrinterOrientation());
677 SetPrintMode((wxPrintMode) setupData.GetPrinterMode());
678 SetFontMetricPath(setupData.GetAFMPath());
679 if (setupData.GetPaperName() != "")
680 SetPaperId(wxThePrintPaperDatabase->ConvertNameToId(setupData.GetPaperName()));
681 SetColour(setupData.GetColour());
682 SetFilename(setupData.GetPrinterFile());
683}
684#endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
685
686
687// ----------------------------------------------------------------------------
688// Print dialog data
689// ----------------------------------------------------------------------------
690
691wxPrintDialogData::wxPrintDialogData()
692{
693#ifdef __WXMSW__
694 m_printDlgData = NULL;
695#endif
696 m_printFromPage = 0;
697 m_printToPage = 0;
698 m_printMinPage = 0;
699 m_printMaxPage = 0;
700 m_printNoCopies = 1;
701 m_printAllPages = FALSE;
702 m_printCollate = FALSE;
703 m_printToFile = FALSE;
704 m_printSelection = FALSE;
705 m_printEnableSelection = FALSE;
706 m_printEnablePageNumbers = TRUE;
707 m_printEnablePrintToFile = TRUE;
708 m_printEnableHelp = FALSE;
709 m_printSetupDialog = FALSE;
710}
711
712wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
713{
714 (*this) = dialogData;
715}
716
717wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
718{
719#ifdef __WXMSW__
720 m_printDlgData = NULL;
721#elif defined( __WXMAC__ )
722 m_macPrintInfo = NULL ;
723#endif
724 m_printFromPage = 0;
725 m_printToPage = 0;
726 m_printMinPage = 0;
727 m_printMaxPage = 0;
728 m_printNoCopies = 1;
729 m_printAllPages = FALSE;
730 m_printCollate = FALSE;
731 m_printToFile = FALSE;
732 m_printSelection = FALSE;
733 m_printEnableSelection = FALSE;
734 m_printEnablePageNumbers = TRUE;
735 m_printEnablePrintToFile = TRUE;
736 m_printEnableHelp = FALSE;
737 m_printSetupDialog = FALSE;
738
739 m_printData = printData;
740}
741
742wxPrintDialogData::~wxPrintDialogData()
743{
744#ifdef __WXMSW__
745 PRINTDLG *pd = (PRINTDLG *) m_printDlgData;
746 if ( pd && pd->hDevMode )
747 GlobalFree(pd->hDevMode);
748 if ( pd )
749 delete pd;
750#elif defined(__WXMAC__)
751 if ( m_macPrintInfo )
752 ::DisposeHandle( (Handle) m_macPrintInfo ) ;
753#endif
754}
755
756#ifdef __WXMSW__
757void wxPrintDialogData::ConvertToNative()
758{
759 m_printData.ConvertToNative();
760
761 PRINTDLG *pd = (PRINTDLG*) m_printDlgData;
762
763 if (!pd)
764 {
765 pd = new PRINTDLG;
766 m_printDlgData = (void*) pd;
767
768 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
769#ifdef __GNUWIN32__
770 pd->lStructSize = 66 ;
771#else
772 pd->lStructSize = sizeof(PRINTDLG);
773#endif
774 pd->hwndOwner = (HWND)NULL;
775 pd->hDevMode = NULL; // Will be created by PrintDlg
776 pd->hDevNames = NULL; // Ditto
777
778 pd->Flags = PD_RETURNDEFAULT;
779 pd->nCopies = 1;
780 }
781
782 // Pass the devmode data to the PRINTDLG structure, since it'll
783 // be needed when PrintDlg is called.
784 if (pd->hDevMode)
785 {
786 GlobalFree(pd->hDevMode);
787 }
788
789 pd->hDevMode = (HGLOBAL)(DWORD) m_printData.GetNativeData();
790
791 m_printData.SetNativeData((void*) NULL);
792
793 wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
794
795 pd->hDC = (HDC) NULL;
796 pd->nFromPage = (UINT)m_printFromPage;
797 pd->nToPage = (UINT)m_printToPage;
798 pd->nMinPage = (UINT)m_printMinPage;
799 pd->nMaxPage = (UINT)m_printMaxPage;
800 pd->nCopies = (UINT)m_printNoCopies;
801
802 pd->Flags = PD_RETURNDC ;
803
804#ifdef __GNUWIN32__
805 pd->lStructSize = 66 ;
806#else
807 pd->lStructSize = sizeof( PRINTDLG );
808#endif
809
810 pd->hwndOwner=(HWND)NULL;
811 pd->hDevNames=(HANDLE)NULL;
812 pd->hInstance=(HINSTANCE)NULL;
813 pd->lCustData = (LPARAM) NULL;
814 pd->lpfnPrintHook = NULL;
815 pd->lpfnSetupHook = NULL;
816 pd->lpPrintTemplateName = NULL;
817 pd->lpSetupTemplateName = NULL;
818 pd->hPrintTemplate = (HGLOBAL) NULL;
819 pd->hSetupTemplate = (HGLOBAL) NULL;
820
821 if ( m_printAllPages )
822 pd->Flags |= PD_ALLPAGES;
823 if ( m_printAllPages )
824 pd->Flags |= PD_SELECTION;
825 if ( m_printCollate )
826 pd->Flags |= PD_COLLATE;
827 if ( m_printToFile )
828 pd->Flags |= PD_PRINTTOFILE;
829 if ( !m_printEnablePrintToFile )
830 pd->Flags |= PD_DISABLEPRINTTOFILE;
831 if ( !m_printEnableSelection )
832 pd->Flags |= PD_NOSELECTION;
833 if ( !m_printEnablePageNumbers )
834 pd->Flags |= PD_NOPAGENUMS;
835 if ( m_printEnableHelp )
836 pd->Flags |= PD_SHOWHELP;
837 if ( m_printSetupDialog )
838 pd->Flags |= PD_PRINTSETUP;
839}
840
841void wxPrintDialogData::ConvertFromNative()
842{
843 PRINTDLG *pd = (PRINTDLG*) m_printDlgData;
844 if ( pd == NULL )
845 return;
846
847 // Pass the devmode data back to the wxPrintData structure where it really belongs.
848 if (pd->hDevMode)
849 {
850 if (m_printData.GetNativeData())
851 {
852 // Make sure we don't leak memory
853 GlobalFree((HGLOBAL)(DWORD) m_printData.GetNativeData());
854 }
855 m_printData.SetNativeData((void*)(long) pd->hDevMode);
856 pd->hDevMode = NULL;
857 }
858
859 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
860 // into wxWindows form.
861 m_printData.ConvertFromNative();
862
863 m_printFromPage = pd->nFromPage ;
864 m_printToPage = pd->nToPage ;
865 m_printMinPage = pd->nMinPage ;
866 m_printMaxPage = pd->nMaxPage ;
867 m_printNoCopies = pd->nCopies ;
868
869 m_printAllPages = ((pd->Flags & PD_ALLPAGES) == PD_ALLPAGES);
870 m_printSelection = ((pd->Flags & PD_SELECTION) == PD_SELECTION);
871 m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE);
872 m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE);
873 m_printEnablePrintToFile = ((pd->Flags & PD_DISABLEPRINTTOFILE) != PD_DISABLEPRINTTOFILE);
874 m_printEnableSelection = ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION);
875 m_printEnablePageNumbers = ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS);
876 m_printEnableHelp = ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP);
877 m_printSetupDialog = ((pd->Flags & PD_PRINTSETUP) == PD_PRINTSETUP);
878
879/* port is obsolete in WIN32
880 // Get the port name
881 if (pd->hDevNames)
882 {
883 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
884 if (lpDevNames) {
885 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
886 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
887 GlobalUnlock(pd->hDevNames);
888
889// wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
890 }
891 }
892*/
893}
894
895void wxPrintDialogData::SetOwnerWindow(wxWindow* win)
896{
897 if ( m_printDlgData == NULL )
898 ConvertToNative();
899
900 if ( m_printDlgData != NULL && win != NULL)
901 {
902 PRINTDLG *pd = (PRINTDLG *) m_printDlgData ;
903 pd->hwndOwner=(HWND) win->GetHWND();
904 }
905}
906#endif // MSW
907
908#ifdef __WXMAC__
909void wxPrintDialogData::ConvertToNative()
910{
911 if ( !m_macPrintInfo )
912 {
913 m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
914 if ( m_macPrintInfo )
915 {
916 ::PrintDefault( m_macPrintInfo ) ;
917 // todo setup the global pagesetup ?
918 }
919 }
920 if ( m_macPrintInfo )
921 {
922 (**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
923 (**m_macPrintInfo).prJob.iFstPage = m_printFromPage ;
924 (**m_macPrintInfo).prJob.iLstPage = m_printToPage ;
925 }
926}
927
928void wxPrintDialogData::ConvertFromNative()
929{
930 if ( m_macPrintInfo )
931 {
932 m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
933 m_printFromPage = (**m_macPrintInfo).prJob.iFstPage ;
934 m_printToPage = (**m_macPrintInfo).prJob.iLstPage ;
935 }
936}
937#endif
938
939
940void wxPrintDialogData::operator=(const wxPrintDialogData& data)
941{
942 m_printFromPage = data.m_printFromPage;
943 m_printToPage = data.m_printToPage;
944 m_printMinPage = data.m_printMinPage;
945 m_printMaxPage = data.m_printMaxPage;
946 m_printNoCopies = data.m_printNoCopies;
947 m_printAllPages = data.m_printAllPages;
948 m_printCollate = data.m_printCollate;
949 m_printToFile = data.m_printToFile;
950 m_printSelection = data.m_printSelection;
951 m_printEnableSelection = data.m_printEnableSelection;
952 m_printEnablePageNumbers = data.m_printEnablePageNumbers;
953 m_printEnableHelp = data.m_printEnableHelp;
954 m_printEnablePrintToFile = data.m_printEnablePrintToFile;
955 m_printSetupDialog = data.m_printSetupDialog;
956
957 m_printData = data.m_printData;
958}
959
960void wxPrintDialogData::operator=(const wxPrintData& data)
961{
962 m_printData = data;
963}
964
965// ----------------------------------------------------------------------------
966// wxPageSetupDialogData
967// ----------------------------------------------------------------------------
968
969wxPageSetupDialogData::wxPageSetupDialogData()
970{
971#if defined(__WIN95__)
972 m_pageSetupData = NULL;
973#elif defined( __WXMAC__ )
974 m_macPageSetupInfo = NULL ;
975#endif
976 m_paperSize = wxSize(0, 0);
977
978 CalculatePaperSizeFromId();
979
980 m_minMarginTopLeft = wxPoint(0, 0);
981 m_minMarginBottomRight = wxPoint(0, 0);
982 m_marginTopLeft = wxPoint(0, 0);
983 m_marginBottomRight = wxPoint(0, 0);
984
985 // Flags
986 m_defaultMinMargins = FALSE;
987 m_enableMargins = TRUE;
988 m_enableOrientation = TRUE;
989 m_enablePaper = TRUE;
990 m_enablePrinter = TRUE;
991 m_enableHelp = FALSE;
992 m_getDefaultInfo = FALSE;
993}
994
995wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
996{
997 (*this) = dialogData;
998}
999
1000wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
1001{
1002#if defined(__WIN95__)
1003 m_pageSetupData = NULL;
1004#elif defined( __WXMAC__ )
1005 m_macPageSetupInfo = NULL ;
1006#endif
1007 m_paperSize = wxSize(0, 0);
1008 m_minMarginTopLeft = wxPoint(0, 0);
1009 m_minMarginBottomRight = wxPoint(0, 0);
1010 m_marginTopLeft = wxPoint(0, 0);
1011 m_marginBottomRight = wxPoint(0, 0);
1012
1013 // Flags
1014 m_defaultMinMargins = FALSE;
1015 m_enableMargins = TRUE;
1016 m_enableOrientation = TRUE;
1017 m_enablePaper = TRUE;
1018 m_enablePrinter = TRUE;
1019 m_enableHelp = FALSE;
1020 m_getDefaultInfo = FALSE;
1021
1022 m_printData = printData;
1023
1024 // The wxPrintData paper size overrides these values, unless the size cannot
1025 // be found.
1026 CalculatePaperSizeFromId();
1027}
1028
1029wxPageSetupDialogData::~wxPageSetupDialogData()
1030{
1031#if defined(__WIN95__) && defined(__WXMSW__)
1032 PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData;
1033 if ( pd && pd->hDevMode )
1034 GlobalFree(pd->hDevMode);
1035 if ( pd )
1036 delete pd;
1037#elif defined( __WXMAC__ )
1038 if( m_macPageSetupInfo )
1039 ::DisposeHandle( (Handle) m_macPageSetupInfo ) ;
1040#endif
1041}
1042
1043void wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data)
1044{
1045 m_paperSize = data.m_paperSize;
1046 m_minMarginTopLeft = data.m_minMarginTopLeft;
1047 m_minMarginBottomRight = data.m_minMarginBottomRight;
1048 m_marginTopLeft = data.m_marginTopLeft;
1049 m_marginBottomRight = data.m_marginBottomRight;
1050 m_defaultMinMargins = data.m_defaultMinMargins;
1051 m_enableMargins = data.m_enableMargins;
1052 m_enableOrientation = data.m_enableOrientation;
1053 m_enablePaper = data.m_enablePaper;
1054 m_enablePrinter = data.m_enablePrinter;
1055 m_getDefaultInfo = data.m_getDefaultInfo;;
1056 m_enableHelp = data.m_enableHelp;
1057
1058 m_printData = data.m_printData;
1059}
1060
1061void wxPageSetupDialogData::operator=(const wxPrintData& data)
1062{
1063 m_printData = data;
1064}
1065
1066#if defined(__WIN95__)
1067void wxPageSetupDialogData::ConvertToNative()
1068{
1069 m_printData.ConvertToNative();
1070
1071 PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData;
1072
1073 if ( m_pageSetupData == NULL )
1074 {
1075 pd = new PAGESETUPDLG;
1076 pd->hDevMode = NULL;
1077 m_pageSetupData = (void *)pd;
1078 }
1079
1080 // Pass the devmode data (created in m_printData.ConvertToNative)
1081 // to the PRINTDLG structure, since it'll
1082 // be needed when PrintDlg is called.
1083
1084 if (pd->hDevMode)
1085 {
1086 GlobalFree(pd->hDevMode);
1087 pd->hDevMode = NULL;
1088 }
1089
1090 pd->hDevMode = (HGLOBAL) m_printData.GetNativeData();
1091
1092 m_printData.SetNativeData((void*) NULL);
1093
1094 wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1095
1096// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1097
1098 pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
1099
1100 if ( m_defaultMinMargins )
1101 pd->Flags |= PSD_DEFAULTMINMARGINS;
1102 if ( !m_enableMargins )
1103 pd->Flags |= PSD_DISABLEMARGINS;
1104 if ( !m_enableOrientation )
1105 pd->Flags |= PSD_DISABLEORIENTATION;
1106 if ( !m_enablePaper )
1107 pd->Flags |= PSD_DISABLEPAPER;
1108 if ( !m_enablePrinter )
1109 pd->Flags |= PSD_DISABLEPRINTER;
1110 if ( m_getDefaultInfo )
1111 pd->Flags |= PSD_RETURNDEFAULT;
1112 if ( m_enableHelp )
1113 pd->Flags |= PSD_SHOWHELP;
1114
1115 // We want the units to be in hundredths of a millimetre
1116 pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
1117
1118 pd->lStructSize = sizeof( PAGESETUPDLG );
1119 pd->hwndOwner=(HWND)NULL;
1120 pd->hDevNames=(HWND)NULL;
1121 pd->hInstance=(HINSTANCE)NULL;
1122
1123 pd->ptPaperSize.x = m_paperSize.x * 100;
1124 pd->ptPaperSize.y = m_paperSize.y * 100;
1125
1126 pd->rtMinMargin.left = m_minMarginTopLeft.x * 100;
1127 pd->rtMinMargin.top = m_minMarginTopLeft.y * 100;
1128 pd->rtMinMargin.right = m_minMarginBottomRight.x * 100;
1129 pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100;
1130
1131 pd->rtMargin.left = m_marginTopLeft.x * 100;
1132 pd->rtMargin.top = m_marginTopLeft.y * 100;
1133 pd->rtMargin.right = m_marginBottomRight.x * 100;
1134 pd->rtMargin.bottom = m_marginBottomRight.y * 100;
1135
1136 pd->lCustData = 0;
1137 pd->lpfnPageSetupHook = NULL;
1138 pd->lpfnPagePaintHook = NULL;
1139 pd->hPageSetupTemplate = NULL;
1140 pd->lpPageSetupTemplateName = NULL;
1141
1142/*
1143 if ( pd->hDevMode )
1144 {
1145 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1146 memset(devMode, 0, sizeof(DEVMODE));
1147 devMode->dmSize = sizeof(DEVMODE);
1148 devMode->dmOrientation = m_orientation;
1149 devMode->dmFields = DM_ORIENTATION;
1150 GlobalUnlock(pd->hDevMode);
1151 }
1152*/
1153}
1154
1155void wxPageSetupDialogData::ConvertFromNative()
1156{
1157 PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
1158 if ( !pd )
1159 return;
1160
1161 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1162 if (pd->hDevMode)
1163 {
1164 if (m_printData.GetNativeData())
1165 {
1166 // Make sure we don't leak memory
1167 GlobalFree((HGLOBAL) m_printData.GetNativeData());
1168 }
1169 m_printData.SetNativeData((void*) pd->hDevMode);
1170 pd->hDevMode = NULL;
1171 }
1172
1173 m_printData.ConvertFromNative();
1174
1175 pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
1176
1177 m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS);
1178 m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS);
1179 m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION);
1180 m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER);
1181 m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER);
1182 m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT);
1183 m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP);
1184
1185 m_paperSize.x = pd->ptPaperSize.x / 100;
1186 m_paperSize.y = pd->ptPaperSize.y / 100;
1187
1188 m_minMarginTopLeft.x = pd->rtMinMargin.left / 100;
1189 m_minMarginTopLeft.y = pd->rtMinMargin.top / 100;
1190 m_minMarginBottomRight.x = pd->rtMinMargin.right / 100;
1191 m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100;
1192
1193 m_marginTopLeft.x = pd->rtMargin.left / 100 ;
1194 m_marginTopLeft.y = pd->rtMargin.top / 100 ;
1195 m_marginBottomRight.x = pd->rtMargin.right / 100 ;
1196 m_marginBottomRight.y = pd->rtMargin.bottom / 100 ;
1197}
1198
1199void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
1200{
1201 if ( m_pageSetupData == NULL )
1202 ConvertToNative();
1203
1204 if ( m_pageSetupData != NULL && win != NULL)
1205 {
1206 PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
1207 pd->hwndOwner=(HWND) win->GetHWND();
1208 }
1209}
1210#endif // Win95
1211
1212#ifdef __WXMAC__
1213void wxPageSetupData::ConvertToNative()
1214{
1215 if ( !m_macPageSetupInfo )
1216 {
1217 m_macPageSetupInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
1218 if ( m_macPageSetupInfo )
1219 {
1220 ::PrintDefault( m_macPageSetupInfo ) ;
1221 }
1222 }
1223 if ( m_macPageSetupInfo )
1224 {
1225 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1226 (**m_macPageSetupInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt ) ;
1227 (**m_macPageSetupInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt ) ;
1228
1229 (**m_macPageSetupInfo).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt ) ;
1230 (**m_macPageSetupInfo).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt ) ;
1231
1232 (**m_macPageSetupInfo).prInfo.rPage.left = 0 ;
1233 (**m_macPageSetupInfo).prInfo.rPage.top = 0 ;
1234 (**m_macPageSetupInfo).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt ) ;
1235 (**m_macPageSetupInfo).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt ) ;
1236
1237 //TODO add custom fields in dialog for margins
1238
1239 }
1240}
1241
1242void wxPageSetupData::ConvertFromNative()
1243{
1244 if ( m_macPageSetupInfo )
1245 {
1246 m_paperSize.x = ((double) (**m_macPageSetupInfo).rPaper.right - (**m_macPageSetupInfo).rPaper.left ) * pt2mm ;
1247 m_paperSize.y = ((double) (**m_macPageSetupInfo).rPaper.bottom - (**m_macPageSetupInfo).rPaper.top ) * pt2mm ;
1248
1249 m_minMarginTopLeft.x = ((double) -(**m_macPageSetupInfo).rPaper.left ) * pt2mm ;
1250 m_minMarginTopLeft.y = ((double) -(**m_macPageSetupInfo).rPaper.top ) * pt2mm ;
1251
1252 m_minMarginBottomRight.x = ((double) (**m_macPageSetupInfo).rPaper.right - (**m_macPageSetupInfo).prInfo.rPage.right ) * pt2mm ;
1253 m_minMarginBottomRight.y = ((double)(**m_macPageSetupInfo).rPaper.bottom - (**m_macPageSetupInfo).prInfo.rPage.bottom ) * pt2mm ;
1254
1255 // adjust minimal values
1256 //TODO add custom fields in dialog for margins
1257
1258 if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
1259 m_marginTopLeft.x = m_minMarginTopLeft.x ;
1260
1261 if ( m_marginBottomRight.x < m_minMarginBottomRight.x )
1262 m_marginBottomRight.x = m_minMarginBottomRight.x ;
1263
1264 if ( m_marginTopLeft.y < m_minMarginTopLeft.y )
1265 m_marginTopLeft.y = m_minMarginTopLeft.y ;
1266
1267 if ( m_marginBottomRight.y < m_minMarginBottomRight.y )
1268 m_marginBottomRight.y = m_minMarginBottomRight.y ;
1269
1270 }
1271}
1272#endif
1273
1274
1275// If a corresponding paper type is found in the paper database, will set the m_printData
1276// paper size id member as well.
1277void wxPageSetupDialogData::SetPaperSize(const wxSize& sz)
1278{
1279 m_paperSize = sz;
1280
1281 CalculateIdFromPaperSize();
1282}
1283
1284// Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1285void wxPageSetupDialogData::SetPaperSize(wxPaperSize id)
1286{
1287 m_printData.SetPaperId(id);
1288
1289 CalculatePaperSizeFromId();
1290}
1291
1292// Use paper size defined in this object to set the wxPrintData
1293// paper id
1294void wxPageSetupDialogData::CalculateIdFromPaperSize()
1295{
1296 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
1297 wxT("wxThePrintPaperDatabase should not be NULL. "
1298 "Do not create global print dialog data objects.") );
1299
1300 wxSize sz = GetPaperSize();
1301
1302 wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
1303 if (id != wxPAPER_NONE)
1304 {
1305 m_printData.SetPaperId(id);
1306 }
1307}
1308
1309// Use paper id in wxPrintData to set this object's paper size
1310void wxPageSetupDialogData::CalculatePaperSizeFromId()
1311{
1312 wxASSERT_MSG( (wxThePrintPaperDatabase != (wxPrintPaperDatabase*) NULL),
1313 wxT("wxThePrintPaperDatabase should not be NULL. "
1314 "Do not create global print dialog data objects.") );
1315
1316 wxSize sz = wxThePrintPaperDatabase->GetSize(m_printData.GetPaperId());
1317
1318 if (sz.x != 0)
1319 {
1320 // sz is in 10ths of a mm, so multiply by 10.
1321 m_paperSize.x = sz.x * 10;
1322 m_paperSize.y = sz.y * 10;
1323 }
1324}
1325
1326#endif // wxUSE_PRINTING_ARCHITECTURE