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 #include "wx/fontdlg.h"
44 #endif // wxUSE_FONTDLG
47 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXX11__)|| defined(__WXPM__) || defined(__WXMAC__)) && wxUSE_POSTSCRIPT
48 #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
51 #if wxUSE_PRINTING_ARCHITECTURE
54 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
55 #include "wx/generic/dcpsg.h"
57 #endif // wxUSE_PRINTING_ARCHITECTURE
61 #include "wx/msw/private.h"
63 #if !defined(__WIN32__)
73 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
79 #if wxUSE_PRINTING_ARCHITECTURE
80 IMPLEMENT_DYNAMIC_CLASS(wxPrintData
, wxObject
)
81 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData
, wxObject
)
82 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData
, wxObject
)
83 #endif // wxUSE_PRINTING_ARCHITECTURE
85 IMPLEMENT_DYNAMIC_CLASS(wxFontData
, wxObject
)
86 IMPLEMENT_DYNAMIC_CLASS(wxColourData
, wxObject
)
89 #include "wx/mac/uma.h"
91 #if defined(TARGET_CARBON) && !defined(__DARWIN__)
92 # if PM_USE_SESSION_APIS
95 # include <PMApplication.h>
101 #define mm2pt 2.83464566929
102 #define pt2mm 0.352777777778
106 #define DMPAPER_USER 256
109 // ============================================================================
111 // ============================================================================
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
117 wxColourData::wxColourData()
120 for (i
= 0; i
< 16; i
++)
121 custColours
[i
].Set(255, 255, 255);
124 dataColour
.Set(0,0,0);
127 wxColourData::wxColourData(const wxColourData
& data
)
133 wxColourData::~wxColourData()
137 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
142 custColours
[i
] = colour
;
145 wxColour
wxColourData::GetCustomColour(int i
)
148 return wxColour(0,0,0);
150 return custColours
[i
];
153 void wxColourData::operator=(const wxColourData
& data
)
156 for (i
= 0; i
< 16; i
++)
157 custColours
[i
] = data
.custColours
[i
];
159 dataColour
= (wxColour
&)data
.dataColour
;
160 chooseFull
= data
.chooseFull
;
163 // ----------------------------------------------------------------------------
165 // ----------------------------------------------------------------------------
167 wxFontData::wxFontData()
169 // Intialize colour to black.
170 fontColour
.Set(0, 0, 0);
174 enableEffects
= TRUE
;
178 m_encoding
= wxFONTENCODING_SYSTEM
;
181 wxFontData::~wxFontData()
187 wxFontDialogBase::~wxFontDialogBase()
191 #endif // wxUSE_FONTDLG
193 #if wxUSE_PRINTING_ARCHITECTURE
194 // ----------------------------------------------------------------------------
196 // ----------------------------------------------------------------------------
198 wxPrintData::wxPrintData()
201 m_devMode
= (void*) NULL
;
202 m_devNames
= (void*) NULL
;
203 #elif defined( __WXMAC__ )
205 m_macPageFormat
= kPMNoPageFormat
;
206 m_macPrintSettings
= kPMNoPrintSettings
;
208 #if PM_USE_SESSION_APIS
209 PMPrintSession macPrintSession
= kPMNoReference
;
212 err
= ::UMAPrOpen(&macPrintSession
) ;
215 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
217 // Note that PMPageFormat is not session-specific, but calling
218 // PMSessionDefaultPageFormat assigns values specific to the printer
219 // associated with the current printing session.
220 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
222 err
= PMSessionDefaultPageFormat((PMPrintSession
)macPrintSession
,
223 (PMPageFormat
)m_macPageFormat
);
226 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
228 // Note that PMPrintSettings is not session-specific, but calling
229 // PMSessionDefaultPrintSettings assigns values specific to the printer
230 // associated with the current printing session.
231 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
233 err
= PMSessionDefaultPrintSettings((PMPrintSession
)macPrintSession
,
234 (PMPrintSettings
)m_macPrintSettings
);
237 ::UMAPrClose(&macPrintSession
) ;
240 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
241 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
243 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
244 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
245 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
246 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
248 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
249 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
250 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
251 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
254 m_printOrientation
= wxPORTRAIT
;
256 m_printCollate
= FALSE
;
261 m_duplexMode
= wxDUPLEX_SIMPLEX
;
262 m_printQuality
= wxPRINT_QUALITY_HIGH
;
263 m_paperId
= wxPAPER_A4
;
264 m_paperSize
= wxSize(210, 297);
266 // PostScript-specific data
267 m_printerCommand
= "";
268 m_previewCommand
= "";
269 m_printerOptions
= "";
272 m_printerScaleX
= 1.0;
273 m_printerScaleY
= 1.0;
274 m_printerTranslateX
= 0;
275 m_printerTranslateY
= 0;
276 m_printMode
= wxPRINT_MODE_FILE
;
279 wxPrintData::wxPrintData(const wxPrintData
& printData
)
283 m_devMode
= (void*) NULL
;
284 m_devNames
= (void*) NULL
;
285 #elif defined( __WXMAC__ )
287 m_macPageFormat
= kPMNoPageFormat
;
288 m_macPrintSettings
= kPMNoPrintSettings
;
290 m_macPrintSettings
= NULL
;
296 wxPrintData::~wxPrintData()
299 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
301 GlobalFree(hDevMode
);
302 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
304 GlobalFree(hDevNames
);
305 #elif defined(__WXMAC__)
307 if (m_macPageFormat
!= kPMNoPageFormat
)
309 #if PM_USE_SESSION_APIS
310 (void)PMRelease(m_macPageFormat
);
312 (void)PMDisposePageFormat(m_macPageFormat
);
314 m_macPageFormat
= kPMNoPageFormat
;
317 if (m_macPrintSettings
!= kPMNoPrintSettings
)
319 #if PM_USE_SESSION_APIS
320 (void)PMRelease(m_macPrintSettings
);
322 (void)PMDisposePrintSettings(m_macPrintSettings
);
324 m_macPrintSettings
= kPMNoPrintSettings
;
328 wxASSERT( m_macPrintSettings
);
329 // we should perhaps delete
334 #if defined(__WXMSW__) // && defined(__WIN32__)
336 #if defined(__WXDEBUG__) && defined(__WIN32__)
337 static wxString
wxGetPrintDlgError()
339 DWORD err
= CommDlgExtendedError();
340 wxString msg
= wxT("Unknown");
343 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
344 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
345 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
346 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
347 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
348 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
349 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
350 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
351 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
352 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
353 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
354 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
355 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
356 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
357 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
358 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
359 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
360 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
361 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
362 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
363 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
364 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
371 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
374 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
375 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
380 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
381 ( driverName
.Length() + 1 +
382 printerName
.Length() + 1 +
383 portName
.Length()+1 ) * sizeof(wxChar
) );
384 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
385 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
386 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
388 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
389 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
390 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
392 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
393 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
394 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
404 void wxPrintData::ConvertToNative()
406 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
407 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
410 // Use PRINTDLG as a way of creating a DEVMODE object
413 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
418 memset(&pd
, 0, sizeof(PRINTDLG
));
419 pd
.lStructSize
= sizeof(PRINTDLG
);
422 pd
.hwndOwner
= (HWND
)NULL
;
423 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
424 pd
.hDevNames
= NULL
; // Ditto
425 //pd.hInstance = (HINSTANCE) wxGetInstance();
427 pd
.Flags
= PD_RETURNDEFAULT
;
430 // Fill out the DEVMODE structure
431 // so we can use it as input in the 'real' PrintDlg
435 GlobalFree(pd
.hDevMode
);
437 GlobalFree(pd
.hDevNames
);
441 #if defined(__WXDEBUG__) && defined(__WIN32__)
442 wxString
str(wxT("Printing error: "));
443 str
+= wxGetPrintDlgError();
449 hDevMode
= pd
.hDevMode
;
450 m_devMode
= (void*)(long) hDevMode
;
453 // We'll create a new DEVNAMEs structure below.
455 GlobalFree(pd
.hDevNames
);
458 // hDevNames = pd->hDevNames;
459 // m_devNames = (void*)(long) hDevNames;
460 // pd->hDevnames = NULL;
467 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
472 devMode
->dmOrientation
= m_printOrientation
;
474 devMode
->dmFields
= DM_ORIENTATION
;
479 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
480 devMode
->dmFields
|= DM_COLLATE
;
483 //// Number of copies
485 devMode
->dmCopies
= m_printNoCopies
;
486 devMode
->dmFields
|= DM_COPIES
;
490 if (m_printerName
!= wxT(""))
492 //int len = wxMin(31, m_printerName.Len());
493 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
494 devMode
->dmDeviceName
[31] = wxT('\0');
500 devMode
->dmColor
= DMCOLOR_COLOR
;
502 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
504 devMode
->dmFields
|= DM_COLOR
;
509 if (m_paperId
== wxPAPER_NONE
)
511 // DEVMODE is in tenths of a milimeter
512 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
513 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
514 devMode
->dmPaperSize
= DMPAPER_USER
;
515 devMode
->dmFields
|= DM_PAPERWIDTH
;
516 devMode
->dmFields
|= DM_PAPERLENGTH
;
520 if (wxThePrintPaperDatabase
)
522 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
525 devMode
->dmPaperSize
= paper
->GetPlatformId();
526 devMode
->dmFields
|= DM_PAPERSIZE
;
535 switch (m_duplexMode
)
537 case wxDUPLEX_HORIZONTAL
: {
538 duplex
= DMDUP_HORIZONTAL
; break;
540 case wxDUPLEX_VERTICAL
: {
541 duplex
= DMDUP_VERTICAL
; break;
544 case wxDUPLEX_SIMPLEX
: {
545 duplex
= DMDUP_SIMPLEX
; break;
548 devMode
->dmDuplex
= duplex
;
549 devMode
->dmFields
|= DM_DUPLEX
;
554 switch (m_printQuality
)
556 case wxPRINT_QUALITY_MEDIUM
: {
557 quality
= DMRES_MEDIUM
; break;
559 case wxPRINT_QUALITY_LOW
: {
560 quality
= DMRES_LOW
; break;
562 case wxPRINT_QUALITY_DRAFT
: {
563 quality
= DMRES_DRAFT
; break;
565 case wxPRINT_QUALITY_HIGH
: {
566 quality
= DMRES_HIGH
; break;
569 quality
= m_printQuality
; break;
572 devMode
->dmPrintQuality
= quality
;
573 devMode
->dmFields
|= DM_PRINTQUALITY
;
575 GlobalUnlock(hDevMode
);
580 GlobalFree(hDevNames
);
583 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
584 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
587 void wxPrintData::ConvertFromNative()
589 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
590 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
597 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
602 if (devMode
->dmFields
& DM_ORIENTATION
)
603 m_printOrientation
= devMode
->dmOrientation
;
609 if (devMode
->dmFields
& DM_COLLATE
)
611 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
612 m_printCollate
= TRUE
;
614 m_printCollate
= FALSE
;
618 //// Number of copies
620 if (devMode
->dmFields
& DM_COPIES
)
622 m_printNoCopies
= devMode
->dmCopies
;
627 if (devMode
->dmDeviceName
[0] != 0)
629 // TODO: make this Unicode compatible
632 while (devMode
->dmDeviceName
[i
] != 0)
634 buf
[i
] = devMode
->dmDeviceName
[i
];
644 if (devMode
->dmFields
& DM_COLOR
)
646 if (devMode
->dmColor
== DMCOLOR_COLOR
)
657 // We don't know size of user defined paper and some buggy drivers
658 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
659 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
660 // code wouldn't set m_paperSize correctly.
661 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
663 if (wxThePrintPaperDatabase
)
665 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
668 m_paperId
= paper
->GetId();
669 m_paperSize
.x
= paper
->GetWidth() / 10;
670 m_paperSize
.y
= paper
->GetHeight() / 10;
674 // Shouldn't really get here
675 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
677 m_paperId
= wxPAPER_NONE
;
684 // Shouldn't really get here
685 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
687 m_paperId
= wxPAPER_NONE
;
692 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
694 // DEVMODE is in tenths of a milimeter
695 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
696 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
697 m_paperId
= wxPAPER_NONE
;
701 // Shouldn't really get here
702 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
706 m_paperId
= wxPAPER_NONE
;
712 if (devMode
->dmFields
& DM_DUPLEX
)
714 switch (devMode
->dmDuplex
)
716 case DMDUP_HORIZONTAL
: {
717 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
719 case DMDUP_VERTICAL
: {
720 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
723 case DMDUP_SIMPLEX
: {
724 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
729 m_duplexMode
= wxDUPLEX_SIMPLEX
;
733 if (devMode
->dmFields
& DM_PRINTQUALITY
)
735 switch (devMode
->dmPrintQuality
)
738 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
741 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
744 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
747 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
751 // TODO: if the printer fills in the resolution in DPI, how
752 // will the application know if it's high, low, draft etc.??
753 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
754 m_printQuality
= devMode
->dmPrintQuality
; break;
760 m_printQuality
= wxPRINT_QUALITY_HIGH
;
762 GlobalUnlock(hDevMode
);
767 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
770 // TODO: Unicode-ification
773 // port is obsolete in WIN32
774 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
776 // Get the printer name
777 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
779 // Not sure if we should check for this mismatch
780 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
782 if (printerName
!= wxT(""))
783 m_printerName
= printerName
;
785 GlobalUnlock(hDevNames
);
793 void wxPrintData::ConvertToNative()
797 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
801 void wxPrintData::ConvertFromNative()
805 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
810 void wxPrintData::operator=(const wxPrintData
& data
)
815 m_macPrintSettings
= data
.m_macPrintSettings
;
816 HandToHand( (Handle
*) &m_macPrintSettings
);
819 m_printNoCopies
= data
.m_printNoCopies
;
820 m_printCollate
= data
.m_printCollate
;
821 m_printOrientation
= data
.m_printOrientation
;
822 m_printerName
= data
.m_printerName
;
823 m_colour
= data
.m_colour
;
824 m_duplexMode
= data
.m_duplexMode
;
825 m_printQuality
= data
.m_printQuality
;
826 m_paperId
= data
.m_paperId
;
827 m_paperSize
= data
.m_paperSize
;
829 // PostScript-specific data
830 m_printerCommand
= data
.m_printerCommand
;
831 m_previewCommand
= data
.m_previewCommand
;
832 m_printerOptions
= data
.m_printerOptions
;
833 m_filename
= data
.m_filename
;
834 m_afmPath
= data
.m_afmPath
;
835 m_printerScaleX
= data
.m_printerScaleX
;
836 m_printerScaleY
= data
.m_printerScaleY
;
837 m_printerTranslateX
= data
.m_printerTranslateX
;
838 m_printerTranslateY
= data
.m_printerTranslateY
;
839 m_printMode
= data
.m_printMode
;
843 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
844 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
846 SetPrinterCommand(setupData
.GetPrinterCommand());
847 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
848 SetPrinterOptions(setupData
.GetPrinterOptions());
851 setupData
.GetPrinterTranslation(& xt
, & yt
);
852 SetPrinterTranslation(xt
, yt
);
855 setupData
.GetPrinterScaling(& xs
, & ys
);
856 SetPrinterScaling(xs
, ys
);
858 SetOrientation(setupData
.GetPrinterOrientation());
859 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
860 SetFontMetricPath(setupData
.GetAFMPath());
861 if (setupData
.GetPaperName() != "")
862 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
863 SetColour(setupData
.GetColour());
864 SetFilename(setupData
.GetPrinterFile());
866 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
868 // Is this data OK for showing the print dialog?
869 bool wxPrintData::Ok() const
872 ((wxPrintData
*)this)->ConvertToNative();
873 return (m_devMode
!= NULL
) ;
879 // ----------------------------------------------------------------------------
881 // ----------------------------------------------------------------------------
883 wxPrintDialogData::wxPrintDialogData()
886 m_printDlgData
= NULL
;
893 m_printAllPages
= FALSE
;
894 m_printCollate
= FALSE
;
895 m_printToFile
= FALSE
;
896 m_printSelection
= FALSE
;
897 m_printEnableSelection
= FALSE
;
898 m_printEnablePageNumbers
= TRUE
;
899 m_printEnablePrintToFile
= TRUE
;
900 m_printEnableHelp
= FALSE
;
901 m_printSetupDialog
= FALSE
;
904 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
908 m_printDlgData
= NULL
;
910 (*this) = dialogData
;
913 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
916 m_printDlgData
= NULL
;
923 m_printAllPages
= FALSE
;
924 m_printCollate
= FALSE
;
925 m_printToFile
= FALSE
;
926 m_printSelection
= FALSE
;
927 m_printEnableSelection
= FALSE
;
928 m_printEnablePageNumbers
= TRUE
;
929 m_printEnablePrintToFile
= TRUE
;
930 m_printEnableHelp
= FALSE
;
931 m_printSetupDialog
= FALSE
;
933 m_printData
= printData
;
936 wxPrintDialogData::~wxPrintDialogData()
939 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
940 if ( pd
&& pd
->hDevMode
)
941 GlobalFree(pd
->hDevMode
);
948 void wxPrintDialogData::ConvertToNative()
950 m_printData
.ConvertToNative();
952 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
957 memset( pd
, 0, sizeof(PRINTDLG
) );
958 m_printDlgData
= (void*) pd
;
960 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
962 pd
->lStructSize
= 66;
964 pd
->lStructSize
= sizeof(PRINTDLG
);
966 pd
->hwndOwner
= (HWND
)NULL
;
967 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
968 pd
->hDevNames
= NULL
; // Ditto
970 pd
->Flags
= PD_RETURNDEFAULT
;
974 // Pass the devmode data to the PRINTDLG structure, since it'll
975 // be needed when PrintDlg is called.
978 GlobalFree(pd
->hDevMode
);
981 // Pass the devnames data to the PRINTDLG structure, since it'll
982 // be needed when PrintDlg is called.
985 GlobalFree(pd
->hDevNames
);
988 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
990 m_printData
.SetNativeData((void*) NULL
);
992 // Shouldn't assert; we should be able to test Ok-ness at a higher level
993 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
995 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
997 m_printData
.SetNativeDataDevNames((void*) NULL
);
999 pd
->hDC
= (HDC
) NULL
;
1000 pd
->nFromPage
= (WORD
)m_printFromPage
;
1001 pd
->nToPage
= (WORD
)m_printToPage
;
1002 pd
->nMinPage
= (WORD
)m_printMinPage
;
1003 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
1004 pd
->nCopies
= (WORD
)m_printNoCopies
;
1006 pd
->Flags
= PD_RETURNDC
;
1009 pd
->lStructSize
= 66;
1011 pd
->lStructSize
= sizeof( PRINTDLG
);
1014 pd
->hwndOwner
=(HWND
)NULL
;
1015 // pd->hDevNames=(HANDLE)NULL;
1016 pd
->hInstance
=(HINSTANCE
)NULL
;
1017 pd
->lCustData
= (LPARAM
) NULL
;
1018 pd
->lpfnPrintHook
= NULL
;
1019 pd
->lpfnSetupHook
= NULL
;
1020 pd
->lpPrintTemplateName
= NULL
;
1021 pd
->lpSetupTemplateName
= NULL
;
1022 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1023 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1025 if ( m_printAllPages
)
1026 pd
->Flags
|= PD_ALLPAGES
;
1027 if ( m_printSelection
)
1028 pd
->Flags
|= PD_SELECTION
;
1029 if ( m_printCollate
)
1030 pd
->Flags
|= PD_COLLATE
;
1031 if ( m_printToFile
)
1032 pd
->Flags
|= PD_PRINTTOFILE
;
1033 if ( !m_printEnablePrintToFile
)
1034 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1035 if ( !m_printEnableSelection
)
1036 pd
->Flags
|= PD_NOSELECTION
;
1037 if ( !m_printEnablePageNumbers
)
1038 pd
->Flags
|= PD_NOPAGENUMS
;
1039 if ( m_printEnableHelp
)
1040 pd
->Flags
|= PD_SHOWHELP
;
1041 if ( m_printSetupDialog
)
1042 pd
->Flags
|= PD_PRINTSETUP
;
1045 void wxPrintDialogData::ConvertFromNative()
1047 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1051 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1054 if (m_printData
.GetNativeData())
1056 // Make sure we don't leak memory
1057 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1059 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1060 pd
->hDevMode
= NULL
;
1063 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1066 if (m_printData
.GetNativeDataDevNames())
1068 // Make sure we don't leak memory
1069 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1071 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1072 pd
->hDevNames
= NULL
;
1075 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1076 // into wxWindows form.
1077 m_printData
.ConvertFromNative();
1079 m_printFromPage
= pd
->nFromPage
;
1080 m_printToPage
= pd
->nToPage
;
1081 m_printMinPage
= pd
->nMinPage
;
1082 m_printMaxPage
= pd
->nMaxPage
;
1083 m_printNoCopies
= pd
->nCopies
;
1085 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1086 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1087 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1088 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1089 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1090 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1091 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1092 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1093 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1095 /* port is obsolete in WIN32
1096 // Get the port name
1099 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1101 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1102 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1103 GlobalUnlock(pd->hDevNames);
1105 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1111 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1113 if ( m_printDlgData
== NULL
)
1116 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1118 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1119 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1125 void wxPrintDialogData::ConvertToNative()
1129 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1130 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1131 m_printData
.ConvertToNative();
1135 void wxPrintDialogData::ConvertFromNative()
1139 m_printData
.ConvertFromNative();
1140 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1141 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1147 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1149 m_printFromPage
= data
.m_printFromPage
;
1150 m_printToPage
= data
.m_printToPage
;
1151 m_printMinPage
= data
.m_printMinPage
;
1152 m_printMaxPage
= data
.m_printMaxPage
;
1153 m_printNoCopies
= data
.m_printNoCopies
;
1154 m_printAllPages
= data
.m_printAllPages
;
1155 m_printCollate
= data
.m_printCollate
;
1156 m_printToFile
= data
.m_printToFile
;
1157 m_printSelection
= data
.m_printSelection
;
1158 m_printEnableSelection
= data
.m_printEnableSelection
;
1159 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1160 m_printEnableHelp
= data
.m_printEnableHelp
;
1161 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1162 m_printSetupDialog
= data
.m_printSetupDialog
;
1164 m_printData
= data
.m_printData
;
1167 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1172 // ----------------------------------------------------------------------------
1173 // wxPageSetupDialogData
1174 // ----------------------------------------------------------------------------
1176 wxPageSetupDialogData::wxPageSetupDialogData()
1178 #if defined(__WIN95__)
1179 m_pageSetupData
= NULL
;
1181 m_paperSize
= wxSize(0, 0);
1183 CalculatePaperSizeFromId();
1185 m_minMarginTopLeft
= wxPoint(0, 0);
1186 m_minMarginBottomRight
= wxPoint(0, 0);
1187 m_marginTopLeft
= wxPoint(0, 0);
1188 m_marginBottomRight
= wxPoint(0, 0);
1191 m_defaultMinMargins
= FALSE
;
1192 m_enableMargins
= TRUE
;
1193 m_enableOrientation
= TRUE
;
1194 m_enablePaper
= TRUE
;
1195 m_enablePrinter
= TRUE
;
1196 m_enableHelp
= FALSE
;
1197 m_getDefaultInfo
= FALSE
;
1200 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1203 #if defined(__WIN95__)
1204 m_pageSetupData
= NULL
;
1206 (*this) = dialogData
;
1209 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1211 #if defined(__WIN95__)
1212 m_pageSetupData
= NULL
;
1214 m_paperSize
= wxSize(0, 0);
1215 m_minMarginTopLeft
= wxPoint(0, 0);
1216 m_minMarginBottomRight
= wxPoint(0, 0);
1217 m_marginTopLeft
= wxPoint(0, 0);
1218 m_marginBottomRight
= wxPoint(0, 0);
1221 m_defaultMinMargins
= FALSE
;
1222 m_enableMargins
= TRUE
;
1223 m_enableOrientation
= TRUE
;
1224 m_enablePaper
= TRUE
;
1225 m_enablePrinter
= TRUE
;
1226 m_enableHelp
= FALSE
;
1227 m_getDefaultInfo
= FALSE
;
1229 m_printData
= printData
;
1231 // The wxPrintData paper size overrides these values, unless the size cannot
1233 CalculatePaperSizeFromId();
1236 wxPageSetupDialogData::~wxPageSetupDialogData()
1238 #if defined(__WIN95__) && defined(__WXMSW__)
1239 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1240 if ( pd
&& pd
->hDevMode
)
1241 GlobalFree(pd
->hDevMode
);
1242 if ( pd
&& pd
->hDevNames
)
1243 GlobalFree(pd
->hDevNames
);
1249 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1251 m_paperSize
= data
.m_paperSize
;
1252 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1253 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1254 m_marginTopLeft
= data
.m_marginTopLeft
;
1255 m_marginBottomRight
= data
.m_marginBottomRight
;
1256 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1257 m_enableMargins
= data
.m_enableMargins
;
1258 m_enableOrientation
= data
.m_enableOrientation
;
1259 m_enablePaper
= data
.m_enablePaper
;
1260 m_enablePrinter
= data
.m_enablePrinter
;
1261 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1262 m_enableHelp
= data
.m_enableHelp
;
1264 m_printData
= data
.m_printData
;
1269 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1276 #if defined(__WIN95__)
1277 void wxPageSetupDialogData::ConvertToNative()
1279 m_printData
.ConvertToNative();
1281 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1283 if ( m_pageSetupData
== NULL
)
1285 pd
= new PAGESETUPDLG
;
1286 pd
->hDevMode
= NULL
;
1287 pd
->hDevNames
= NULL
;
1288 m_pageSetupData
= (void *)pd
;
1291 // Pass the devmode data (created in m_printData.ConvertToNative)
1292 // to the PRINTDLG structure, since it'll
1293 // be needed when PrintDlg is called.
1297 GlobalFree(pd
->hDevMode
);
1298 pd
->hDevMode
= NULL
;
1301 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1303 m_printData
.SetNativeData((void*) NULL
);
1305 // Shouldn't assert; we should be able to test Ok-ness at a higher level
1306 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1308 // Pass the devnames data (created in m_printData.ConvertToNative)
1309 // to the PRINTDLG structure, since it'll
1310 // be needed when PrintDlg is called.
1314 GlobalFree(pd
->hDevNames
);
1315 pd
->hDevNames
= NULL
;
1318 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1320 m_printData
.SetNativeDataDevNames((void*) NULL
);
1322 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1324 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1326 if ( m_defaultMinMargins
)
1327 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1328 if ( !m_enableMargins
)
1329 pd
->Flags
|= PSD_DISABLEMARGINS
;
1330 if ( !m_enableOrientation
)
1331 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1332 if ( !m_enablePaper
)
1333 pd
->Flags
|= PSD_DISABLEPAPER
;
1334 if ( !m_enablePrinter
)
1335 pd
->Flags
|= PSD_DISABLEPRINTER
;
1336 if ( m_getDefaultInfo
)
1337 pd
->Flags
|= PSD_RETURNDEFAULT
;
1339 pd
->Flags
|= PSD_SHOWHELP
;
1341 // We want the units to be in hundredths of a millimetre
1342 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1344 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1345 pd
->hwndOwner
=(HWND
)NULL
;
1346 // pd->hDevNames=(HWND)NULL;
1347 pd
->hInstance
=(HINSTANCE
)NULL
;
1348 // PAGESETUPDLG is in hundreds of a mm
1349 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1350 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1352 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1353 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1354 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1355 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1357 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1358 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1359 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1360 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1363 pd
->lpfnPageSetupHook
= NULL
;
1364 pd
->lpfnPagePaintHook
= NULL
;
1365 pd
->hPageSetupTemplate
= NULL
;
1366 pd
->lpPageSetupTemplateName
= NULL
;
1371 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1372 memset(devMode, 0, sizeof(DEVMODE));
1373 devMode->dmSize = sizeof(DEVMODE);
1374 devMode->dmOrientation = m_orientation;
1375 devMode->dmFields = DM_ORIENTATION;
1376 GlobalUnlock(pd->hDevMode);
1381 void wxPageSetupDialogData::ConvertFromNative()
1383 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1387 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1390 if (m_printData
.GetNativeData())
1392 // Make sure we don't leak memory
1393 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1395 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1396 pd
->hDevMode
= NULL
;
1399 m_printData
.ConvertFromNative();
1401 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1404 if (m_printData
.GetNativeDataDevNames())
1406 // Make sure we don't leak memory
1407 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1409 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1410 pd
->hDevNames
= NULL
;
1413 m_printData
.ConvertFromNative();
1415 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1417 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1418 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1419 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1420 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1421 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1422 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1423 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1425 // PAGESETUPDLG is in hundreds of a mm
1426 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1427 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1429 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1430 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1431 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1432 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1434 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1435 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1436 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1437 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1440 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1442 if ( m_pageSetupData
== NULL
)
1445 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1447 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1448 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1454 void wxPageSetupDialogData::ConvertToNative()
1456 m_printData
.ConvertToNative();
1457 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1460 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1461 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1463 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1464 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1466 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1467 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1468 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1469 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1473 void wxPageSetupDialogData::ConvertFromNative()
1475 m_printData
.ConvertFromNative ();
1479 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1480 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1482 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1483 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1485 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1486 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1488 // adjust minimal values
1489 //TODO add custom fields in dialog for margins
1491 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1492 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1494 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1495 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1497 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1498 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1500 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1501 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1506 // If a corresponding paper type is found in the paper database, will set the m_printData
1507 // paper size id member as well.
1508 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1512 CalculateIdFromPaperSize();
1515 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1516 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1518 m_printData
.SetPaperId(id
);
1520 CalculatePaperSizeFromId();
1523 // Use paper size defined in this object to set the wxPrintData
1525 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1527 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1528 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1530 wxSize sz
= GetPaperSize();
1532 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1533 if (id
!= wxPAPER_NONE
)
1535 m_printData
.SetPaperId(id
);
1539 // Use paper id in wxPrintData to set this object's paper size
1540 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1542 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1543 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1545 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1547 // sz is in 10ths of a mm, while paper size is in mm
1548 m_paperSize
.x
= sz
.x
/ 10;
1549 m_paperSize
.y
= sz
.y
/ 10;
1552 #endif // wxUSE_PRINTING_ARCHITECTURE