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__)) && 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__ )
175 m_macPrintInfo
= NULL
;
177 m_printOrientation
= wxPORTRAIT
;
179 m_printCollate
= FALSE
;
184 m_duplexMode
= wxDUPLEX_SIMPLEX
;
185 m_printQuality
= wxPRINT_QUALITY_HIGH
;
186 m_paperId
= wxPAPER_A4
;
187 m_paperSize
= wxSize(210, 297);
189 // PostScript-specific data
190 m_printerCommand
= "";
191 m_previewCommand
= "";
192 m_printerOptions
= "";
195 m_printerScaleX
= 1.0;
196 m_printerScaleY
= 1.0;
197 m_printerTranslateX
= 0;
198 m_printerTranslateY
= 0;
199 m_printMode
= wxPRINT_MODE_FILE
;
202 wxPrintData::wxPrintData(const wxPrintData
& printData
)
205 m_devMode
= (void*) NULL
;
206 m_devNames
= (void*) NULL
;
207 #elif defined( __WXMAC__ )
208 m_macPrintInfo
= NULL
;
213 wxPrintData::~wxPrintData()
216 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
218 GlobalFree(hDevMode
);
219 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
221 GlobalFree(hDevNames
);
222 #elif defined(__WXMAC__)
223 if ( m_macPrintInfo
)
224 ::DisposeHandle( (Handle
) m_macPrintInfo
) ;
228 #if defined(__WXMSW__) // && defined(__WIN32__)
230 #if defined(__WXDEBUG__) && defined(__WIN32__)
231 static wxString
wxGetPrintDlgError()
233 DWORD err
= CommDlgExtendedError();
234 wxString msg
= wxT("Unknown");
237 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
238 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
239 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
240 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
241 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
242 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
243 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
244 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
245 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
246 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
247 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
248 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
249 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
250 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
251 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
252 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
253 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
254 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
255 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
256 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
257 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
258 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
265 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
268 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
269 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
274 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
275 driverName
.Length() + 1 +
276 printerName
.Length() + 1 +
277 portName
.Length()+1);
278 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
279 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
280 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wDriverOffset
, driverName
);
282 lpDev
->wDeviceOffset
= (WORD
)(lpDev
->wDriverOffset
+ driverName
.Length()+1);
283 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wDeviceOffset
, printerName
);
285 lpDev
->wOutputOffset
= (WORD
)(lpDev
->wDeviceOffset
+ printerName
.Length()+1);
286 wxStrcpy((wxChar
*)lpDev
+ lpDev
->wOutputOffset
, portName
);
295 void wxPrintData::ConvertToNative()
297 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
298 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
301 // Use PRINTDLG as a way of creating a DEVMODE object
302 PRINTDLG
*pd
= new PRINTDLG
;
304 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
307 pd
->lStructSize
= 66 ;
309 memset(pd
, 0, sizeof(PRINTDLG
));
310 pd
->lStructSize
= sizeof(PRINTDLG
);
313 pd
->hwndOwner
= (HWND
)NULL
;
314 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
315 pd
->hDevNames
= NULL
; // Ditto
316 pd
->hInstance
= (HINSTANCE
) wxGetInstance();
318 pd
->Flags
= PD_RETURNDEFAULT
;
321 // Fill out the DEVMODE structure
322 // so we can use it as input in the 'real' PrintDlg
326 GlobalFree(pd
->hDevMode
);
328 GlobalFree(pd
->hDevNames
);
330 pd
->hDevNames
= NULL
;
332 #if defined(__WXDEBUG__) && defined(__WIN32__)
333 wxString
str(wxT("Printing error: "));
334 str
+= wxGetPrintDlgError();
340 hDevMode
= pd
->hDevMode
;
341 m_devMode
= (void*)(long) hDevMode
;
344 // We'll create a new DEVNAMEs structure below.
346 GlobalFree(pd
->hDevNames
);
347 pd
->hDevNames
= NULL
;
349 // hDevNames = pd->hDevNames;
350 // m_devNames = (void*)(long) hDevNames;
351 // pd->hDevnames = NULL;
360 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
365 devMode
->dmOrientation
= m_printOrientation
;
367 devMode
->dmFields
= DM_ORIENTATION
;
372 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
373 devMode
->dmFields
|= DM_COLLATE
;
376 //// Number of copies
378 devMode
->dmCopies
= m_printNoCopies
;
379 devMode
->dmFields
|= DM_COPIES
;
383 if (m_printerName
!= wxT(""))
385 // TODO: make this Unicode compatible
386 int len
= wxMin(31, m_printerName
.Len());
388 for (i
= 0; i
< len
; i
++)
389 devMode
->dmDeviceName
[i
] = m_printerName
.GetChar(i
);
390 devMode
->dmDeviceName
[i
] = 0;
396 devMode
->dmColor
= DMCOLOR_COLOR
;
398 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
400 devMode
->dmFields
|= DM_COLOR
;
405 if (m_paperId
== wxPAPER_NONE
)
407 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
408 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
409 devMode
->dmFields
|= DM_PAPERWIDTH
;
410 devMode
->dmFields
|= DM_PAPERLENGTH
;
414 if (wxThePrintPaperDatabase
)
416 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
419 devMode
->dmPaperSize
= paper
->GetPlatformId();
420 devMode
->dmFields
|= DM_PAPERSIZE
;
429 switch (m_duplexMode
)
431 case wxDUPLEX_HORIZONTAL
: {
432 duplex
= DMDUP_HORIZONTAL
; break;
434 case wxDUPLEX_VERTICAL
: {
435 duplex
= DMDUP_VERTICAL
; break;
438 case wxDUPLEX_SIMPLEX
: {
439 duplex
= DMDUP_SIMPLEX
; break;
442 devMode
->dmDuplex
= duplex
;
443 devMode
->dmFields
|= DM_DUPLEX
;
448 switch (m_printQuality
)
450 case wxPRINT_QUALITY_MEDIUM
: {
451 quality
= DMRES_MEDIUM
; break;
453 case wxPRINT_QUALITY_LOW
: {
454 quality
= DMRES_LOW
; break;
456 case wxPRINT_QUALITY_DRAFT
: {
457 quality
= DMRES_DRAFT
; break;
459 case wxPRINT_QUALITY_HIGH
: {
460 quality
= DMRES_HIGH
; break;
463 quality
= m_printQuality
; break;
466 devMode
->dmPrintQuality
= quality
;
467 devMode
->dmFields
|= DM_PRINTQUALITY
;
469 GlobalUnlock(hDevMode
);
474 GlobalFree(hDevNames
);
477 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
478 hDevNames
= wxCreateDevNames("", m_printerName
, "");
481 void wxPrintData::ConvertFromNative()
483 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
484 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
491 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
496 if (devMode
->dmFields
& DM_ORIENTATION
)
497 m_printOrientation
= devMode
->dmOrientation
;
503 if (devMode
->dmFields
& DM_COLLATE
)
505 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
506 m_printCollate
= TRUE
;
508 m_printCollate
= FALSE
;
512 //// Number of copies
514 if (devMode
->dmFields
& DM_COPIES
)
516 m_printNoCopies
= devMode
->dmCopies
;
521 if (devMode
->dmDeviceName
[0] != 0)
523 // TODO: make this Unicode compatible
526 while (devMode
->dmDeviceName
[i
] != 0)
528 buf
[i
] = devMode
->dmDeviceName
[i
];
538 if (devMode
->dmFields
& DM_COLOR
)
540 if (devMode
->dmColor
== DMCOLOR_COLOR
)
551 if (devMode
->dmFields
& DM_PAPERSIZE
)
553 if (wxThePrintPaperDatabase
)
555 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
558 m_paperId
= paper
->GetId();
559 m_paperSize
.x
= paper
->GetWidth() / 10 ;
560 m_paperSize
.y
= paper
->GetHeight() / 10 ;
564 // Shouldn't really get here
565 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
567 m_paperId
= wxPAPER_NONE
;
574 // Shouldn't really get here
575 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
577 m_paperId
= wxPAPER_NONE
;
582 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
584 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
585 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
586 m_paperId
= wxPAPER_NONE
;
590 // Shouldn't really get here
591 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
595 m_paperId
= wxPAPER_NONE
;
601 if (devMode
->dmFields
& DM_DUPLEX
)
603 switch (devMode
->dmDuplex
)
605 case DMDUP_HORIZONTAL
: {
606 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
608 case DMDUP_VERTICAL
: {
609 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
612 case DMDUP_SIMPLEX
: {
613 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
618 m_duplexMode
= wxDUPLEX_SIMPLEX
;
622 if (devMode
->dmFields
& DM_PRINTQUALITY
)
624 switch (devMode
->dmPrintQuality
)
627 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
630 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
633 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
636 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
640 // TODO: if the printer fills in the resolution in DPI, how
641 // will the application know if it's high, low, draft etc.??
642 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
643 m_printQuality
= devMode
->dmPrintQuality
; break;
649 m_printQuality
= wxPRINT_QUALITY_HIGH
;
651 GlobalUnlock(hDevMode
);
656 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
659 // TODO: Unicode-ification
662 // port is obsolete in WIN32
663 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
665 // Get the printer name
666 wxString printerName
= (LPSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
668 // Not sure if we should check for this mismatch
669 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
671 if (printerName
!= "")
672 m_printerName
= printerName
;
674 GlobalUnlock(hDevNames
);
682 void wxPrintData::ConvertToNative()
684 if ( !m_macPrintInfo
)
686 m_macPrintInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) ) ;
687 if ( m_macPrintInfo
)
689 ::PrintDefault( m_macPrintInfo
) ;
690 // todo setup the global pagesetup ?
693 if ( m_macPrintInfo
)
695 (**m_macPrintInfo
).prJob
.iCopies
= m_printNoCopies
;
696 (**m_macPrintInfo
).prJob
.iFstPage
= 0 ;
697 (**m_macPrintInfo
).prJob
.iLstPage
= 0 ;
701 void wxPrintData::ConvertFromNative()
703 if ( m_macPrintInfo
)
705 m_printNoCopies
= (**m_macPrintInfo
).prJob
.iCopies
;
710 void wxPrintData::operator=(const wxPrintData
& data
)
712 m_printNoCopies
= data
.m_printNoCopies
;
713 m_printCollate
= data
.m_printCollate
;
714 m_printOrientation
= data
.m_printOrientation
;
715 m_printerName
= data
.m_printerName
;
716 m_colour
= data
.m_colour
;
717 m_duplexMode
= data
.m_duplexMode
;
718 m_printQuality
= data
.m_printQuality
;
719 m_paperId
= data
.m_paperId
;
720 m_paperSize
= data
.m_paperSize
;
722 // PostScript-specific data
723 m_printerCommand
= data
.m_printerCommand
;
724 m_previewCommand
= data
.m_previewCommand
;
725 m_printerOptions
= data
.m_printerOptions
;
726 m_filename
= data
.m_filename
;
727 m_afmPath
= data
.m_afmPath
;
728 m_printerScaleX
= data
.m_printerScaleX
;
729 m_printerScaleY
= data
.m_printerScaleY
;
730 m_printerTranslateX
= data
.m_printerTranslateX
;
731 m_printerTranslateY
= data
.m_printerTranslateY
;
732 m_printMode
= data
.m_printMode
;
736 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
737 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
739 SetPrinterCommand(setupData
.GetPrinterCommand());
740 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
741 SetPrinterOptions(setupData
.GetPrinterOptions());
744 setupData
.GetPrinterTranslation(& xt
, & yt
);
745 SetPrinterTranslation(xt
, yt
);
748 setupData
.GetPrinterScaling(& xs
, & ys
);
749 SetPrinterScaling(xs
, ys
);
751 SetOrientation(setupData
.GetPrinterOrientation());
752 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
753 SetFontMetricPath(setupData
.GetAFMPath());
754 if (setupData
.GetPaperName() != "")
755 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
756 SetColour(setupData
.GetColour());
757 SetFilename(setupData
.GetPrinterFile());
759 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
762 // ----------------------------------------------------------------------------
764 // ----------------------------------------------------------------------------
766 wxPrintDialogData::wxPrintDialogData()
769 m_printDlgData
= NULL
;
770 #elif defined( __WXMAC__ )
771 m_macPrintInfo
= NULL
;
778 m_printAllPages
= FALSE
;
779 m_printCollate
= FALSE
;
780 m_printToFile
= FALSE
;
781 m_printSelection
= FALSE
;
782 m_printEnableSelection
= FALSE
;
783 m_printEnablePageNumbers
= TRUE
;
784 m_printEnablePrintToFile
= TRUE
;
785 m_printEnableHelp
= FALSE
;
786 m_printSetupDialog
= FALSE
;
789 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
792 m_printDlgData
= NULL
;
793 #elif defined( __WXMAC__ )
794 m_macPrintInfo
= NULL
;
796 (*this) = dialogData
;
799 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
802 m_printDlgData
= NULL
;
803 #elif defined( __WXMAC__ )
804 m_macPrintInfo
= NULL
;
811 m_printAllPages
= FALSE
;
812 m_printCollate
= FALSE
;
813 m_printToFile
= FALSE
;
814 m_printSelection
= FALSE
;
815 m_printEnableSelection
= FALSE
;
816 m_printEnablePageNumbers
= TRUE
;
817 m_printEnablePrintToFile
= TRUE
;
818 m_printEnableHelp
= FALSE
;
819 m_printSetupDialog
= FALSE
;
821 m_printData
= printData
;
824 wxPrintDialogData::~wxPrintDialogData()
827 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
828 if ( pd
&& pd
->hDevMode
)
829 GlobalFree(pd
->hDevMode
);
832 #elif defined(__WXMAC__)
833 if ( m_macPrintInfo
)
834 ::DisposeHandle( (Handle
) m_macPrintInfo
) ;
839 void wxPrintDialogData::ConvertToNative()
841 m_printData
.ConvertToNative();
843 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
848 m_printDlgData
= (void*) pd
;
850 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
852 pd
->lStructSize
= 66 ;
854 pd
->lStructSize
= sizeof(PRINTDLG
);
856 pd
->hwndOwner
= (HWND
)NULL
;
857 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
858 pd
->hDevNames
= NULL
; // Ditto
860 pd
->Flags
= PD_RETURNDEFAULT
;
864 // Pass the devmode data to the PRINTDLG structure, since it'll
865 // be needed when PrintDlg is called.
868 GlobalFree(pd
->hDevMode
);
871 // Pass the devnames data to the PRINTDLG structure, since it'll
872 // be needed when PrintDlg is called.
875 GlobalFree(pd
->hDevNames
);
878 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
880 m_printData
.SetNativeData((void*) NULL
);
882 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
884 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
886 m_printData
.SetNativeDataDevNames((void*) NULL
);
888 pd
->hDC
= (HDC
) NULL
;
889 pd
->nFromPage
= (UINT
)m_printFromPage
;
890 pd
->nToPage
= (UINT
)m_printToPage
;
891 pd
->nMinPage
= (UINT
)m_printMinPage
;
892 pd
->nMaxPage
= (UINT
)m_printMaxPage
;
893 pd
->nCopies
= (UINT
)m_printNoCopies
;
895 pd
->Flags
= PD_RETURNDC
;
898 pd
->lStructSize
= 66 ;
900 pd
->lStructSize
= sizeof( PRINTDLG
);
903 pd
->hwndOwner
=(HWND
)NULL
;
904 // pd->hDevNames=(HANDLE)NULL;
905 pd
->hInstance
=(HINSTANCE
)NULL
;
906 pd
->lCustData
= (LPARAM
) NULL
;
907 pd
->lpfnPrintHook
= NULL
;
908 pd
->lpfnSetupHook
= NULL
;
909 pd
->lpPrintTemplateName
= NULL
;
910 pd
->lpSetupTemplateName
= NULL
;
911 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
912 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
914 if ( m_printAllPages
)
915 pd
->Flags
|= PD_ALLPAGES
;
916 if ( m_printAllPages
)
917 pd
->Flags
|= PD_SELECTION
;
918 if ( m_printCollate
)
919 pd
->Flags
|= PD_COLLATE
;
921 pd
->Flags
|= PD_PRINTTOFILE
;
922 if ( !m_printEnablePrintToFile
)
923 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
924 if ( !m_printEnableSelection
)
925 pd
->Flags
|= PD_NOSELECTION
;
926 if ( !m_printEnablePageNumbers
)
927 pd
->Flags
|= PD_NOPAGENUMS
;
928 if ( m_printEnableHelp
)
929 pd
->Flags
|= PD_SHOWHELP
;
930 if ( m_printSetupDialog
)
931 pd
->Flags
|= PD_PRINTSETUP
;
934 void wxPrintDialogData::ConvertFromNative()
936 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
940 // Pass the devmode data back to the wxPrintData structure where it really belongs.
943 if (m_printData
.GetNativeData())
945 // Make sure we don't leak memory
946 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
948 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
952 // Pass the devnames data back to the wxPrintData structure where it really belongs.
955 if (m_printData
.GetNativeDataDevNames())
957 // Make sure we don't leak memory
958 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
960 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
961 pd
->hDevNames
= NULL
;
964 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
965 // into wxWindows form.
966 m_printData
.ConvertFromNative();
968 m_printFromPage
= pd
->nFromPage
;
969 m_printToPage
= pd
->nToPage
;
970 m_printMinPage
= pd
->nMinPage
;
971 m_printMaxPage
= pd
->nMaxPage
;
972 m_printNoCopies
= pd
->nCopies
;
974 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
975 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
976 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
977 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
978 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
979 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
980 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
981 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
982 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
984 /* port is obsolete in WIN32
988 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
990 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
991 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
992 GlobalUnlock(pd->hDevNames);
994 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1000 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1002 if ( m_printDlgData
== NULL
)
1005 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1007 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1008 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1014 void wxPrintDialogData::ConvertToNative()
1016 if ( !m_macPrintInfo
)
1018 m_macPrintInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) ) ;
1019 if ( m_macPrintInfo
)
1021 ::PrintDefault( m_macPrintInfo
) ;
1022 // todo setup the global pagesetup ?
1025 if ( m_macPrintInfo
)
1027 (**m_macPrintInfo
).prJob
.iCopies
= m_printNoCopies
;
1028 (**m_macPrintInfo
).prJob
.iFstPage
= m_printFromPage
;
1029 (**m_macPrintInfo
).prJob
.iLstPage
= m_printToPage
;
1033 void wxPrintDialogData::ConvertFromNative()
1035 if ( m_macPrintInfo
)
1037 m_printNoCopies
= (**m_macPrintInfo
).prJob
.iCopies
;
1038 m_printFromPage
= (**m_macPrintInfo
).prJob
.iFstPage
;
1039 m_printToPage
= (**m_macPrintInfo
).prJob
.iLstPage
;
1045 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1047 m_printFromPage
= data
.m_printFromPage
;
1048 m_printToPage
= data
.m_printToPage
;
1049 m_printMinPage
= data
.m_printMinPage
;
1050 m_printMaxPage
= data
.m_printMaxPage
;
1051 m_printNoCopies
= data
.m_printNoCopies
;
1052 m_printAllPages
= data
.m_printAllPages
;
1053 m_printCollate
= data
.m_printCollate
;
1054 m_printToFile
= data
.m_printToFile
;
1055 m_printSelection
= data
.m_printSelection
;
1056 m_printEnableSelection
= data
.m_printEnableSelection
;
1057 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1058 m_printEnableHelp
= data
.m_printEnableHelp
;
1059 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1060 m_printSetupDialog
= data
.m_printSetupDialog
;
1062 m_printData
= data
.m_printData
;
1065 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1070 // ----------------------------------------------------------------------------
1071 // wxPageSetupDialogData
1072 // ----------------------------------------------------------------------------
1074 wxPageSetupDialogData::wxPageSetupDialogData()
1076 #if defined(__WIN95__)
1077 m_pageSetupData
= NULL
;
1078 #elif defined( __WXMAC__ )
1079 m_macPageSetupInfo
= NULL
;
1081 m_paperSize
= wxSize(0, 0);
1083 CalculatePaperSizeFromId();
1085 m_minMarginTopLeft
= wxPoint(0, 0);
1086 m_minMarginBottomRight
= wxPoint(0, 0);
1087 m_marginTopLeft
= wxPoint(0, 0);
1088 m_marginBottomRight
= wxPoint(0, 0);
1091 m_defaultMinMargins
= FALSE
;
1092 m_enableMargins
= TRUE
;
1093 m_enableOrientation
= TRUE
;
1094 m_enablePaper
= TRUE
;
1095 m_enablePrinter
= TRUE
;
1096 m_enableHelp
= FALSE
;
1097 m_getDefaultInfo
= FALSE
;
1100 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1102 #if defined(__WIN95__)
1103 m_pageSetupData
= NULL
;
1104 #elif defined( __WXMAC__ )
1105 m_macPageSetupInfo
= NULL
;
1107 (*this) = dialogData
;
1110 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1112 #if defined(__WIN95__)
1113 m_pageSetupData
= NULL
;
1114 #elif defined( __WXMAC__ )
1115 m_macPageSetupInfo
= NULL
;
1117 m_paperSize
= wxSize(0, 0);
1118 m_minMarginTopLeft
= wxPoint(0, 0);
1119 m_minMarginBottomRight
= wxPoint(0, 0);
1120 m_marginTopLeft
= wxPoint(0, 0);
1121 m_marginBottomRight
= wxPoint(0, 0);
1124 m_defaultMinMargins
= FALSE
;
1125 m_enableMargins
= TRUE
;
1126 m_enableOrientation
= TRUE
;
1127 m_enablePaper
= TRUE
;
1128 m_enablePrinter
= TRUE
;
1129 m_enableHelp
= FALSE
;
1130 m_getDefaultInfo
= FALSE
;
1132 m_printData
= printData
;
1134 // The wxPrintData paper size overrides these values, unless the size cannot
1136 CalculatePaperSizeFromId();
1139 wxPageSetupDialogData::~wxPageSetupDialogData()
1141 #if defined(__WIN95__) && defined(__WXMSW__)
1142 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1143 if ( pd
&& pd
->hDevMode
)
1144 GlobalFree(pd
->hDevMode
);
1145 if ( pd
&& pd
->hDevNames
)
1146 GlobalFree(pd
->hDevNames
);
1149 #elif defined( __WXMAC__ )
1150 if( m_macPageSetupInfo
)
1151 ::DisposeHandle( (Handle
) m_macPageSetupInfo
) ;
1155 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1157 m_paperSize
= data
.m_paperSize
;
1158 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1159 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1160 m_marginTopLeft
= data
.m_marginTopLeft
;
1161 m_marginBottomRight
= data
.m_marginBottomRight
;
1162 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1163 m_enableMargins
= data
.m_enableMargins
;
1164 m_enableOrientation
= data
.m_enableOrientation
;
1165 m_enablePaper
= data
.m_enablePaper
;
1166 m_enablePrinter
= data
.m_enablePrinter
;
1167 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1168 m_enableHelp
= data
.m_enableHelp
;
1170 m_printData
= data
.m_printData
;
1173 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1178 #if defined(__WIN95__)
1179 void wxPageSetupDialogData::ConvertToNative()
1181 m_printData
.ConvertToNative();
1183 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1185 if ( m_pageSetupData
== NULL
)
1187 pd
= new PAGESETUPDLG
;
1188 pd
->hDevMode
= NULL
;
1189 pd
->hDevNames
= NULL
;
1190 m_pageSetupData
= (void *)pd
;
1193 // Pass the devmode data (created in m_printData.ConvertToNative)
1194 // to the PRINTDLG structure, since it'll
1195 // be needed when PrintDlg is called.
1199 GlobalFree(pd
->hDevMode
);
1200 pd
->hDevMode
= NULL
;
1203 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1205 m_printData
.SetNativeData((void*) NULL
);
1207 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1209 // Pass the devnames data (created in m_printData.ConvertToNative)
1210 // to the PRINTDLG structure, since it'll
1211 // be needed when PrintDlg is called.
1215 GlobalFree(pd
->hDevNames
);
1216 pd
->hDevNames
= NULL
;
1219 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1221 m_printData
.SetNativeDataDevNames((void*) NULL
);
1223 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1225 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1227 if ( m_defaultMinMargins
)
1228 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1229 if ( !m_enableMargins
)
1230 pd
->Flags
|= PSD_DISABLEMARGINS
;
1231 if ( !m_enableOrientation
)
1232 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1233 if ( !m_enablePaper
)
1234 pd
->Flags
|= PSD_DISABLEPAPER
;
1235 if ( !m_enablePrinter
)
1236 pd
->Flags
|= PSD_DISABLEPRINTER
;
1237 if ( m_getDefaultInfo
)
1238 pd
->Flags
|= PSD_RETURNDEFAULT
;
1240 pd
->Flags
|= PSD_SHOWHELP
;
1242 // We want the units to be in hundredths of a millimetre
1243 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1245 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1246 pd
->hwndOwner
=(HWND
)NULL
;
1247 // pd->hDevNames=(HWND)NULL;
1248 pd
->hInstance
=(HINSTANCE
)NULL
;
1250 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1251 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1253 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1254 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1255 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1256 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1258 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1259 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1260 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1261 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1264 pd
->lpfnPageSetupHook
= NULL
;
1265 pd
->lpfnPagePaintHook
= NULL
;
1266 pd
->hPageSetupTemplate
= NULL
;
1267 pd
->lpPageSetupTemplateName
= NULL
;
1272 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1273 memset(devMode, 0, sizeof(DEVMODE));
1274 devMode->dmSize = sizeof(DEVMODE);
1275 devMode->dmOrientation = m_orientation;
1276 devMode->dmFields = DM_ORIENTATION;
1277 GlobalUnlock(pd->hDevMode);
1282 void wxPageSetupDialogData::ConvertFromNative()
1284 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1288 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1291 if (m_printData
.GetNativeData())
1293 // Make sure we don't leak memory
1294 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1296 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1297 pd
->hDevMode
= NULL
;
1300 m_printData
.ConvertFromNative();
1302 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1305 if (m_printData
.GetNativeDataDevNames())
1307 // Make sure we don't leak memory
1308 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1310 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1311 pd
->hDevNames
= NULL
;
1314 m_printData
.ConvertFromNative();
1316 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1318 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1319 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1320 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1321 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1322 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1323 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1324 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1326 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1327 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1329 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1330 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1331 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1332 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1334 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100 ;
1335 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100 ;
1336 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100 ;
1337 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100 ;
1340 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1342 if ( m_pageSetupData
== NULL
)
1345 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1347 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1348 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1354 void wxPageSetupDialogData::ConvertToNative()
1356 if ( !m_macPageSetupInfo
)
1358 m_macPageSetupInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) ) ;
1359 if ( m_macPageSetupInfo
)
1361 ::PrintDefault( m_macPageSetupInfo
) ;
1364 if ( m_macPageSetupInfo
)
1366 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1367 (**m_macPageSetupInfo
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
) ;
1368 (**m_macPageSetupInfo
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
) ;
1370 (**m_macPageSetupInfo
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
) ;
1371 (**m_macPageSetupInfo
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
) ;
1373 (**m_macPageSetupInfo
).prInfo
.rPage
.left
= 0 ;
1374 (**m_macPageSetupInfo
).prInfo
.rPage
.top
= 0 ;
1375 (**m_macPageSetupInfo
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
) ;
1376 (**m_macPageSetupInfo
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
) ;
1378 //TODO add custom fields in dialog for margins
1383 void wxPageSetupDialogData::ConvertFromNative()
1385 if ( m_macPageSetupInfo
)
1387 m_paperSize
.x
= ((double) (**m_macPageSetupInfo
).rPaper
.right
- (**m_macPageSetupInfo
).rPaper
.left
) * pt2mm
;
1388 m_paperSize
.y
= ((double) (**m_macPageSetupInfo
).rPaper
.bottom
- (**m_macPageSetupInfo
).rPaper
.top
) * pt2mm
;
1390 m_minMarginTopLeft
.x
= ((double) -(**m_macPageSetupInfo
).rPaper
.left
) * pt2mm
;
1391 m_minMarginTopLeft
.y
= ((double) -(**m_macPageSetupInfo
).rPaper
.top
) * pt2mm
;
1393 m_minMarginBottomRight
.x
= ((double) (**m_macPageSetupInfo
).rPaper
.right
- (**m_macPageSetupInfo
).prInfo
.rPage
.right
) * pt2mm
;
1394 m_minMarginBottomRight
.y
= ((double)(**m_macPageSetupInfo
).rPaper
.bottom
- (**m_macPageSetupInfo
).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
;
1416 // If a corresponding paper type is found in the paper database, will set the m_printData
1417 // paper size id member as well.
1418 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1422 CalculateIdFromPaperSize();
1425 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1426 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1428 m_printData
.SetPaperId(id
);
1430 CalculatePaperSizeFromId();
1433 // Use paper size defined in this object to set the wxPrintData
1435 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1437 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1438 wxT("wxThePrintPaperDatabase should not be NULL. "
1439 "Do not create global print dialog data objects.") );
1441 wxSize sz
= GetPaperSize();
1443 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1444 if (id
!= wxPAPER_NONE
)
1446 m_printData
.SetPaperId(id
);
1450 // Use paper id in wxPrintData to set this object's paper size
1451 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1453 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1454 wxT("wxThePrintPaperDatabase should not be NULL. "
1455 "Do not create global print dialog data objects.") );
1457 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1461 // sz is in 10ths of a mm, so multiply by 10.
1462 m_paperSize
.x
= sz
.x
* 10;
1463 m_paperSize
.y
= sz
.y
* 10;
1467 #endif // wxUSE_PRINTING_ARCHITECTURE