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