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 #include "wx/mac/uma.h"
87 #define mm2pt 2.83464566929
88 #define pt2mm 0.352777777778
92 #define DMPAPER_USER 256
95 // ============================================================================
97 // ============================================================================
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 wxColourData::wxColourData()
106 for (i
= 0; i
< 16; i
++)
107 custColours
[i
].Set(255, 255, 255);
110 dataColour
.Set(0,0,0);
113 wxColourData::wxColourData(const wxColourData
& data
)
118 wxColourData::~wxColourData()
122 void wxColourData::SetCustomColour(int i
, wxColour
& colour
)
127 custColours
[i
] = colour
;
130 wxColour
wxColourData::GetCustomColour(int i
)
133 return wxColour(0,0,0);
135 return custColours
[i
];
138 void wxColourData::operator=(const wxColourData
& data
)
141 for (i
= 0; i
< 16; i
++)
142 custColours
[i
] = data
.custColours
[i
];
144 dataColour
= (wxColour
&)data
.dataColour
;
145 chooseFull
= data
.chooseFull
;
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
152 wxFontData::wxFontData()
154 // Intialize colour to black.
155 fontColour
.Set(0, 0, 0);
159 enableEffects
= TRUE
;
163 m_encoding
= wxFONTENCODING_SYSTEM
;
166 wxFontData::~wxFontData()
170 #if wxUSE_PRINTING_ARCHITECTURE
171 // ----------------------------------------------------------------------------
173 // ----------------------------------------------------------------------------
175 wxPrintData::wxPrintData()
178 m_devMode
= (void*) NULL
;
179 m_devNames
= (void*) NULL
;
180 #elif defined( __WXMAC__ )
182 m_macPageFormat
= kPMNoPageFormat
;
183 m_macPrintSettings
= kPMNoPrintSettings
;
185 #if PM_USE_SESSION_APIS
186 PMPrintSession macPrintSession
= kPMNoReference
;
189 err
= ::UMAPrOpen(&macPrintSession
) ;
192 err
= PMCreatePageFormat(&m_macPageFormat
);
194 // Note that PMPageFormat is not session-specific, but calling
195 // PMSessionDefaultPageFormat assigns values specific to the printer
196 // associated with the current printing session.
197 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
199 err
= PMSessionDefaultPageFormat(macPrintSession
, m_macPageFormat
);
202 err
= PMCreatePrintSettings(&m_macPrintSettings
);
204 // Note that PMPrintSettings is not session-specific, but calling
205 // PMSessionDefaultPrintSettings assigns values specific to the printer
206 // associated with the current printing session.
207 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
209 err
= PMSessionDefaultPrintSettings(macPrintSession
, m_macPrintSettings
);
212 ::UMAPrClose(&macPrintSession
) ;
215 m_macPrintInfo
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
216 (**m_macPrintInfo
).iPrVersion
= 0; // something invalid
218 (**m_macPrintInfo
).prInfo
.iHRes
= 72;
219 (**m_macPrintInfo
).prInfo
.iVRes
= 72;
220 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
221 (**m_macPrintInfo
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
223 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
224 (**m_macPrintInfo
).rPaper
= r2
;
225 (**m_macPrintInfo
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
226 (**m_macPrintInfo
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
229 m_printOrientation
= wxPORTRAIT
;
231 m_printCollate
= FALSE
;
236 m_duplexMode
= wxDUPLEX_SIMPLEX
;
237 m_printQuality
= wxPRINT_QUALITY_HIGH
;
238 m_paperId
= wxPAPER_A4
;
239 m_paperSize
= wxSize(210, 297);
241 // PostScript-specific data
242 m_printerCommand
= "";
243 m_previewCommand
= "";
244 m_printerOptions
= "";
247 m_printerScaleX
= 1.0;
248 m_printerScaleY
= 1.0;
249 m_printerTranslateX
= 0;
250 m_printerTranslateY
= 0;
251 m_printMode
= wxPRINT_MODE_FILE
;
254 wxPrintData::wxPrintData(const wxPrintData
& printData
)
257 m_devMode
= (void*) NULL
;
258 m_devNames
= (void*) NULL
;
259 #elif defined( __WXMAC__ )
261 m_macPageFormat
= kPMNoPageFormat
;
262 m_macPrintSettings
= kPMNoPrintSettings
;
264 m_macPrintInfo
= NULL
;
270 wxPrintData::~wxPrintData()
273 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
275 GlobalFree(hDevMode
);
276 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
278 GlobalFree(hDevNames
);
279 #elif defined(__WXMAC__)
281 if (m_macPageFormat
!= kPMNoPageFormat
)
283 #if PM_USE_SESSION_APIS
284 (void)PMRelease(m_macPageFormat
);
286 (void)PMDisposePageFormat(m_macPageFormat
);
288 m_macPageFormat
= kPMNoPageFormat
;
291 if (m_macPrintSettings
!= kPMNoPrintSettings
)
293 #if PM_USE_SESSION_APIS
294 (void)PMRelease(m_macPrintSettings
);
296 (void)PMDisposePrintSettings(m_macPrintSettings
);
298 m_macPrintSettings
= kPMNoPrintSettings
;
302 wxASSERT( m_macPrintInfo
);
303 // we should perhaps delete
308 #if defined(__WXMSW__) // && defined(__WIN32__)
310 #if defined(__WXDEBUG__) && defined(__WIN32__)
311 static wxString
wxGetPrintDlgError()
313 DWORD err
= CommDlgExtendedError();
314 wxString msg
= wxT("Unknown");
317 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
318 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
319 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
320 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
321 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
322 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
323 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
324 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
325 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
326 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
327 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
328 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
329 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
330 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
331 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
332 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
333 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
334 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
335 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
336 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
337 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
338 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
345 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
348 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
349 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
354 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
355 ( driverName
.Length() + 1 +
356 printerName
.Length() + 1 +
357 portName
.Length()+1 ) * sizeof(wxChar
) );
358 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
359 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
360 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
362 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
363 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
364 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
366 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
367 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
368 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
378 void wxPrintData::ConvertToNative()
380 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
381 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
384 // Use PRINTDLG as a way of creating a DEVMODE object
387 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
392 memset(&pd
, 0, sizeof(PRINTDLG
));
393 pd
.lStructSize
= sizeof(PRINTDLG
);
396 pd
.hwndOwner
= (HWND
)NULL
;
397 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
398 pd
.hDevNames
= NULL
; // Ditto
399 //pd.hInstance = (HINSTANCE) wxGetInstance();
401 pd
.Flags
= PD_RETURNDEFAULT
;
404 // Fill out the DEVMODE structure
405 // so we can use it as input in the 'real' PrintDlg
409 GlobalFree(pd
.hDevMode
);
411 GlobalFree(pd
.hDevNames
);
415 #if defined(__WXDEBUG__) && defined(__WIN32__)
416 wxString
str(wxT("Printing error: "));
417 str
+= wxGetPrintDlgError();
423 hDevMode
= pd
.hDevMode
;
424 m_devMode
= (void*)(long) hDevMode
;
427 // We'll create a new DEVNAMEs structure below.
429 GlobalFree(pd
.hDevNames
);
432 // hDevNames = pd->hDevNames;
433 // m_devNames = (void*)(long) hDevNames;
434 // pd->hDevnames = NULL;
441 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
446 devMode
->dmOrientation
= m_printOrientation
;
448 devMode
->dmFields
= DM_ORIENTATION
;
453 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
454 devMode
->dmFields
|= DM_COLLATE
;
457 //// Number of copies
459 devMode
->dmCopies
= m_printNoCopies
;
460 devMode
->dmFields
|= DM_COPIES
;
464 if (m_printerName
!= wxT(""))
466 //int len = wxMin(31, m_printerName.Len());
467 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
468 devMode
->dmDeviceName
[31] = wxT('\0');
474 devMode
->dmColor
= DMCOLOR_COLOR
;
476 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
478 devMode
->dmFields
|= DM_COLOR
;
483 if (m_paperId
== wxPAPER_NONE
)
485 // DEVMODE is in tenths of a milimeter
486 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
487 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
488 devMode
->dmPaperSize
= DMPAPER_USER
;
489 devMode
->dmFields
|= DM_PAPERWIDTH
;
490 devMode
->dmFields
|= DM_PAPERLENGTH
;
494 if (wxThePrintPaperDatabase
)
496 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
499 devMode
->dmPaperSize
= paper
->GetPlatformId();
500 devMode
->dmFields
|= DM_PAPERSIZE
;
509 switch (m_duplexMode
)
511 case wxDUPLEX_HORIZONTAL
: {
512 duplex
= DMDUP_HORIZONTAL
; break;
514 case wxDUPLEX_VERTICAL
: {
515 duplex
= DMDUP_VERTICAL
; break;
518 case wxDUPLEX_SIMPLEX
: {
519 duplex
= DMDUP_SIMPLEX
; break;
522 devMode
->dmDuplex
= duplex
;
523 devMode
->dmFields
|= DM_DUPLEX
;
528 switch (m_printQuality
)
530 case wxPRINT_QUALITY_MEDIUM
: {
531 quality
= DMRES_MEDIUM
; break;
533 case wxPRINT_QUALITY_LOW
: {
534 quality
= DMRES_LOW
; break;
536 case wxPRINT_QUALITY_DRAFT
: {
537 quality
= DMRES_DRAFT
; break;
539 case wxPRINT_QUALITY_HIGH
: {
540 quality
= DMRES_HIGH
; break;
543 quality
= m_printQuality
; break;
546 devMode
->dmPrintQuality
= quality
;
547 devMode
->dmFields
|= DM_PRINTQUALITY
;
549 GlobalUnlock(hDevMode
);
554 GlobalFree(hDevNames
);
557 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
558 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
561 void wxPrintData::ConvertFromNative()
563 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
564 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
571 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
576 if (devMode
->dmFields
& DM_ORIENTATION
)
577 m_printOrientation
= devMode
->dmOrientation
;
583 if (devMode
->dmFields
& DM_COLLATE
)
585 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
586 m_printCollate
= TRUE
;
588 m_printCollate
= FALSE
;
592 //// Number of copies
594 if (devMode
->dmFields
& DM_COPIES
)
596 m_printNoCopies
= devMode
->dmCopies
;
601 if (devMode
->dmDeviceName
[0] != 0)
603 // TODO: make this Unicode compatible
606 while (devMode
->dmDeviceName
[i
] != 0)
608 buf
[i
] = devMode
->dmDeviceName
[i
];
618 if (devMode
->dmFields
& DM_COLOR
)
620 if (devMode
->dmColor
== DMCOLOR_COLOR
)
631 // We don't know size of user defined paper and some buggy drivers
632 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
633 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
634 // code wouldn't set m_paperSize correctly.
635 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
637 if (wxThePrintPaperDatabase
)
639 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
642 m_paperId
= paper
->GetId();
643 m_paperSize
.x
= paper
->GetWidth() / 10;
644 m_paperSize
.y
= paper
->GetHeight() / 10;
648 // Shouldn't really get here
649 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
651 m_paperId
= wxPAPER_NONE
;
658 // Shouldn't really get here
659 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
661 m_paperId
= wxPAPER_NONE
;
666 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
668 // DEVMODE is in tenths of a milimeter
669 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
670 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
671 m_paperId
= wxPAPER_NONE
;
675 // Shouldn't really get here
676 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
680 m_paperId
= wxPAPER_NONE
;
686 if (devMode
->dmFields
& DM_DUPLEX
)
688 switch (devMode
->dmDuplex
)
690 case DMDUP_HORIZONTAL
: {
691 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
693 case DMDUP_VERTICAL
: {
694 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
697 case DMDUP_SIMPLEX
: {
698 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
703 m_duplexMode
= wxDUPLEX_SIMPLEX
;
707 if (devMode
->dmFields
& DM_PRINTQUALITY
)
709 switch (devMode
->dmPrintQuality
)
712 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
715 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
718 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
721 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
725 // TODO: if the printer fills in the resolution in DPI, how
726 // will the application know if it's high, low, draft etc.??
727 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
728 m_printQuality
= devMode
->dmPrintQuality
; break;
734 m_printQuality
= wxPRINT_QUALITY_HIGH
;
736 GlobalUnlock(hDevMode
);
741 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
744 // TODO: Unicode-ification
747 // port is obsolete in WIN32
748 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
750 // Get the printer name
751 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
753 // Not sure if we should check for this mismatch
754 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
756 if (printerName
!= wxT(""))
757 m_printerName
= printerName
;
759 GlobalUnlock(hDevNames
);
767 void wxPrintData::ConvertToNative()
771 (**m_macPrintInfo
).prJob
.iCopies
= m_printNoCopies
;
775 void wxPrintData::ConvertFromNative()
779 m_printNoCopies
= (**m_macPrintInfo
).prJob
.iCopies
;
784 void wxPrintData::operator=(const wxPrintData
& data
)
789 m_macPrintInfo
= data
.m_macPrintInfo
;
790 HandToHand( (Handle
*) &m_macPrintInfo
);
793 m_printNoCopies
= data
.m_printNoCopies
;
794 m_printCollate
= data
.m_printCollate
;
795 m_printOrientation
= data
.m_printOrientation
;
796 m_printerName
= data
.m_printerName
;
797 m_colour
= data
.m_colour
;
798 m_duplexMode
= data
.m_duplexMode
;
799 m_printQuality
= data
.m_printQuality
;
800 m_paperId
= data
.m_paperId
;
801 m_paperSize
= data
.m_paperSize
;
803 // PostScript-specific data
804 m_printerCommand
= data
.m_printerCommand
;
805 m_previewCommand
= data
.m_previewCommand
;
806 m_printerOptions
= data
.m_printerOptions
;
807 m_filename
= data
.m_filename
;
808 m_afmPath
= data
.m_afmPath
;
809 m_printerScaleX
= data
.m_printerScaleX
;
810 m_printerScaleY
= data
.m_printerScaleY
;
811 m_printerTranslateX
= data
.m_printerTranslateX
;
812 m_printerTranslateY
= data
.m_printerTranslateY
;
813 m_printMode
= data
.m_printMode
;
817 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
818 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
820 SetPrinterCommand(setupData
.GetPrinterCommand());
821 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
822 SetPrinterOptions(setupData
.GetPrinterOptions());
825 setupData
.GetPrinterTranslation(& xt
, & yt
);
826 SetPrinterTranslation(xt
, yt
);
829 setupData
.GetPrinterScaling(& xs
, & ys
);
830 SetPrinterScaling(xs
, ys
);
832 SetOrientation(setupData
.GetPrinterOrientation());
833 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
834 SetFontMetricPath(setupData
.GetAFMPath());
835 if (setupData
.GetPaperName() != "")
836 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
837 SetColour(setupData
.GetColour());
838 SetFilename(setupData
.GetPrinterFile());
840 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
843 // ----------------------------------------------------------------------------
845 // ----------------------------------------------------------------------------
847 wxPrintDialogData::wxPrintDialogData()
850 m_printDlgData
= NULL
;
857 m_printAllPages
= FALSE
;
858 m_printCollate
= FALSE
;
859 m_printToFile
= FALSE
;
860 m_printSelection
= FALSE
;
861 m_printEnableSelection
= FALSE
;
862 m_printEnablePageNumbers
= TRUE
;
863 m_printEnablePrintToFile
= TRUE
;
864 m_printEnableHelp
= FALSE
;
865 m_printSetupDialog
= FALSE
;
868 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
871 m_printDlgData
= NULL
;
873 (*this) = dialogData
;
876 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
879 m_printDlgData
= NULL
;
886 m_printAllPages
= FALSE
;
887 m_printCollate
= FALSE
;
888 m_printToFile
= FALSE
;
889 m_printSelection
= FALSE
;
890 m_printEnableSelection
= FALSE
;
891 m_printEnablePageNumbers
= TRUE
;
892 m_printEnablePrintToFile
= TRUE
;
893 m_printEnableHelp
= FALSE
;
894 m_printSetupDialog
= FALSE
;
896 m_printData
= printData
;
899 wxPrintDialogData::~wxPrintDialogData()
902 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
903 if ( pd
&& pd
->hDevMode
)
904 GlobalFree(pd
->hDevMode
);
911 void wxPrintDialogData::ConvertToNative()
913 m_printData
.ConvertToNative();
915 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
920 memset( pd
, 0, sizeof(PRINTDLG
) );
921 m_printDlgData
= (void*) pd
;
923 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
925 pd
->lStructSize
= 66;
927 pd
->lStructSize
= sizeof(PRINTDLG
);
929 pd
->hwndOwner
= (HWND
)NULL
;
930 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
931 pd
->hDevNames
= NULL
; // Ditto
933 pd
->Flags
= PD_RETURNDEFAULT
;
937 // Pass the devmode data to the PRINTDLG structure, since it'll
938 // be needed when PrintDlg is called.
941 GlobalFree(pd
->hDevMode
);
944 // Pass the devnames data to the PRINTDLG structure, since it'll
945 // be needed when PrintDlg is called.
948 GlobalFree(pd
->hDevNames
);
951 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
953 m_printData
.SetNativeData((void*) NULL
);
955 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
957 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
959 m_printData
.SetNativeDataDevNames((void*) NULL
);
961 pd
->hDC
= (HDC
) NULL
;
962 pd
->nFromPage
= (WORD
)m_printFromPage
;
963 pd
->nToPage
= (WORD
)m_printToPage
;
964 pd
->nMinPage
= (WORD
)m_printMinPage
;
965 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
966 pd
->nCopies
= (WORD
)m_printNoCopies
;
968 pd
->Flags
= PD_RETURNDC
;
971 pd
->lStructSize
= 66;
973 pd
->lStructSize
= sizeof( PRINTDLG
);
976 pd
->hwndOwner
=(HWND
)NULL
;
977 // pd->hDevNames=(HANDLE)NULL;
978 pd
->hInstance
=(HINSTANCE
)NULL
;
979 pd
->lCustData
= (LPARAM
) NULL
;
980 pd
->lpfnPrintHook
= NULL
;
981 pd
->lpfnSetupHook
= NULL
;
982 pd
->lpPrintTemplateName
= NULL
;
983 pd
->lpSetupTemplateName
= NULL
;
984 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
985 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
987 if ( m_printAllPages
)
988 pd
->Flags
|= PD_ALLPAGES
;
989 if ( m_printSelection
)
990 pd
->Flags
|= PD_SELECTION
;
991 if ( m_printCollate
)
992 pd
->Flags
|= PD_COLLATE
;
994 pd
->Flags
|= PD_PRINTTOFILE
;
995 if ( !m_printEnablePrintToFile
)
996 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
997 if ( !m_printEnableSelection
)
998 pd
->Flags
|= PD_NOSELECTION
;
999 if ( !m_printEnablePageNumbers
)
1000 pd
->Flags
|= PD_NOPAGENUMS
;
1001 if ( m_printEnableHelp
)
1002 pd
->Flags
|= PD_SHOWHELP
;
1003 if ( m_printSetupDialog
)
1004 pd
->Flags
|= PD_PRINTSETUP
;
1007 void wxPrintDialogData::ConvertFromNative()
1009 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1013 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1016 if (m_printData
.GetNativeData())
1018 // Make sure we don't leak memory
1019 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1021 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1022 pd
->hDevMode
= NULL
;
1025 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1028 if (m_printData
.GetNativeDataDevNames())
1030 // Make sure we don't leak memory
1031 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1033 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1034 pd
->hDevNames
= NULL
;
1037 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1038 // into wxWindows form.
1039 m_printData
.ConvertFromNative();
1041 m_printFromPage
= pd
->nFromPage
;
1042 m_printToPage
= pd
->nToPage
;
1043 m_printMinPage
= pd
->nMinPage
;
1044 m_printMaxPage
= pd
->nMaxPage
;
1045 m_printNoCopies
= pd
->nCopies
;
1047 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1048 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1049 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1050 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1051 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1052 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1053 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1054 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1055 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1057 /* port is obsolete in WIN32
1058 // Get the port name
1061 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1063 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1064 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1065 GlobalUnlock(pd->hDevNames);
1067 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1073 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1075 if ( m_printDlgData
== NULL
)
1078 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1080 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1081 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1087 void wxPrintDialogData::ConvertToNative()
1091 (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
= m_printFromPage
;
1092 (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
= m_printToPage
;
1093 m_printData
.ConvertToNative();
1097 void wxPrintDialogData::ConvertFromNative()
1101 m_printData
.ConvertFromNative();
1102 m_printFromPage
= (**m_printData
.m_macPrintInfo
).prJob
.iFstPage
;
1103 m_printToPage
= (**m_printData
.m_macPrintInfo
).prJob
.iLstPage
;
1109 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1111 m_printFromPage
= data
.m_printFromPage
;
1112 m_printToPage
= data
.m_printToPage
;
1113 m_printMinPage
= data
.m_printMinPage
;
1114 m_printMaxPage
= data
.m_printMaxPage
;
1115 m_printNoCopies
= data
.m_printNoCopies
;
1116 m_printAllPages
= data
.m_printAllPages
;
1117 m_printCollate
= data
.m_printCollate
;
1118 m_printToFile
= data
.m_printToFile
;
1119 m_printSelection
= data
.m_printSelection
;
1120 m_printEnableSelection
= data
.m_printEnableSelection
;
1121 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1122 m_printEnableHelp
= data
.m_printEnableHelp
;
1123 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1124 m_printSetupDialog
= data
.m_printSetupDialog
;
1126 m_printData
= data
.m_printData
;
1129 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1134 // ----------------------------------------------------------------------------
1135 // wxPageSetupDialogData
1136 // ----------------------------------------------------------------------------
1138 wxPageSetupDialogData::wxPageSetupDialogData()
1140 #if defined(__WIN95__)
1141 m_pageSetupData
= NULL
;
1143 m_paperSize
= wxSize(0, 0);
1145 CalculatePaperSizeFromId();
1147 m_minMarginTopLeft
= wxPoint(0, 0);
1148 m_minMarginBottomRight
= wxPoint(0, 0);
1149 m_marginTopLeft
= wxPoint(0, 0);
1150 m_marginBottomRight
= wxPoint(0, 0);
1153 m_defaultMinMargins
= FALSE
;
1154 m_enableMargins
= TRUE
;
1155 m_enableOrientation
= TRUE
;
1156 m_enablePaper
= TRUE
;
1157 m_enablePrinter
= TRUE
;
1158 m_enableHelp
= FALSE
;
1159 m_getDefaultInfo
= FALSE
;
1162 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1164 #if defined(__WIN95__)
1165 m_pageSetupData
= NULL
;
1167 (*this) = dialogData
;
1170 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1172 #if defined(__WIN95__)
1173 m_pageSetupData
= NULL
;
1175 m_paperSize
= wxSize(0, 0);
1176 m_minMarginTopLeft
= wxPoint(0, 0);
1177 m_minMarginBottomRight
= wxPoint(0, 0);
1178 m_marginTopLeft
= wxPoint(0, 0);
1179 m_marginBottomRight
= wxPoint(0, 0);
1182 m_defaultMinMargins
= FALSE
;
1183 m_enableMargins
= TRUE
;
1184 m_enableOrientation
= TRUE
;
1185 m_enablePaper
= TRUE
;
1186 m_enablePrinter
= TRUE
;
1187 m_enableHelp
= FALSE
;
1188 m_getDefaultInfo
= FALSE
;
1190 m_printData
= printData
;
1192 // The wxPrintData paper size overrides these values, unless the size cannot
1194 CalculatePaperSizeFromId();
1197 wxPageSetupDialogData::~wxPageSetupDialogData()
1199 #if defined(__WIN95__) && defined(__WXMSW__)
1200 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1201 if ( pd
&& pd
->hDevMode
)
1202 GlobalFree(pd
->hDevMode
);
1203 if ( pd
&& pd
->hDevNames
)
1204 GlobalFree(pd
->hDevNames
);
1210 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1212 m_paperSize
= data
.m_paperSize
;
1213 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1214 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1215 m_marginTopLeft
= data
.m_marginTopLeft
;
1216 m_marginBottomRight
= data
.m_marginBottomRight
;
1217 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1218 m_enableMargins
= data
.m_enableMargins
;
1219 m_enableOrientation
= data
.m_enableOrientation
;
1220 m_enablePaper
= data
.m_enablePaper
;
1221 m_enablePrinter
= data
.m_enablePrinter
;
1222 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1223 m_enableHelp
= data
.m_enableHelp
;
1225 m_printData
= data
.m_printData
;
1228 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1233 #if defined(__WIN95__)
1234 void wxPageSetupDialogData::ConvertToNative()
1236 m_printData
.ConvertToNative();
1238 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1240 if ( m_pageSetupData
== NULL
)
1242 pd
= new PAGESETUPDLG
;
1243 pd
->hDevMode
= NULL
;
1244 pd
->hDevNames
= NULL
;
1245 m_pageSetupData
= (void *)pd
;
1248 // Pass the devmode data (created in m_printData.ConvertToNative)
1249 // to the PRINTDLG structure, since it'll
1250 // be needed when PrintDlg is called.
1254 GlobalFree(pd
->hDevMode
);
1255 pd
->hDevMode
= NULL
;
1258 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1260 m_printData
.SetNativeData((void*) NULL
);
1262 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1264 // Pass the devnames data (created in m_printData.ConvertToNative)
1265 // to the PRINTDLG structure, since it'll
1266 // be needed when PrintDlg is called.
1270 GlobalFree(pd
->hDevNames
);
1271 pd
->hDevNames
= NULL
;
1274 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1276 m_printData
.SetNativeDataDevNames((void*) NULL
);
1278 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1280 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1282 if ( m_defaultMinMargins
)
1283 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1284 if ( !m_enableMargins
)
1285 pd
->Flags
|= PSD_DISABLEMARGINS
;
1286 if ( !m_enableOrientation
)
1287 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1288 if ( !m_enablePaper
)
1289 pd
->Flags
|= PSD_DISABLEPAPER
;
1290 if ( !m_enablePrinter
)
1291 pd
->Flags
|= PSD_DISABLEPRINTER
;
1292 if ( m_getDefaultInfo
)
1293 pd
->Flags
|= PSD_RETURNDEFAULT
;
1295 pd
->Flags
|= PSD_SHOWHELP
;
1297 // We want the units to be in hundredths of a millimetre
1298 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1300 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1301 pd
->hwndOwner
=(HWND
)NULL
;
1302 // pd->hDevNames=(HWND)NULL;
1303 pd
->hInstance
=(HINSTANCE
)NULL
;
1304 // PAGESETUPDLG is in hundreds of a mm
1305 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1306 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1308 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1309 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1310 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1311 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1313 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1314 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1315 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1316 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1319 pd
->lpfnPageSetupHook
= NULL
;
1320 pd
->lpfnPagePaintHook
= NULL
;
1321 pd
->hPageSetupTemplate
= NULL
;
1322 pd
->lpPageSetupTemplateName
= NULL
;
1327 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1328 memset(devMode, 0, sizeof(DEVMODE));
1329 devMode->dmSize = sizeof(DEVMODE);
1330 devMode->dmOrientation = m_orientation;
1331 devMode->dmFields = DM_ORIENTATION;
1332 GlobalUnlock(pd->hDevMode);
1337 void wxPageSetupDialogData::ConvertFromNative()
1339 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1343 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1346 if (m_printData
.GetNativeData())
1348 // Make sure we don't leak memory
1349 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1351 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1352 pd
->hDevMode
= NULL
;
1355 m_printData
.ConvertFromNative();
1357 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1360 if (m_printData
.GetNativeDataDevNames())
1362 // Make sure we don't leak memory
1363 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1365 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1366 pd
->hDevNames
= NULL
;
1369 m_printData
.ConvertFromNative();
1371 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1373 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1374 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1375 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1376 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1377 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1378 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1379 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1381 // PAGESETUPDLG is in hundreds of a mm
1382 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1383 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1385 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1386 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1387 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1388 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1390 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1391 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1392 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1393 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1396 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1398 if ( m_pageSetupData
== NULL
)
1401 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1403 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1404 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1410 void wxPageSetupDialogData::ConvertToNative()
1412 m_printData
.ConvertToNative();
1413 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1416 (**m_printData
.m_macPrintInfo
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1417 (**m_printData
.m_macPrintInfo
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1419 (**m_printData
.m_macPrintInfo
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1420 (**m_printData
.m_macPrintInfo
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1422 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.left
= 0;
1423 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.top
= 0;
1424 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1425 (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1429 void wxPageSetupDialogData::ConvertFromNative()
1431 m_printData
.ConvertFromNative ();
1435 m_paperSize
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1436 m_paperSize
.y
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1438 m_minMarginTopLeft
.x
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.left
) * pt2mm
;
1439 m_minMarginTopLeft
.y
= ((double) -(**m_printData
.m_macPrintInfo
).rPaper
.top
) * pt2mm
;
1441 m_minMarginBottomRight
.x
= ((double) (**m_printData
.m_macPrintInfo
).rPaper
.right
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.right
) * pt2mm
;
1442 m_minMarginBottomRight
.y
= ((double)(**m_printData
.m_macPrintInfo
).rPaper
.bottom
- (**m_printData
.m_macPrintInfo
).prInfo
.rPage
.bottom
) * pt2mm
;
1444 // adjust minimal values
1445 //TODO add custom fields in dialog for margins
1447 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1448 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1450 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1451 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1453 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1454 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1456 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1457 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1462 // If a corresponding paper type is found in the paper database, will set the m_printData
1463 // paper size id member as well.
1464 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1468 CalculateIdFromPaperSize();
1471 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1472 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1474 m_printData
.SetPaperId(id
);
1476 CalculatePaperSizeFromId();
1479 // Use paper size defined in this object to set the wxPrintData
1481 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1483 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1484 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1486 wxSize sz
= GetPaperSize();
1488 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1489 if (id
!= wxPAPER_NONE
)
1491 m_printData
.SetPaperId(id
);
1495 // Use paper id in wxPrintData to set this object's paper size
1496 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1498 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1499 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1501 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1505 // sz is in 10ths of a mm, so multiply by 10.
1506 m_paperSize
.x
= sz
.x
* 10;
1507 m_paperSize
.y
= sz
.y
* 10;
1511 #endif // wxUSE_PRINTING_ARCHITECTURE