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