1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI data
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "cmndata.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/string.h"
38 #include "wx/gdicmn.h"
39 #include "wx/cmndata.h"
43 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT
44 #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
47 #if wxUSE_PRINTING_ARCHITECTURE
50 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
51 #include "wx/generic/dcpsg.h"
53 #endif // wxUSE_PRINTING_ARCHITECTURE
57 #include "wx/msw/private.h"
59 #if !defined(__WIN32__)
69 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
75 #if wxUSE_PRINTING_ARCHITECTURE
76 IMPLEMENT_DYNAMIC_CLASS(wxPrintData
, wxObject
)
77 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData
, wxObject
)
78 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData
, wxObject
)
79 #endif // wxUSE_PRINTING_ARCHITECTURE
81 IMPLEMENT_DYNAMIC_CLASS(wxFontData
, wxObject
)
82 IMPLEMENT_DYNAMIC_CLASS(wxColourData
, wxObject
)
85 #define mm2pt 2.83464566929
86 #define pt2mm 0.352777777778
89 // ============================================================================
91 // ============================================================================
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 wxColourData::wxColourData()
100 for (i
= 0; i
< 16; i
++)
101 custColours
[i
].Set(255, 255, 255);
104 dataColour
.Set(0,0,0);
107 wxColourData::wxColourData(const wxColourData
& data
)
112 wxColourData::~wxColourData()
116 void wxColourData::SetCustomColour(int i
, wxColour
& colour
)
121 custColours
[i
] = colour
;
124 wxColour
wxColourData::GetCustomColour(int i
)
127 return wxColour(0,0,0);
129 return custColours
[i
];
132 void wxColourData::operator=(const wxColourData
& data
)
135 for (i
= 0; i
< 16; i
++)
136 custColours
[i
] = data
.custColours
[i
];
138 dataColour
= (wxColour
&)data
.dataColour
;
139 chooseFull
= data
.chooseFull
;
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 wxFontData::wxFontData()
148 // Intialize colour to black.
149 fontColour
.Set(0, 0, 0);
153 enableEffects
= TRUE
;
157 m_encoding
= wxFONTENCODING_SYSTEM
;
160 wxFontData::~wxFontData()
164 #if wxUSE_PRINTING_ARCHITECTURE
165 // ----------------------------------------------------------------------------
167 // ----------------------------------------------------------------------------
169 wxPrintData::wxPrintData()
172 m_devMode
= (void*) NULL
;
173 m_devNames
= (void*) NULL
;
174 #elif defined( __WXMAC__ )
176 m_macPageFormat
= kPMNoPageFormat
;
177 m_macPrintSettings
= kPMNoPrintSettings
;
179 m_macPrintInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) ) ;
180 (**m_macPrintInfo
).iPrVersion
= 0; // something invalid
182 (**m_macPrintInfo
).prInfo
.iHRes
= 72;
183 (**m_macPrintInfo
).prInfo
.iVRes
= 72;
184 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 } ;
185 (**m_macPrintInfo
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
187 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 } ;
188 (**m_macPrintInfo
).rPaper
= r2
;
189 (**m_macPrintInfo
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
190 (**m_macPrintInfo
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
193 m_printOrientation
= wxPORTRAIT
;
195 m_printCollate
= FALSE
;
200 m_duplexMode
= wxDUPLEX_SIMPLEX
;
201 m_printQuality
= wxPRINT_QUALITY_HIGH
;
202 m_paperId
= wxPAPER_A4
;
203 m_paperSize
= wxSize(210, 297);
205 // PostScript-specific data
206 m_printerCommand
= "";
207 m_previewCommand
= "";
208 m_printerOptions
= "";
211 m_printerScaleX
= 1.0;
212 m_printerScaleY
= 1.0;
213 m_printerTranslateX
= 0;
214 m_printerTranslateY
= 0;
215 m_printMode
= wxPRINT_MODE_FILE
;
218 wxPrintData::wxPrintData(const wxPrintData
& printData
)
221 m_devMode
= (void*) NULL
;
222 m_devNames
= (void*) NULL
;
223 #elif defined( __WXMAC__ )
225 m_macPageFormat
= kPMNoPageFormat
;
226 m_macPrintSettings
= kPMNoPrintSettings
;
228 m_macPrintInfo
= NULL
;
234 wxPrintData::~wxPrintData()
237 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
239 GlobalFree(hDevMode
);
240 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
242 GlobalFree(hDevNames
);
243 #elif defined(__WXMAC__)
245 if (m_macPageFormat
!= kPMNoPageFormat
)
247 (void)PMDisposePageFormat(m_macPageFormat
);
248 m_macPageFormat
= kPMNoPageFormat
;
251 if (m_macPrintSettings
!= kPMNoPrintSettings
)
253 (void)PMDisposePrintSettings(m_macPrintSettings
);
254 m_macPrintSettings
= kPMNoPrintSettings
;
257 wxASSERT( m_macPrintInfo
) ;
258 // we should perhaps delete
263 #if defined(__WXMSW__) // && defined(__WIN32__)
265 #if defined(__WXDEBUG__) && defined(__WIN32__)
266 static wxString
wxGetPrintDlgError()
268 DWORD err
= CommDlgExtendedError();
269 wxString msg
= wxT("Unknown");
272 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
273 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
274 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
275 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
276 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
277 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
278 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
279 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
280 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
281 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
282 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
283 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
284 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
285 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
286 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
287 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
288 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
289 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
290 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
291 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
292 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
293 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
300 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
303 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
304 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
309 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
310 driverName
.Length() + 1 +
311 printerName
.Length() + 1 +
312 portName
.Length()+1);
313 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
314 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
315 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wDriverOffset
, driverName
);
317 lpDev
->wDeviceOffset
= (WORD
)(lpDev
->wDriverOffset
+ driverName
.Length()+1);
318 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wDeviceOffset
, printerName
);
320 lpDev
->wOutputOffset
= (WORD
)(lpDev
->wDeviceOffset
+ printerName
.Length()+1);
321 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wOutputOffset
, portName
);
330 void wxPrintData::ConvertToNative()
332 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
333 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
336 // Use PRINTDLG as a way of creating a DEVMODE object
337 PRINTDLG
*pd
= new PRINTDLG
;
339 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
342 pd
->lStructSize
= 66 ;
344 memset(pd
, 0, sizeof(PRINTDLG
));
345 pd
->lStructSize
= sizeof(PRINTDLG
);
348 pd
->hwndOwner
= (HWND
)NULL
;
349 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
350 pd
->hDevNames
= NULL
; // Ditto
351 pd
->hInstance
= (HINSTANCE
) wxGetInstance();
353 pd
->Flags
= PD_RETURNDEFAULT
;
356 // Fill out the DEVMODE structure
357 // so we can use it as input in the 'real' PrintDlg
361 GlobalFree(pd
->hDevMode
);
363 GlobalFree(pd
->hDevNames
);
365 pd
->hDevNames
= NULL
;
367 #if defined(__WXDEBUG__) && defined(__WIN32__)
368 wxString
str(wxT("Printing error: "));
369 str
+= wxGetPrintDlgError();
375 hDevMode
= pd
->hDevMode
;
376 m_devMode
= (void*)(long) hDevMode
;
379 // We'll create a new DEVNAMEs structure below.
381 GlobalFree(pd
->hDevNames
);
382 pd
->hDevNames
= NULL
;
384 // hDevNames = pd->hDevNames;
385 // m_devNames = (void*)(long) hDevNames;
386 // pd->hDevnames = NULL;
395 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
400 devMode
->dmOrientation
= m_printOrientation
;
402 devMode
->dmFields
= DM_ORIENTATION
;
407 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
408 devMode
->dmFields
|= DM_COLLATE
;
411 //// Number of copies
413 devMode
->dmCopies
= m_printNoCopies
;
414 devMode
->dmFields
|= DM_COPIES
;
418 if (m_printerName
!= wxT(""))
420 // TODO: make this Unicode compatible
421 int len
= wxMin(31, m_printerName
.Len());
423 for (i
= 0; i
< len
; i
++)
424 devMode
->dmDeviceName
[i
] = m_printerName
.GetChar(i
);
425 devMode
->dmDeviceName
[i
] = 0;
431 devMode
->dmColor
= DMCOLOR_COLOR
;
433 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
435 devMode
->dmFields
|= DM_COLOR
;
440 if (m_paperId
== wxPAPER_NONE
)
442 // DEVMODE is in tenths of a milimeter
443 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
444 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
445 devMode
->dmPaperSize
= DMPAPER_USER
;
446 devMode
->dmFields
|= DM_PAPERWIDTH
;
447 devMode
->dmFields
|= DM_PAPERLENGTH
;
451 if (wxThePrintPaperDatabase
)
453 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
456 devMode
->dmPaperSize
= paper
->GetPlatformId();
457 devMode
->dmFields
|= DM_PAPERSIZE
;
466 switch (m_duplexMode
)
468 case wxDUPLEX_HORIZONTAL
: {
469 duplex
= DMDUP_HORIZONTAL
; break;
471 case wxDUPLEX_VERTICAL
: {
472 duplex
= DMDUP_VERTICAL
; break;
475 case wxDUPLEX_SIMPLEX
: {
476 duplex
= DMDUP_SIMPLEX
; break;
479 devMode
->dmDuplex
= duplex
;
480 devMode
->dmFields
|= DM_DUPLEX
;
485 switch (m_printQuality
)
487 case wxPRINT_QUALITY_MEDIUM
: {
488 quality
= DMRES_MEDIUM
; break;
490 case wxPRINT_QUALITY_LOW
: {
491 quality
= DMRES_LOW
; break;
493 case wxPRINT_QUALITY_DRAFT
: {
494 quality
= DMRES_DRAFT
; break;
496 case wxPRINT_QUALITY_HIGH
: {
497 quality
= DMRES_HIGH
; break;
500 quality
= m_printQuality
; break;
503 devMode
->dmPrintQuality
= quality
;
504 devMode
->dmFields
|= DM_PRINTQUALITY
;
506 GlobalUnlock(hDevMode
);
511 GlobalFree(hDevNames
);
514 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
515 m_devNames
= (void*) (long) wxCreateDevNames("", m_printerName
, "");
518 void wxPrintData::ConvertFromNative()
520 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
521 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
528 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
533 if (devMode
->dmFields
& DM_ORIENTATION
)
534 m_printOrientation
= devMode
->dmOrientation
;
540 if (devMode
->dmFields
& DM_COLLATE
)
542 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
543 m_printCollate
= TRUE
;
545 m_printCollate
= FALSE
;
549 //// Number of copies
551 if (devMode
->dmFields
& DM_COPIES
)
553 m_printNoCopies
= devMode
->dmCopies
;
558 if (devMode
->dmDeviceName
[0] != 0)
560 // TODO: make this Unicode compatible
563 while (devMode
->dmDeviceName
[i
] != 0)
565 buf
[i
] = devMode
->dmDeviceName
[i
];
575 if (devMode
->dmFields
& DM_COLOR
)
577 if (devMode
->dmColor
== DMCOLOR_COLOR
)
588 if (devMode
->dmFields
& DM_PAPERSIZE
)
590 if (wxThePrintPaperDatabase
)
592 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
595 m_paperId
= paper
->GetId();
596 m_paperSize
.x
= paper
->GetWidth() / 10 ;
597 m_paperSize
.y
= paper
->GetHeight() / 10 ;
601 // Shouldn't really get here
602 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
604 m_paperId
= wxPAPER_NONE
;
611 // Shouldn't really get here
612 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
614 m_paperId
= wxPAPER_NONE
;
619 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
621 // DEVMODE is in tenths of a milimeter
622 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
623 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
624 m_paperId
= wxPAPER_NONE
;
628 // Shouldn't really get here
629 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
633 m_paperId
= wxPAPER_NONE
;
639 if (devMode
->dmFields
& DM_DUPLEX
)
641 switch (devMode
->dmDuplex
)
643 case DMDUP_HORIZONTAL
: {
644 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
646 case DMDUP_VERTICAL
: {
647 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
650 case DMDUP_SIMPLEX
: {
651 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
656 m_duplexMode
= wxDUPLEX_SIMPLEX
;
660 if (devMode
->dmFields
& DM_PRINTQUALITY
)
662 switch (devMode
->dmPrintQuality
)
665 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
668 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
671 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
674 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
678 // TODO: if the printer fills in the resolution in DPI, how
679 // will the application know if it's high, low, draft etc.??
680 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
681 m_printQuality
= devMode
->dmPrintQuality
; break;
687 m_printQuality
= wxPRINT_QUALITY_HIGH
;
689 GlobalUnlock(hDevMode
);
694 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
697 // TODO: Unicode-ification
700 // port is obsolete in WIN32
701 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
703 // Get the printer name
704 wxString printerName
= (LPSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
706 // Not sure if we should check for this mismatch
707 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
709 if (printerName
!= wxT(""))
710 m_printerName
= printerName
;
712 GlobalUnlock(hDevNames
);
720 void wxPrintData::ConvertToNative()
724 (**m_macPrintInfo
).prJob
.iCopies
= m_printNoCopies
;
728 void wxPrintData::ConvertFromNative()
732 m_printNoCopies
= (**m_macPrintInfo
).prJob
.iCopies
;
737 void wxPrintData::operator=(const wxPrintData
& data
)
742 m_macPrintInfo
= data
.m_macPrintInfo
;
743 HandToHand( (Handle
*) &m_macPrintInfo
) ;
746 m_printNoCopies
= data
.m_printNoCopies
;
747 m_printCollate
= data
.m_printCollate
;
748 m_printOrientation
= data
.m_printOrientation
;
749 m_printerName
= data
.m_printerName
;
750 m_colour
= data
.m_colour
;
751 m_duplexMode
= data
.m_duplexMode
;
752 m_printQuality
= data
.m_printQuality
;
753 m_paperId
= data
.m_paperId
;
754 m_paperSize
= data
.m_paperSize
;
756 // PostScript-specific data
757 m_printerCommand
= data
.m_printerCommand
;
758 m_previewCommand
= data
.m_previewCommand
;
759 m_printerOptions
= data
.m_printerOptions
;
760 m_filename
= data
.m_filename
;
761 m_afmPath
= data
.m_afmPath
;
762 m_printerScaleX
= data
.m_printerScaleX
;
763 m_printerScaleY
= data
.m_printerScaleY
;
764 m_printerTranslateX
= data
.m_printerTranslateX
;
765 m_printerTranslateY
= data
.m_printerTranslateY
;
766 m_printMode
= data
.m_printMode
;
770 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
771 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
773 SetPrinterCommand(setupData
.GetPrinterCommand());
774 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
775 SetPrinterOptions(setupData
.GetPrinterOptions());
778 setupData
.GetPrinterTranslation(& xt
, & yt
);
779 SetPrinterTranslation(xt
, yt
);
782 setupData
.GetPrinterScaling(& xs
, & ys
);
783 SetPrinterScaling(xs
, ys
);
785 SetOrientation(setupData
.GetPrinterOrientation());
786 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
787 SetFontMetricPath(setupData
.GetAFMPath());
788 if (setupData
.GetPaperName() != "")
789 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
790 SetColour(setupData
.GetColour());
791 SetFilename(setupData
.GetPrinterFile());
793 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
796 // ----------------------------------------------------------------------------
798 // ----------------------------------------------------------------------------
800 wxPrintDialogData::wxPrintDialogData()
803 m_printDlgData
= NULL
;
810 m_printAllPages
= FALSE
;
811 m_printCollate
= FALSE
;
812 m_printToFile
= FALSE
;
813 m_printSelection
= FALSE
;
814 m_printEnableSelection
= FALSE
;
815 m_printEnablePageNumbers
= TRUE
;
816 m_printEnablePrintToFile
= TRUE
;
817 m_printEnableHelp
= FALSE
;
818 m_printSetupDialog
= FALSE
;
821 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
824 m_printDlgData
= NULL
;
826 (*this) = dialogData
;
829 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
832 m_printDlgData
= NULL
;
839 m_printAllPages
= FALSE
;
840 m_printCollate
= FALSE
;
841 m_printToFile
= FALSE
;
842 m_printSelection
= FALSE
;
843 m_printEnableSelection
= FALSE
;
844 m_printEnablePageNumbers
= TRUE
;
845 m_printEnablePrintToFile
= TRUE
;
846 m_printEnableHelp
= FALSE
;
847 m_printSetupDialog
= FALSE
;
849 m_printData
= printData
;
852 wxPrintDialogData::~wxPrintDialogData()
855 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
856 if ( pd
&& pd
->hDevMode
)
857 GlobalFree(pd
->hDevMode
);
864 void wxPrintDialogData::ConvertToNative()
866 m_printData
.ConvertToNative();
868 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
873 m_printDlgData
= (void*) pd
;
875 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
877 pd
->lStructSize
= 66 ;
879 pd
->lStructSize
= sizeof(PRINTDLG
);
881 pd
->hwndOwner
= (HWND
)NULL
;
882 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
883 pd
->hDevNames
= NULL
; // Ditto
885 pd
->Flags
= PD_RETURNDEFAULT
;
889 // Pass the devmode data to the PRINTDLG structure, since it'll
890 // be needed when PrintDlg is called.
893 GlobalFree(pd
->hDevMode
);
896 // Pass the devnames data to the PRINTDLG structure, since it'll
897 // be needed when PrintDlg is called.
900 GlobalFree(pd
->hDevNames
);
903 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
905 m_printData
.SetNativeData((void*) NULL
);
907 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
909 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
911 m_printData
.SetNativeDataDevNames((void*) NULL
);
913 pd
->hDC
= (HDC
) NULL
;
914 pd
->nFromPage
= (UINT
)m_printFromPage
;
915 pd
->nToPage
= (UINT
)m_printToPage
;
916 pd
->nMinPage
= (UINT
)m_printMinPage
;
917 pd
->nMaxPage
= (UINT
)m_printMaxPage
;
918 pd
->nCopies
= (UINT
)m_printNoCopies
;
920 pd
->Flags
= PD_RETURNDC
;
923 pd
->lStructSize
= 66 ;
925 pd
->lStructSize
= sizeof( PRINTDLG
);
928 pd
->hwndOwner
=(HWND
)NULL
;
929 // pd->hDevNames=(HANDLE)NULL;
930 pd
->hInstance
=(HINSTANCE
)NULL
;
931 pd
->lCustData
= (LPARAM
) NULL
;
932 pd
->lpfnPrintHook
= NULL
;
933 pd
->lpfnSetupHook
= NULL
;
934 pd
->lpPrintTemplateName
= NULL
;
935 pd
->lpSetupTemplateName
= NULL
;
936 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
937 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
939 if ( m_printAllPages
)
940 pd
->Flags
|= PD_ALLPAGES
;
941 if ( m_printAllPages
)
942 pd
->Flags
|= PD_SELECTION
;
943 if ( m_printCollate
)
944 pd
->Flags
|= PD_COLLATE
;
946 pd
->Flags
|= PD_PRINTTOFILE
;
947 if ( !m_printEnablePrintToFile
)
948 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
949 if ( !m_printEnableSelection
)
950 pd
->Flags
|= PD_NOSELECTION
;
951 if ( !m_printEnablePageNumbers
)
952 pd
->Flags
|= PD_NOPAGENUMS
;
953 if ( m_printEnableHelp
)
954 pd
->Flags
|= PD_SHOWHELP
;
955 if ( m_printSetupDialog
)
956 pd
->Flags
|= PD_PRINTSETUP
;
959 void wxPrintDialogData::ConvertFromNative()
961 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
965 // Pass the devmode data back to the wxPrintData structure where it really belongs.
968 if (m_printData
.GetNativeData())
970 // Make sure we don't leak memory
971 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
973 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
977 // Pass the devnames data back to the wxPrintData structure where it really belongs.
980 if (m_printData
.GetNativeDataDevNames())
982 // Make sure we don't leak memory
983 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
985 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
986 pd
->hDevNames
= NULL
;
989 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
990 // into wxWindows form.
991 m_printData
.ConvertFromNative();
993 m_printFromPage
= pd
->nFromPage
;
994 m_printToPage
= pd
->nToPage
;
995 m_printMinPage
= pd
->nMinPage
;
996 m_printMaxPage
= pd
->nMaxPage
;
997 m_printNoCopies
= pd
->nCopies
;
999 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1000 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1001 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1002 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1003 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1004 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1005 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1006 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1007 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1009 /* port is obsolete in WIN32
1010 // Get the port name
1013 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1015 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1016 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1017 GlobalUnlock(pd->hDevNames);
1019 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1025 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1027 if ( m_printDlgData
== NULL
)
1030 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1032 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1033 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1039 void wxPrintDialogData::ConvertToNative()
1041 #ifdef TARGET_CARBON
1043 (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
= m_printFromPage
;
1044 (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
= m_printToPage
;
1045 m_printData
.ConvertToNative() ;
1049 void wxPrintDialogData::ConvertFromNative()
1051 #ifdef TARGET_CARBON
1053 m_printData
.ConvertFromNative() ;
1054 m_printFromPage
= (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
;
1055 m_printToPage
= (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
;
1061 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1063 m_printFromPage
= data
.m_printFromPage
;
1064 m_printToPage
= data
.m_printToPage
;
1065 m_printMinPage
= data
.m_printMinPage
;
1066 m_printMaxPage
= data
.m_printMaxPage
;
1067 m_printNoCopies
= data
.m_printNoCopies
;
1068 m_printAllPages
= data
.m_printAllPages
;
1069 m_printCollate
= data
.m_printCollate
;
1070 m_printToFile
= data
.m_printToFile
;
1071 m_printSelection
= data
.m_printSelection
;
1072 m_printEnableSelection
= data
.m_printEnableSelection
;
1073 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1074 m_printEnableHelp
= data
.m_printEnableHelp
;
1075 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1076 m_printSetupDialog
= data
.m_printSetupDialog
;
1078 m_printData
= data
.m_printData
;
1081 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1086 // ----------------------------------------------------------------------------
1087 // wxPageSetupDialogData
1088 // ----------------------------------------------------------------------------
1090 wxPageSetupDialogData::wxPageSetupDialogData()
1092 #if defined(__WIN95__)
1093 m_pageSetupData
= NULL
;
1095 m_paperSize
= wxSize(0, 0);
1097 CalculatePaperSizeFromId();
1099 m_minMarginTopLeft
= wxPoint(0, 0);
1100 m_minMarginBottomRight
= wxPoint(0, 0);
1101 m_marginTopLeft
= wxPoint(0, 0);
1102 m_marginBottomRight
= wxPoint(0, 0);
1105 m_defaultMinMargins
= FALSE
;
1106 m_enableMargins
= TRUE
;
1107 m_enableOrientation
= TRUE
;
1108 m_enablePaper
= TRUE
;
1109 m_enablePrinter
= TRUE
;
1110 m_enableHelp
= FALSE
;
1111 m_getDefaultInfo
= FALSE
;
1114 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1116 #if defined(__WIN95__)
1117 m_pageSetupData
= NULL
;
1119 (*this) = dialogData
;
1122 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1124 #if defined(__WIN95__)
1125 m_pageSetupData
= NULL
;
1127 m_paperSize
= wxSize(0, 0);
1128 m_minMarginTopLeft
= wxPoint(0, 0);
1129 m_minMarginBottomRight
= wxPoint(0, 0);
1130 m_marginTopLeft
= wxPoint(0, 0);
1131 m_marginBottomRight
= wxPoint(0, 0);
1134 m_defaultMinMargins
= FALSE
;
1135 m_enableMargins
= TRUE
;
1136 m_enableOrientation
= TRUE
;
1137 m_enablePaper
= TRUE
;
1138 m_enablePrinter
= TRUE
;
1139 m_enableHelp
= FALSE
;
1140 m_getDefaultInfo
= FALSE
;
1142 m_printData
= printData
;
1144 // The wxPrintData paper size overrides these values, unless the size cannot
1146 CalculatePaperSizeFromId();
1149 wxPageSetupDialogData::~wxPageSetupDialogData()
1151 #if defined(__WIN95__) && defined(__WXMSW__)
1152 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1153 if ( pd
&& pd
->hDevMode
)
1154 GlobalFree(pd
->hDevMode
);
1155 if ( pd
&& pd
->hDevNames
)
1156 GlobalFree(pd
->hDevNames
);
1162 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1164 m_paperSize
= data
.m_paperSize
;
1165 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1166 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1167 m_marginTopLeft
= data
.m_marginTopLeft
;
1168 m_marginBottomRight
= data
.m_marginBottomRight
;
1169 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1170 m_enableMargins
= data
.m_enableMargins
;
1171 m_enableOrientation
= data
.m_enableOrientation
;
1172 m_enablePaper
= data
.m_enablePaper
;
1173 m_enablePrinter
= data
.m_enablePrinter
;
1174 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1175 m_enableHelp
= data
.m_enableHelp
;
1177 m_printData
= data
.m_printData
;
1180 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1185 #if defined(__WIN95__)
1186 void wxPageSetupDialogData::ConvertToNative()
1188 m_printData
.ConvertToNative();
1190 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1192 if ( m_pageSetupData
== NULL
)
1194 pd
= new PAGESETUPDLG
;
1195 pd
->hDevMode
= NULL
;
1196 pd
->hDevNames
= NULL
;
1197 m_pageSetupData
= (void *)pd
;
1200 // Pass the devmode data (created in m_printData.ConvertToNative)
1201 // to the PRINTDLG structure, since it'll
1202 // be needed when PrintDlg is called.
1206 GlobalFree(pd
->hDevMode
);
1207 pd
->hDevMode
= NULL
;
1210 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1212 m_printData
.SetNativeData((void*) NULL
);
1214 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1216 // Pass the devnames data (created in m_printData.ConvertToNative)
1217 // to the PRINTDLG structure, since it'll
1218 // be needed when PrintDlg is called.
1222 GlobalFree(pd
->hDevNames
);
1223 pd
->hDevNames
= NULL
;
1226 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1228 m_printData
.SetNativeDataDevNames((void*) NULL
);
1230 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1232 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1234 if ( m_defaultMinMargins
)
1235 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1236 if ( !m_enableMargins
)
1237 pd
->Flags
|= PSD_DISABLEMARGINS
;
1238 if ( !m_enableOrientation
)
1239 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1240 if ( !m_enablePaper
)
1241 pd
->Flags
|= PSD_DISABLEPAPER
;
1242 if ( !m_enablePrinter
)
1243 pd
->Flags
|= PSD_DISABLEPRINTER
;
1244 if ( m_getDefaultInfo
)
1245 pd
->Flags
|= PSD_RETURNDEFAULT
;
1247 pd
->Flags
|= PSD_SHOWHELP
;
1249 // We want the units to be in hundredths of a millimetre
1250 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1252 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1253 pd
->hwndOwner
=(HWND
)NULL
;
1254 // pd->hDevNames=(HWND)NULL;
1255 pd
->hInstance
=(HINSTANCE
)NULL
;
1256 // PAGESETUPDLG is in hundreds of a mm
1257 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1258 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1260 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1261 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1262 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1263 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1265 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1266 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1267 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1268 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1271 pd
->lpfnPageSetupHook
= NULL
;
1272 pd
->lpfnPagePaintHook
= NULL
;
1273 pd
->hPageSetupTemplate
= NULL
;
1274 pd
->lpPageSetupTemplateName
= NULL
;
1279 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1280 memset(devMode, 0, sizeof(DEVMODE));
1281 devMode->dmSize = sizeof(DEVMODE);
1282 devMode->dmOrientation = m_orientation;
1283 devMode->dmFields = DM_ORIENTATION;
1284 GlobalUnlock(pd->hDevMode);
1289 void wxPageSetupDialogData::ConvertFromNative()
1291 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1295 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1298 if (m_printData
.GetNativeData())
1300 // Make sure we don't leak memory
1301 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1303 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1304 pd
->hDevMode
= NULL
;
1307 m_printData
.ConvertFromNative();
1309 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1312 if (m_printData
.GetNativeDataDevNames())
1314 // Make sure we don't leak memory
1315 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1317 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1318 pd
->hDevNames
= NULL
;
1321 m_printData
.ConvertFromNative();
1323 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1325 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1326 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1327 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1328 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1329 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1330 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1331 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1333 // PAGESETUPDLG is in hundreds of a mm
1334 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1335 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1337 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1338 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1339 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1340 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1342 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100 ;
1343 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100 ;
1344 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100 ;
1345 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100 ;
1348 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1350 if ( m_pageSetupData
== NULL
)
1353 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1355 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1356 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1362 void wxPageSetupDialogData::ConvertToNative()
1364 m_printData
.ConvertToNative() ;
1365 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1366 #ifdef TARGET_CARBON
1368 (**m_printData
.m_macPrintInfo
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
) ;
1369 (**m_printData
.m_macPrintInfo
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
) ;
1371 (**m_printData
.m_macPrintInfo
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
) ;
1372 (**m_printData
.m_macPrintInfo
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
) ;
1374 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.left
= 0 ;
1375 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.top
= 0 ;
1376 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
) ;
1377 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
) ;
1381 void wxPageSetupDialogData::ConvertFromNative()
1383 m_printData
.ConvertFromNative () ;
1385 #ifdef TARGET_CARBON
1387 m_paperSize
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1388 m_paperSize
.y
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1390 m_minMarginTopLeft
.x
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1391 m_minMarginTopLeft
.y
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1393 m_minMarginBottomRight
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
) * pt2mm
;
1394 m_minMarginBottomRight
.y
= ((double)(**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
) * pt2mm
;
1396 // adjust minimal values
1397 //TODO add custom fields in dialog for margins
1399 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1400 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1402 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1403 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1405 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1406 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1408 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1409 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1414 // If a corresponding paper type is found in the paper database, will set the m_printData
1415 // paper size id member as well.
1416 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1420 CalculateIdFromPaperSize();
1423 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1424 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1426 m_printData
.SetPaperId(id
);
1428 CalculatePaperSizeFromId();
1431 // Use paper size defined in this object to set the wxPrintData
1433 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1435 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1436 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1438 wxSize sz
= GetPaperSize();
1440 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1441 if (id
!= wxPAPER_NONE
)
1443 m_printData
.SetPaperId(id
);
1447 // Use paper id in wxPrintData to set this object's paper size
1448 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1450 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1451 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1453 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1457 // sz is in 10ths of a mm, so multiply by 10.
1458 m_paperSize
.x
= sz
.x
* 10;
1459 m_paperSize
.y
= sz
.y
* 10;
1463 #endif // wxUSE_PRINTING_ARCHITECTURE