1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI data
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "cmndata.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/string.h"
38 #include "wx/gdicmn.h"
39 #include "wx/cmndata.h"
43 #if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__) || defined(__WXMAC__)) && wxUSE_POSTSCRIPT
44 #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1
47 #if wxUSE_PRINTING_ARCHITECTURE
50 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
51 #include "wx/generic/dcpsg.h"
53 #endif // wxUSE_PRINTING_ARCHITECTURE
57 #include "wx/msw/private.h"
59 #if !defined(__WIN32__)
69 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
75 #if wxUSE_PRINTING_ARCHITECTURE
76 IMPLEMENT_DYNAMIC_CLASS(wxPrintData
, wxObject
)
77 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData
, wxObject
)
78 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData
, wxObject
)
79 #endif // wxUSE_PRINTING_ARCHITECTURE
81 IMPLEMENT_DYNAMIC_CLASS(wxFontData
, wxObject
)
82 IMPLEMENT_DYNAMIC_CLASS(wxColourData
, wxObject
)
85 #include "wx/mac/uma.h"
87 #define mm2pt 2.83464566929
88 #define pt2mm 0.352777777778
92 #define DMPAPER_USER 256
95 // ============================================================================
97 // ============================================================================
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 wxColourData::wxColourData()
106 for (i
= 0; i
< 16; i
++)
107 custColours
[i
].Set(255, 255, 255);
110 dataColour
.Set(0,0,0);
113 wxColourData::wxColourData(const wxColourData
& data
)
118 wxColourData::~wxColourData()
122 void wxColourData::SetCustomColour(int i
, wxColour
& colour
)
127 custColours
[i
] = colour
;
130 wxColour
wxColourData::GetCustomColour(int i
)
133 return wxColour(0,0,0);
135 return custColours
[i
];
138 void wxColourData::operator=(const wxColourData
& data
)
141 for (i
= 0; i
< 16; i
++)
142 custColours
[i
] = data
.custColours
[i
];
144 dataColour
= (wxColour
&)data
.dataColour
;
145 chooseFull
= data
.chooseFull
;
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
152 wxFontData::wxFontData()
154 // Intialize colour to black.
155 fontColour
.Set(0, 0, 0);
159 enableEffects
= TRUE
;
163 m_encoding
= wxFONTENCODING_SYSTEM
;
166 wxFontData::~wxFontData()
170 #if wxUSE_PRINTING_ARCHITECTURE
171 // ----------------------------------------------------------------------------
173 // ----------------------------------------------------------------------------
175 wxPrintData::wxPrintData()
178 m_devMode
= (void*) NULL
;
179 m_devNames
= (void*) NULL
;
180 #elif defined( __WXMAC__ )
182 m_macPageFormat
= kPMNoPageFormat
;
183 m_macPrintSettings
= kPMNoPrintSettings
;
185 #if PM_USE_SESSION_APIS
186 PMPrintSession macPrintSession
= kPMNoReference
;
189 err
= ::UMAPrOpen(&macPrintSession
) ;
192 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
194 // Note that PMPageFormat is not session-specific, but calling
195 // PMSessionDefaultPageFormat assigns values specific to the printer
196 // associated with the current printing session.
197 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
199 err
= PMSessionDefaultPageFormat((PMPrintSession
)macPrintSession
,
200 (PMPageFormat
)m_macPageFormat
);
203 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
205 // Note that PMPrintSettings is not session-specific, but calling
206 // PMSessionDefaultPrintSettings assigns values specific to the printer
207 // associated with the current printing session.
208 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
210 err
= PMSessionDefaultPrintSettings((PMPrintSession
)macPrintSession
,
211 (PMPrintSettings
)m_macPrintSettings
);
214 ::UMAPrClose(&macPrintSession
) ;
217 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
218 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
220 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
221 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
222 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
223 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
225 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
226 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
227 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
228 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
231 m_printOrientation
= wxPORTRAIT
;
233 m_printCollate
= FALSE
;
238 m_duplexMode
= wxDUPLEX_SIMPLEX
;
239 m_printQuality
= wxPRINT_QUALITY_HIGH
;
240 m_paperId
= wxPAPER_A4
;
241 m_paperSize
= wxSize(210, 297);
243 // PostScript-specific data
244 m_printerCommand
= "";
245 m_previewCommand
= "";
246 m_printerOptions
= "";
249 m_printerScaleX
= 1.0;
250 m_printerScaleY
= 1.0;
251 m_printerTranslateX
= 0;
252 m_printerTranslateY
= 0;
253 m_printMode
= wxPRINT_MODE_FILE
;
256 wxPrintData::wxPrintData(const wxPrintData
& printData
)
259 m_devMode
= (void*) NULL
;
260 m_devNames
= (void*) NULL
;
261 #elif defined( __WXMAC__ )
263 m_macPageFormat
= kPMNoPageFormat
;
264 m_macPrintSettings
= kPMNoPrintSettings
;
266 m_macPrintSettings
= NULL
;
272 wxPrintData::~wxPrintData()
275 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
277 GlobalFree(hDevMode
);
278 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
280 GlobalFree(hDevNames
);
281 #elif defined(__WXMAC__)
283 if (m_macPageFormat
!= kPMNoPageFormat
)
285 #if PM_USE_SESSION_APIS
286 (void)PMRelease(m_macPageFormat
);
288 (void)PMDisposePageFormat(m_macPageFormat
);
290 m_macPageFormat
= kPMNoPageFormat
;
293 if (m_macPrintSettings
!= kPMNoPrintSettings
)
295 #if PM_USE_SESSION_APIS
296 (void)PMRelease(m_macPrintSettings
);
298 (void)PMDisposePrintSettings(m_macPrintSettings
);
300 m_macPrintSettings
= kPMNoPrintSettings
;
304 wxASSERT( m_macPrintSettings
);
305 // we should perhaps delete
310 #if defined(__WXMSW__) // && defined(__WIN32__)
312 #if defined(__WXDEBUG__) && defined(__WIN32__)
313 static wxString
wxGetPrintDlgError()
315 DWORD err
= CommDlgExtendedError();
316 wxString msg
= wxT("Unknown");
319 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
320 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
321 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
322 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
323 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
324 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
325 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
326 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
327 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
328 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
329 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
330 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
331 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
332 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
333 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
334 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
335 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
336 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
337 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
338 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
339 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
340 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
347 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
350 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
351 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
356 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
357 ( driverName
.Length() + 1 +
358 printerName
.Length() + 1 +
359 portName
.Length()+1 ) * sizeof(wxChar
) );
360 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
361 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
362 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
364 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
365 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
366 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
368 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
369 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
370 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
380 void wxPrintData::ConvertToNative()
382 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
383 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
386 // Use PRINTDLG as a way of creating a DEVMODE object
389 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
394 memset(&pd
, 0, sizeof(PRINTDLG
));
395 pd
.lStructSize
= sizeof(PRINTDLG
);
398 pd
.hwndOwner
= (HWND
)NULL
;
399 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
400 pd
.hDevNames
= NULL
; // Ditto
401 //pd.hInstance = (HINSTANCE) wxGetInstance();
403 pd
.Flags
= PD_RETURNDEFAULT
;
406 // Fill out the DEVMODE structure
407 // so we can use it as input in the 'real' PrintDlg
411 GlobalFree(pd
.hDevMode
);
413 GlobalFree(pd
.hDevNames
);
417 #if defined(__WXDEBUG__) && defined(__WIN32__)
418 wxString
str(wxT("Printing error: "));
419 str
+= wxGetPrintDlgError();
425 hDevMode
= pd
.hDevMode
;
426 m_devMode
= (void*)(long) hDevMode
;
429 // We'll create a new DEVNAMEs structure below.
431 GlobalFree(pd
.hDevNames
);
434 // hDevNames = pd->hDevNames;
435 // m_devNames = (void*)(long) hDevNames;
436 // pd->hDevnames = NULL;
443 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
448 devMode
->dmOrientation
= m_printOrientation
;
450 devMode
->dmFields
= DM_ORIENTATION
;
455 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
456 devMode
->dmFields
|= DM_COLLATE
;
459 //// Number of copies
461 devMode
->dmCopies
= m_printNoCopies
;
462 devMode
->dmFields
|= DM_COPIES
;
466 if (m_printerName
!= wxT(""))
468 //int len = wxMin(31, m_printerName.Len());
469 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
470 devMode
->dmDeviceName
[31] = wxT('\0');
476 devMode
->dmColor
= DMCOLOR_COLOR
;
478 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
480 devMode
->dmFields
|= DM_COLOR
;
485 if (m_paperId
== wxPAPER_NONE
)
487 // DEVMODE is in tenths of a milimeter
488 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
489 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
490 devMode
->dmPaperSize
= DMPAPER_USER
;
491 devMode
->dmFields
|= DM_PAPERWIDTH
;
492 devMode
->dmFields
|= DM_PAPERLENGTH
;
496 if (wxThePrintPaperDatabase
)
498 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
501 devMode
->dmPaperSize
= paper
->GetPlatformId();
502 devMode
->dmFields
|= DM_PAPERSIZE
;
511 switch (m_duplexMode
)
513 case wxDUPLEX_HORIZONTAL
: {
514 duplex
= DMDUP_HORIZONTAL
; break;
516 case wxDUPLEX_VERTICAL
: {
517 duplex
= DMDUP_VERTICAL
; break;
520 case wxDUPLEX_SIMPLEX
: {
521 duplex
= DMDUP_SIMPLEX
; break;
524 devMode
->dmDuplex
= duplex
;
525 devMode
->dmFields
|= DM_DUPLEX
;
530 switch (m_printQuality
)
532 case wxPRINT_QUALITY_MEDIUM
: {
533 quality
= DMRES_MEDIUM
; break;
535 case wxPRINT_QUALITY_LOW
: {
536 quality
= DMRES_LOW
; break;
538 case wxPRINT_QUALITY_DRAFT
: {
539 quality
= DMRES_DRAFT
; break;
541 case wxPRINT_QUALITY_HIGH
: {
542 quality
= DMRES_HIGH
; break;
545 quality
= m_printQuality
; break;
548 devMode
->dmPrintQuality
= quality
;
549 devMode
->dmFields
|= DM_PRINTQUALITY
;
551 GlobalUnlock(hDevMode
);
556 GlobalFree(hDevNames
);
559 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
560 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
563 void wxPrintData::ConvertFromNative()
565 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
566 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
573 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
578 if (devMode
->dmFields
& DM_ORIENTATION
)
579 m_printOrientation
= devMode
->dmOrientation
;
585 if (devMode
->dmFields
& DM_COLLATE
)
587 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
588 m_printCollate
= TRUE
;
590 m_printCollate
= FALSE
;
594 //// Number of copies
596 if (devMode
->dmFields
& DM_COPIES
)
598 m_printNoCopies
= devMode
->dmCopies
;
603 if (devMode
->dmDeviceName
[0] != 0)
605 // TODO: make this Unicode compatible
608 while (devMode
->dmDeviceName
[i
] != 0)
610 buf
[i
] = devMode
->dmDeviceName
[i
];
620 if (devMode
->dmFields
& DM_COLOR
)
622 if (devMode
->dmColor
== DMCOLOR_COLOR
)
633 // We don't know size of user defined paper and some buggy drivers
634 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
635 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
636 // code wouldn't set m_paperSize correctly.
637 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
639 if (wxThePrintPaperDatabase
)
641 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
644 m_paperId
= paper
->GetId();
645 m_paperSize
.x
= paper
->GetWidth() / 10;
646 m_paperSize
.y
= paper
->GetHeight() / 10;
650 // Shouldn't really get here
651 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
653 m_paperId
= wxPAPER_NONE
;
660 // Shouldn't really get here
661 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
663 m_paperId
= wxPAPER_NONE
;
668 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
670 // DEVMODE is in tenths of a milimeter
671 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
672 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
673 m_paperId
= wxPAPER_NONE
;
677 // Shouldn't really get here
678 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
682 m_paperId
= wxPAPER_NONE
;
688 if (devMode
->dmFields
& DM_DUPLEX
)
690 switch (devMode
->dmDuplex
)
692 case DMDUP_HORIZONTAL
: {
693 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
695 case DMDUP_VERTICAL
: {
696 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
699 case DMDUP_SIMPLEX
: {
700 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
705 m_duplexMode
= wxDUPLEX_SIMPLEX
;
709 if (devMode
->dmFields
& DM_PRINTQUALITY
)
711 switch (devMode
->dmPrintQuality
)
714 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
717 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
720 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
723 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
727 // TODO: if the printer fills in the resolution in DPI, how
728 // will the application know if it's high, low, draft etc.??
729 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
730 m_printQuality
= devMode
->dmPrintQuality
; break;
736 m_printQuality
= wxPRINT_QUALITY_HIGH
;
738 GlobalUnlock(hDevMode
);
743 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
746 // TODO: Unicode-ification
749 // port is obsolete in WIN32
750 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
752 // Get the printer name
753 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
755 // Not sure if we should check for this mismatch
756 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
758 if (printerName
!= wxT(""))
759 m_printerName
= printerName
;
761 GlobalUnlock(hDevNames
);
769 void wxPrintData::ConvertToNative()
773 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
777 void wxPrintData::ConvertFromNative()
781 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
786 void wxPrintData::operator=(const wxPrintData
& data
)
791 m_macPrintSettings
= data
.m_macPrintSettings
;
792 HandToHand( (Handle
*) &m_macPrintSettings
);
795 m_printNoCopies
= data
.m_printNoCopies
;
796 m_printCollate
= data
.m_printCollate
;
797 m_printOrientation
= data
.m_printOrientation
;
798 m_printerName
= data
.m_printerName
;
799 m_colour
= data
.m_colour
;
800 m_duplexMode
= data
.m_duplexMode
;
801 m_printQuality
= data
.m_printQuality
;
802 m_paperId
= data
.m_paperId
;
803 m_paperSize
= data
.m_paperSize
;
805 // PostScript-specific data
806 m_printerCommand
= data
.m_printerCommand
;
807 m_previewCommand
= data
.m_previewCommand
;
808 m_printerOptions
= data
.m_printerOptions
;
809 m_filename
= data
.m_filename
;
810 m_afmPath
= data
.m_afmPath
;
811 m_printerScaleX
= data
.m_printerScaleX
;
812 m_printerScaleY
= data
.m_printerScaleY
;
813 m_printerTranslateX
= data
.m_printerTranslateX
;
814 m_printerTranslateY
= data
.m_printerTranslateY
;
815 m_printMode
= data
.m_printMode
;
819 #if wxCOMPATIBILITY_WITH_PRINTSETUPDATA
820 void wxPrintData::operator=(const wxPrintSetupData
& setupData
)
822 SetPrinterCommand(setupData
.GetPrinterCommand());
823 SetPreviewCommand(setupData
.GetPrintPreviewCommand());
824 SetPrinterOptions(setupData
.GetPrinterOptions());
827 setupData
.GetPrinterTranslation(& xt
, & yt
);
828 SetPrinterTranslation(xt
, yt
);
831 setupData
.GetPrinterScaling(& xs
, & ys
);
832 SetPrinterScaling(xs
, ys
);
834 SetOrientation(setupData
.GetPrinterOrientation());
835 SetPrintMode((wxPrintMode
) setupData
.GetPrinterMode());
836 SetFontMetricPath(setupData
.GetAFMPath());
837 if (setupData
.GetPaperName() != "")
838 SetPaperId(wxThePrintPaperDatabase
->ConvertNameToId(setupData
.GetPaperName()));
839 SetColour(setupData
.GetColour());
840 SetFilename(setupData
.GetPrinterFile());
842 #endif // wxCOMPATIBILITY_WITH_PRINTSETUPDATA
845 // ----------------------------------------------------------------------------
847 // ----------------------------------------------------------------------------
849 wxPrintDialogData::wxPrintDialogData()
852 m_printDlgData
= NULL
;
859 m_printAllPages
= FALSE
;
860 m_printCollate
= FALSE
;
861 m_printToFile
= FALSE
;
862 m_printSelection
= FALSE
;
863 m_printEnableSelection
= FALSE
;
864 m_printEnablePageNumbers
= TRUE
;
865 m_printEnablePrintToFile
= TRUE
;
866 m_printEnableHelp
= FALSE
;
867 m_printSetupDialog
= FALSE
;
870 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
873 m_printDlgData
= NULL
;
875 (*this) = dialogData
;
878 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
881 m_printDlgData
= NULL
;
888 m_printAllPages
= FALSE
;
889 m_printCollate
= FALSE
;
890 m_printToFile
= FALSE
;
891 m_printSelection
= FALSE
;
892 m_printEnableSelection
= FALSE
;
893 m_printEnablePageNumbers
= TRUE
;
894 m_printEnablePrintToFile
= TRUE
;
895 m_printEnableHelp
= FALSE
;
896 m_printSetupDialog
= FALSE
;
898 m_printData
= printData
;
901 wxPrintDialogData::~wxPrintDialogData()
904 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
905 if ( pd
&& pd
->hDevMode
)
906 GlobalFree(pd
->hDevMode
);
913 void wxPrintDialogData::ConvertToNative()
915 m_printData
.ConvertToNative();
917 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
922 memset( pd
, 0, sizeof(PRINTDLG
) );
923 m_printDlgData
= (void*) pd
;
925 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
927 pd
->lStructSize
= 66;
929 pd
->lStructSize
= sizeof(PRINTDLG
);
931 pd
->hwndOwner
= (HWND
)NULL
;
932 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
933 pd
->hDevNames
= NULL
; // Ditto
935 pd
->Flags
= PD_RETURNDEFAULT
;
939 // Pass the devmode data to the PRINTDLG structure, since it'll
940 // be needed when PrintDlg is called.
943 GlobalFree(pd
->hDevMode
);
946 // Pass the devnames data to the PRINTDLG structure, since it'll
947 // be needed when PrintDlg is called.
950 GlobalFree(pd
->hDevNames
);
953 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
955 m_printData
.SetNativeData((void*) NULL
);
957 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
959 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
961 m_printData
.SetNativeDataDevNames((void*) NULL
);
963 pd
->hDC
= (HDC
) NULL
;
964 pd
->nFromPage
= (WORD
)m_printFromPage
;
965 pd
->nToPage
= (WORD
)m_printToPage
;
966 pd
->nMinPage
= (WORD
)m_printMinPage
;
967 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
968 pd
->nCopies
= (WORD
)m_printNoCopies
;
970 pd
->Flags
= PD_RETURNDC
;
973 pd
->lStructSize
= 66;
975 pd
->lStructSize
= sizeof( PRINTDLG
);
978 pd
->hwndOwner
=(HWND
)NULL
;
979 // pd->hDevNames=(HANDLE)NULL;
980 pd
->hInstance
=(HINSTANCE
)NULL
;
981 pd
->lCustData
= (LPARAM
) NULL
;
982 pd
->lpfnPrintHook
= NULL
;
983 pd
->lpfnSetupHook
= NULL
;
984 pd
->lpPrintTemplateName
= NULL
;
985 pd
->lpSetupTemplateName
= NULL
;
986 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
987 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
989 if ( m_printAllPages
)
990 pd
->Flags
|= PD_ALLPAGES
;
991 if ( m_printSelection
)
992 pd
->Flags
|= PD_SELECTION
;
993 if ( m_printCollate
)
994 pd
->Flags
|= PD_COLLATE
;
996 pd
->Flags
|= PD_PRINTTOFILE
;
997 if ( !m_printEnablePrintToFile
)
998 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
999 if ( !m_printEnableSelection
)
1000 pd
->Flags
|= PD_NOSELECTION
;
1001 if ( !m_printEnablePageNumbers
)
1002 pd
->Flags
|= PD_NOPAGENUMS
;
1003 if ( m_printEnableHelp
)
1004 pd
->Flags
|= PD_SHOWHELP
;
1005 if ( m_printSetupDialog
)
1006 pd
->Flags
|= PD_PRINTSETUP
;
1009 void wxPrintDialogData::ConvertFromNative()
1011 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1015 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1018 if (m_printData
.GetNativeData())
1020 // Make sure we don't leak memory
1021 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1023 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1024 pd
->hDevMode
= NULL
;
1027 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1030 if (m_printData
.GetNativeDataDevNames())
1032 // Make sure we don't leak memory
1033 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1035 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1036 pd
->hDevNames
= NULL
;
1039 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1040 // into wxWindows form.
1041 m_printData
.ConvertFromNative();
1043 m_printFromPage
= pd
->nFromPage
;
1044 m_printToPage
= pd
->nToPage
;
1045 m_printMinPage
= pd
->nMinPage
;
1046 m_printMaxPage
= pd
->nMaxPage
;
1047 m_printNoCopies
= pd
->nCopies
;
1049 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1050 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1051 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1052 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1053 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1054 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1055 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1056 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1057 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1059 /* port is obsolete in WIN32
1060 // Get the port name
1063 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1065 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1066 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1067 GlobalUnlock(pd->hDevNames);
1069 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1075 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1077 if ( m_printDlgData
== NULL
)
1080 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1082 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1083 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1089 void wxPrintDialogData::ConvertToNative()
1093 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1094 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1095 m_printData
.ConvertToNative();
1099 void wxPrintDialogData::ConvertFromNative()
1103 m_printData
.ConvertFromNative();
1104 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1105 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1111 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1113 m_printFromPage
= data
.m_printFromPage
;
1114 m_printToPage
= data
.m_printToPage
;
1115 m_printMinPage
= data
.m_printMinPage
;
1116 m_printMaxPage
= data
.m_printMaxPage
;
1117 m_printNoCopies
= data
.m_printNoCopies
;
1118 m_printAllPages
= data
.m_printAllPages
;
1119 m_printCollate
= data
.m_printCollate
;
1120 m_printToFile
= data
.m_printToFile
;
1121 m_printSelection
= data
.m_printSelection
;
1122 m_printEnableSelection
= data
.m_printEnableSelection
;
1123 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1124 m_printEnableHelp
= data
.m_printEnableHelp
;
1125 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1126 m_printSetupDialog
= data
.m_printSetupDialog
;
1128 m_printData
= data
.m_printData
;
1131 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1136 // ----------------------------------------------------------------------------
1137 // wxPageSetupDialogData
1138 // ----------------------------------------------------------------------------
1140 wxPageSetupDialogData::wxPageSetupDialogData()
1142 #if defined(__WIN95__)
1143 m_pageSetupData
= NULL
;
1145 m_paperSize
= wxSize(0, 0);
1147 CalculatePaperSizeFromId();
1149 m_minMarginTopLeft
= wxPoint(0, 0);
1150 m_minMarginBottomRight
= wxPoint(0, 0);
1151 m_marginTopLeft
= wxPoint(0, 0);
1152 m_marginBottomRight
= wxPoint(0, 0);
1155 m_defaultMinMargins
= FALSE
;
1156 m_enableMargins
= TRUE
;
1157 m_enableOrientation
= TRUE
;
1158 m_enablePaper
= TRUE
;
1159 m_enablePrinter
= TRUE
;
1160 m_enableHelp
= FALSE
;
1161 m_getDefaultInfo
= FALSE
;
1164 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1166 #if defined(__WIN95__)
1167 m_pageSetupData
= NULL
;
1169 (*this) = dialogData
;
1172 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1174 #if defined(__WIN95__)
1175 m_pageSetupData
= NULL
;
1177 m_paperSize
= wxSize(0, 0);
1178 m_minMarginTopLeft
= wxPoint(0, 0);
1179 m_minMarginBottomRight
= wxPoint(0, 0);
1180 m_marginTopLeft
= wxPoint(0, 0);
1181 m_marginBottomRight
= wxPoint(0, 0);
1184 m_defaultMinMargins
= FALSE
;
1185 m_enableMargins
= TRUE
;
1186 m_enableOrientation
= TRUE
;
1187 m_enablePaper
= TRUE
;
1188 m_enablePrinter
= TRUE
;
1189 m_enableHelp
= FALSE
;
1190 m_getDefaultInfo
= FALSE
;
1192 m_printData
= printData
;
1194 // The wxPrintData paper size overrides these values, unless the size cannot
1196 CalculatePaperSizeFromId();
1199 wxPageSetupDialogData::~wxPageSetupDialogData()
1201 #if defined(__WIN95__) && defined(__WXMSW__)
1202 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1203 if ( pd
&& pd
->hDevMode
)
1204 GlobalFree(pd
->hDevMode
);
1205 if ( pd
&& pd
->hDevNames
)
1206 GlobalFree(pd
->hDevNames
);
1212 void wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1214 m_paperSize
= data
.m_paperSize
;
1215 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1216 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1217 m_marginTopLeft
= data
.m_marginTopLeft
;
1218 m_marginBottomRight
= data
.m_marginBottomRight
;
1219 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1220 m_enableMargins
= data
.m_enableMargins
;
1221 m_enableOrientation
= data
.m_enableOrientation
;
1222 m_enablePaper
= data
.m_enablePaper
;
1223 m_enablePrinter
= data
.m_enablePrinter
;
1224 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1225 m_enableHelp
= data
.m_enableHelp
;
1227 m_printData
= data
.m_printData
;
1230 void wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1235 #if defined(__WIN95__)
1236 void wxPageSetupDialogData::ConvertToNative()
1238 m_printData
.ConvertToNative();
1240 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1242 if ( m_pageSetupData
== NULL
)
1244 pd
= new PAGESETUPDLG
;
1245 pd
->hDevMode
= NULL
;
1246 pd
->hDevNames
= NULL
;
1247 m_pageSetupData
= (void *)pd
;
1250 // Pass the devmode data (created in m_printData.ConvertToNative)
1251 // to the PRINTDLG structure, since it'll
1252 // be needed when PrintDlg is called.
1256 GlobalFree(pd
->hDevMode
);
1257 pd
->hDevMode
= NULL
;
1260 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1262 m_printData
.SetNativeData((void*) NULL
);
1264 wxASSERT_MSG( (pd
->hDevMode
), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1266 // Pass the devnames data (created in m_printData.ConvertToNative)
1267 // to the PRINTDLG structure, since it'll
1268 // be needed when PrintDlg is called.
1272 GlobalFree(pd
->hDevNames
);
1273 pd
->hDevNames
= NULL
;
1276 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1278 m_printData
.SetNativeDataDevNames((void*) NULL
);
1280 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1282 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1284 if ( m_defaultMinMargins
)
1285 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1286 if ( !m_enableMargins
)
1287 pd
->Flags
|= PSD_DISABLEMARGINS
;
1288 if ( !m_enableOrientation
)
1289 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1290 if ( !m_enablePaper
)
1291 pd
->Flags
|= PSD_DISABLEPAPER
;
1292 if ( !m_enablePrinter
)
1293 pd
->Flags
|= PSD_DISABLEPRINTER
;
1294 if ( m_getDefaultInfo
)
1295 pd
->Flags
|= PSD_RETURNDEFAULT
;
1297 pd
->Flags
|= PSD_SHOWHELP
;
1299 // We want the units to be in hundredths of a millimetre
1300 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1302 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1303 pd
->hwndOwner
=(HWND
)NULL
;
1304 // pd->hDevNames=(HWND)NULL;
1305 pd
->hInstance
=(HINSTANCE
)NULL
;
1306 // PAGESETUPDLG is in hundreds of a mm
1307 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1308 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1310 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1311 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1312 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1313 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1315 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1316 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1317 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1318 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1321 pd
->lpfnPageSetupHook
= NULL
;
1322 pd
->lpfnPagePaintHook
= NULL
;
1323 pd
->hPageSetupTemplate
= NULL
;
1324 pd
->lpPageSetupTemplateName
= NULL
;
1329 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1330 memset(devMode, 0, sizeof(DEVMODE));
1331 devMode->dmSize = sizeof(DEVMODE);
1332 devMode->dmOrientation = m_orientation;
1333 devMode->dmFields = DM_ORIENTATION;
1334 GlobalUnlock(pd->hDevMode);
1339 void wxPageSetupDialogData::ConvertFromNative()
1341 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1345 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1348 if (m_printData
.GetNativeData())
1350 // Make sure we don't leak memory
1351 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1353 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1354 pd
->hDevMode
= NULL
;
1357 m_printData
.ConvertFromNative();
1359 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1362 if (m_printData
.GetNativeDataDevNames())
1364 // Make sure we don't leak memory
1365 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1367 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1368 pd
->hDevNames
= NULL
;
1371 m_printData
.ConvertFromNative();
1373 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1375 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1376 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1377 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1378 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1379 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1380 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1381 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1383 // PAGESETUPDLG is in hundreds of a mm
1384 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1385 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1387 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1388 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1389 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1390 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1392 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1393 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1394 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1395 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1398 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1400 if ( m_pageSetupData
== NULL
)
1403 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1405 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1406 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1412 void wxPageSetupDialogData::ConvertToNative()
1414 m_printData
.ConvertToNative();
1415 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1418 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1419 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1421 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1422 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1424 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1425 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1426 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1427 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1431 void wxPageSetupDialogData::ConvertFromNative()
1433 m_printData
.ConvertFromNative ();
1437 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1438 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1440 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1441 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1443 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1444 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1446 // adjust minimal values
1447 //TODO add custom fields in dialog for margins
1449 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1450 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1452 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1453 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1455 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1456 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1458 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1459 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1464 // If a corresponding paper type is found in the paper database, will set the m_printData
1465 // paper size id member as well.
1466 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1470 CalculateIdFromPaperSize();
1473 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1474 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1476 m_printData
.SetPaperId(id
);
1478 CalculatePaperSizeFromId();
1481 // Use paper size defined in this object to set the wxPrintData
1483 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1485 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1486 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1488 wxSize sz
= GetPaperSize();
1490 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1491 if (id
!= wxPAPER_NONE
)
1493 m_printData
.SetPaperId(id
);
1497 // Use paper id in wxPrintData to set this object's paper size
1498 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1500 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1501 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1503 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1507 // sz is in 10ths of a mm, so multiply by 10.
1508 m_paperSize
.x
= sz
.x
* 10;
1509 m_paperSize
.y
= sz
.y
* 10;
1513 #endif // wxUSE_PRINTING_ARCHITECTURE