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__)
64 #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
70 #if wxUSE_PRINTING_ARCHITECTURE
71 IMPLEMENT_DYNAMIC_CLASS(wxPrintData
, wxObject
)
72 IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData
, wxObject
)
73 IMPLEMENT_DYNAMIC_CLASS(wxPageSetupDialogData
, wxObject
)
74 #endif // wxUSE_PRINTING_ARCHITECTURE
76 IMPLEMENT_DYNAMIC_CLASS(wxFontData
, wxObject
)
77 IMPLEMENT_DYNAMIC_CLASS(wxColourData
, wxObject
)
80 #include "wx/mac/uma.h"
82 #if defined(TARGET_CARBON) && !defined(__DARWIN__)
83 # if PM_USE_SESSION_APIS
86 # include <PMApplication.h>
92 #define mm2pt 2.83464566929
93 #define pt2mm 0.352777777778
97 #define DMPAPER_USER 256
100 // ============================================================================
102 // ============================================================================
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 wxColourData::wxColourData()
111 for (i
= 0; i
< 16; i
++)
112 custColours
[i
].Set(255, 255, 255);
115 dataColour
.Set(0,0,0);
118 wxColourData::wxColourData(const wxColourData
& data
)
124 wxColourData::~wxColourData()
128 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
133 custColours
[i
] = colour
;
136 wxColour
wxColourData::GetCustomColour(int i
)
139 return wxColour(0,0,0);
141 return custColours
[i
];
144 void wxColourData::operator=(const wxColourData
& data
)
147 for (i
= 0; i
< 16; i
++)
148 custColours
[i
] = data
.custColours
[i
];
150 dataColour
= (wxColour
&)data
.dataColour
;
151 chooseFull
= data
.chooseFull
;
154 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
158 wxFontData::wxFontData()
160 // Intialize colour to black.
161 fontColour
= wxNullColour
;
165 enableEffects
= TRUE
;
169 m_encoding
= wxFONTENCODING_SYSTEM
;
172 wxFontData::~wxFontData()
178 wxFontDialogBase::~wxFontDialogBase()
182 #endif // wxUSE_FONTDLG
184 #if wxUSE_PRINTING_ARCHITECTURE
185 // ----------------------------------------------------------------------------
187 // ----------------------------------------------------------------------------
189 wxPrintData::wxPrintData()
192 m_devMode
= (void*) NULL
;
193 m_devNames
= (void*) NULL
;
194 #elif defined( __WXMAC__ )
196 m_macPageFormat
= kPMNoPageFormat
;
197 m_macPrintSettings
= kPMNoPrintSettings
;
198 m_macPrintSession
= kPMNoReference
;
200 #if PM_USE_SESSION_APIS
203 err
= PMCreateSession((PMPrintSession
*)&m_macPrintSession
) ;
207 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
209 // Note that PMPageFormat is not session-specific, but calling
210 // PMSessionDefaultPageFormat assigns values specific to the printer
211 // associated with the current printing session.
212 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
214 err
= PMSessionDefaultPageFormat((PMPrintSession
)m_macPrintSession
,
215 (PMPageFormat
)m_macPageFormat
);
218 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
220 // Note that PMPrintSettings is not session-specific, but calling
221 // PMSessionDefaultPrintSettings assigns values specific to the printer
222 // associated with the current printing session.
223 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
225 err
= PMSessionDefaultPrintSettings((PMPrintSession
)m_macPrintSession
,
226 (PMPrintSettings
)m_macPrintSettings
);
232 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
233 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
235 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
236 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
237 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
238 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
240 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
241 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
242 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
243 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
246 m_printOrientation
= wxPORTRAIT
;
248 m_printCollate
= FALSE
;
251 m_printerName
= wxT("");
253 m_duplexMode
= wxDUPLEX_SIMPLEX
;
254 m_printQuality
= wxPRINT_QUALITY_HIGH
;
255 m_paperId
= wxPAPER_A4
;
256 m_paperSize
= wxSize(210, 297);
258 // PostScript-specific data
259 m_previewCommand
= wxT("");
260 m_filename
= wxT("");
262 m_printerCommand
= wxT("print");
263 m_printerOptions
= wxT("/nonotify/queue=psqueue");
264 m_afmPath
= wxT("sys$ps_font_metrics:");
268 m_printerCommand
= wxT("print");
269 m_printerOptions
= wxT("");
270 m_afmPath
= wxT("c:\\windows\\system\\");
273 #if !defined(__VMS__) && !defined(__WXMSW__)
274 m_printerCommand
= wxT("lpr");
275 m_printerOptions
= wxT("");
279 m_printerScaleX
= 1.0;
280 m_printerScaleY
= 1.0;
281 m_printerTranslateX
= 0;
282 m_printerTranslateY
= 0;
283 m_printMode
= wxPRINT_MODE_FILE
;
286 wxPrintData::wxPrintData(const wxPrintData
& printData
)
290 m_devMode
= (void*) NULL
;
291 m_devNames
= (void*) NULL
;
292 #elif defined( __WXMAC__ )
294 m_macPageFormat
= kPMNoPageFormat
;
295 m_macPrintSettings
= kPMNoPrintSettings
;
296 m_macPrintSession
= kPMNoReference
;
298 m_macPrintSettings
= NULL
;
304 wxPrintData::~wxPrintData()
307 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
309 GlobalFree(hDevMode
);
310 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
312 GlobalFree(hDevNames
);
313 #elif defined(__WXMAC__)
315 if (m_macPageFormat
!= kPMNoPageFormat
)
317 #if PM_USE_SESSION_APIS
318 (void)PMRelease(m_macPageFormat
);
320 (void)PMDisposePageFormat(m_macPageFormat
);
322 m_macPageFormat
= kPMNoPageFormat
;
325 if (m_macPrintSettings
!= kPMNoPrintSettings
)
327 #if PM_USE_SESSION_APIS
328 (void)PMRelease(m_macPrintSettings
);
330 (void)PMDisposePrintSettings(m_macPrintSettings
);
332 m_macPrintSettings
= kPMNoPrintSettings
;
335 if ( m_macPrintSession
!= kPMNoReference
)
337 #if PM_USE_SESSION_APIS
338 (void)PMRelease(m_macPrintSession
);
340 (void)PMDisposePrintSession(m_macPrintSession
);
342 m_macPrintSession
= kPMNoReference
;
345 wxASSERT( m_macPrintSettings
);
346 // we should perhaps delete
351 #if defined(__WXMSW__) // && defined(__WIN32__)
353 #if defined(__WXDEBUG__) && defined(__WIN32__)
354 static wxString
wxGetPrintDlgError()
356 DWORD err
= CommDlgExtendedError();
357 wxString msg
= wxT("Unknown");
360 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
361 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
362 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
363 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
364 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
365 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
366 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
367 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
368 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
369 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
370 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
371 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
372 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
373 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
374 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
375 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
376 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
377 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
378 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
379 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
380 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
381 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
388 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
391 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
392 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
397 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
398 ( driverName
.Length() + 1 +
399 printerName
.Length() + 1 +
400 portName
.Length()+1 ) * sizeof(wxChar
) );
401 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
402 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
403 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
405 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
406 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
407 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
409 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
410 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
411 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
421 void wxPrintData::ConvertToNative()
423 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
424 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
427 // Use PRINTDLG as a way of creating a DEVMODE object
430 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
435 memset(&pd
, 0, sizeof(PRINTDLG
));
436 pd
.lStructSize
= sizeof(PRINTDLG
);
439 pd
.hwndOwner
= (HWND
)NULL
;
440 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
441 pd
.hDevNames
= NULL
; // Ditto
442 //pd.hInstance = (HINSTANCE) wxGetInstance();
444 pd
.Flags
= PD_RETURNDEFAULT
;
447 // Fill out the DEVMODE structure
448 // so we can use it as input in the 'real' PrintDlg
452 GlobalFree(pd
.hDevMode
);
454 GlobalFree(pd
.hDevNames
);
458 #if defined(__WXDEBUG__) && defined(__WIN32__)
459 wxString
str(wxT("Printing error: "));
460 str
+= wxGetPrintDlgError();
466 hDevMode
= pd
.hDevMode
;
467 m_devMode
= (void*)(long) hDevMode
;
470 // We'll create a new DEVNAMEs structure below.
472 GlobalFree(pd
.hDevNames
);
475 // hDevNames = pd->hDevNames;
476 // m_devNames = (void*)(long) hDevNames;
477 // pd->hDevnames = NULL;
484 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
489 devMode
->dmOrientation
= m_printOrientation
;
491 devMode
->dmFields
= DM_ORIENTATION
;
496 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
497 devMode
->dmFields
|= DM_COLLATE
;
500 //// Number of copies
502 devMode
->dmCopies
= m_printNoCopies
;
503 devMode
->dmFields
|= DM_COPIES
;
507 if (m_printerName
!= wxT(""))
509 //int len = wxMin(31, m_printerName.Len());
510 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
511 devMode
->dmDeviceName
[31] = wxT('\0');
517 devMode
->dmColor
= DMCOLOR_COLOR
;
519 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
521 devMode
->dmFields
|= DM_COLOR
;
526 if (m_paperId
== wxPAPER_NONE
)
528 // DEVMODE is in tenths of a milimeter
529 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
530 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
531 devMode
->dmPaperSize
= DMPAPER_USER
;
532 devMode
->dmFields
|= DM_PAPERWIDTH
;
533 devMode
->dmFields
|= DM_PAPERLENGTH
;
537 if (wxThePrintPaperDatabase
)
539 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
542 devMode
->dmPaperSize
= paper
->GetPlatformId();
543 devMode
->dmFields
|= DM_PAPERSIZE
;
552 switch (m_duplexMode
)
554 case wxDUPLEX_HORIZONTAL
: {
555 duplex
= DMDUP_HORIZONTAL
; break;
557 case wxDUPLEX_VERTICAL
: {
558 duplex
= DMDUP_VERTICAL
; break;
561 case wxDUPLEX_SIMPLEX
: {
562 duplex
= DMDUP_SIMPLEX
; break;
565 devMode
->dmDuplex
= duplex
;
566 devMode
->dmFields
|= DM_DUPLEX
;
571 switch (m_printQuality
)
573 case wxPRINT_QUALITY_MEDIUM
: {
574 quality
= DMRES_MEDIUM
; break;
576 case wxPRINT_QUALITY_LOW
: {
577 quality
= DMRES_LOW
; break;
579 case wxPRINT_QUALITY_DRAFT
: {
580 quality
= DMRES_DRAFT
; break;
582 case wxPRINT_QUALITY_HIGH
: {
583 quality
= DMRES_HIGH
; break;
586 quality
= m_printQuality
; break;
589 devMode
->dmPrintQuality
= quality
;
590 devMode
->dmFields
|= DM_PRINTQUALITY
;
592 GlobalUnlock(hDevMode
);
597 GlobalFree(hDevNames
);
600 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
601 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
604 void wxPrintData::ConvertFromNative()
606 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
607 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
614 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
619 if (devMode
->dmFields
& DM_ORIENTATION
)
620 m_printOrientation
= devMode
->dmOrientation
;
626 if (devMode
->dmFields
& DM_COLLATE
)
628 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
629 m_printCollate
= TRUE
;
631 m_printCollate
= FALSE
;
635 //// Number of copies
637 if (devMode
->dmFields
& DM_COPIES
)
639 m_printNoCopies
= devMode
->dmCopies
;
644 if (devMode
->dmDeviceName
[0] != 0)
646 m_printerName
= devMode
->dmDeviceName
;
651 if (devMode
->dmFields
& DM_COLOR
)
653 if (devMode
->dmColor
== DMCOLOR_COLOR
)
664 // We don't know size of user defined paper and some buggy drivers
665 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
666 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
667 // code wouldn't set m_paperSize correctly.
668 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
670 if (wxThePrintPaperDatabase
)
672 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
675 m_paperId
= paper
->GetId();
676 m_paperSize
.x
= paper
->GetWidth() / 10;
677 m_paperSize
.y
= paper
->GetHeight() / 10;
681 // Shouldn't really get here
682 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
684 m_paperId
= wxPAPER_NONE
;
691 // Shouldn't really get here
692 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
694 m_paperId
= wxPAPER_NONE
;
699 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
701 // DEVMODE is in tenths of a milimeter
702 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
703 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
704 m_paperId
= wxPAPER_NONE
;
708 // Shouldn't really get here
709 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
713 m_paperId
= wxPAPER_NONE
;
719 if (devMode
->dmFields
& DM_DUPLEX
)
721 switch (devMode
->dmDuplex
)
723 case DMDUP_HORIZONTAL
: {
724 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
726 case DMDUP_VERTICAL
: {
727 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
730 case DMDUP_SIMPLEX
: {
731 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
736 m_duplexMode
= wxDUPLEX_SIMPLEX
;
740 if (devMode
->dmFields
& DM_PRINTQUALITY
)
742 switch (devMode
->dmPrintQuality
)
745 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
748 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
751 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
754 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
758 // TODO: if the printer fills in the resolution in DPI, how
759 // will the application know if it's high, low, draft etc.??
760 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
761 m_printQuality
= devMode
->dmPrintQuality
; break;
767 m_printQuality
= wxPRINT_QUALITY_HIGH
;
769 GlobalUnlock(hDevMode
);
774 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
777 // TODO: Unicode-ification
780 // port is obsolete in WIN32
781 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
783 // Get the printer name
784 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
786 // Not sure if we should check for this mismatch
787 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
789 if (printerName
!= wxT(""))
790 m_printerName
= printerName
;
792 GlobalUnlock(hDevNames
);
800 void wxPrintData::ConvertToNative()
804 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
808 void wxPrintData::ConvertFromNative()
812 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
817 void wxPrintData::operator=(const wxPrintData
& data
)
821 if ( m_macPrintSettings
!= kPMNoPrintSettings
)
823 PMRelease( m_macPrintSettings
) ;
824 m_macPrintSettings
= kPMNoPrintSettings
;
826 if ( data
.m_macPrintSettings
!= kPMNoPrintSettings
)
828 m_macPrintSettings
= data
.m_macPrintSettings
;
829 PMRetain( m_macPrintSettings
) ;
831 if ( m_macPageFormat
!= kPMNoPageFormat
)
833 PMRelease( m_macPageFormat
) ;
834 m_macPageFormat
= kPMNoPageFormat
;
836 if ( data
.m_macPageFormat
!= kPMNoPageFormat
)
838 m_macPageFormat
= data
.m_macPageFormat
;
839 PMRetain( m_macPageFormat
) ;
842 m_macPrintSettings
= data
.m_macPrintSettings
;
843 HandToHand( (Handle
*) &m_macPrintSettings
);
846 m_printNoCopies
= data
.m_printNoCopies
;
847 m_printCollate
= data
.m_printCollate
;
848 m_printOrientation
= data
.m_printOrientation
;
849 m_printerName
= data
.m_printerName
;
850 m_colour
= data
.m_colour
;
851 m_duplexMode
= data
.m_duplexMode
;
852 m_printQuality
= data
.m_printQuality
;
853 m_paperId
= data
.m_paperId
;
854 m_paperSize
= data
.m_paperSize
;
856 // PostScript-specific data
857 m_printerCommand
= data
.m_printerCommand
;
858 m_previewCommand
= data
.m_previewCommand
;
859 m_printerOptions
= data
.m_printerOptions
;
860 m_filename
= data
.m_filename
;
861 m_afmPath
= data
.m_afmPath
;
862 m_printerScaleX
= data
.m_printerScaleX
;
863 m_printerScaleY
= data
.m_printerScaleY
;
864 m_printerTranslateX
= data
.m_printerTranslateX
;
865 m_printerTranslateY
= data
.m_printerTranslateY
;
866 m_printMode
= data
.m_printMode
;
869 // Is this data OK for showing the print dialog?
870 bool wxPrintData::Ok() const
873 ((wxPrintData
*)this)->ConvertToNative();
874 return (m_devMode
!= NULL
) ;
880 // ----------------------------------------------------------------------------
882 // ----------------------------------------------------------------------------
884 wxPrintDialogData::wxPrintDialogData()
887 m_printDlgData
= NULL
;
894 m_printAllPages
= FALSE
;
895 m_printCollate
= FALSE
;
896 m_printToFile
= FALSE
;
897 m_printSelection
= FALSE
;
898 m_printEnableSelection
= FALSE
;
899 m_printEnablePageNumbers
= TRUE
;
900 m_printEnablePrintToFile
= TRUE
;
901 m_printEnableHelp
= FALSE
;
902 m_printSetupDialog
= FALSE
;
905 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
909 m_printDlgData
= NULL
;
911 (*this) = dialogData
;
914 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
917 m_printDlgData
= NULL
;
924 m_printAllPages
= FALSE
;
925 m_printCollate
= FALSE
;
926 m_printToFile
= FALSE
;
927 m_printSelection
= FALSE
;
928 m_printEnableSelection
= FALSE
;
929 m_printEnablePageNumbers
= TRUE
;
930 m_printEnablePrintToFile
= TRUE
;
931 m_printEnableHelp
= FALSE
;
932 m_printSetupDialog
= FALSE
;
934 m_printData
= printData
;
937 wxPrintDialogData::~wxPrintDialogData()
940 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
941 if ( pd
&& pd
->hDevMode
)
942 GlobalFree(pd
->hDevMode
);
949 void wxPrintDialogData::ConvertToNative()
951 m_printData
.ConvertToNative();
953 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
958 memset( pd
, 0, sizeof(PRINTDLG
) );
959 m_printDlgData
= (void*) pd
;
961 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
963 pd
->lStructSize
= 66;
965 pd
->lStructSize
= sizeof(PRINTDLG
);
967 pd
->hwndOwner
= (HWND
)NULL
;
968 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
969 pd
->hDevNames
= NULL
; // Ditto
971 pd
->Flags
= PD_RETURNDEFAULT
;
975 // Pass the devmode data to the PRINTDLG structure, since it'll
976 // be needed when PrintDlg is called.
979 GlobalFree(pd
->hDevMode
);
982 // Pass the devnames data to the PRINTDLG structure, since it'll
983 // be needed when PrintDlg is called.
986 GlobalFree(pd
->hDevNames
);
989 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
991 m_printData
.SetNativeData((void*) NULL
);
993 // Shouldn't assert; we should be able to test Ok-ness at a higher level
994 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
996 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
998 m_printData
.SetNativeDataDevNames((void*) NULL
);
1000 pd
->hDC
= (HDC
) NULL
;
1001 pd
->nFromPage
= (WORD
)m_printFromPage
;
1002 pd
->nToPage
= (WORD
)m_printToPage
;
1003 pd
->nMinPage
= (WORD
)m_printMinPage
;
1004 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
1005 pd
->nCopies
= (WORD
)m_printNoCopies
;
1007 pd
->Flags
= PD_RETURNDC
;
1010 pd
->lStructSize
= 66;
1012 pd
->lStructSize
= sizeof( PRINTDLG
);
1015 pd
->hwndOwner
=(HWND
)NULL
;
1016 // pd->hDevNames=(HANDLE)NULL;
1017 pd
->hInstance
=(HINSTANCE
)NULL
;
1018 pd
->lCustData
= (LPARAM
) NULL
;
1019 pd
->lpfnPrintHook
= NULL
;
1020 pd
->lpfnSetupHook
= NULL
;
1021 pd
->lpPrintTemplateName
= NULL
;
1022 pd
->lpSetupTemplateName
= NULL
;
1023 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1024 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1026 if ( m_printAllPages
)
1027 pd
->Flags
|= PD_ALLPAGES
;
1028 if ( m_printSelection
)
1029 pd
->Flags
|= PD_SELECTION
;
1030 if ( m_printCollate
)
1031 pd
->Flags
|= PD_COLLATE
;
1032 if ( m_printToFile
)
1033 pd
->Flags
|= PD_PRINTTOFILE
;
1034 if ( !m_printEnablePrintToFile
)
1035 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1036 if ( !m_printEnableSelection
)
1037 pd
->Flags
|= PD_NOSELECTION
;
1038 if ( !m_printEnablePageNumbers
)
1039 pd
->Flags
|= PD_NOPAGENUMS
;
1040 if ( m_printEnableHelp
)
1041 pd
->Flags
|= PD_SHOWHELP
;
1042 if ( m_printSetupDialog
)
1043 pd
->Flags
|= PD_PRINTSETUP
;
1046 void wxPrintDialogData::ConvertFromNative()
1048 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1052 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1055 if (m_printData
.GetNativeData())
1057 // Make sure we don't leak memory
1058 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1060 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1061 pd
->hDevMode
= NULL
;
1064 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1067 if (m_printData
.GetNativeDataDevNames())
1069 // Make sure we don't leak memory
1070 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1072 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1073 pd
->hDevNames
= NULL
;
1076 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1077 // into wxWindows form.
1078 m_printData
.ConvertFromNative();
1080 m_printFromPage
= pd
->nFromPage
;
1081 m_printToPage
= pd
->nToPage
;
1082 m_printMinPage
= pd
->nMinPage
;
1083 m_printMaxPage
= pd
->nMaxPage
;
1084 m_printNoCopies
= pd
->nCopies
;
1086 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1087 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1088 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1089 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1090 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1091 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1092 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1093 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1094 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1096 /* port is obsolete in WIN32
1097 // Get the port name
1100 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1102 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1103 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1104 GlobalUnlock(pd->hDevNames);
1106 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1112 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1114 if ( m_printDlgData
== NULL
)
1117 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1119 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1120 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1126 void wxPrintDialogData::ConvertToNative()
1130 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1131 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1132 m_printData
.ConvertToNative();
1136 void wxPrintDialogData::ConvertFromNative()
1140 m_printData
.ConvertFromNative();
1141 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1142 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1148 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1150 m_printFromPage
= data
.m_printFromPage
;
1151 m_printToPage
= data
.m_printToPage
;
1152 m_printMinPage
= data
.m_printMinPage
;
1153 m_printMaxPage
= data
.m_printMaxPage
;
1154 m_printNoCopies
= data
.m_printNoCopies
;
1155 m_printAllPages
= data
.m_printAllPages
;
1156 m_printCollate
= data
.m_printCollate
;
1157 m_printToFile
= data
.m_printToFile
;
1158 m_printSelection
= data
.m_printSelection
;
1159 m_printEnableSelection
= data
.m_printEnableSelection
;
1160 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1161 m_printEnableHelp
= data
.m_printEnableHelp
;
1162 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1163 m_printSetupDialog
= data
.m_printSetupDialog
;
1165 m_printData
= data
.m_printData
;
1168 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1173 // ----------------------------------------------------------------------------
1174 // wxPageSetupDialogData
1175 // ----------------------------------------------------------------------------
1177 wxPageSetupDialogData::wxPageSetupDialogData()
1179 #if defined(__WIN95__)
1180 m_pageSetupData
= NULL
;
1182 m_paperSize
= wxSize(0, 0);
1184 CalculatePaperSizeFromId();
1186 m_minMarginTopLeft
= wxPoint(0, 0);
1187 m_minMarginBottomRight
= wxPoint(0, 0);
1188 m_marginTopLeft
= wxPoint(0, 0);
1189 m_marginBottomRight
= wxPoint(0, 0);
1192 m_defaultMinMargins
= FALSE
;
1193 m_enableMargins
= TRUE
;
1194 m_enableOrientation
= TRUE
;
1195 m_enablePaper
= TRUE
;
1196 m_enablePrinter
= TRUE
;
1197 m_enableHelp
= FALSE
;
1198 m_getDefaultInfo
= FALSE
;
1201 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1204 #if defined(__WIN95__)
1205 m_pageSetupData
= NULL
;
1207 (*this) = dialogData
;
1210 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1212 #if defined(__WIN95__)
1213 m_pageSetupData
= NULL
;
1215 m_paperSize
= wxSize(0, 0);
1216 m_minMarginTopLeft
= wxPoint(0, 0);
1217 m_minMarginBottomRight
= wxPoint(0, 0);
1218 m_marginTopLeft
= wxPoint(0, 0);
1219 m_marginBottomRight
= wxPoint(0, 0);
1222 m_defaultMinMargins
= FALSE
;
1223 m_enableMargins
= TRUE
;
1224 m_enableOrientation
= TRUE
;
1225 m_enablePaper
= TRUE
;
1226 m_enablePrinter
= TRUE
;
1227 m_enableHelp
= FALSE
;
1228 m_getDefaultInfo
= FALSE
;
1230 m_printData
= printData
;
1232 // The wxPrintData paper size overrides these values, unless the size cannot
1234 CalculatePaperSizeFromId();
1237 wxPageSetupDialogData::~wxPageSetupDialogData()
1239 #if defined(__WIN95__) && defined(__WXMSW__)
1240 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1241 if ( pd
&& pd
->hDevMode
)
1242 GlobalFree(pd
->hDevMode
);
1243 if ( pd
&& pd
->hDevNames
)
1244 GlobalFree(pd
->hDevNames
);
1250 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1252 m_paperSize
= data
.m_paperSize
;
1253 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1254 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1255 m_marginTopLeft
= data
.m_marginTopLeft
;
1256 m_marginBottomRight
= data
.m_marginBottomRight
;
1257 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1258 m_enableMargins
= data
.m_enableMargins
;
1259 m_enableOrientation
= data
.m_enableOrientation
;
1260 m_enablePaper
= data
.m_enablePaper
;
1261 m_enablePrinter
= data
.m_enablePrinter
;
1262 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1263 m_enableHelp
= data
.m_enableHelp
;
1265 m_printData
= data
.m_printData
;
1270 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1277 #if defined(__WIN95__)
1278 void wxPageSetupDialogData::ConvertToNative()
1280 m_printData
.ConvertToNative();
1282 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1284 if ( m_pageSetupData
== NULL
)
1286 pd
= new PAGESETUPDLG
;
1287 pd
->hDevMode
= NULL
;
1288 pd
->hDevNames
= NULL
;
1289 m_pageSetupData
= (void *)pd
;
1292 // Pass the devmode data (created in m_printData.ConvertToNative)
1293 // to the PRINTDLG structure, since it'll
1294 // be needed when PrintDlg is called.
1298 GlobalFree(pd
->hDevMode
);
1299 pd
->hDevMode
= NULL
;
1302 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1304 m_printData
.SetNativeData((void*) NULL
);
1306 // Shouldn't assert; we should be able to test Ok-ness at a higher level
1307 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1309 // Pass the devnames data (created in m_printData.ConvertToNative)
1310 // to the PRINTDLG structure, since it'll
1311 // be needed when PrintDlg is called.
1315 GlobalFree(pd
->hDevNames
);
1316 pd
->hDevNames
= NULL
;
1319 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1321 m_printData
.SetNativeDataDevNames((void*) NULL
);
1323 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1325 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1327 if ( m_defaultMinMargins
)
1328 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1329 if ( !m_enableMargins
)
1330 pd
->Flags
|= PSD_DISABLEMARGINS
;
1331 if ( !m_enableOrientation
)
1332 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1333 if ( !m_enablePaper
)
1334 pd
->Flags
|= PSD_DISABLEPAPER
;
1335 if ( !m_enablePrinter
)
1336 pd
->Flags
|= PSD_DISABLEPRINTER
;
1337 if ( m_getDefaultInfo
)
1338 pd
->Flags
|= PSD_RETURNDEFAULT
;
1340 pd
->Flags
|= PSD_SHOWHELP
;
1342 // We want the units to be in hundredths of a millimetre
1343 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1345 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1346 pd
->hwndOwner
=(HWND
)NULL
;
1347 // pd->hDevNames=(HWND)NULL;
1348 pd
->hInstance
=(HINSTANCE
)NULL
;
1349 // PAGESETUPDLG is in hundreds of a mm
1350 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1351 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1353 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1354 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1355 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1356 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1358 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1359 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1360 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1361 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1364 pd
->lpfnPageSetupHook
= NULL
;
1365 pd
->lpfnPagePaintHook
= NULL
;
1366 pd
->hPageSetupTemplate
= NULL
;
1367 pd
->lpPageSetupTemplateName
= NULL
;
1372 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1373 memset(devMode, 0, sizeof(DEVMODE));
1374 devMode->dmSize = sizeof(DEVMODE);
1375 devMode->dmOrientation = m_orientation;
1376 devMode->dmFields = DM_ORIENTATION;
1377 GlobalUnlock(pd->hDevMode);
1382 void wxPageSetupDialogData::ConvertFromNative()
1384 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1388 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1391 if (m_printData
.GetNativeData())
1393 // Make sure we don't leak memory
1394 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1396 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1397 pd
->hDevMode
= NULL
;
1400 m_printData
.ConvertFromNative();
1402 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1405 if (m_printData
.GetNativeDataDevNames())
1407 // Make sure we don't leak memory
1408 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1410 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1411 pd
->hDevNames
= NULL
;
1414 m_printData
.ConvertFromNative();
1416 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1418 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1419 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1420 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1421 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1422 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1423 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1424 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1426 // PAGESETUPDLG is in hundreds of a mm
1427 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1428 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1430 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1431 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1432 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1433 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1435 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1436 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1437 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1438 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1441 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1443 if ( m_pageSetupData
== NULL
)
1446 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1448 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1449 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1455 void wxPageSetupDialogData::ConvertToNative()
1457 m_printData
.ConvertToNative();
1458 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1461 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1462 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1464 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1465 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1467 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1468 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1469 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1470 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1474 void wxPageSetupDialogData::ConvertFromNative()
1476 m_printData
.ConvertFromNative ();
1481 OSStatus err
= PMGetAdjustedPaperRect((PMPageFormat
)m_printData
.m_macPageFormat
, &rPaper
);
1484 m_paperSize
.x
= (int)(((double) rPaper
.right
- rPaper
.left
) * pt2mm
);
1485 m_paperSize
.y
= (int)(((double) rPaper
.bottom
- rPaper
.top
) * pt2mm
);
1487 m_minMarginTopLeft
.x
= (int)(((double) - rPaper
.left
) * pt2mm
);
1488 m_minMarginTopLeft
.y
= (int)(((double) - rPaper
.top
) * pt2mm
);
1490 // m_minMarginBottomRight.x = ((double) rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
1491 // m_minMarginBottomRight.y = ((double)(**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
1494 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1495 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1497 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1498 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1500 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1501 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1503 // adjust minimal values
1504 //TODO add custom fields in dialog for margins
1506 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1507 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1509 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1510 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1512 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1513 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1515 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1516 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1521 // If a corresponding paper type is found in the paper database, will set the m_printData
1522 // paper size id member as well.
1523 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1527 CalculateIdFromPaperSize();
1530 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1531 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1533 m_printData
.SetPaperId(id
);
1535 CalculatePaperSizeFromId();
1538 // Use paper size defined in this object to set the wxPrintData
1540 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1542 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1543 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1545 wxSize sz
= GetPaperSize();
1547 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1548 if (id
!= wxPAPER_NONE
)
1550 m_printData
.SetPaperId(id
);
1554 // Use paper id in wxPrintData to set this object's paper size
1555 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1557 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1558 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1560 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1562 // sz is in 10ths of a mm, while paper size is in mm
1563 m_paperSize
.x
= sz
.x
/ 10;
1564 m_paperSize
.y
= sz
.y
/ 10;
1567 #endif // wxUSE_PRINTING_ARCHITECTURE