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__) || defined(__WXMAC__)) && 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
90 #define DMPAPER_USER 256
93 // ============================================================================
95 // ============================================================================
97 // ----------------------------------------------------------------------------
99 // ----------------------------------------------------------------------------
101 wxColourData::wxColourData()
104 for (i
= 0; i
< 16; i
++)
105 custColours
[i
].Set(255, 255, 255);
108 dataColour
.Set(0,0,0);
111 wxColourData::wxColourData(const wxColourData
& data
)
116 wxColourData::~wxColourData()
120 void wxColourData::SetCustomColour(int i
, wxColour
& colour
)
125 custColours
[i
] = colour
;
128 wxColour
wxColourData::GetCustomColour(int i
)
131 return wxColour(0,0,0);
133 return custColours
[i
];
136 void wxColourData::operator=(const wxColourData
& data
)
139 for (i
= 0; i
< 16; i
++)
140 custColours
[i
] = data
.custColours
[i
];
142 dataColour
= (wxColour
&)data
.dataColour
;
143 chooseFull
= data
.chooseFull
;
146 // ----------------------------------------------------------------------------
148 // ----------------------------------------------------------------------------
150 wxFontData::wxFontData()
152 // Intialize colour to black.
153 fontColour
.Set(0, 0, 0);
157 enableEffects
= TRUE
;
161 m_encoding
= wxFONTENCODING_SYSTEM
;
164 wxFontData::~wxFontData()
168 #if wxUSE_PRINTING_ARCHITECTURE
169 // ----------------------------------------------------------------------------
171 // ----------------------------------------------------------------------------
173 wxPrintData::wxPrintData()
176 m_devMode
= (void*) NULL
;
177 m_devNames
= (void*) NULL
;
178 #elif defined( __WXMAC__ )
180 m_macPageFormat
= kPMNoPageFormat
;
181 m_macPrintSettings
= kPMNoPrintSettings
;
183 m_macPrintInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
184 (**m_macPrintInfo
).iPrVersion
= 0; // something invalid
186 (**m_macPrintInfo
).prInfo
.iHRes
= 72;
187 (**m_macPrintInfo
).prInfo
.iVRes
= 72;
188 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
189 (**m_macPrintInfo
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
191 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
192 (**m_macPrintInfo
).rPaper
= r2
;
193 (**m_macPrintInfo
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
194 (**m_macPrintInfo
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
197 m_printOrientation
= wxPORTRAIT
;
199 m_printCollate
= FALSE
;
204 m_duplexMode
= wxDUPLEX_SIMPLEX
;
205 m_printQuality
= wxPRINT_QUALITY_HIGH
;
206 m_paperId
= wxPAPER_A4
;
207 m_paperSize
= wxSize(210, 297);
209 // PostScript-specific data
210 m_printerCommand
= "";
211 m_previewCommand
= "";
212 m_printerOptions
= "";
215 m_printerScaleX
= 1.0;
216 m_printerScaleY
= 1.0;
217 m_printerTranslateX
= 0;
218 m_printerTranslateY
= 0;
219 m_printMode
= wxPRINT_MODE_FILE
;
222 wxPrintData::wxPrintData(const wxPrintData
& printData
)
225 m_devMode
= (void*) NULL
;
226 m_devNames
= (void*) NULL
;
227 #elif defined( __WXMAC__ )
229 m_macPageFormat
= kPMNoPageFormat
;
230 m_macPrintSettings
= kPMNoPrintSettings
;
232 m_macPrintInfo
= NULL
;
238 wxPrintData::~wxPrintData()
241 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
243 GlobalFree(hDevMode
);
244 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
246 GlobalFree(hDevNames
);
247 #elif defined(__WXMAC__)
249 if (m_macPageFormat
!= kPMNoPageFormat
)
251 #if PM_USE_SESSION_APIS
252 (void)PMRelease(m_macPageFormat
);
254 (void)PMDisposePageFormat(m_macPageFormat
);
256 m_macPageFormat
= kPMNoPageFormat
;
259 if (m_macPrintSettings
!= kPMNoPrintSettings
)
261 #if PM_USE_SESSION_APIS
262 (void)PMRelease(m_macPrintSettings
);
264 (void)PMDisposePrintSettings(m_macPrintSettings
);
266 m_macPrintSettings
= kPMNoPrintSettings
;
269 wxASSERT( m_macPrintInfo
);
270 // we should perhaps delete
275 #if defined(__WXMSW__) // && defined(__WIN32__)
277 #if defined(__WXDEBUG__) && defined(__WIN32__)
278 static wxString
wxGetPrintDlgError()
280 DWORD err
= CommDlgExtendedError();
281 wxString msg
= wxT("Unknown");
284 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
285 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
286 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
287 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
288 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
289 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
290 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
291 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
292 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
293 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
294 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
295 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
296 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
297 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
298 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
299 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
300 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
301 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
302 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
303 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
304 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
305 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
312 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
315 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
316 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
321 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
322 ( driverName
.Length() + 1 +
323 printerName
.Length() + 1 +
324 portName
.Length()+1 ) * sizeof(wxChar
) );
325 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
326 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
327 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
329 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
330 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
331 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
333 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
334 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
335 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
345 void wxPrintData::ConvertToNative()
347 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
348 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
351 // Use PRINTDLG as a way of creating a DEVMODE object
354 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
359 memset(&pd
, 0, sizeof(PRINTDLG
));
360 pd
.lStructSize
= sizeof(PRINTDLG
);
363 pd
.hwndOwner
= (HWND
)NULL
;
364 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
365 pd
.hDevNames
= NULL
; // Ditto
366 //pd.hInstance = (HINSTANCE) wxGetInstance();
368 pd
.Flags
= PD_RETURNDEFAULT
;
371 // Fill out the DEVMODE structure
372 // so we can use it as input in the 'real' PrintDlg
376 GlobalFree(pd
.hDevMode
);
378 GlobalFree(pd
.hDevNames
);
382 #if defined(__WXDEBUG__) && defined(__WIN32__)
383 wxString
str(wxT("Printing error: "));
384 str
+= wxGetPrintDlgError();
390 hDevMode
= pd
.hDevMode
;
391 m_devMode
= (void*)(long) hDevMode
;
394 // We'll create a new DEVNAMEs structure below.
396 GlobalFree(pd
.hDevNames
);
399 // hDevNames = pd->hDevNames;
400 // m_devNames = (void*)(long) hDevNames;
401 // pd->hDevnames = NULL;
408 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
413 devMode
->dmOrientation
= m_printOrientation
;
415 devMode
->dmFields
= DM_ORIENTATION
;
420 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
421 devMode
->dmFields
|= DM_COLLATE
;
424 //// Number of copies
426 devMode
->dmCopies
= m_printNoCopies
;
427 devMode
->dmFields
|= DM_COPIES
;
431 if (m_printerName
!= wxT(""))
433 //int len = wxMin(31, m_printerName.Len());
434 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
435 devMode
->dmDeviceName
[31] = wxT('\0');
441 devMode
->dmColor
= DMCOLOR_COLOR
;
443 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
445 devMode
->dmFields
|= DM_COLOR
;
450 if (m_paperId
== wxPAPER_NONE
)
452 // DEVMODE is in tenths of a milimeter
453 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
454 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
455 devMode
->dmPaperSize
= DMPAPER_USER
;
456 devMode
->dmFields
|= DM_PAPERWIDTH
;
457 devMode
->dmFields
|= DM_PAPERLENGTH
;
461 if (wxThePrintPaperDatabase
)
463 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
466 devMode
->dmPaperSize
= paper
->GetPlatformId();
467 devMode
->dmFields
|= DM_PAPERSIZE
;
476 switch (m_duplexMode
)
478 case wxDUPLEX_HORIZONTAL
: {
479 duplex
= DMDUP_HORIZONTAL
; break;
481 case wxDUPLEX_VERTICAL
: {
482 duplex
= DMDUP_VERTICAL
; break;
485 case wxDUPLEX_SIMPLEX
: {
486 duplex
= DMDUP_SIMPLEX
; break;
489 devMode
->dmDuplex
= duplex
;
490 devMode
->dmFields
|= DM_DUPLEX
;
495 switch (m_printQuality
)
497 case wxPRINT_QUALITY_MEDIUM
: {
498 quality
= DMRES_MEDIUM
; break;
500 case wxPRINT_QUALITY_LOW
: {
501 quality
= DMRES_LOW
; break;
503 case wxPRINT_QUALITY_DRAFT
: {
504 quality
= DMRES_DRAFT
; break;
506 case wxPRINT_QUALITY_HIGH
: {
507 quality
= DMRES_HIGH
; break;
510 quality
= m_printQuality
; break;
513 devMode
->dmPrintQuality
= quality
;
514 devMode
->dmFields
|= DM_PRINTQUALITY
;
516 GlobalUnlock(hDevMode
);
521 GlobalFree(hDevNames
);
524 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
525 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
528 void wxPrintData::ConvertFromNative()
530 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
531 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
538 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
543 if (devMode
->dmFields
& DM_ORIENTATION
)
544 m_printOrientation
= devMode
->dmOrientation
;
550 if (devMode
->dmFields
& DM_COLLATE
)
552 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
553 m_printCollate
= TRUE
;
555 m_printCollate
= FALSE
;
559 //// Number of copies
561 if (devMode
->dmFields
& DM_COPIES
)
563 m_printNoCopies
= devMode
->dmCopies
;
568 if (devMode
->dmDeviceName
[0] != 0)
570 // TODO: make this Unicode compatible
573 while (devMode
->dmDeviceName
[i
] != 0)
575 buf
[i
] = devMode
->dmDeviceName
[i
];
585 if (devMode
->dmFields
& DM_COLOR
)
587 if (devMode
->dmColor
== DMCOLOR_COLOR
)
598 // We don't know size of user defined paper and some buggy drivers
599 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
600 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
601 // code wouldn't set m_paperSize correctly.
602 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
604 if (wxThePrintPaperDatabase
)
606 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
609 m_paperId
= paper
->GetId();
610 m_paperSize
.x
= paper
->GetWidth() / 10;
611 m_paperSize
.y
= paper
->GetHeight() / 10;
615 // Shouldn't really get here
616 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
618 m_paperId
= wxPAPER_NONE
;
625 // Shouldn't really get here
626 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
628 m_paperId
= wxPAPER_NONE
;
633 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
635 // DEVMODE is in tenths of a milimeter
636 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
637 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
638 m_paperId
= wxPAPER_NONE
;
642 // Shouldn't really get here
643 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
647 m_paperId
= wxPAPER_NONE
;
653 if (devMode
->dmFields
& DM_DUPLEX
)
655 switch (devMode
->dmDuplex
)
657 case DMDUP_HORIZONTAL
: {
658 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
660 case DMDUP_VERTICAL
: {
661 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
664 case DMDUP_SIMPLEX
: {
665 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
670 m_duplexMode
= wxDUPLEX_SIMPLEX
;
674 if (devMode
->dmFields
& DM_PRINTQUALITY
)
676 switch (devMode
->dmPrintQuality
)
679 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
682 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
685 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
688 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
692 // TODO: if the printer fills in the resolution in DPI, how
693 // will the application know if it's high, low, draft etc.??
694 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
695 m_printQuality
= devMode
->dmPrintQuality
; break;
701 m_printQuality
= wxPRINT_QUALITY_HIGH
;
703 GlobalUnlock(hDevMode
);
708 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
711 // TODO: Unicode-ification
714 // port is obsolete in WIN32
715 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
717 // Get the printer name
718 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
720 // Not sure if we should check for this mismatch
721 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
723 if (printerName
!= wxT(""))
724 m_printerName
= printerName
;
726 GlobalUnlock(hDevNames
);
734 void wxPrintData::ConvertToNative()
738 (**m_macPrintInfo
).prJob
.iCopies
= m_printNoCopies
;
742 void wxPrintData::ConvertFromNative()
746 m_printNoCopies
= (**m_macPrintInfo
).prJob
.iCopies
;
751 void wxPrintData::operator=(const wxPrintData
& data
)
756 m_macPrintInfo
= data
.m_macPrintInfo
;
757 HandToHand( (Handle
*) &m_macPrintInfo
);
760 m_printNoCopies
= data
.m_printNoCopies
;
761 m_printCollate
= data
.m_printCollate
;
762 m_printOrientation
= data
.m_printOrientation
;
763 m_printerName
= data
.m_printerName
;
764 m_colour
= data
.m_colour
;
765 m_duplexMode
= data
.m_duplexMode
;
766 m_printQuality
= data
.m_printQuality
;
767 m_paperId
= data
.m_paperId
;
768 m_paperSize
= data
.m_paperSize
;
770 // PostScript-specific data
771 m_printerCommand
= data
.m_printerCommand
;
772 m_previewCommand
= data
.m_previewCommand
;
773 m_printerOptions
= data
.m_printerOptions
;
774 m_filename
= data
.m_filename
;
775 m_afmPath
= data
.m_afmPath
;
776 m_printerScaleX
= data
.m_printerScaleX
;
777 m_printerScaleY
= data
.m_printerScaleY
;
778 m_printerTranslateX
= data
.m_printerTranslateX
;
779 m_printerTranslateY
= data
.m_printerTranslateY
;
780 m_printMode
= data
.m_printMode
;
784 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
785 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
787 SetPrinterCommand(setupData
.GetPrinterCommand());
788 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
789 SetPrinterOptions(setupData
.GetPrinterOptions());
792 setupData
.GetPrinterTranslation(& xt
, & yt
);
793 SetPrinterTranslation(xt
, yt
);
796 setupData
.GetPrinterScaling(& xs
, & ys
);
797 SetPrinterScaling(xs
, ys
);
799 SetOrientation(setupData
.GetPrinterOrientation());
800 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
801 SetFontMetricPath(setupData
.GetAFMPath());
802 if (setupData
.GetPaperName() != "")
803 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
804 SetColour(setupData
.GetColour());
805 SetFilename(setupData
.GetPrinterFile());
807 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
810 // ----------------------------------------------------------------------------
812 // ----------------------------------------------------------------------------
814 wxPrintDialogData::wxPrintDialogData()
817 m_printDlgData
= NULL
;
824 m_printAllPages
= FALSE
;
825 m_printCollate
= FALSE
;
826 m_printToFile
= FALSE
;
827 m_printSelection
= FALSE
;
828 m_printEnableSelection
= FALSE
;
829 m_printEnablePageNumbers
= TRUE
;
830 m_printEnablePrintToFile
= TRUE
;
831 m_printEnableHelp
= FALSE
;
832 m_printSetupDialog
= FALSE
;
835 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
838 m_printDlgData
= NULL
;
840 (*this) = dialogData
;
843 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
846 m_printDlgData
= NULL
;
853 m_printAllPages
= FALSE
;
854 m_printCollate
= FALSE
;
855 m_printToFile
= FALSE
;
856 m_printSelection
= FALSE
;
857 m_printEnableSelection
= FALSE
;
858 m_printEnablePageNumbers
= TRUE
;
859 m_printEnablePrintToFile
= TRUE
;
860 m_printEnableHelp
= FALSE
;
861 m_printSetupDialog
= FALSE
;
863 m_printData
= printData
;
866 wxPrintDialogData::~wxPrintDialogData()
869 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
870 if ( pd
&& pd
->hDevMode
)
871 GlobalFree(pd
->hDevMode
);
878 void wxPrintDialogData::ConvertToNative()
880 m_printData
.ConvertToNative();
882 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
887 memset( pd
, 0, sizeof(PRINTDLG
) );
888 m_printDlgData
= (void*) pd
;
890 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
892 pd
->lStructSize
= 66;
894 pd
->lStructSize
= sizeof(PRINTDLG
);
896 pd
->hwndOwner
= (HWND
)NULL
;
897 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
898 pd
->hDevNames
= NULL
; // Ditto
900 pd
->Flags
= PD_RETURNDEFAULT
;
904 // Pass the devmode data to the PRINTDLG structure, since it'll
905 // be needed when PrintDlg is called.
908 GlobalFree(pd
->hDevMode
);
911 // Pass the devnames data to the PRINTDLG structure, since it'll
912 // be needed when PrintDlg is called.
915 GlobalFree(pd
->hDevNames
);
918 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
920 m_printData
.SetNativeData((void*) NULL
);
922 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
924 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
926 m_printData
.SetNativeDataDevNames((void*) NULL
);
928 pd
->hDC
= (HDC
) NULL
;
929 pd
->nFromPage
= (WORD
)m_printFromPage
;
930 pd
->nToPage
= (WORD
)m_printToPage
;
931 pd
->nMinPage
= (WORD
)m_printMinPage
;
932 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
933 pd
->nCopies
= (WORD
)m_printNoCopies
;
935 pd
->Flags
= PD_RETURNDC
;
938 pd
->lStructSize
= 66;
940 pd
->lStructSize
= sizeof( PRINTDLG
);
943 pd
->hwndOwner
=(HWND
)NULL
;
944 // pd->hDevNames=(HANDLE)NULL;
945 pd
->hInstance
=(HINSTANCE
)NULL
;
946 pd
->lCustData
= (LPARAM
) NULL
;
947 pd
->lpfnPrintHook
= NULL
;
948 pd
->lpfnSetupHook
= NULL
;
949 pd
->lpPrintTemplateName
= NULL
;
950 pd
->lpSetupTemplateName
= NULL
;
951 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
952 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
954 if ( m_printAllPages
)
955 pd
->Flags
|= PD_ALLPAGES
;
956 if ( m_printSelection
)
957 pd
->Flags
|= PD_SELECTION
;
958 if ( m_printCollate
)
959 pd
->Flags
|= PD_COLLATE
;
961 pd
->Flags
|= PD_PRINTTOFILE
;
962 if ( !m_printEnablePrintToFile
)
963 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
964 if ( !m_printEnableSelection
)
965 pd
->Flags
|= PD_NOSELECTION
;
966 if ( !m_printEnablePageNumbers
)
967 pd
->Flags
|= PD_NOPAGENUMS
;
968 if ( m_printEnableHelp
)
969 pd
->Flags
|= PD_SHOWHELP
;
970 if ( m_printSetupDialog
)
971 pd
->Flags
|= PD_PRINTSETUP
;
974 void wxPrintDialogData::ConvertFromNative()
976 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
980 // Pass the devmode data back to the wxPrintData structure where it really belongs.
983 if (m_printData
.GetNativeData())
985 // Make sure we don't leak memory
986 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
988 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
992 // Pass the devnames data back to the wxPrintData structure where it really belongs.
995 if (m_printData
.GetNativeDataDevNames())
997 // Make sure we don't leak memory
998 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1000 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1001 pd
->hDevNames
= NULL
;
1004 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1005 // into wxWindows form.
1006 m_printData
.ConvertFromNative();
1008 m_printFromPage
= pd
->nFromPage
;
1009 m_printToPage
= pd
->nToPage
;
1010 m_printMinPage
= pd
->nMinPage
;
1011 m_printMaxPage
= pd
->nMaxPage
;
1012 m_printNoCopies
= pd
->nCopies
;
1014 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1015 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1016 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1017 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1018 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1019 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1020 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1021 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1022 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1024 /* port is obsolete in WIN32
1025 // Get the port name
1028 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1030 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1031 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1032 GlobalUnlock(pd->hDevNames);
1034 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1040 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1042 if ( m_printDlgData
== NULL
)
1045 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1047 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1048 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1054 void wxPrintDialogData::ConvertToNative()
1056 #ifdef TARGET_CARBON
1058 (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
= m_printFromPage
;
1059 (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
= m_printToPage
;
1060 m_printData
.ConvertToNative();
1064 void wxPrintDialogData::ConvertFromNative()
1066 #ifdef TARGET_CARBON
1068 m_printData
.ConvertFromNative();
1069 m_printFromPage
= (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
;
1070 m_printToPage
= (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
;
1076 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1078 m_printFromPage
= data
.m_printFromPage
;
1079 m_printToPage
= data
.m_printToPage
;
1080 m_printMinPage
= data
.m_printMinPage
;
1081 m_printMaxPage
= data
.m_printMaxPage
;
1082 m_printNoCopies
= data
.m_printNoCopies
;
1083 m_printAllPages
= data
.m_printAllPages
;
1084 m_printCollate
= data
.m_printCollate
;
1085 m_printToFile
= data
.m_printToFile
;
1086 m_printSelection
= data
.m_printSelection
;
1087 m_printEnableSelection
= data
.m_printEnableSelection
;
1088 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1089 m_printEnableHelp
= data
.m_printEnableHelp
;
1090 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1091 m_printSetupDialog
= data
.m_printSetupDialog
;
1093 m_printData
= data
.m_printData
;
1096 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1101 // ----------------------------------------------------------------------------
1102 // wxPageSetupDialogData
1103 // ----------------------------------------------------------------------------
1105 wxPageSetupDialogData::wxPageSetupDialogData()
1107 #if defined(__WIN95__)
1108 m_pageSetupData
= NULL
;
1110 m_paperSize
= wxSize(0, 0);
1112 CalculatePaperSizeFromId();
1114 m_minMarginTopLeft
= wxPoint(0, 0);
1115 m_minMarginBottomRight
= wxPoint(0, 0);
1116 m_marginTopLeft
= wxPoint(0, 0);
1117 m_marginBottomRight
= wxPoint(0, 0);
1120 m_defaultMinMargins
= FALSE
;
1121 m_enableMargins
= TRUE
;
1122 m_enableOrientation
= TRUE
;
1123 m_enablePaper
= TRUE
;
1124 m_enablePrinter
= TRUE
;
1125 m_enableHelp
= FALSE
;
1126 m_getDefaultInfo
= FALSE
;
1129 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1131 #if defined(__WIN95__)
1132 m_pageSetupData
= NULL
;
1134 (*this) = dialogData
;
1137 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1139 #if defined(__WIN95__)
1140 m_pageSetupData
= NULL
;
1142 m_paperSize
= wxSize(0, 0);
1143 m_minMarginTopLeft
= wxPoint(0, 0);
1144 m_minMarginBottomRight
= wxPoint(0, 0);
1145 m_marginTopLeft
= wxPoint(0, 0);
1146 m_marginBottomRight
= wxPoint(0, 0);
1149 m_defaultMinMargins
= FALSE
;
1150 m_enableMargins
= TRUE
;
1151 m_enableOrientation
= TRUE
;
1152 m_enablePaper
= TRUE
;
1153 m_enablePrinter
= TRUE
;
1154 m_enableHelp
= FALSE
;
1155 m_getDefaultInfo
= FALSE
;
1157 m_printData
= printData
;
1159 // The wxPrintData paper size overrides these values, unless the size cannot
1161 CalculatePaperSizeFromId();
1164 wxPageSetupDialogData::~wxPageSetupDialogData()
1166 #if defined(__WIN95__) && defined(__WXMSW__)
1167 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1168 if ( pd
&& pd
->hDevMode
)
1169 GlobalFree(pd
->hDevMode
);
1170 if ( pd
&& pd
->hDevNames
)
1171 GlobalFree(pd
->hDevNames
);
1177 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1179 m_paperSize
= data
.m_paperSize
;
1180 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1181 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1182 m_marginTopLeft
= data
.m_marginTopLeft
;
1183 m_marginBottomRight
= data
.m_marginBottomRight
;
1184 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1185 m_enableMargins
= data
.m_enableMargins
;
1186 m_enableOrientation
= data
.m_enableOrientation
;
1187 m_enablePaper
= data
.m_enablePaper
;
1188 m_enablePrinter
= data
.m_enablePrinter
;
1189 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1190 m_enableHelp
= data
.m_enableHelp
;
1192 m_printData
= data
.m_printData
;
1195 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1200 #if defined(__WIN95__)
1201 void wxPageSetupDialogData::ConvertToNative()
1203 m_printData
.ConvertToNative();
1205 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1207 if ( m_pageSetupData
== NULL
)
1209 pd
= new PAGESETUPDLG
;
1210 pd
->hDevMode
= NULL
;
1211 pd
->hDevNames
= NULL
;
1212 m_pageSetupData
= (void *)pd
;
1215 // Pass the devmode data (created in m_printData.ConvertToNative)
1216 // to the PRINTDLG structure, since it'll
1217 // be needed when PrintDlg is called.
1221 GlobalFree(pd
->hDevMode
);
1222 pd
->hDevMode
= NULL
;
1225 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1227 m_printData
.SetNativeData((void*) NULL
);
1229 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1231 // Pass the devnames data (created in m_printData.ConvertToNative)
1232 // to the PRINTDLG structure, since it'll
1233 // be needed when PrintDlg is called.
1237 GlobalFree(pd
->hDevNames
);
1238 pd
->hDevNames
= NULL
;
1241 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1243 m_printData
.SetNativeDataDevNames((void*) NULL
);
1245 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1247 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1249 if ( m_defaultMinMargins
)
1250 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1251 if ( !m_enableMargins
)
1252 pd
->Flags
|= PSD_DISABLEMARGINS
;
1253 if ( !m_enableOrientation
)
1254 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1255 if ( !m_enablePaper
)
1256 pd
->Flags
|= PSD_DISABLEPAPER
;
1257 if ( !m_enablePrinter
)
1258 pd
->Flags
|= PSD_DISABLEPRINTER
;
1259 if ( m_getDefaultInfo
)
1260 pd
->Flags
|= PSD_RETURNDEFAULT
;
1262 pd
->Flags
|= PSD_SHOWHELP
;
1264 // We want the units to be in hundredths of a millimetre
1265 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1267 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1268 pd
->hwndOwner
=(HWND
)NULL
;
1269 // pd->hDevNames=(HWND)NULL;
1270 pd
->hInstance
=(HINSTANCE
)NULL
;
1271 // PAGESETUPDLG is in hundreds of a mm
1272 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1273 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1275 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1276 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1277 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1278 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1280 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1281 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1282 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1283 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1286 pd
->lpfnPageSetupHook
= NULL
;
1287 pd
->lpfnPagePaintHook
= NULL
;
1288 pd
->hPageSetupTemplate
= NULL
;
1289 pd
->lpPageSetupTemplateName
= NULL
;
1294 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1295 memset(devMode, 0, sizeof(DEVMODE));
1296 devMode->dmSize = sizeof(DEVMODE);
1297 devMode->dmOrientation = m_orientation;
1298 devMode->dmFields = DM_ORIENTATION;
1299 GlobalUnlock(pd->hDevMode);
1304 void wxPageSetupDialogData::ConvertFromNative()
1306 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1310 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1313 if (m_printData
.GetNativeData())
1315 // Make sure we don't leak memory
1316 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1318 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1319 pd
->hDevMode
= NULL
;
1322 m_printData
.ConvertFromNative();
1324 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1327 if (m_printData
.GetNativeDataDevNames())
1329 // Make sure we don't leak memory
1330 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1332 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1333 pd
->hDevNames
= NULL
;
1336 m_printData
.ConvertFromNative();
1338 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1340 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1341 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1342 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1343 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1344 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1345 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1346 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1348 // PAGESETUPDLG is in hundreds of a mm
1349 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1350 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1352 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1353 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1354 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1355 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1357 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1358 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1359 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1360 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1363 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1365 if ( m_pageSetupData
== NULL
)
1368 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1370 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1371 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1377 void wxPageSetupDialogData::ConvertToNative()
1379 m_printData
.ConvertToNative();
1380 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1381 #ifdef TARGET_CARBON
1383 (**m_printData
.m_macPrintInfo
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1384 (**m_printData
.m_macPrintInfo
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1386 (**m_printData
.m_macPrintInfo
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1387 (**m_printData
.m_macPrintInfo
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1389 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.left
= 0;
1390 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.top
= 0;
1391 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1392 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1396 void wxPageSetupDialogData::ConvertFromNative()
1398 m_printData
.ConvertFromNative ();
1400 #ifdef TARGET_CARBON
1402 m_paperSize
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1403 m_paperSize
.y
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1405 m_minMarginTopLeft
.x
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1406 m_minMarginTopLeft
.y
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1408 m_minMarginBottomRight
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
) * pt2mm
;
1409 m_minMarginBottomRight
.y
= ((double)(**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
) * pt2mm
;
1411 // adjust minimal values
1412 //TODO add custom fields in dialog for margins
1414 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1415 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1417 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1418 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1420 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1421 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1423 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1424 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1429 // If a corresponding paper type is found in the paper database, will set the m_printData
1430 // paper size id member as well.
1431 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1435 CalculateIdFromPaperSize();
1438 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1439 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1441 m_printData
.SetPaperId(id
);
1443 CalculatePaperSizeFromId();
1446 // Use paper size defined in this object to set the wxPrintData
1448 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1450 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1451 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1453 wxSize sz
= GetPaperSize();
1455 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1456 if (id
!= wxPAPER_NONE
)
1458 m_printData
.SetPaperId(id
);
1462 // Use paper id in wxPrintData to set this object's paper size
1463 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1465 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1466 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1468 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1472 // sz is in 10ths of a mm, so multiply by 10.
1473 m_paperSize
.x
= sz
.x
* 10;
1474 m_paperSize
.y
= sz
.y
* 10;
1478 #endif // wxUSE_PRINTING_ARCHITECTURE