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
46 #if wxUSE_PRINTING_ARCHITECTURE
48 #endif // wxUSE_PRINTING_ARCHITECTURE
52 #include "wx/msw/private.h"
54 #if !defined(__WIN32__)
59 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
65 #if wxUSE_PRINTING_ARCHITECTURE
66 IMPLEMENT_DYNAMIC_CLASS(wxPrintData
, wxObject
)
67 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData
, wxObject
)
68 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData
, wxObject
)
69 #endif // wxUSE_PRINTING_ARCHITECTURE
71 IMPLEMENT_DYNAMIC_CLASS(wxFontData
, wxObject
)
72 IMPLEMENT_DYNAMIC_CLASS(wxColourData
, wxObject
)
75 #include "wx/mac/uma.h"
77 #if defined(TARGET_CARBON) && !defined(__DARWIN__)
78 # if PM_USE_SESSION_APIS
81 # include <PMApplication.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
)
119 wxColourData::~wxColourData()
123 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
128 custColours
[i
] = colour
;
131 wxColour
wxColourData::GetCustomColour(int i
)
134 return wxColour(0,0,0);
136 return custColours
[i
];
139 void wxColourData::operator=(const wxColourData
& data
)
142 for (i
= 0; i
< 16; i
++)
143 custColours
[i
] = data
.custColours
[i
];
145 dataColour
= (wxColour
&)data
.dataColour
;
146 chooseFull
= data
.chooseFull
;
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
153 wxFontData::wxFontData()
155 // Intialize colour to black.
156 fontColour
= wxNullColour
;
160 enableEffects
= TRUE
;
164 m_encoding
= wxFONTENCODING_SYSTEM
;
167 wxFontData::~wxFontData()
173 wxFontDialogBase::~wxFontDialogBase()
177 #endif // wxUSE_FONTDLG
179 #if wxUSE_PRINTING_ARCHITECTURE
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 wxPrintData::wxPrintData()
187 m_devMode
= (void*) NULL
;
188 m_devNames
= (void*) NULL
;
189 #elif defined( __WXMAC__ )
191 m_macPageFormat
= kPMNoPageFormat
;
192 m_macPrintSettings
= kPMNoPrintSettings
;
193 m_macPrintSession
= kPMNoReference
;
195 #if PM_USE_SESSION_APIS
198 err
= PMCreateSession((PMPrintSession
*)&m_macPrintSession
) ;
202 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
204 // Note that PMPageFormat is not session-specific, but calling
205 // PMSessionDefaultPageFormat assigns values specific to the printer
206 // associated with the current printing session.
207 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
209 err
= PMSessionDefaultPageFormat((PMPrintSession
)m_macPrintSession
,
210 (PMPageFormat
)m_macPageFormat
);
213 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
215 // Note that PMPrintSettings is not session-specific, but calling
216 // PMSessionDefaultPrintSettings assigns values specific to the printer
217 // associated with the current printing session.
218 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
220 err
= PMSessionDefaultPrintSettings((PMPrintSession
)m_macPrintSession
,
221 (PMPrintSettings
)m_macPrintSettings
);
227 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
228 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
230 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
231 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
232 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
233 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
235 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
236 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
237 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
238 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
241 m_printOrientation
= wxPORTRAIT
;
243 m_printCollate
= FALSE
;
246 m_printerName
= wxT("");
248 m_duplexMode
= wxDUPLEX_SIMPLEX
;
249 m_printQuality
= wxPRINT_QUALITY_HIGH
;
250 m_paperId
= wxPAPER_A4
;
251 m_paperSize
= wxSize(210, 297);
253 // PostScript-specific data
254 m_previewCommand
= wxT("");
255 m_filename
= wxT("");
257 m_printerCommand
= wxT("print");
258 m_printerOptions
= wxT("/nonotify/queue=psqueue");
259 m_afmPath
= wxT("sys$ps_font_metrics:");
263 m_printerCommand
= wxT("print");
264 m_printerOptions
= wxT("");
265 m_afmPath
= wxT("c:\\windows\\system\\");
268 #if !defined(__VMS__) && !defined(__WXMSW__)
269 m_printerCommand
= wxT("lpr");
270 m_printerOptions
= wxT("");
274 m_printerScaleX
= 1.0;
275 m_printerScaleY
= 1.0;
276 m_printerTranslateX
= 0;
277 m_printerTranslateY
= 0;
278 m_printMode
= wxPRINT_MODE_FILE
;
281 wxPrintData::wxPrintData(const wxPrintData
& printData
)
285 m_devMode
= (void*) NULL
;
286 m_devNames
= (void*) NULL
;
287 #elif defined( __WXMAC__ )
289 m_macPageFormat
= kPMNoPageFormat
;
290 m_macPrintSettings
= kPMNoPrintSettings
;
291 m_macPrintSession
= kPMNoReference
;
293 m_macPrintSettings
= NULL
;
299 wxPrintData::~wxPrintData()
302 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
304 GlobalFree(hDevMode
);
305 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
307 GlobalFree(hDevNames
);
308 #elif defined(__WXMAC__)
310 if (m_macPageFormat
!= kPMNoPageFormat
)
312 #if PM_USE_SESSION_APIS
313 (void)PMRelease(m_macPageFormat
);
315 (void)PMDisposePageFormat(m_macPageFormat
);
317 m_macPageFormat
= kPMNoPageFormat
;
320 if (m_macPrintSettings
!= kPMNoPrintSettings
)
322 #if PM_USE_SESSION_APIS
323 (void)PMRelease(m_macPrintSettings
);
325 (void)PMDisposePrintSettings(m_macPrintSettings
);
327 m_macPrintSettings
= kPMNoPrintSettings
;
330 if ( m_macPrintSession
!= kPMNoReference
)
332 #if PM_USE_SESSION_APIS
333 (void)PMRelease(m_macPrintSession
);
335 (void)PMDisposePrintSession(m_macPrintSession
);
337 m_macPrintSession
= kPMNoReference
;
340 wxASSERT( m_macPrintSettings
);
341 // we should perhaps delete
346 #if defined(__WXMSW__) // && defined(__WIN32__)
348 #if defined(__WXDEBUG__) && defined(__WIN32__)
349 static wxString
wxGetPrintDlgError()
351 DWORD err
= CommDlgExtendedError();
352 wxString msg
= wxT("Unknown");
355 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
356 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
357 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
358 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
359 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
360 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
361 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
362 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
363 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
364 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
365 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
366 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
367 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
368 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
369 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
370 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
371 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
372 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
373 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
374 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
375 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
376 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
383 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
386 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
387 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
392 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
393 ( driverName
.Length() + 1 +
394 printerName
.Length() + 1 +
395 portName
.Length()+1 ) * sizeof(wxChar
) );
396 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
397 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
398 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
400 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
401 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
402 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
404 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
405 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
406 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
416 void wxPrintData::ConvertToNative()
418 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
419 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
422 // Use PRINTDLG as a way of creating a DEVMODE object
425 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
430 memset(&pd
, 0, sizeof(PRINTDLG
));
431 pd
.lStructSize
= sizeof(PRINTDLG
);
434 pd
.hwndOwner
= (HWND
)NULL
;
435 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
436 pd
.hDevNames
= NULL
; // Ditto
437 //pd.hInstance = (HINSTANCE) wxGetInstance();
439 pd
.Flags
= PD_RETURNDEFAULT
;
442 // Fill out the DEVMODE structure
443 // so we can use it as input in the 'real' PrintDlg
447 GlobalFree(pd
.hDevMode
);
449 GlobalFree(pd
.hDevNames
);
453 #if defined(__WXDEBUG__) && defined(__WIN32__)
454 wxString
str(wxT("Printing error: "));
455 str
+= wxGetPrintDlgError();
461 hDevMode
= pd
.hDevMode
;
462 m_devMode
= (void*)(long) hDevMode
;
465 // We'll create a new DEVNAMEs structure below.
467 GlobalFree(pd
.hDevNames
);
470 // hDevNames = pd->hDevNames;
471 // m_devNames = (void*)(long) hDevNames;
472 // pd->hDevnames = NULL;
479 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
483 devMode
->dmOrientation
= m_printOrientation
;
488 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
489 devMode
->dmFields
|= DM_COLLATE
;
492 //// Number of copies
494 devMode
->dmCopies
= m_printNoCopies
;
495 devMode
->dmFields
|= DM_COPIES
;
499 if (m_printerName
!= wxT(""))
501 //int len = wxMin(31, m_printerName.Len());
502 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
503 devMode
->dmDeviceName
[31] = wxT('\0');
509 devMode
->dmColor
= DMCOLOR_COLOR
;
511 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
513 devMode
->dmFields
|= DM_COLOR
;
517 if (m_paperId
== wxPAPER_NONE
)
519 // DEVMODE is in tenths of a milimeter
520 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
521 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
522 devMode
->dmPaperSize
= DMPAPER_USER
;
523 devMode
->dmFields
|= DM_PAPERWIDTH
;
524 devMode
->dmFields
|= DM_PAPERLENGTH
;
528 if (wxThePrintPaperDatabase
)
530 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
533 devMode
->dmPaperSize
= paper
->GetPlatformId();
534 devMode
->dmFields
|= DM_PAPERSIZE
;
542 switch (m_duplexMode
)
544 case wxDUPLEX_HORIZONTAL
: {
545 duplex
= DMDUP_HORIZONTAL
; break;
547 case wxDUPLEX_VERTICAL
: {
548 duplex
= DMDUP_VERTICAL
; break;
551 case wxDUPLEX_SIMPLEX
: {
552 duplex
= DMDUP_SIMPLEX
; break;
555 devMode
->dmDuplex
= duplex
;
556 devMode
->dmFields
|= DM_DUPLEX
;
561 switch (m_printQuality
)
563 case wxPRINT_QUALITY_MEDIUM
: {
564 quality
= DMRES_MEDIUM
; break;
566 case wxPRINT_QUALITY_LOW
: {
567 quality
= DMRES_LOW
; break;
569 case wxPRINT_QUALITY_DRAFT
: {
570 quality
= DMRES_DRAFT
; break;
572 case wxPRINT_QUALITY_HIGH
: {
573 quality
= DMRES_HIGH
; break;
576 quality
= m_printQuality
; break;
579 devMode
->dmPrintQuality
= quality
;
580 devMode
->dmFields
|= DM_PRINTQUALITY
;
582 GlobalUnlock(hDevMode
);
587 GlobalFree(hDevNames
);
590 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
591 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
594 void wxPrintData::ConvertFromNative()
596 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
597 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
604 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
608 if (devMode
->dmFields
& DM_ORIENTATION
)
609 m_printOrientation
= devMode
->dmOrientation
;
614 if (devMode
->dmFields
& DM_COLLATE
)
616 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
617 m_printCollate
= TRUE
;
619 m_printCollate
= FALSE
;
623 //// Number of copies
625 if (devMode
->dmFields
& DM_COPIES
)
627 m_printNoCopies
= devMode
->dmCopies
;
632 if (devMode
->dmDeviceName
[0] != 0)
634 m_printerName
= devMode
->dmDeviceName
;
639 if (devMode
->dmFields
& DM_COLOR
)
641 if (devMode
->dmColor
== DMCOLOR_COLOR
)
651 // We don't know size of user defined paper and some buggy drivers
652 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
653 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
654 // code wouldn't set m_paperSize correctly.
655 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
657 if (wxThePrintPaperDatabase
)
659 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
662 m_paperId
= paper
->GetId();
663 m_paperSize
.x
= paper
->GetWidth() / 10;
664 m_paperSize
.y
= paper
->GetHeight() / 10;
668 // Shouldn't really get here
669 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
671 m_paperId
= wxPAPER_NONE
;
678 // Shouldn't really get here
679 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
681 m_paperId
= wxPAPER_NONE
;
686 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
688 // DEVMODE is in tenths of a milimeter
689 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
690 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
691 m_paperId
= wxPAPER_NONE
;
695 // Shouldn't really get here
696 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
700 m_paperId
= wxPAPER_NONE
;
705 if (devMode
->dmFields
& DM_DUPLEX
)
707 switch (devMode
->dmDuplex
)
709 case DMDUP_HORIZONTAL
: {
710 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
712 case DMDUP_VERTICAL
: {
713 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
716 case DMDUP_SIMPLEX
: {
717 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
722 m_duplexMode
= wxDUPLEX_SIMPLEX
;
726 if (devMode
->dmFields
& DM_PRINTQUALITY
)
728 switch (devMode
->dmPrintQuality
)
731 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
734 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
737 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
740 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
744 // TODO: if the printer fills in the resolution in DPI, how
745 // will the application know if it's high, low, draft etc.??
746 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
747 m_printQuality
= devMode
->dmPrintQuality
; break;
753 m_printQuality
= wxPRINT_QUALITY_HIGH
;
755 GlobalUnlock(hDevMode
);
760 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
763 // TODO: Unicode-ification
766 // port is obsolete in WIN32
767 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
769 // Get the printer name
770 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
772 // Not sure if we should check for this mismatch
773 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
775 if (printerName
!= wxT(""))
776 m_printerName
= printerName
;
778 GlobalUnlock(hDevNames
);
786 void wxPrintData::ConvertToNative()
790 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
794 void wxPrintData::ConvertFromNative()
798 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
803 void wxPrintData::operator=(const wxPrintData
& data
)
807 if ( m_macPrintSettings
!= kPMNoPrintSettings
)
809 PMRelease( m_macPrintSettings
) ;
810 m_macPrintSettings
= kPMNoPrintSettings
;
812 if ( data
.m_macPrintSettings
!= kPMNoPrintSettings
)
814 m_macPrintSettings
= data
.m_macPrintSettings
;
815 PMRetain( m_macPrintSettings
) ;
817 if ( m_macPageFormat
!= kPMNoPageFormat
)
819 PMRelease( m_macPageFormat
) ;
820 m_macPageFormat
= kPMNoPageFormat
;
822 if ( data
.m_macPageFormat
!= kPMNoPageFormat
)
824 m_macPageFormat
= data
.m_macPageFormat
;
825 PMRetain( m_macPageFormat
) ;
828 m_macPrintSettings
= data
.m_macPrintSettings
;
829 HandToHand( (Handle
*) &m_macPrintSettings
);
832 m_printNoCopies
= data
.m_printNoCopies
;
833 m_printCollate
= data
.m_printCollate
;
834 m_printOrientation
= data
.m_printOrientation
;
835 m_printerName
= data
.m_printerName
;
836 m_colour
= data
.m_colour
;
837 m_duplexMode
= data
.m_duplexMode
;
838 m_printQuality
= data
.m_printQuality
;
839 m_paperId
= data
.m_paperId
;
840 m_paperSize
= data
.m_paperSize
;
842 // PostScript-specific data
843 m_printerCommand
= data
.m_printerCommand
;
844 m_previewCommand
= data
.m_previewCommand
;
845 m_printerOptions
= data
.m_printerOptions
;
846 m_filename
= data
.m_filename
;
847 m_afmPath
= data
.m_afmPath
;
848 m_printerScaleX
= data
.m_printerScaleX
;
849 m_printerScaleY
= data
.m_printerScaleY
;
850 m_printerTranslateX
= data
.m_printerTranslateX
;
851 m_printerTranslateY
= data
.m_printerTranslateY
;
852 m_printMode
= data
.m_printMode
;
855 // Is this data OK for showing the print dialog?
856 bool wxPrintData::Ok() const
859 ((wxPrintData
*)this)->ConvertToNative();
860 return (m_devMode
!= NULL
) ;
866 // ----------------------------------------------------------------------------
868 // ----------------------------------------------------------------------------
870 wxPrintDialogData::wxPrintDialogData()
873 m_printDlgData
= NULL
;
880 m_printAllPages
= FALSE
;
881 m_printCollate
= FALSE
;
882 m_printToFile
= FALSE
;
883 m_printSelection
= FALSE
;
884 m_printEnableSelection
= FALSE
;
885 m_printEnablePageNumbers
= TRUE
;
886 m_printEnablePrintToFile
= TRUE
;
887 m_printEnableHelp
= FALSE
;
888 m_printSetupDialog
= FALSE
;
891 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
895 m_printDlgData
= NULL
;
897 (*this) = dialogData
;
900 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
903 m_printDlgData
= NULL
;
910 m_printAllPages
= FALSE
;
911 m_printCollate
= FALSE
;
912 m_printToFile
= FALSE
;
913 m_printSelection
= FALSE
;
914 m_printEnableSelection
= FALSE
;
915 m_printEnablePageNumbers
= TRUE
;
916 m_printEnablePrintToFile
= TRUE
;
917 m_printEnableHelp
= FALSE
;
918 m_printSetupDialog
= FALSE
;
920 m_printData
= printData
;
923 wxPrintDialogData::~wxPrintDialogData()
926 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
927 if ( pd
&& pd
->hDevMode
)
928 GlobalFree(pd
->hDevMode
);
935 void wxPrintDialogData::ConvertToNative()
937 m_printData
.ConvertToNative();
939 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
944 memset( pd
, 0, sizeof(PRINTDLG
) );
945 m_printDlgData
= (void*) pd
;
947 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
949 pd
->lStructSize
= 66;
951 pd
->lStructSize
= sizeof(PRINTDLG
);
953 pd
->hwndOwner
= (HWND
)NULL
;
954 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
955 pd
->hDevNames
= NULL
; // Ditto
957 pd
->Flags
= PD_RETURNDEFAULT
;
961 // Pass the devmode data to the PRINTDLG structure, since it'll
962 // be needed when PrintDlg is called.
965 GlobalFree(pd
->hDevMode
);
968 // Pass the devnames data to the PRINTDLG structure, since it'll
969 // be needed when PrintDlg is called.
972 GlobalFree(pd
->hDevNames
);
975 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
977 m_printData
.SetNativeData((void*) NULL
);
979 // Shouldn't assert; we should be able to test Ok-ness at a higher level
980 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
982 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
984 m_printData
.SetNativeDataDevNames((void*) NULL
);
986 pd
->hDC
= (HDC
) NULL
;
987 pd
->nFromPage
= (WORD
)m_printFromPage
;
988 pd
->nToPage
= (WORD
)m_printToPage
;
989 pd
->nMinPage
= (WORD
)m_printMinPage
;
990 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
991 pd
->nCopies
= (WORD
)m_printNoCopies
;
993 pd
->Flags
= PD_RETURNDC
;
996 pd
->lStructSize
= 66;
998 pd
->lStructSize
= sizeof( PRINTDLG
);
1001 pd
->hwndOwner
=(HWND
)NULL
;
1002 // pd->hDevNames=(HANDLE)NULL;
1003 pd
->hInstance
=(HINSTANCE
)NULL
;
1004 pd
->lCustData
= (LPARAM
) NULL
;
1005 pd
->lpfnPrintHook
= NULL
;
1006 pd
->lpfnSetupHook
= NULL
;
1007 pd
->lpPrintTemplateName
= NULL
;
1008 pd
->lpSetupTemplateName
= NULL
;
1009 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1010 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1012 if ( m_printAllPages
)
1013 pd
->Flags
|= PD_ALLPAGES
;
1014 if ( m_printSelection
)
1015 pd
->Flags
|= PD_SELECTION
;
1016 if ( m_printCollate
)
1017 pd
->Flags
|= PD_COLLATE
;
1018 if ( m_printToFile
)
1019 pd
->Flags
|= PD_PRINTTOFILE
;
1020 if ( !m_printEnablePrintToFile
)
1021 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1022 if ( !m_printEnableSelection
)
1023 pd
->Flags
|= PD_NOSELECTION
;
1024 if ( !m_printEnablePageNumbers
)
1025 pd
->Flags
|= PD_NOPAGENUMS
;
1026 if ( m_printEnableHelp
)
1027 pd
->Flags
|= PD_SHOWHELP
;
1028 if ( m_printSetupDialog
)
1029 pd
->Flags
|= PD_PRINTSETUP
;
1032 void wxPrintDialogData::ConvertFromNative()
1034 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1038 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1041 if (m_printData
.GetNativeData())
1043 // Make sure we don't leak memory
1044 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1046 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1047 pd
->hDevMode
= NULL
;
1050 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1053 if (m_printData
.GetNativeDataDevNames())
1055 // Make sure we don't leak memory
1056 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1058 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1059 pd
->hDevNames
= NULL
;
1062 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1063 // into wxWindows form.
1064 m_printData
.ConvertFromNative();
1066 m_printFromPage
= pd
->nFromPage
;
1067 m_printToPage
= pd
->nToPage
;
1068 m_printMinPage
= pd
->nMinPage
;
1069 m_printMaxPage
= pd
->nMaxPage
;
1070 m_printNoCopies
= pd
->nCopies
;
1072 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1073 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1074 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1075 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1076 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1077 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1078 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1079 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1080 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1082 /* port is obsolete in WIN32
1083 // Get the port name
1086 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1088 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1089 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1090 GlobalUnlock(pd->hDevNames);
1092 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1098 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1100 if ( m_printDlgData
== NULL
)
1103 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1105 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1106 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1112 void wxPrintDialogData::ConvertToNative()
1116 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1117 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1118 m_printData
.ConvertToNative();
1122 void wxPrintDialogData::ConvertFromNative()
1126 m_printData
.ConvertFromNative();
1127 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1128 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1134 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1136 m_printFromPage
= data
.m_printFromPage
;
1137 m_printToPage
= data
.m_printToPage
;
1138 m_printMinPage
= data
.m_printMinPage
;
1139 m_printMaxPage
= data
.m_printMaxPage
;
1140 m_printNoCopies
= data
.m_printNoCopies
;
1141 m_printAllPages
= data
.m_printAllPages
;
1142 m_printCollate
= data
.m_printCollate
;
1143 m_printToFile
= data
.m_printToFile
;
1144 m_printSelection
= data
.m_printSelection
;
1145 m_printEnableSelection
= data
.m_printEnableSelection
;
1146 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1147 m_printEnableHelp
= data
.m_printEnableHelp
;
1148 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1149 m_printSetupDialog
= data
.m_printSetupDialog
;
1151 m_printData
= data
.m_printData
;
1154 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1159 // ----------------------------------------------------------------------------
1160 // wxPageSetupDialogData
1161 // ----------------------------------------------------------------------------
1163 wxPageSetupDialogData::wxPageSetupDialogData()
1165 #if defined(__WIN95__)
1166 m_pageSetupData
= NULL
;
1168 m_paperSize
= wxSize(0, 0);
1170 CalculatePaperSizeFromId();
1172 m_minMarginTopLeft
= wxPoint(0, 0);
1173 m_minMarginBottomRight
= wxPoint(0, 0);
1174 m_marginTopLeft
= wxPoint(0, 0);
1175 m_marginBottomRight
= wxPoint(0, 0);
1178 m_defaultMinMargins
= FALSE
;
1179 m_enableMargins
= TRUE
;
1180 m_enableOrientation
= TRUE
;
1181 m_enablePaper
= TRUE
;
1182 m_enablePrinter
= TRUE
;
1183 m_enableHelp
= FALSE
;
1184 m_getDefaultInfo
= FALSE
;
1187 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1190 #if defined(__WIN95__)
1191 m_pageSetupData
= NULL
;
1193 (*this) = dialogData
;
1196 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1198 #if defined(__WIN95__)
1199 m_pageSetupData
= NULL
;
1201 m_paperSize
= wxSize(0, 0);
1202 m_minMarginTopLeft
= wxPoint(0, 0);
1203 m_minMarginBottomRight
= wxPoint(0, 0);
1204 m_marginTopLeft
= wxPoint(0, 0);
1205 m_marginBottomRight
= wxPoint(0, 0);
1208 m_defaultMinMargins
= FALSE
;
1209 m_enableMargins
= TRUE
;
1210 m_enableOrientation
= TRUE
;
1211 m_enablePaper
= TRUE
;
1212 m_enablePrinter
= TRUE
;
1213 m_enableHelp
= FALSE
;
1214 m_getDefaultInfo
= FALSE
;
1216 m_printData
= printData
;
1218 // The wxPrintData paper size overrides these values, unless the size cannot
1220 CalculatePaperSizeFromId();
1223 wxPageSetupDialogData::~wxPageSetupDialogData()
1225 #if defined(__WIN95__) && defined(__WXMSW__)
1226 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1227 if ( pd
&& pd
->hDevMode
)
1228 GlobalFree(pd
->hDevMode
);
1229 if ( pd
&& pd
->hDevNames
)
1230 GlobalFree(pd
->hDevNames
);
1236 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1238 m_paperSize
= data
.m_paperSize
;
1239 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1240 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1241 m_marginTopLeft
= data
.m_marginTopLeft
;
1242 m_marginBottomRight
= data
.m_marginBottomRight
;
1243 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1244 m_enableMargins
= data
.m_enableMargins
;
1245 m_enableOrientation
= data
.m_enableOrientation
;
1246 m_enablePaper
= data
.m_enablePaper
;
1247 m_enablePrinter
= data
.m_enablePrinter
;
1248 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1249 m_enableHelp
= data
.m_enableHelp
;
1251 m_printData
= data
.m_printData
;
1256 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1263 #if defined(__WIN95__)
1264 void wxPageSetupDialogData::ConvertToNative()
1266 m_printData
.ConvertToNative();
1268 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1270 if ( m_pageSetupData
== NULL
)
1272 pd
= new PAGESETUPDLG
;
1273 pd
->hDevMode
= NULL
;
1274 pd
->hDevNames
= NULL
;
1275 m_pageSetupData
= (void *)pd
;
1278 // Pass the devmode data (created in m_printData.ConvertToNative)
1279 // to the PRINTDLG structure, since it'll
1280 // be needed when PrintDlg is called.
1284 GlobalFree(pd
->hDevMode
);
1285 pd
->hDevMode
= NULL
;
1288 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1290 m_printData
.SetNativeData((void*) NULL
);
1292 // Shouldn't assert; we should be able to test Ok-ness at a higher level
1293 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1295 // Pass the devnames data (created in m_printData.ConvertToNative)
1296 // to the PRINTDLG structure, since it'll
1297 // be needed when PrintDlg is called.
1301 GlobalFree(pd
->hDevNames
);
1302 pd
->hDevNames
= NULL
;
1305 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1307 m_printData
.SetNativeDataDevNames((void*) NULL
);
1309 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1311 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1313 if ( m_defaultMinMargins
)
1314 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1315 if ( !m_enableMargins
)
1316 pd
->Flags
|= PSD_DISABLEMARGINS
;
1317 if ( !m_enableOrientation
)
1318 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1319 if ( !m_enablePaper
)
1320 pd
->Flags
|= PSD_DISABLEPAPER
;
1321 if ( !m_enablePrinter
)
1322 pd
->Flags
|= PSD_DISABLEPRINTER
;
1323 if ( m_getDefaultInfo
)
1324 pd
->Flags
|= PSD_RETURNDEFAULT
;
1326 pd
->Flags
|= PSD_SHOWHELP
;
1328 // We want the units to be in hundredths of a millimetre
1329 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1331 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1332 pd
->hwndOwner
=(HWND
)NULL
;
1333 // pd->hDevNames=(HWND)NULL;
1334 pd
->hInstance
=(HINSTANCE
)NULL
;
1335 // PAGESETUPDLG is in hundreds of a mm
1336 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1337 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1339 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1340 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1341 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1342 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1344 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1345 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1346 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1347 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1350 pd
->lpfnPageSetupHook
= NULL
;
1351 pd
->lpfnPagePaintHook
= NULL
;
1352 pd
->hPageSetupTemplate
= NULL
;
1353 pd
->lpPageSetupTemplateName
= NULL
;
1358 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1359 memset(devMode, 0, sizeof(DEVMODE));
1360 devMode->dmSize = sizeof(DEVMODE);
1361 devMode->dmOrientation = m_orientation;
1362 devMode->dmFields = DM_ORIENTATION;
1363 GlobalUnlock(pd->hDevMode);
1368 void wxPageSetupDialogData::ConvertFromNative()
1370 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1374 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1377 if (m_printData
.GetNativeData())
1379 // Make sure we don't leak memory
1380 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1382 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1383 pd
->hDevMode
= NULL
;
1386 m_printData
.ConvertFromNative();
1388 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1391 if (m_printData
.GetNativeDataDevNames())
1393 // Make sure we don't leak memory
1394 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1396 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1397 pd
->hDevNames
= NULL
;
1400 m_printData
.ConvertFromNative();
1402 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1404 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1405 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1406 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1407 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1408 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1409 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1410 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1412 // PAGESETUPDLG is in hundreds of a mm
1413 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1414 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1416 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1417 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1418 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1419 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1421 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1422 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1423 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1424 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1427 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1429 if ( m_pageSetupData
== NULL
)
1432 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1434 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1435 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1441 void wxPageSetupDialogData::ConvertToNative()
1443 m_printData
.ConvertToNative();
1444 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1447 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1448 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1450 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1451 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1453 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1454 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1455 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1456 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1460 void wxPageSetupDialogData::ConvertFromNative()
1462 m_printData
.ConvertFromNative ();
1467 OSStatus err
= PMGetAdjustedPaperRect((PMPageFormat
)m_printData
.m_macPageFormat
, &rPaper
);
1470 m_paperSize
.x
= (int)(((double) rPaper
.right
- rPaper
.left
) * pt2mm
);
1471 m_paperSize
.y
= (int)(((double) rPaper
.bottom
- rPaper
.top
) * pt2mm
);
1473 m_minMarginTopLeft
.x
= (int)(((double) - rPaper
.left
) * pt2mm
);
1474 m_minMarginTopLeft
.y
= (int)(((double) - rPaper
.top
) * pt2mm
);
1476 // m_minMarginBottomRight.x = ((double) rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
1477 // m_minMarginBottomRight.y = ((double)(**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
1480 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1481 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1483 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1484 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1486 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1487 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1489 // adjust minimal values
1490 //TODO add custom fields in dialog for margins
1492 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1493 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1495 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1496 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1498 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1499 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1501 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1502 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1507 // If a corresponding paper type is found in the paper database, will set the m_printData
1508 // paper size id member as well.
1509 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1513 CalculateIdFromPaperSize();
1516 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1517 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1519 m_printData
.SetPaperId(id
);
1521 CalculatePaperSizeFromId();
1524 // Use paper size defined in this object to set the wxPrintData
1526 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1528 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1529 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1531 wxSize sz
= GetPaperSize();
1533 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1534 if (id
!= wxPAPER_NONE
)
1536 m_printData
.SetPaperId(id
);
1540 // Use paper id in wxPrintData to set this object's paper size
1541 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1543 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1544 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1546 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1548 // sz is in 10ths of a mm, while paper size is in mm
1549 m_paperSize
.x
= sz
.x
/ 10;
1550 m_paperSize
.y
= sz
.y
/ 10;
1553 #endif // wxUSE_PRINTING_ARCHITECTURE