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
856 // Is this data OK for showing the print dialog?
857 bool wxPrintData::Ok() const
860 ((wxPrintData
*)this)->ConvertToNative();
861 return (m_devMode
!= NULL
) ;
867 // ----------------------------------------------------------------------------
869 // ----------------------------------------------------------------------------
871 wxPrintDialogData::wxPrintDialogData()
874 m_printDlgData
= NULL
;
881 m_printAllPages
= FALSE
;
882 m_printCollate
= FALSE
;
883 m_printToFile
= FALSE
;
884 m_printSelection
= FALSE
;
885 m_printEnableSelection
= FALSE
;
886 m_printEnablePageNumbers
= TRUE
;
887 m_printEnablePrintToFile
= TRUE
;
888 m_printEnableHelp
= FALSE
;
889 m_printSetupDialog
= FALSE
;
892 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
896 m_printDlgData
= NULL
;
898 (*this) = dialogData
;
901 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
904 m_printDlgData
= NULL
;
911 m_printAllPages
= FALSE
;
912 m_printCollate
= FALSE
;
913 m_printToFile
= FALSE
;
914 m_printSelection
= FALSE
;
915 m_printEnableSelection
= FALSE
;
916 m_printEnablePageNumbers
= TRUE
;
917 m_printEnablePrintToFile
= TRUE
;
918 m_printEnableHelp
= FALSE
;
919 m_printSetupDialog
= FALSE
;
921 m_printData
= printData
;
924 wxPrintDialogData::~wxPrintDialogData()
927 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
928 if ( pd
&& pd
->hDevMode
)
929 GlobalFree(pd
->hDevMode
);
936 void wxPrintDialogData::ConvertToNative()
938 m_printData
.ConvertToNative();
940 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
945 memset( pd
, 0, sizeof(PRINTDLG
) );
946 m_printDlgData
= (void*) pd
;
948 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
950 pd
->lStructSize
= 66;
952 pd
->lStructSize
= sizeof(PRINTDLG
);
954 pd
->hwndOwner
= (HWND
)NULL
;
955 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
956 pd
->hDevNames
= NULL
; // Ditto
958 pd
->Flags
= PD_RETURNDEFAULT
;
962 // Pass the devmode data to the PRINTDLG structure, since it'll
963 // be needed when PrintDlg is called.
966 GlobalFree(pd
->hDevMode
);
969 // Pass the devnames data to the PRINTDLG structure, since it'll
970 // be needed when PrintDlg is called.
973 GlobalFree(pd
->hDevNames
);
976 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
978 m_printData
.SetNativeData((void*) NULL
);
980 // Shouldn't assert; we should be able to test Ok-ness at a higher level
981 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
983 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
985 m_printData
.SetNativeDataDevNames((void*) NULL
);
987 pd
->hDC
= (HDC
) NULL
;
988 pd
->nFromPage
= (WORD
)m_printFromPage
;
989 pd
->nToPage
= (WORD
)m_printToPage
;
990 pd
->nMinPage
= (WORD
)m_printMinPage
;
991 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
992 pd
->nCopies
= (WORD
)m_printNoCopies
;
994 pd
->Flags
= PD_RETURNDC
;
997 pd
->lStructSize
= 66;
999 pd
->lStructSize
= sizeof( PRINTDLG
);
1002 pd
->hwndOwner
=(HWND
)NULL
;
1003 // pd->hDevNames=(HANDLE)NULL;
1004 pd
->hInstance
=(HINSTANCE
)NULL
;
1005 pd
->lCustData
= (LPARAM
) NULL
;
1006 pd
->lpfnPrintHook
= NULL
;
1007 pd
->lpfnSetupHook
= NULL
;
1008 pd
->lpPrintTemplateName
= NULL
;
1009 pd
->lpSetupTemplateName
= NULL
;
1010 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1011 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1013 if ( m_printAllPages
)
1014 pd
->Flags
|= PD_ALLPAGES
;
1015 if ( m_printSelection
)
1016 pd
->Flags
|= PD_SELECTION
;
1017 if ( m_printCollate
)
1018 pd
->Flags
|= PD_COLLATE
;
1019 if ( m_printToFile
)
1020 pd
->Flags
|= PD_PRINTTOFILE
;
1021 if ( !m_printEnablePrintToFile
)
1022 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1023 if ( !m_printEnableSelection
)
1024 pd
->Flags
|= PD_NOSELECTION
;
1025 if ( !m_printEnablePageNumbers
)
1026 pd
->Flags
|= PD_NOPAGENUMS
;
1027 if ( m_printEnableHelp
)
1028 pd
->Flags
|= PD_SHOWHELP
;
1029 if ( m_printSetupDialog
)
1030 pd
->Flags
|= PD_PRINTSETUP
;
1033 void wxPrintDialogData::ConvertFromNative()
1035 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1039 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1042 if (m_printData
.GetNativeData())
1044 // Make sure we don't leak memory
1045 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1047 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1048 pd
->hDevMode
= NULL
;
1051 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1054 if (m_printData
.GetNativeDataDevNames())
1056 // Make sure we don't leak memory
1057 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1059 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1060 pd
->hDevNames
= NULL
;
1063 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1064 // into wxWindows form.
1065 m_printData
.ConvertFromNative();
1067 m_printFromPage
= pd
->nFromPage
;
1068 m_printToPage
= pd
->nToPage
;
1069 m_printMinPage
= pd
->nMinPage
;
1070 m_printMaxPage
= pd
->nMaxPage
;
1071 m_printNoCopies
= pd
->nCopies
;
1073 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1074 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1075 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1076 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1077 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1078 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1079 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1080 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1081 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1083 /* port is obsolete in WIN32
1084 // Get the port name
1087 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1089 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1090 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1091 GlobalUnlock(pd->hDevNames);
1093 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1099 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1101 if ( m_printDlgData
== NULL
)
1104 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1106 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1107 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1113 void wxPrintDialogData::ConvertToNative()
1117 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1118 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1119 m_printData
.ConvertToNative();
1123 void wxPrintDialogData::ConvertFromNative()
1127 m_printData
.ConvertFromNative();
1128 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1129 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1135 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1137 m_printFromPage
= data
.m_printFromPage
;
1138 m_printToPage
= data
.m_printToPage
;
1139 m_printMinPage
= data
.m_printMinPage
;
1140 m_printMaxPage
= data
.m_printMaxPage
;
1141 m_printNoCopies
= data
.m_printNoCopies
;
1142 m_printAllPages
= data
.m_printAllPages
;
1143 m_printCollate
= data
.m_printCollate
;
1144 m_printToFile
= data
.m_printToFile
;
1145 m_printSelection
= data
.m_printSelection
;
1146 m_printEnableSelection
= data
.m_printEnableSelection
;
1147 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1148 m_printEnableHelp
= data
.m_printEnableHelp
;
1149 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1150 m_printSetupDialog
= data
.m_printSetupDialog
;
1152 m_printData
= data
.m_printData
;
1155 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1160 // ----------------------------------------------------------------------------
1161 // wxPageSetupDialogData
1162 // ----------------------------------------------------------------------------
1164 wxPageSetupDialogData::wxPageSetupDialogData()
1166 #if defined(__WIN95__)
1167 m_pageSetupData
= NULL
;
1169 m_paperSize
= wxSize(0, 0);
1171 CalculatePaperSizeFromId();
1173 m_minMarginTopLeft
= wxPoint(0, 0);
1174 m_minMarginBottomRight
= wxPoint(0, 0);
1175 m_marginTopLeft
= wxPoint(0, 0);
1176 m_marginBottomRight
= wxPoint(0, 0);
1179 m_defaultMinMargins
= FALSE
;
1180 m_enableMargins
= TRUE
;
1181 m_enableOrientation
= TRUE
;
1182 m_enablePaper
= TRUE
;
1183 m_enablePrinter
= TRUE
;
1184 m_enableHelp
= FALSE
;
1185 m_getDefaultInfo
= FALSE
;
1188 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1191 #if defined(__WIN95__)
1192 m_pageSetupData
= NULL
;
1194 (*this) = dialogData
;
1197 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1199 #if defined(__WIN95__)
1200 m_pageSetupData
= NULL
;
1202 m_paperSize
= wxSize(0, 0);
1203 m_minMarginTopLeft
= wxPoint(0, 0);
1204 m_minMarginBottomRight
= wxPoint(0, 0);
1205 m_marginTopLeft
= wxPoint(0, 0);
1206 m_marginBottomRight
= wxPoint(0, 0);
1209 m_defaultMinMargins
= FALSE
;
1210 m_enableMargins
= TRUE
;
1211 m_enableOrientation
= TRUE
;
1212 m_enablePaper
= TRUE
;
1213 m_enablePrinter
= TRUE
;
1214 m_enableHelp
= FALSE
;
1215 m_getDefaultInfo
= FALSE
;
1217 m_printData
= printData
;
1219 // The wxPrintData paper size overrides these values, unless the size cannot
1221 CalculatePaperSizeFromId();
1224 wxPageSetupDialogData::~wxPageSetupDialogData()
1226 #if defined(__WIN95__) && defined(__WXMSW__)
1227 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1228 if ( pd
&& pd
->hDevMode
)
1229 GlobalFree(pd
->hDevMode
);
1230 if ( pd
&& pd
->hDevNames
)
1231 GlobalFree(pd
->hDevNames
);
1237 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1239 m_paperSize
= data
.m_paperSize
;
1240 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1241 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1242 m_marginTopLeft
= data
.m_marginTopLeft
;
1243 m_marginBottomRight
= data
.m_marginBottomRight
;
1244 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1245 m_enableMargins
= data
.m_enableMargins
;
1246 m_enableOrientation
= data
.m_enableOrientation
;
1247 m_enablePaper
= data
.m_enablePaper
;
1248 m_enablePrinter
= data
.m_enablePrinter
;
1249 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1250 m_enableHelp
= data
.m_enableHelp
;
1252 m_printData
= data
.m_printData
;
1257 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1264 #if defined(__WIN95__)
1265 void wxPageSetupDialogData::ConvertToNative()
1267 m_printData
.ConvertToNative();
1269 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1271 if ( m_pageSetupData
== NULL
)
1273 pd
= new PAGESETUPDLG
;
1274 pd
->hDevMode
= NULL
;
1275 pd
->hDevNames
= NULL
;
1276 m_pageSetupData
= (void *)pd
;
1279 // Pass the devmode data (created in m_printData.ConvertToNative)
1280 // to the PRINTDLG structure, since it'll
1281 // be needed when PrintDlg is called.
1285 GlobalFree(pd
->hDevMode
);
1286 pd
->hDevMode
= NULL
;
1289 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1291 m_printData
.SetNativeData((void*) NULL
);
1293 // Shouldn't assert; we should be able to test Ok-ness at a higher level
1294 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1296 // Pass the devnames data (created in m_printData.ConvertToNative)
1297 // to the PRINTDLG structure, since it'll
1298 // be needed when PrintDlg is called.
1302 GlobalFree(pd
->hDevNames
);
1303 pd
->hDevNames
= NULL
;
1306 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1308 m_printData
.SetNativeDataDevNames((void*) NULL
);
1310 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1312 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1314 if ( m_defaultMinMargins
)
1315 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1316 if ( !m_enableMargins
)
1317 pd
->Flags
|= PSD_DISABLEMARGINS
;
1318 if ( !m_enableOrientation
)
1319 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1320 if ( !m_enablePaper
)
1321 pd
->Flags
|= PSD_DISABLEPAPER
;
1322 if ( !m_enablePrinter
)
1323 pd
->Flags
|= PSD_DISABLEPRINTER
;
1324 if ( m_getDefaultInfo
)
1325 pd
->Flags
|= PSD_RETURNDEFAULT
;
1327 pd
->Flags
|= PSD_SHOWHELP
;
1329 // We want the units to be in hundredths of a millimetre
1330 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1332 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1333 pd
->hwndOwner
=(HWND
)NULL
;
1334 // pd->hDevNames=(HWND)NULL;
1335 pd
->hInstance
=(HINSTANCE
)NULL
;
1336 // PAGESETUPDLG is in hundreds of a mm
1337 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1338 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1340 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1341 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1342 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1343 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1345 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1346 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1347 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1348 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1351 pd
->lpfnPageSetupHook
= NULL
;
1352 pd
->lpfnPagePaintHook
= NULL
;
1353 pd
->hPageSetupTemplate
= NULL
;
1354 pd
->lpPageSetupTemplateName
= NULL
;
1359 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1360 memset(devMode, 0, sizeof(DEVMODE));
1361 devMode->dmSize = sizeof(DEVMODE);
1362 devMode->dmOrientation = m_orientation;
1363 devMode->dmFields = DM_ORIENTATION;
1364 GlobalUnlock(pd->hDevMode);
1369 void wxPageSetupDialogData::ConvertFromNative()
1371 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1375 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1378 if (m_printData
.GetNativeData())
1380 // Make sure we don't leak memory
1381 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1383 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1384 pd
->hDevMode
= NULL
;
1387 m_printData
.ConvertFromNative();
1389 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1392 if (m_printData
.GetNativeDataDevNames())
1394 // Make sure we don't leak memory
1395 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1397 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1398 pd
->hDevNames
= NULL
;
1401 m_printData
.ConvertFromNative();
1403 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1405 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1406 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1407 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1408 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1409 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1410 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1411 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1413 // PAGESETUPDLG is in hundreds of a mm
1414 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1415 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1417 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1418 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1419 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1420 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1422 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1423 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1424 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1425 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1428 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1430 if ( m_pageSetupData
== NULL
)
1433 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1435 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1436 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1442 void wxPageSetupDialogData::ConvertToNative()
1444 m_printData
.ConvertToNative();
1445 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1448 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1449 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1451 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1452 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1454 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1455 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1456 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1457 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1461 void wxPageSetupDialogData::ConvertFromNative()
1463 m_printData
.ConvertFromNative ();
1467 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1468 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1470 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1471 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1473 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1474 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1476 // adjust minimal values
1477 //TODO add custom fields in dialog for margins
1479 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1480 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1482 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1483 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1485 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1486 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1488 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1489 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1494 // If a corresponding paper type is found in the paper database, will set the m_printData
1495 // paper size id member as well.
1496 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1500 CalculateIdFromPaperSize();
1503 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1504 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1506 m_printData
.SetPaperId(id
);
1508 CalculatePaperSizeFromId();
1511 // Use paper size defined in this object to set the wxPrintData
1513 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1515 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1516 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1518 wxSize sz
= GetPaperSize();
1520 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1521 if (id
!= wxPAPER_NONE
)
1523 m_printData
.SetPaperId(id
);
1527 // Use paper id in wxPrintData to set this object's paper size
1528 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1530 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1531 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1533 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1535 // sz is in 10ths of a mm, while paper size is in mm
1536 m_paperSize
.x
= sz
.x
/ 10;
1537 m_paperSize
.y
= sz
.y
/ 10;
1540 #endif // wxUSE_PRINTING_ARCHITECTURE