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(__WXX11__)|| 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 #if defined(TARGET_CARBON) && !defined(__DARWIN__)
88 # if PM_USE_SESSION_APIS
91 # include <PMApplication.h>
97 #define mm2pt 2.83464566929
98 #define pt2mm 0.352777777778
102 #define DMPAPER_USER 256
105 // ============================================================================
107 // ============================================================================
109 // ----------------------------------------------------------------------------
111 // ----------------------------------------------------------------------------
113 wxColourData::wxColourData()
116 for (i
= 0; i
< 16; i
++)
117 custColours
[i
].Set(255, 255, 255);
120 dataColour
.Set(0,0,0);
123 wxColourData::wxColourData(const wxColourData
& data
)
128 wxColourData::~wxColourData()
132 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
137 custColours
[i
] = colour
;
140 wxColour
wxColourData::GetCustomColour(int i
)
143 return wxColour(0,0,0);
145 return custColours
[i
];
148 void wxColourData::operator=(const wxColourData
& data
)
151 for (i
= 0; i
< 16; i
++)
152 custColours
[i
] = data
.custColours
[i
];
154 dataColour
= (wxColour
&)data
.dataColour
;
155 chooseFull
= data
.chooseFull
;
158 // ----------------------------------------------------------------------------
160 // ----------------------------------------------------------------------------
162 wxFontData::wxFontData()
164 // Intialize colour to black.
165 fontColour
.Set(0, 0, 0);
169 enableEffects
= TRUE
;
173 m_encoding
= wxFONTENCODING_SYSTEM
;
176 wxFontData::~wxFontData()
180 #if wxUSE_PRINTING_ARCHITECTURE
181 // ----------------------------------------------------------------------------
183 // ----------------------------------------------------------------------------
185 wxPrintData::wxPrintData()
188 m_devMode
= (void*) NULL
;
189 m_devNames
= (void*) NULL
;
190 #elif defined( __WXMAC__ )
192 m_macPageFormat
= kPMNoPageFormat
;
193 m_macPrintSettings
= kPMNoPrintSettings
;
195 #if PM_USE_SESSION_APIS
196 PMPrintSession macPrintSession
= kPMNoReference
;
199 err
= ::UMAPrOpen(&macPrintSession
) ;
202 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
204 // Note that PMPageFormat is not session-specific, but calling
205 // PMSessionDefaultPageFormat assigns values specific to the printer
206 // associated with the current printing session.
207 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
209 err
= PMSessionDefaultPageFormat((PMPrintSession
)macPrintSession
,
210 (PMPageFormat
)m_macPageFormat
);
213 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
215 // Note that PMPrintSettings is not session-specific, but calling
216 // PMSessionDefaultPrintSettings assigns values specific to the printer
217 // associated with the current printing session.
218 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
220 err
= PMSessionDefaultPrintSettings((PMPrintSession
)macPrintSession
,
221 (PMPrintSettings
)m_macPrintSettings
);
224 ::UMAPrClose(&macPrintSession
) ;
227 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
228 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
230 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
231 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
232 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
233 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
235 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
236 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
237 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
238 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
241 m_printOrientation
= wxPORTRAIT
;
243 m_printCollate
= FALSE
;
248 m_duplexMode
= wxDUPLEX_SIMPLEX
;
249 m_printQuality
= wxPRINT_QUALITY_HIGH
;
250 m_paperId
= wxPAPER_A4
;
251 m_paperSize
= wxSize(210, 297);
253 // PostScript-specific data
254 m_printerCommand
= "";
255 m_previewCommand
= "";
256 m_printerOptions
= "";
259 m_printerScaleX
= 1.0;
260 m_printerScaleY
= 1.0;
261 m_printerTranslateX
= 0;
262 m_printerTranslateY
= 0;
263 m_printMode
= wxPRINT_MODE_FILE
;
266 wxPrintData::wxPrintData(const wxPrintData
& printData
)
269 m_devMode
= (void*) NULL
;
270 m_devNames
= (void*) NULL
;
271 #elif defined( __WXMAC__ )
273 m_macPageFormat
= kPMNoPageFormat
;
274 m_macPrintSettings
= kPMNoPrintSettings
;
276 m_macPrintSettings
= NULL
;
282 wxPrintData::~wxPrintData()
285 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
287 GlobalFree(hDevMode
);
288 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
290 GlobalFree(hDevNames
);
291 #elif defined(__WXMAC__)
293 if (m_macPageFormat
!= kPMNoPageFormat
)
295 #if PM_USE_SESSION_APIS
296 (void)PMRelease(m_macPageFormat
);
298 (void)PMDisposePageFormat(m_macPageFormat
);
300 m_macPageFormat
= kPMNoPageFormat
;
303 if (m_macPrintSettings
!= kPMNoPrintSettings
)
305 #if PM_USE_SESSION_APIS
306 (void)PMRelease(m_macPrintSettings
);
308 (void)PMDisposePrintSettings(m_macPrintSettings
);
310 m_macPrintSettings
= kPMNoPrintSettings
;
314 wxASSERT( m_macPrintSettings
);
315 // we should perhaps delete
320 #if defined(__WXMSW__) // && defined(__WIN32__)
322 #if defined(__WXDEBUG__) && defined(__WIN32__)
323 static wxString
wxGetPrintDlgError()
325 DWORD err
= CommDlgExtendedError();
326 wxString msg
= wxT("Unknown");
329 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
330 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
331 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
332 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
333 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
334 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
335 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
336 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
337 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
338 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
339 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
340 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
341 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
342 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
343 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
344 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
345 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
346 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
347 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
348 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
349 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
350 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
357 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
360 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
361 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
366 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
367 ( driverName
.Length() + 1 +
368 printerName
.Length() + 1 +
369 portName
.Length()+1 ) * sizeof(wxChar
) );
370 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
371 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
372 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
374 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
375 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
376 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
378 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
379 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
380 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
390 void wxPrintData::ConvertToNative()
392 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
393 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
396 // Use PRINTDLG as a way of creating a DEVMODE object
399 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
404 memset(&pd
, 0, sizeof(PRINTDLG
));
405 pd
.lStructSize
= sizeof(PRINTDLG
);
408 pd
.hwndOwner
= (HWND
)NULL
;
409 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
410 pd
.hDevNames
= NULL
; // Ditto
411 //pd.hInstance = (HINSTANCE) wxGetInstance();
413 pd
.Flags
= PD_RETURNDEFAULT
;
416 // Fill out the DEVMODE structure
417 // so we can use it as input in the 'real' PrintDlg
421 GlobalFree(pd
.hDevMode
);
423 GlobalFree(pd
.hDevNames
);
427 #if defined(__WXDEBUG__) && defined(__WIN32__)
428 wxString
str(wxT("Printing error: "));
429 str
+= wxGetPrintDlgError();
435 hDevMode
= pd
.hDevMode
;
436 m_devMode
= (void*)(long) hDevMode
;
439 // We'll create a new DEVNAMEs structure below.
441 GlobalFree(pd
.hDevNames
);
444 // hDevNames = pd->hDevNames;
445 // m_devNames = (void*)(long) hDevNames;
446 // pd->hDevnames = NULL;
453 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
458 devMode
->dmOrientation
= m_printOrientation
;
460 devMode
->dmFields
= DM_ORIENTATION
;
465 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
466 devMode
->dmFields
|= DM_COLLATE
;
469 //// Number of copies
471 devMode
->dmCopies
= m_printNoCopies
;
472 devMode
->dmFields
|= DM_COPIES
;
476 if (m_printerName
!= wxT(""))
478 //int len = wxMin(31, m_printerName.Len());
479 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
480 devMode
->dmDeviceName
[31] = wxT('\0');
486 devMode
->dmColor
= DMCOLOR_COLOR
;
488 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
490 devMode
->dmFields
|= DM_COLOR
;
495 if (m_paperId
== wxPAPER_NONE
)
497 // DEVMODE is in tenths of a milimeter
498 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
499 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
500 devMode
->dmPaperSize
= DMPAPER_USER
;
501 devMode
->dmFields
|= DM_PAPERWIDTH
;
502 devMode
->dmFields
|= DM_PAPERLENGTH
;
506 if (wxThePrintPaperDatabase
)
508 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
511 devMode
->dmPaperSize
= paper
->GetPlatformId();
512 devMode
->dmFields
|= DM_PAPERSIZE
;
521 switch (m_duplexMode
)
523 case wxDUPLEX_HORIZONTAL
: {
524 duplex
= DMDUP_HORIZONTAL
; break;
526 case wxDUPLEX_VERTICAL
: {
527 duplex
= DMDUP_VERTICAL
; break;
530 case wxDUPLEX_SIMPLEX
: {
531 duplex
= DMDUP_SIMPLEX
; break;
534 devMode
->dmDuplex
= duplex
;
535 devMode
->dmFields
|= DM_DUPLEX
;
540 switch (m_printQuality
)
542 case wxPRINT_QUALITY_MEDIUM
: {
543 quality
= DMRES_MEDIUM
; break;
545 case wxPRINT_QUALITY_LOW
: {
546 quality
= DMRES_LOW
; break;
548 case wxPRINT_QUALITY_DRAFT
: {
549 quality
= DMRES_DRAFT
; break;
551 case wxPRINT_QUALITY_HIGH
: {
552 quality
= DMRES_HIGH
; break;
555 quality
= m_printQuality
; break;
558 devMode
->dmPrintQuality
= quality
;
559 devMode
->dmFields
|= DM_PRINTQUALITY
;
561 GlobalUnlock(hDevMode
);
566 GlobalFree(hDevNames
);
569 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
570 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
573 void wxPrintData::ConvertFromNative()
575 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
576 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
583 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
588 if (devMode
->dmFields
& DM_ORIENTATION
)
589 m_printOrientation
= devMode
->dmOrientation
;
595 if (devMode
->dmFields
& DM_COLLATE
)
597 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
598 m_printCollate
= TRUE
;
600 m_printCollate
= FALSE
;
604 //// Number of copies
606 if (devMode
->dmFields
& DM_COPIES
)
608 m_printNoCopies
= devMode
->dmCopies
;
613 if (devMode
->dmDeviceName
[0] != 0)
615 // TODO: make this Unicode compatible
618 while (devMode
->dmDeviceName
[i
] != 0)
620 buf
[i
] = devMode
->dmDeviceName
[i
];
630 if (devMode
->dmFields
& DM_COLOR
)
632 if (devMode
->dmColor
== DMCOLOR_COLOR
)
643 // We don't know size of user defined paper and some buggy drivers
644 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
645 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
646 // code wouldn't set m_paperSize correctly.
647 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
649 if (wxThePrintPaperDatabase
)
651 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
654 m_paperId
= paper
->GetId();
655 m_paperSize
.x
= paper
->GetWidth() / 10;
656 m_paperSize
.y
= paper
->GetHeight() / 10;
660 // Shouldn't really get here
661 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
663 m_paperId
= wxPAPER_NONE
;
670 // Shouldn't really get here
671 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
673 m_paperId
= wxPAPER_NONE
;
678 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
680 // DEVMODE is in tenths of a milimeter
681 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
682 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
683 m_paperId
= wxPAPER_NONE
;
687 // Shouldn't really get here
688 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
692 m_paperId
= wxPAPER_NONE
;
698 if (devMode
->dmFields
& DM_DUPLEX
)
700 switch (devMode
->dmDuplex
)
702 case DMDUP_HORIZONTAL
: {
703 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
705 case DMDUP_VERTICAL
: {
706 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
709 case DMDUP_SIMPLEX
: {
710 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
715 m_duplexMode
= wxDUPLEX_SIMPLEX
;
719 if (devMode
->dmFields
& DM_PRINTQUALITY
)
721 switch (devMode
->dmPrintQuality
)
724 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
727 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
730 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
733 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
737 // TODO: if the printer fills in the resolution in DPI, how
738 // will the application know if it's high, low, draft etc.??
739 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
740 m_printQuality
= devMode
->dmPrintQuality
; break;
746 m_printQuality
= wxPRINT_QUALITY_HIGH
;
748 GlobalUnlock(hDevMode
);
753 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
756 // TODO: Unicode-ification
759 // port is obsolete in WIN32
760 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
762 // Get the printer name
763 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
765 // Not sure if we should check for this mismatch
766 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
768 if (printerName
!= wxT(""))
769 m_printerName
= printerName
;
771 GlobalUnlock(hDevNames
);
779 void wxPrintData::ConvertToNative()
783 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
787 void wxPrintData::ConvertFromNative()
791 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
796 void wxPrintData::operator=(const wxPrintData
& data
)
801 m_macPrintSettings
= data
.m_macPrintSettings
;
802 HandToHand( (Handle
*) &m_macPrintSettings
);
805 m_printNoCopies
= data
.m_printNoCopies
;
806 m_printCollate
= data
.m_printCollate
;
807 m_printOrientation
= data
.m_printOrientation
;
808 m_printerName
= data
.m_printerName
;
809 m_colour
= data
.m_colour
;
810 m_duplexMode
= data
.m_duplexMode
;
811 m_printQuality
= data
.m_printQuality
;
812 m_paperId
= data
.m_paperId
;
813 m_paperSize
= data
.m_paperSize
;
815 // PostScript-specific data
816 m_printerCommand
= data
.m_printerCommand
;
817 m_previewCommand
= data
.m_previewCommand
;
818 m_printerOptions
= data
.m_printerOptions
;
819 m_filename
= data
.m_filename
;
820 m_afmPath
= data
.m_afmPath
;
821 m_printerScaleX
= data
.m_printerScaleX
;
822 m_printerScaleY
= data
.m_printerScaleY
;
823 m_printerTranslateX
= data
.m_printerTranslateX
;
824 m_printerTranslateY
= data
.m_printerTranslateY
;
825 m_printMode
= data
.m_printMode
;
829 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
830 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
832 SetPrinterCommand(setupData
.GetPrinterCommand());
833 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
834 SetPrinterOptions(setupData
.GetPrinterOptions());
837 setupData
.GetPrinterTranslation(& xt
, & yt
);
838 SetPrinterTranslation(xt
, yt
);
841 setupData
.GetPrinterScaling(& xs
, & ys
);
842 SetPrinterScaling(xs
, ys
);
844 SetOrientation(setupData
.GetPrinterOrientation());
845 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
846 SetFontMetricPath(setupData
.GetAFMPath());
847 if (setupData
.GetPaperName() != "")
848 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
849 SetColour(setupData
.GetColour());
850 SetFilename(setupData
.GetPrinterFile());
852 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
855 // ----------------------------------------------------------------------------
857 // ----------------------------------------------------------------------------
859 wxPrintDialogData::wxPrintDialogData()
862 m_printDlgData
= NULL
;
869 m_printAllPages
= FALSE
;
870 m_printCollate
= FALSE
;
871 m_printToFile
= FALSE
;
872 m_printSelection
= FALSE
;
873 m_printEnableSelection
= FALSE
;
874 m_printEnablePageNumbers
= TRUE
;
875 m_printEnablePrintToFile
= TRUE
;
876 m_printEnableHelp
= FALSE
;
877 m_printSetupDialog
= FALSE
;
880 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
883 m_printDlgData
= NULL
;
885 (*this) = dialogData
;
888 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
891 m_printDlgData
= NULL
;
898 m_printAllPages
= FALSE
;
899 m_printCollate
= FALSE
;
900 m_printToFile
= FALSE
;
901 m_printSelection
= FALSE
;
902 m_printEnableSelection
= FALSE
;
903 m_printEnablePageNumbers
= TRUE
;
904 m_printEnablePrintToFile
= TRUE
;
905 m_printEnableHelp
= FALSE
;
906 m_printSetupDialog
= FALSE
;
908 m_printData
= printData
;
911 wxPrintDialogData::~wxPrintDialogData()
914 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
915 if ( pd
&& pd
->hDevMode
)
916 GlobalFree(pd
->hDevMode
);
923 void wxPrintDialogData::ConvertToNative()
925 m_printData
.ConvertToNative();
927 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
932 memset( pd
, 0, sizeof(PRINTDLG
) );
933 m_printDlgData
= (void*) pd
;
935 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
937 pd
->lStructSize
= 66;
939 pd
->lStructSize
= sizeof(PRINTDLG
);
941 pd
->hwndOwner
= (HWND
)NULL
;
942 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
943 pd
->hDevNames
= NULL
; // Ditto
945 pd
->Flags
= PD_RETURNDEFAULT
;
949 // Pass the devmode data to the PRINTDLG structure, since it'll
950 // be needed when PrintDlg is called.
953 GlobalFree(pd
->hDevMode
);
956 // Pass the devnames data to the PRINTDLG structure, since it'll
957 // be needed when PrintDlg is called.
960 GlobalFree(pd
->hDevNames
);
963 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
965 m_printData
.SetNativeData((void*) NULL
);
967 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
969 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
971 m_printData
.SetNativeDataDevNames((void*) NULL
);
973 pd
->hDC
= (HDC
) NULL
;
974 pd
->nFromPage
= (WORD
)m_printFromPage
;
975 pd
->nToPage
= (WORD
)m_printToPage
;
976 pd
->nMinPage
= (WORD
)m_printMinPage
;
977 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
978 pd
->nCopies
= (WORD
)m_printNoCopies
;
980 pd
->Flags
= PD_RETURNDC
;
983 pd
->lStructSize
= 66;
985 pd
->lStructSize
= sizeof( PRINTDLG
);
988 pd
->hwndOwner
=(HWND
)NULL
;
989 // pd->hDevNames=(HANDLE)NULL;
990 pd
->hInstance
=(HINSTANCE
)NULL
;
991 pd
->lCustData
= (LPARAM
) NULL
;
992 pd
->lpfnPrintHook
= NULL
;
993 pd
->lpfnSetupHook
= NULL
;
994 pd
->lpPrintTemplateName
= NULL
;
995 pd
->lpSetupTemplateName
= NULL
;
996 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
997 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
999 if ( m_printAllPages
)
1000 pd
->Flags
|= PD_ALLPAGES
;
1001 if ( m_printSelection
)
1002 pd
->Flags
|= PD_SELECTION
;
1003 if ( m_printCollate
)
1004 pd
->Flags
|= PD_COLLATE
;
1005 if ( m_printToFile
)
1006 pd
->Flags
|= PD_PRINTTOFILE
;
1007 if ( !m_printEnablePrintToFile
)
1008 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1009 if ( !m_printEnableSelection
)
1010 pd
->Flags
|= PD_NOSELECTION
;
1011 if ( !m_printEnablePageNumbers
)
1012 pd
->Flags
|= PD_NOPAGENUMS
;
1013 if ( m_printEnableHelp
)
1014 pd
->Flags
|= PD_SHOWHELP
;
1015 if ( m_printSetupDialog
)
1016 pd
->Flags
|= PD_PRINTSETUP
;
1019 void wxPrintDialogData::ConvertFromNative()
1021 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1025 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1028 if (m_printData
.GetNativeData())
1030 // Make sure we don't leak memory
1031 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1033 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1034 pd
->hDevMode
= NULL
;
1037 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1040 if (m_printData
.GetNativeDataDevNames())
1042 // Make sure we don't leak memory
1043 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1045 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1046 pd
->hDevNames
= NULL
;
1049 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1050 // into wxWindows form.
1051 m_printData
.ConvertFromNative();
1053 m_printFromPage
= pd
->nFromPage
;
1054 m_printToPage
= pd
->nToPage
;
1055 m_printMinPage
= pd
->nMinPage
;
1056 m_printMaxPage
= pd
->nMaxPage
;
1057 m_printNoCopies
= pd
->nCopies
;
1059 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1060 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1061 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1062 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1063 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1064 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1065 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1066 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1067 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1069 /* port is obsolete in WIN32
1070 // Get the port name
1073 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1075 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1076 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1077 GlobalUnlock(pd->hDevNames);
1079 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1085 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1087 if ( m_printDlgData
== NULL
)
1090 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1092 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1093 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1099 void wxPrintDialogData::ConvertToNative()
1103 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1104 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1105 m_printData
.ConvertToNative();
1109 void wxPrintDialogData::ConvertFromNative()
1113 m_printData
.ConvertFromNative();
1114 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1115 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1121 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1123 m_printFromPage
= data
.m_printFromPage
;
1124 m_printToPage
= data
.m_printToPage
;
1125 m_printMinPage
= data
.m_printMinPage
;
1126 m_printMaxPage
= data
.m_printMaxPage
;
1127 m_printNoCopies
= data
.m_printNoCopies
;
1128 m_printAllPages
= data
.m_printAllPages
;
1129 m_printCollate
= data
.m_printCollate
;
1130 m_printToFile
= data
.m_printToFile
;
1131 m_printSelection
= data
.m_printSelection
;
1132 m_printEnableSelection
= data
.m_printEnableSelection
;
1133 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1134 m_printEnableHelp
= data
.m_printEnableHelp
;
1135 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1136 m_printSetupDialog
= data
.m_printSetupDialog
;
1138 m_printData
= data
.m_printData
;
1141 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1146 // ----------------------------------------------------------------------------
1147 // wxPageSetupDialogData
1148 // ----------------------------------------------------------------------------
1150 wxPageSetupDialogData::wxPageSetupDialogData()
1152 #if defined(__WIN95__)
1153 m_pageSetupData
= NULL
;
1155 m_paperSize
= wxSize(0, 0);
1157 CalculatePaperSizeFromId();
1159 m_minMarginTopLeft
= wxPoint(0, 0);
1160 m_minMarginBottomRight
= wxPoint(0, 0);
1161 m_marginTopLeft
= wxPoint(0, 0);
1162 m_marginBottomRight
= wxPoint(0, 0);
1165 m_defaultMinMargins
= FALSE
;
1166 m_enableMargins
= TRUE
;
1167 m_enableOrientation
= TRUE
;
1168 m_enablePaper
= TRUE
;
1169 m_enablePrinter
= TRUE
;
1170 m_enableHelp
= FALSE
;
1171 m_getDefaultInfo
= FALSE
;
1174 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1176 #if defined(__WIN95__)
1177 m_pageSetupData
= NULL
;
1179 (*this) = dialogData
;
1182 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1184 #if defined(__WIN95__)
1185 m_pageSetupData
= NULL
;
1187 m_paperSize
= wxSize(0, 0);
1188 m_minMarginTopLeft
= wxPoint(0, 0);
1189 m_minMarginBottomRight
= wxPoint(0, 0);
1190 m_marginTopLeft
= wxPoint(0, 0);
1191 m_marginBottomRight
= wxPoint(0, 0);
1194 m_defaultMinMargins
= FALSE
;
1195 m_enableMargins
= TRUE
;
1196 m_enableOrientation
= TRUE
;
1197 m_enablePaper
= TRUE
;
1198 m_enablePrinter
= TRUE
;
1199 m_enableHelp
= FALSE
;
1200 m_getDefaultInfo
= FALSE
;
1202 m_printData
= printData
;
1204 // The wxPrintData paper size overrides these values, unless the size cannot
1206 CalculatePaperSizeFromId();
1209 wxPageSetupDialogData::~wxPageSetupDialogData()
1211 #if defined(__WIN95__) && defined(__WXMSW__)
1212 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1213 if ( pd
&& pd
->hDevMode
)
1214 GlobalFree(pd
->hDevMode
);
1215 if ( pd
&& pd
->hDevNames
)
1216 GlobalFree(pd
->hDevNames
);
1222 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1224 m_paperSize
= data
.m_paperSize
;
1225 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1226 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1227 m_marginTopLeft
= data
.m_marginTopLeft
;
1228 m_marginBottomRight
= data
.m_marginBottomRight
;
1229 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1230 m_enableMargins
= data
.m_enableMargins
;
1231 m_enableOrientation
= data
.m_enableOrientation
;
1232 m_enablePaper
= data
.m_enablePaper
;
1233 m_enablePrinter
= data
.m_enablePrinter
;
1234 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1235 m_enableHelp
= data
.m_enableHelp
;
1237 m_printData
= data
.m_printData
;
1240 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1245 #if defined(__WIN95__)
1246 void wxPageSetupDialogData::ConvertToNative()
1248 m_printData
.ConvertToNative();
1250 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1252 if ( m_pageSetupData
== NULL
)
1254 pd
= new PAGESETUPDLG
;
1255 pd
->hDevMode
= NULL
;
1256 pd
->hDevNames
= NULL
;
1257 m_pageSetupData
= (void *)pd
;
1260 // Pass the devmode data (created in m_printData.ConvertToNative)
1261 // to the PRINTDLG structure, since it'll
1262 // be needed when PrintDlg is called.
1266 GlobalFree(pd
->hDevMode
);
1267 pd
->hDevMode
= NULL
;
1270 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1272 m_printData
.SetNativeData((void*) NULL
);
1274 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1276 // Pass the devnames data (created in m_printData.ConvertToNative)
1277 // to the PRINTDLG structure, since it'll
1278 // be needed when PrintDlg is called.
1282 GlobalFree(pd
->hDevNames
);
1283 pd
->hDevNames
= NULL
;
1286 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1288 m_printData
.SetNativeDataDevNames((void*) NULL
);
1290 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1292 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1294 if ( m_defaultMinMargins
)
1295 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1296 if ( !m_enableMargins
)
1297 pd
->Flags
|= PSD_DISABLEMARGINS
;
1298 if ( !m_enableOrientation
)
1299 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1300 if ( !m_enablePaper
)
1301 pd
->Flags
|= PSD_DISABLEPAPER
;
1302 if ( !m_enablePrinter
)
1303 pd
->Flags
|= PSD_DISABLEPRINTER
;
1304 if ( m_getDefaultInfo
)
1305 pd
->Flags
|= PSD_RETURNDEFAULT
;
1307 pd
->Flags
|= PSD_SHOWHELP
;
1309 // We want the units to be in hundredths of a millimetre
1310 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1312 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1313 pd
->hwndOwner
=(HWND
)NULL
;
1314 // pd->hDevNames=(HWND)NULL;
1315 pd
->hInstance
=(HINSTANCE
)NULL
;
1316 // PAGESETUPDLG is in hundreds of a mm
1317 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1318 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1320 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1321 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1322 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1323 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1325 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1326 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1327 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1328 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1331 pd
->lpfnPageSetupHook
= NULL
;
1332 pd
->lpfnPagePaintHook
= NULL
;
1333 pd
->hPageSetupTemplate
= NULL
;
1334 pd
->lpPageSetupTemplateName
= NULL
;
1339 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1340 memset(devMode, 0, sizeof(DEVMODE));
1341 devMode->dmSize = sizeof(DEVMODE);
1342 devMode->dmOrientation = m_orientation;
1343 devMode->dmFields = DM_ORIENTATION;
1344 GlobalUnlock(pd->hDevMode);
1349 void wxPageSetupDialogData::ConvertFromNative()
1351 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1355 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1358 if (m_printData
.GetNativeData())
1360 // Make sure we don't leak memory
1361 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1363 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1364 pd
->hDevMode
= NULL
;
1367 m_printData
.ConvertFromNative();
1369 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1372 if (m_printData
.GetNativeDataDevNames())
1374 // Make sure we don't leak memory
1375 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1377 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1378 pd
->hDevNames
= NULL
;
1381 m_printData
.ConvertFromNative();
1383 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1385 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1386 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1387 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1388 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1389 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1390 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1391 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1393 // PAGESETUPDLG is in hundreds of a mm
1394 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1395 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1397 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1398 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1399 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1400 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1402 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1403 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1404 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1405 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1408 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1410 if ( m_pageSetupData
== NULL
)
1413 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1415 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1416 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1422 void wxPageSetupDialogData::ConvertToNative()
1424 m_printData
.ConvertToNative();
1425 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1428 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1429 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1431 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1432 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1434 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1435 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1436 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1437 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1441 void wxPageSetupDialogData::ConvertFromNative()
1443 m_printData
.ConvertFromNative ();
1447 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1448 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1450 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1451 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1453 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1454 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1456 // adjust minimal values
1457 //TODO add custom fields in dialog for margins
1459 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1460 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1462 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1463 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1465 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1466 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1468 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1469 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1474 // If a corresponding paper type is found in the paper database, will set the m_printData
1475 // paper size id member as well.
1476 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1480 CalculateIdFromPaperSize();
1483 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1484 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1486 m_printData
.SetPaperId(id
);
1488 CalculatePaperSizeFromId();
1491 // Use paper size defined in this object to set the wxPrintData
1493 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1495 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1496 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1498 wxSize sz
= GetPaperSize();
1500 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1501 if (id
!= wxPAPER_NONE
)
1503 m_printData
.SetPaperId(id
);
1507 // Use paper id in wxPrintData to set this object's paper size
1508 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1510 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1511 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1513 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1515 // sz is in 10ths of a mm, while paper size is in mm
1516 m_paperSize
.x
= sz
.x
/ 10;
1517 m_paperSize
.y
= sz
.y
/ 10;
1520 #endif // wxUSE_PRINTING_ARCHITECTURE