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
)
129 wxColourData::~wxColourData()
133 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
138 custColours
[i
] = colour
;
141 wxColour
wxColourData::GetCustomColour(int i
)
144 return wxColour(0,0,0);
146 return custColours
[i
];
149 void wxColourData::operator=(const wxColourData
& data
)
152 for (i
= 0; i
< 16; i
++)
153 custColours
[i
] = data
.custColours
[i
];
155 dataColour
= (wxColour
&)data
.dataColour
;
156 chooseFull
= data
.chooseFull
;
159 // ----------------------------------------------------------------------------
161 // ----------------------------------------------------------------------------
163 wxFontData::wxFontData()
165 // Intialize colour to black.
166 fontColour
.Set(0, 0, 0);
170 enableEffects
= TRUE
;
174 m_encoding
= wxFONTENCODING_SYSTEM
;
177 wxFontData::~wxFontData()
181 #if wxUSE_PRINTING_ARCHITECTURE
182 // ----------------------------------------------------------------------------
184 // ----------------------------------------------------------------------------
186 wxPrintData::wxPrintData()
189 m_devMode
= (void*) NULL
;
190 m_devNames
= (void*) NULL
;
191 #elif defined( __WXMAC__ )
193 m_macPageFormat
= kPMNoPageFormat
;
194 m_macPrintSettings
= kPMNoPrintSettings
;
196 #if PM_USE_SESSION_APIS
197 PMPrintSession macPrintSession
= kPMNoReference
;
200 err
= ::UMAPrOpen(&macPrintSession
) ;
203 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
205 // Note that PMPageFormat is not session-specific, but calling
206 // PMSessionDefaultPageFormat assigns values specific to the printer
207 // associated with the current printing session.
208 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
210 err
= PMSessionDefaultPageFormat((PMPrintSession
)macPrintSession
,
211 (PMPageFormat
)m_macPageFormat
);
214 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
216 // Note that PMPrintSettings is not session-specific, but calling
217 // PMSessionDefaultPrintSettings assigns values specific to the printer
218 // associated with the current printing session.
219 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
221 err
= PMSessionDefaultPrintSettings((PMPrintSession
)macPrintSession
,
222 (PMPrintSettings
)m_macPrintSettings
);
225 ::UMAPrClose(&macPrintSession
) ;
228 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
229 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
231 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
232 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
233 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
234 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
236 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
237 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
238 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
239 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
242 m_printOrientation
= wxPORTRAIT
;
244 m_printCollate
= FALSE
;
249 m_duplexMode
= wxDUPLEX_SIMPLEX
;
250 m_printQuality
= wxPRINT_QUALITY_HIGH
;
251 m_paperId
= wxPAPER_A4
;
252 m_paperSize
= wxSize(210, 297);
254 // PostScript-specific data
255 m_printerCommand
= "";
256 m_previewCommand
= "";
257 m_printerOptions
= "";
260 m_printerScaleX
= 1.0;
261 m_printerScaleY
= 1.0;
262 m_printerTranslateX
= 0;
263 m_printerTranslateY
= 0;
264 m_printMode
= wxPRINT_MODE_FILE
;
267 wxPrintData::wxPrintData(const wxPrintData
& printData
)
271 m_devMode
= (void*) NULL
;
272 m_devNames
= (void*) NULL
;
273 #elif defined( __WXMAC__ )
275 m_macPageFormat
= kPMNoPageFormat
;
276 m_macPrintSettings
= kPMNoPrintSettings
;
278 m_macPrintSettings
= NULL
;
284 wxPrintData::~wxPrintData()
287 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
289 GlobalFree(hDevMode
);
290 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
292 GlobalFree(hDevNames
);
293 #elif defined(__WXMAC__)
295 if (m_macPageFormat
!= kPMNoPageFormat
)
297 #if PM_USE_SESSION_APIS
298 (void)PMRelease(m_macPageFormat
);
300 (void)PMDisposePageFormat(m_macPageFormat
);
302 m_macPageFormat
= kPMNoPageFormat
;
305 if (m_macPrintSettings
!= kPMNoPrintSettings
)
307 #if PM_USE_SESSION_APIS
308 (void)PMRelease(m_macPrintSettings
);
310 (void)PMDisposePrintSettings(m_macPrintSettings
);
312 m_macPrintSettings
= kPMNoPrintSettings
;
316 wxASSERT( m_macPrintSettings
);
317 // we should perhaps delete
322 #if defined(__WXMSW__) // && defined(__WIN32__)
324 #if defined(__WXDEBUG__) && defined(__WIN32__)
325 static wxString
wxGetPrintDlgError()
327 DWORD err
= CommDlgExtendedError();
328 wxString msg
= wxT("Unknown");
331 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
332 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
333 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
334 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
335 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
336 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
337 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
338 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
339 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
340 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
341 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
342 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
343 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
344 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
345 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
346 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
347 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
348 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
349 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
350 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
351 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
352 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
359 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
362 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
363 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
368 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
369 ( driverName
.Length() + 1 +
370 printerName
.Length() + 1 +
371 portName
.Length()+1 ) * sizeof(wxChar
) );
372 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
373 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
374 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
376 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
377 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
378 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
380 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
381 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
382 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
392 void wxPrintData::ConvertToNative()
394 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
395 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
398 // Use PRINTDLG as a way of creating a DEVMODE object
401 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
406 memset(&pd
, 0, sizeof(PRINTDLG
));
407 pd
.lStructSize
= sizeof(PRINTDLG
);
410 pd
.hwndOwner
= (HWND
)NULL
;
411 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
412 pd
.hDevNames
= NULL
; // Ditto
413 //pd.hInstance = (HINSTANCE) wxGetInstance();
415 pd
.Flags
= PD_RETURNDEFAULT
;
418 // Fill out the DEVMODE structure
419 // so we can use it as input in the 'real' PrintDlg
423 GlobalFree(pd
.hDevMode
);
425 GlobalFree(pd
.hDevNames
);
429 #if defined(__WXDEBUG__) && defined(__WIN32__)
430 wxString
str(wxT("Printing error: "));
431 str
+= wxGetPrintDlgError();
437 hDevMode
= pd
.hDevMode
;
438 m_devMode
= (void*)(long) hDevMode
;
441 // We'll create a new DEVNAMEs structure below.
443 GlobalFree(pd
.hDevNames
);
446 // hDevNames = pd->hDevNames;
447 // m_devNames = (void*)(long) hDevNames;
448 // pd->hDevnames = NULL;
455 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
460 devMode
->dmOrientation
= m_printOrientation
;
462 devMode
->dmFields
= DM_ORIENTATION
;
467 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
468 devMode
->dmFields
|= DM_COLLATE
;
471 //// Number of copies
473 devMode
->dmCopies
= m_printNoCopies
;
474 devMode
->dmFields
|= DM_COPIES
;
478 if (m_printerName
!= wxT(""))
480 //int len = wxMin(31, m_printerName.Len());
481 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
482 devMode
->dmDeviceName
[31] = wxT('\0');
488 devMode
->dmColor
= DMCOLOR_COLOR
;
490 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
492 devMode
->dmFields
|= DM_COLOR
;
497 if (m_paperId
== wxPAPER_NONE
)
499 // DEVMODE is in tenths of a milimeter
500 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
501 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
502 devMode
->dmPaperSize
= DMPAPER_USER
;
503 devMode
->dmFields
|= DM_PAPERWIDTH
;
504 devMode
->dmFields
|= DM_PAPERLENGTH
;
508 if (wxThePrintPaperDatabase
)
510 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
513 devMode
->dmPaperSize
= paper
->GetPlatformId();
514 devMode
->dmFields
|= DM_PAPERSIZE
;
523 switch (m_duplexMode
)
525 case wxDUPLEX_HORIZONTAL
: {
526 duplex
= DMDUP_HORIZONTAL
; break;
528 case wxDUPLEX_VERTICAL
: {
529 duplex
= DMDUP_VERTICAL
; break;
532 case wxDUPLEX_SIMPLEX
: {
533 duplex
= DMDUP_SIMPLEX
; break;
536 devMode
->dmDuplex
= duplex
;
537 devMode
->dmFields
|= DM_DUPLEX
;
542 switch (m_printQuality
)
544 case wxPRINT_QUALITY_MEDIUM
: {
545 quality
= DMRES_MEDIUM
; break;
547 case wxPRINT_QUALITY_LOW
: {
548 quality
= DMRES_LOW
; break;
550 case wxPRINT_QUALITY_DRAFT
: {
551 quality
= DMRES_DRAFT
; break;
553 case wxPRINT_QUALITY_HIGH
: {
554 quality
= DMRES_HIGH
; break;
557 quality
= m_printQuality
; break;
560 devMode
->dmPrintQuality
= quality
;
561 devMode
->dmFields
|= DM_PRINTQUALITY
;
563 GlobalUnlock(hDevMode
);
568 GlobalFree(hDevNames
);
571 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
572 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
575 void wxPrintData::ConvertFromNative()
577 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
578 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
585 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
590 if (devMode
->dmFields
& DM_ORIENTATION
)
591 m_printOrientation
= devMode
->dmOrientation
;
597 if (devMode
->dmFields
& DM_COLLATE
)
599 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
600 m_printCollate
= TRUE
;
602 m_printCollate
= FALSE
;
606 //// Number of copies
608 if (devMode
->dmFields
& DM_COPIES
)
610 m_printNoCopies
= devMode
->dmCopies
;
615 if (devMode
->dmDeviceName
[0] != 0)
617 // TODO: make this Unicode compatible
620 while (devMode
->dmDeviceName
[i
] != 0)
622 buf
[i
] = devMode
->dmDeviceName
[i
];
632 if (devMode
->dmFields
& DM_COLOR
)
634 if (devMode
->dmColor
== DMCOLOR_COLOR
)
645 // We don't know size of user defined paper and some buggy drivers
646 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
647 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
648 // code wouldn't set m_paperSize correctly.
649 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
651 if (wxThePrintPaperDatabase
)
653 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
656 m_paperId
= paper
->GetId();
657 m_paperSize
.x
= paper
->GetWidth() / 10;
658 m_paperSize
.y
= paper
->GetHeight() / 10;
662 // Shouldn't really get here
663 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
665 m_paperId
= wxPAPER_NONE
;
672 // Shouldn't really get here
673 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
675 m_paperId
= wxPAPER_NONE
;
680 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
682 // DEVMODE is in tenths of a milimeter
683 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
684 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
685 m_paperId
= wxPAPER_NONE
;
689 // Shouldn't really get here
690 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
694 m_paperId
= wxPAPER_NONE
;
700 if (devMode
->dmFields
& DM_DUPLEX
)
702 switch (devMode
->dmDuplex
)
704 case DMDUP_HORIZONTAL
: {
705 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
707 case DMDUP_VERTICAL
: {
708 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
711 case DMDUP_SIMPLEX
: {
712 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
717 m_duplexMode
= wxDUPLEX_SIMPLEX
;
721 if (devMode
->dmFields
& DM_PRINTQUALITY
)
723 switch (devMode
->dmPrintQuality
)
726 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
729 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
732 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
735 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
739 // TODO: if the printer fills in the resolution in DPI, how
740 // will the application know if it's high, low, draft etc.??
741 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
742 m_printQuality
= devMode
->dmPrintQuality
; break;
748 m_printQuality
= wxPRINT_QUALITY_HIGH
;
750 GlobalUnlock(hDevMode
);
755 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
758 // TODO: Unicode-ification
761 // port is obsolete in WIN32
762 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
764 // Get the printer name
765 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
767 // Not sure if we should check for this mismatch
768 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
770 if (printerName
!= wxT(""))
771 m_printerName
= printerName
;
773 GlobalUnlock(hDevNames
);
781 void wxPrintData::ConvertToNative()
785 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
789 void wxPrintData::ConvertFromNative()
793 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
798 void wxPrintData::operator=(const wxPrintData
& data
)
803 m_macPrintSettings
= data
.m_macPrintSettings
;
804 HandToHand( (Handle
*) &m_macPrintSettings
);
807 m_printNoCopies
= data
.m_printNoCopies
;
808 m_printCollate
= data
.m_printCollate
;
809 m_printOrientation
= data
.m_printOrientation
;
810 m_printerName
= data
.m_printerName
;
811 m_colour
= data
.m_colour
;
812 m_duplexMode
= data
.m_duplexMode
;
813 m_printQuality
= data
.m_printQuality
;
814 m_paperId
= data
.m_paperId
;
815 m_paperSize
= data
.m_paperSize
;
817 // PostScript-specific data
818 m_printerCommand
= data
.m_printerCommand
;
819 m_previewCommand
= data
.m_previewCommand
;
820 m_printerOptions
= data
.m_printerOptions
;
821 m_filename
= data
.m_filename
;
822 m_afmPath
= data
.m_afmPath
;
823 m_printerScaleX
= data
.m_printerScaleX
;
824 m_printerScaleY
= data
.m_printerScaleY
;
825 m_printerTranslateX
= data
.m_printerTranslateX
;
826 m_printerTranslateY
= data
.m_printerTranslateY
;
827 m_printMode
= data
.m_printMode
;
831 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
832 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
834 SetPrinterCommand(setupData
.GetPrinterCommand());
835 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
836 SetPrinterOptions(setupData
.GetPrinterOptions());
839 setupData
.GetPrinterTranslation(& xt
, & yt
);
840 SetPrinterTranslation(xt
, yt
);
843 setupData
.GetPrinterScaling(& xs
, & ys
);
844 SetPrinterScaling(xs
, ys
);
846 SetOrientation(setupData
.GetPrinterOrientation());
847 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
848 SetFontMetricPath(setupData
.GetAFMPath());
849 if (setupData
.GetPaperName() != "")
850 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
851 SetColour(setupData
.GetColour());
852 SetFilename(setupData
.GetPrinterFile());
854 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
857 // ----------------------------------------------------------------------------
859 // ----------------------------------------------------------------------------
861 wxPrintDialogData::wxPrintDialogData()
864 m_printDlgData
= NULL
;
871 m_printAllPages
= FALSE
;
872 m_printCollate
= FALSE
;
873 m_printToFile
= FALSE
;
874 m_printSelection
= FALSE
;
875 m_printEnableSelection
= FALSE
;
876 m_printEnablePageNumbers
= TRUE
;
877 m_printEnablePrintToFile
= TRUE
;
878 m_printEnableHelp
= FALSE
;
879 m_printSetupDialog
= FALSE
;
882 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
886 m_printDlgData
= NULL
;
888 (*this) = dialogData
;
891 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
894 m_printDlgData
= NULL
;
901 m_printAllPages
= FALSE
;
902 m_printCollate
= FALSE
;
903 m_printToFile
= FALSE
;
904 m_printSelection
= FALSE
;
905 m_printEnableSelection
= FALSE
;
906 m_printEnablePageNumbers
= TRUE
;
907 m_printEnablePrintToFile
= TRUE
;
908 m_printEnableHelp
= FALSE
;
909 m_printSetupDialog
= FALSE
;
911 m_printData
= printData
;
914 wxPrintDialogData::~wxPrintDialogData()
917 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
918 if ( pd
&& pd
->hDevMode
)
919 GlobalFree(pd
->hDevMode
);
926 void wxPrintDialogData::ConvertToNative()
928 m_printData
.ConvertToNative();
930 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
935 memset( pd
, 0, sizeof(PRINTDLG
) );
936 m_printDlgData
= (void*) pd
;
938 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
940 pd
->lStructSize
= 66;
942 pd
->lStructSize
= sizeof(PRINTDLG
);
944 pd
->hwndOwner
= (HWND
)NULL
;
945 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
946 pd
->hDevNames
= NULL
; // Ditto
948 pd
->Flags
= PD_RETURNDEFAULT
;
952 // Pass the devmode data to the PRINTDLG structure, since it'll
953 // be needed when PrintDlg is called.
956 GlobalFree(pd
->hDevMode
);
959 // Pass the devnames data to the PRINTDLG structure, since it'll
960 // be needed when PrintDlg is called.
963 GlobalFree(pd
->hDevNames
);
966 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
968 m_printData
.SetNativeData((void*) NULL
);
970 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
972 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
974 m_printData
.SetNativeDataDevNames((void*) NULL
);
976 pd
->hDC
= (HDC
) NULL
;
977 pd
->nFromPage
= (WORD
)m_printFromPage
;
978 pd
->nToPage
= (WORD
)m_printToPage
;
979 pd
->nMinPage
= (WORD
)m_printMinPage
;
980 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
981 pd
->nCopies
= (WORD
)m_printNoCopies
;
983 pd
->Flags
= PD_RETURNDC
;
986 pd
->lStructSize
= 66;
988 pd
->lStructSize
= sizeof( PRINTDLG
);
991 pd
->hwndOwner
=(HWND
)NULL
;
992 // pd->hDevNames=(HANDLE)NULL;
993 pd
->hInstance
=(HINSTANCE
)NULL
;
994 pd
->lCustData
= (LPARAM
) NULL
;
995 pd
->lpfnPrintHook
= NULL
;
996 pd
->lpfnSetupHook
= NULL
;
997 pd
->lpPrintTemplateName
= NULL
;
998 pd
->lpSetupTemplateName
= NULL
;
999 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1000 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1002 if ( m_printAllPages
)
1003 pd
->Flags
|= PD_ALLPAGES
;
1004 if ( m_printSelection
)
1005 pd
->Flags
|= PD_SELECTION
;
1006 if ( m_printCollate
)
1007 pd
->Flags
|= PD_COLLATE
;
1008 if ( m_printToFile
)
1009 pd
->Flags
|= PD_PRINTTOFILE
;
1010 if ( !m_printEnablePrintToFile
)
1011 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1012 if ( !m_printEnableSelection
)
1013 pd
->Flags
|= PD_NOSELECTION
;
1014 if ( !m_printEnablePageNumbers
)
1015 pd
->Flags
|= PD_NOPAGENUMS
;
1016 if ( m_printEnableHelp
)
1017 pd
->Flags
|= PD_SHOWHELP
;
1018 if ( m_printSetupDialog
)
1019 pd
->Flags
|= PD_PRINTSETUP
;
1022 void wxPrintDialogData::ConvertFromNative()
1024 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1028 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1031 if (m_printData
.GetNativeData())
1033 // Make sure we don't leak memory
1034 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1036 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1037 pd
->hDevMode
= NULL
;
1040 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1043 if (m_printData
.GetNativeDataDevNames())
1045 // Make sure we don't leak memory
1046 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1048 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1049 pd
->hDevNames
= NULL
;
1052 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1053 // into wxWindows form.
1054 m_printData
.ConvertFromNative();
1056 m_printFromPage
= pd
->nFromPage
;
1057 m_printToPage
= pd
->nToPage
;
1058 m_printMinPage
= pd
->nMinPage
;
1059 m_printMaxPage
= pd
->nMaxPage
;
1060 m_printNoCopies
= pd
->nCopies
;
1062 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1063 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1064 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1065 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1066 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1067 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1068 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1069 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1070 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1072 /* port is obsolete in WIN32
1073 // Get the port name
1076 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1078 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1079 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1080 GlobalUnlock(pd->hDevNames);
1082 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1088 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1090 if ( m_printDlgData
== NULL
)
1093 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1095 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1096 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1102 void wxPrintDialogData::ConvertToNative()
1106 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1107 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1108 m_printData
.ConvertToNative();
1112 void wxPrintDialogData::ConvertFromNative()
1116 m_printData
.ConvertFromNative();
1117 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1118 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1124 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1126 m_printFromPage
= data
.m_printFromPage
;
1127 m_printToPage
= data
.m_printToPage
;
1128 m_printMinPage
= data
.m_printMinPage
;
1129 m_printMaxPage
= data
.m_printMaxPage
;
1130 m_printNoCopies
= data
.m_printNoCopies
;
1131 m_printAllPages
= data
.m_printAllPages
;
1132 m_printCollate
= data
.m_printCollate
;
1133 m_printToFile
= data
.m_printToFile
;
1134 m_printSelection
= data
.m_printSelection
;
1135 m_printEnableSelection
= data
.m_printEnableSelection
;
1136 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1137 m_printEnableHelp
= data
.m_printEnableHelp
;
1138 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1139 m_printSetupDialog
= data
.m_printSetupDialog
;
1141 m_printData
= data
.m_printData
;
1144 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1149 // ----------------------------------------------------------------------------
1150 // wxPageSetupDialogData
1151 // ----------------------------------------------------------------------------
1153 wxPageSetupDialogData::wxPageSetupDialogData()
1155 #if defined(__WIN95__)
1156 m_pageSetupData
= NULL
;
1158 m_paperSize
= wxSize(0, 0);
1160 CalculatePaperSizeFromId();
1162 m_minMarginTopLeft
= wxPoint(0, 0);
1163 m_minMarginBottomRight
= wxPoint(0, 0);
1164 m_marginTopLeft
= wxPoint(0, 0);
1165 m_marginBottomRight
= wxPoint(0, 0);
1168 m_defaultMinMargins
= FALSE
;
1169 m_enableMargins
= TRUE
;
1170 m_enableOrientation
= TRUE
;
1171 m_enablePaper
= TRUE
;
1172 m_enablePrinter
= TRUE
;
1173 m_enableHelp
= FALSE
;
1174 m_getDefaultInfo
= FALSE
;
1177 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1180 #if defined(__WIN95__)
1181 m_pageSetupData
= NULL
;
1183 (*this) = dialogData
;
1186 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1188 #if defined(__WIN95__)
1189 m_pageSetupData
= NULL
;
1191 m_paperSize
= wxSize(0, 0);
1192 m_minMarginTopLeft
= wxPoint(0, 0);
1193 m_minMarginBottomRight
= wxPoint(0, 0);
1194 m_marginTopLeft
= wxPoint(0, 0);
1195 m_marginBottomRight
= wxPoint(0, 0);
1198 m_defaultMinMargins
= FALSE
;
1199 m_enableMargins
= TRUE
;
1200 m_enableOrientation
= TRUE
;
1201 m_enablePaper
= TRUE
;
1202 m_enablePrinter
= TRUE
;
1203 m_enableHelp
= FALSE
;
1204 m_getDefaultInfo
= FALSE
;
1206 m_printData
= printData
;
1208 // The wxPrintData paper size overrides these values, unless the size cannot
1210 CalculatePaperSizeFromId();
1213 wxPageSetupDialogData::~wxPageSetupDialogData()
1215 #if defined(__WIN95__) && defined(__WXMSW__)
1216 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1217 if ( pd
&& pd
->hDevMode
)
1218 GlobalFree(pd
->hDevMode
);
1219 if ( pd
&& pd
->hDevNames
)
1220 GlobalFree(pd
->hDevNames
);
1226 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1228 m_paperSize
= data
.m_paperSize
;
1229 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1230 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1231 m_marginTopLeft
= data
.m_marginTopLeft
;
1232 m_marginBottomRight
= data
.m_marginBottomRight
;
1233 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1234 m_enableMargins
= data
.m_enableMargins
;
1235 m_enableOrientation
= data
.m_enableOrientation
;
1236 m_enablePaper
= data
.m_enablePaper
;
1237 m_enablePrinter
= data
.m_enablePrinter
;
1238 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1239 m_enableHelp
= data
.m_enableHelp
;
1241 m_printData
= data
.m_printData
;
1246 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1253 #if defined(__WIN95__)
1254 void wxPageSetupDialogData::ConvertToNative()
1256 m_printData
.ConvertToNative();
1258 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1260 if ( m_pageSetupData
== NULL
)
1262 pd
= new PAGESETUPDLG
;
1263 pd
->hDevMode
= NULL
;
1264 pd
->hDevNames
= NULL
;
1265 m_pageSetupData
= (void *)pd
;
1268 // Pass the devmode data (created in m_printData.ConvertToNative)
1269 // to the PRINTDLG structure, since it'll
1270 // be needed when PrintDlg is called.
1274 GlobalFree(pd
->hDevMode
);
1275 pd
->hDevMode
= NULL
;
1278 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1280 m_printData
.SetNativeData((void*) NULL
);
1282 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1284 // Pass the devnames data (created in m_printData.ConvertToNative)
1285 // to the PRINTDLG structure, since it'll
1286 // be needed when PrintDlg is called.
1290 GlobalFree(pd
->hDevNames
);
1291 pd
->hDevNames
= NULL
;
1294 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1296 m_printData
.SetNativeDataDevNames((void*) NULL
);
1298 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1300 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1302 if ( m_defaultMinMargins
)
1303 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1304 if ( !m_enableMargins
)
1305 pd
->Flags
|= PSD_DISABLEMARGINS
;
1306 if ( !m_enableOrientation
)
1307 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1308 if ( !m_enablePaper
)
1309 pd
->Flags
|= PSD_DISABLEPAPER
;
1310 if ( !m_enablePrinter
)
1311 pd
->Flags
|= PSD_DISABLEPRINTER
;
1312 if ( m_getDefaultInfo
)
1313 pd
->Flags
|= PSD_RETURNDEFAULT
;
1315 pd
->Flags
|= PSD_SHOWHELP
;
1317 // We want the units to be in hundredths of a millimetre
1318 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1320 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1321 pd
->hwndOwner
=(HWND
)NULL
;
1322 // pd->hDevNames=(HWND)NULL;
1323 pd
->hInstance
=(HINSTANCE
)NULL
;
1324 // PAGESETUPDLG is in hundreds of a mm
1325 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1326 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1328 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1329 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1330 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1331 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1333 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1334 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1335 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1336 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1339 pd
->lpfnPageSetupHook
= NULL
;
1340 pd
->lpfnPagePaintHook
= NULL
;
1341 pd
->hPageSetupTemplate
= NULL
;
1342 pd
->lpPageSetupTemplateName
= NULL
;
1347 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1348 memset(devMode, 0, sizeof(DEVMODE));
1349 devMode->dmSize = sizeof(DEVMODE);
1350 devMode->dmOrientation = m_orientation;
1351 devMode->dmFields = DM_ORIENTATION;
1352 GlobalUnlock(pd->hDevMode);
1357 void wxPageSetupDialogData::ConvertFromNative()
1359 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1363 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1366 if (m_printData
.GetNativeData())
1368 // Make sure we don't leak memory
1369 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1371 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1372 pd
->hDevMode
= NULL
;
1375 m_printData
.ConvertFromNative();
1377 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1380 if (m_printData
.GetNativeDataDevNames())
1382 // Make sure we don't leak memory
1383 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1385 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1386 pd
->hDevNames
= NULL
;
1389 m_printData
.ConvertFromNative();
1391 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1393 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1394 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1395 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1396 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1397 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1398 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1399 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1401 // PAGESETUPDLG is in hundreds of a mm
1402 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1403 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1405 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1406 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1407 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1408 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1410 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1411 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1412 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1413 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1416 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1418 if ( m_pageSetupData
== NULL
)
1421 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1423 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1424 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1430 void wxPageSetupDialogData::ConvertToNative()
1432 m_printData
.ConvertToNative();
1433 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1436 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1437 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1439 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1440 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1442 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1443 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1444 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1445 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1449 void wxPageSetupDialogData::ConvertFromNative()
1451 m_printData
.ConvertFromNative ();
1455 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1456 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1458 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1459 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1461 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1462 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1464 // adjust minimal values
1465 //TODO add custom fields in dialog for margins
1467 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1468 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1470 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1471 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1473 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1474 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1476 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1477 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1482 // If a corresponding paper type is found in the paper database, will set the m_printData
1483 // paper size id member as well.
1484 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1488 CalculateIdFromPaperSize();
1491 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1492 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1494 m_printData
.SetPaperId(id
);
1496 CalculatePaperSizeFromId();
1499 // Use paper size defined in this object to set the wxPrintData
1501 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1503 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1504 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1506 wxSize sz
= GetPaperSize();
1508 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1509 if (id
!= wxPAPER_NONE
)
1511 m_printData
.SetPaperId(id
);
1515 // Use paper id in wxPrintData to set this object's paper size
1516 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1518 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1519 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1521 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1523 // sz is in 10ths of a mm, while paper size is in mm
1524 m_paperSize
.x
= sz
.x
/ 10;
1525 m_paperSize
.y
= sz
.y
/ 10;
1528 #endif // wxUSE_PRINTING_ARCHITECTURE