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
;
199 #if PM_USE_SESSION_APIS
200 PMPrintSession macPrintSession
= kPMNoReference
;
203 err
= ::UMAPrOpen(&macPrintSession
) ;
206 err
= PMCreatePageFormat((PMPageFormat
*)&m_macPageFormat
);
208 // Note that PMPageFormat is not session-specific, but calling
209 // PMSessionDefaultPageFormat assigns values specific to the printer
210 // associated with the current printing session.
211 if ((err
== noErr
) && (m_macPageFormat
!= kPMNoPageFormat
))
213 err
= PMSessionDefaultPageFormat((PMPrintSession
)macPrintSession
,
214 (PMPageFormat
)m_macPageFormat
);
217 err
= PMCreatePrintSettings((PMPrintSettings
*)&m_macPrintSettings
);
219 // Note that PMPrintSettings is not session-specific, but calling
220 // PMSessionDefaultPrintSettings assigns values specific to the printer
221 // associated with the current printing session.
222 if ((err
== noErr
) && (m_macPrintSettings
!= kPMNoPrintSettings
))
224 err
= PMSessionDefaultPrintSettings((PMPrintSession
)macPrintSession
,
225 (PMPrintSettings
)m_macPrintSettings
);
228 ::UMAPrClose(&macPrintSession
) ;
231 m_macPrintSettings
= (THPrint
) NewHandleClear( sizeof( TPrint
) );
232 (**(THPrint
)m_macPrintSettings
).iPrVersion
= 0; // something invalid
234 (**(THPrint
)m_macPrintSettings
).prInfo
.iHRes
= 72;
235 (**(THPrint
)m_macPrintSettings
).prInfo
.iVRes
= 72;
236 Rect r1
= { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
237 (**(THPrint
)m_macPrintSettings
).prInfo
.rPage
= r1
;// must have its top left & (0,0)
239 Rect r2
= { -18, -36, 8*72 - 18, 11*72 - 36 };
240 (**(THPrint
)m_macPrintSettings
).rPaper
= r2
;
241 (**(THPrint
)m_macPrintSettings
).prStl
.iPageV
= 11 * 120 ; // 11 inches in 120th of an inch
242 (**(THPrint
)m_macPrintSettings
).prStl
.iPageH
= 8 * 120 ; // 8 inches in 120th of an inch
245 m_printOrientation
= wxPORTRAIT
;
247 m_printCollate
= FALSE
;
252 m_duplexMode
= wxDUPLEX_SIMPLEX
;
253 m_printQuality
= wxPRINT_QUALITY_HIGH
;
254 m_paperId
= wxPAPER_A4
;
255 m_paperSize
= wxSize(210, 297);
257 // PostScript-specific data
258 m_previewCommand
= wxT("");
259 m_filename
= wxT("");
261 m_printerCommand
= wxT("print");
262 m_printerOptions
= wxT("/nonotify/queue=psqueue");
263 m_afmPath
= wxT("sys$ps_font_metrics:");
267 m_printerCommand
= wxT("print");
268 m_printerOptions
= wxT("");
269 m_afmPath
= wxT("c:\\windows\\system\\");
272 #if !defined(__VMS__) && !defined(__WXMSW__)
273 m_printerCommand
= wxT("lpr");
274 m_printerOptions
= wxT("");
278 m_printerScaleX
= 1.0;
279 m_printerScaleY
= 1.0;
280 m_printerTranslateX
= 0;
281 m_printerTranslateY
= 0;
282 m_printMode
= wxPRINT_MODE_FILE
;
285 wxPrintData::wxPrintData(const wxPrintData
& printData
)
289 m_devMode
= (void*) NULL
;
290 m_devNames
= (void*) NULL
;
291 #elif defined( __WXMAC__ )
293 m_macPageFormat
= kPMNoPageFormat
;
294 m_macPrintSettings
= kPMNoPrintSettings
;
296 m_macPrintSettings
= NULL
;
302 wxPrintData::~wxPrintData()
305 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
307 GlobalFree(hDevMode
);
308 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
310 GlobalFree(hDevNames
);
311 #elif defined(__WXMAC__)
313 if (m_macPageFormat
!= kPMNoPageFormat
)
315 #if PM_USE_SESSION_APIS
316 (void)PMRelease(m_macPageFormat
);
318 (void)PMDisposePageFormat(m_macPageFormat
);
320 m_macPageFormat
= kPMNoPageFormat
;
323 if (m_macPrintSettings
!= kPMNoPrintSettings
)
325 #if PM_USE_SESSION_APIS
326 (void)PMRelease(m_macPrintSettings
);
328 (void)PMDisposePrintSettings(m_macPrintSettings
);
330 m_macPrintSettings
= kPMNoPrintSettings
;
334 wxASSERT( m_macPrintSettings
);
335 // we should perhaps delete
340 #if defined(__WXMSW__) // && defined(__WIN32__)
342 #if defined(__WXDEBUG__) && defined(__WIN32__)
343 static wxString
wxGetPrintDlgError()
345 DWORD err
= CommDlgExtendedError();
346 wxString msg
= wxT("Unknown");
349 case CDERR_FINDRESFAILURE
: msg
= wxT("CDERR_FINDRESFAILURE"); break;
350 case CDERR_INITIALIZATION
: msg
= wxT("CDERR_INITIALIZATION"); break;
351 case CDERR_LOADRESFAILURE
: msg
= wxT("CDERR_LOADRESFAILURE"); break;
352 case CDERR_LOADSTRFAILURE
: msg
= wxT("CDERR_LOADSTRFAILURE"); break;
353 case CDERR_LOCKRESFAILURE
: msg
= wxT("CDERR_LOCKRESFAILURE"); break;
354 case CDERR_MEMALLOCFAILURE
: msg
= wxT("CDERR_MEMALLOCFAILURE"); break;
355 case CDERR_MEMLOCKFAILURE
: msg
= wxT("CDERR_MEMLOCKFAILURE"); break;
356 case CDERR_NOHINSTANCE
: msg
= wxT("CDERR_NOHINSTANCE"); break;
357 case CDERR_NOHOOK
: msg
= wxT("CDERR_NOHOOK"); break;
358 case CDERR_NOTEMPLATE
: msg
= wxT("CDERR_NOTEMPLATE"); break;
359 case CDERR_STRUCTSIZE
: msg
= wxT("CDERR_STRUCTSIZE"); break;
360 case PDERR_RETDEFFAILURE
: msg
= wxT("PDERR_RETDEFFAILURE"); break;
361 case PDERR_PRINTERNOTFOUND
: msg
= wxT("PDERR_PRINTERNOTFOUND"); break;
362 case PDERR_PARSEFAILURE
: msg
= wxT("PDERR_PARSEFAILURE"); break;
363 case PDERR_NODEVICES
: msg
= wxT("PDERR_NODEVICES"); break;
364 case PDERR_NODEFAULTPRN
: msg
= wxT("PDERR_NODEFAULTPRN"); break;
365 case PDERR_LOADDRVFAILURE
: msg
= wxT("PDERR_LOADDRVFAILURE"); break;
366 case PDERR_INITFAILURE
: msg
= wxT("PDERR_INITFAILURE"); break;
367 case PDERR_GETDEVMODEFAIL
: msg
= wxT("PDERR_GETDEVMODEFAIL"); break;
368 case PDERR_DNDMMISMATCH
: msg
= wxT("PDERR_DNDMMISMATCH"); break;
369 case PDERR_DEFAULTDIFFERENT
: msg
= wxT("PDERR_DEFAULTDIFFERENT"); break;
370 case PDERR_CREATEICFAILURE
: msg
= wxT("PDERR_CREATEICFAILURE"); break;
377 static HGLOBAL
wxCreateDevNames(const wxString
& driverName
, const wxString
& printerName
, const wxString
& portName
)
380 // if (!driverName.IsEmpty() && !printerName.IsEmpty() && !portName.IsEmpty())
381 if (driverName
.IsEmpty() && printerName
.IsEmpty() && portName
.IsEmpty())
386 hDev
= GlobalAlloc(GPTR
, 4*sizeof(WORD
)+
387 ( driverName
.Length() + 1 +
388 printerName
.Length() + 1 +
389 portName
.Length()+1 ) * sizeof(wxChar
) );
390 LPDEVNAMES lpDev
= (LPDEVNAMES
)GlobalLock(hDev
);
391 lpDev
->wDriverOffset
= sizeof(WORD
)*4;
392 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDriverOffset
), driverName
);
394 lpDev
->wDeviceOffset
= (WORD
)( lpDev
->wDriverOffset
+
395 sizeof(wxChar
) * ( driverName
.Length() + 1 ) );
396 wxStrcpy((wxChar
*)((char*)lpDev
+ lpDev
->wDeviceOffset
), printerName
);
398 lpDev
->wOutputOffset
= (WORD
)( lpDev
->wDeviceOffset
+
399 sizeof(wxChar
) * ( printerName
.Length() + 1 ) );
400 wxStrcpy((wxChar
*)((char*) lpDev
+ lpDev
->wOutputOffset
), portName
);
410 void wxPrintData::ConvertToNative()
412 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
413 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
416 // Use PRINTDLG as a way of creating a DEVMODE object
419 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
424 memset(&pd
, 0, sizeof(PRINTDLG
));
425 pd
.lStructSize
= sizeof(PRINTDLG
);
428 pd
.hwndOwner
= (HWND
)NULL
;
429 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
430 pd
.hDevNames
= NULL
; // Ditto
431 //pd.hInstance = (HINSTANCE) wxGetInstance();
433 pd
.Flags
= PD_RETURNDEFAULT
;
436 // Fill out the DEVMODE structure
437 // so we can use it as input in the 'real' PrintDlg
441 GlobalFree(pd
.hDevMode
);
443 GlobalFree(pd
.hDevNames
);
447 #if defined(__WXDEBUG__) && defined(__WIN32__)
448 wxString
str(wxT("Printing error: "));
449 str
+= wxGetPrintDlgError();
455 hDevMode
= pd
.hDevMode
;
456 m_devMode
= (void*)(long) hDevMode
;
459 // We'll create a new DEVNAMEs structure below.
461 GlobalFree(pd
.hDevNames
);
464 // hDevNames = pd->hDevNames;
465 // m_devNames = (void*)(long) hDevNames;
466 // pd->hDevnames = NULL;
473 LPDEVMODE devMode
= (LPDEVMODE
) GlobalLock(hDevMode
);
478 devMode
->dmOrientation
= m_printOrientation
;
480 devMode
->dmFields
= DM_ORIENTATION
;
485 devMode
->dmCollate
= (m_printCollate
? DMCOLLATE_TRUE
: DMCOLLATE_FALSE
);
486 devMode
->dmFields
|= DM_COLLATE
;
489 //// Number of copies
491 devMode
->dmCopies
= m_printNoCopies
;
492 devMode
->dmFields
|= DM_COPIES
;
496 if (m_printerName
!= wxT(""))
498 //int len = wxMin(31, m_printerName.Len());
499 wxStrncpy((wxChar
*)devMode
->dmDeviceName
,m_printerName
.c_str(),31);
500 devMode
->dmDeviceName
[31] = wxT('\0');
506 devMode
->dmColor
= DMCOLOR_COLOR
;
508 devMode
->dmColor
= DMCOLOR_MONOCHROME
;
510 devMode
->dmFields
|= DM_COLOR
;
515 if (m_paperId
== wxPAPER_NONE
)
517 // DEVMODE is in tenths of a milimeter
518 devMode
->dmPaperWidth
= m_paperSize
.x
* 10;
519 devMode
->dmPaperLength
= m_paperSize
.y
* 10;
520 devMode
->dmPaperSize
= DMPAPER_USER
;
521 devMode
->dmFields
|= DM_PAPERWIDTH
;
522 devMode
->dmFields
|= DM_PAPERLENGTH
;
526 if (wxThePrintPaperDatabase
)
528 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperType(m_paperId
);
531 devMode
->dmPaperSize
= paper
->GetPlatformId();
532 devMode
->dmFields
|= DM_PAPERSIZE
;
541 switch (m_duplexMode
)
543 case wxDUPLEX_HORIZONTAL
: {
544 duplex
= DMDUP_HORIZONTAL
; break;
546 case wxDUPLEX_VERTICAL
: {
547 duplex
= DMDUP_VERTICAL
; break;
550 case wxDUPLEX_SIMPLEX
: {
551 duplex
= DMDUP_SIMPLEX
; break;
554 devMode
->dmDuplex
= duplex
;
555 devMode
->dmFields
|= DM_DUPLEX
;
560 switch (m_printQuality
)
562 case wxPRINT_QUALITY_MEDIUM
: {
563 quality
= DMRES_MEDIUM
; break;
565 case wxPRINT_QUALITY_LOW
: {
566 quality
= DMRES_LOW
; break;
568 case wxPRINT_QUALITY_DRAFT
: {
569 quality
= DMRES_DRAFT
; break;
571 case wxPRINT_QUALITY_HIGH
: {
572 quality
= DMRES_HIGH
; break;
575 quality
= m_printQuality
; break;
578 devMode
->dmPrintQuality
= quality
;
579 devMode
->dmFields
|= DM_PRINTQUALITY
;
581 GlobalUnlock(hDevMode
);
586 GlobalFree(hDevNames
);
589 // TODO: I hope it's OK to pass some empty strings to DEVNAMES.
590 m_devNames
= (void*) (long) wxCreateDevNames(wxT(""), m_printerName
, wxT(""));
593 void wxPrintData::ConvertFromNative()
595 HGLOBAL hDevMode
= (HGLOBAL
)(DWORD
) m_devMode
;
596 HGLOBAL hDevNames
= (HGLOBAL
)(DWORD
) m_devNames
;
603 LPDEVMODE devMode
= (LPDEVMODE
)GlobalLock(hDevMode
);
608 if (devMode
->dmFields
& DM_ORIENTATION
)
609 m_printOrientation
= devMode
->dmOrientation
;
615 if (devMode
->dmFields
& DM_COLLATE
)
617 if (devMode
->dmCollate
== DMCOLLATE_TRUE
)
618 m_printCollate
= TRUE
;
620 m_printCollate
= FALSE
;
624 //// Number of copies
626 if (devMode
->dmFields
& DM_COPIES
)
628 m_printNoCopies
= devMode
->dmCopies
;
633 if (devMode
->dmDeviceName
[0] != 0)
635 // TODO: make this Unicode compatible
638 while (devMode
->dmDeviceName
[i
] != 0)
640 buf
[i
] = devMode
->dmDeviceName
[i
];
650 if (devMode
->dmFields
& DM_COLOR
)
652 if (devMode
->dmColor
== DMCOLOR_COLOR
)
663 // We don't know size of user defined paper and some buggy drivers
664 // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since
665 // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this
666 // code wouldn't set m_paperSize correctly.
667 if ((devMode
->dmFields
& DM_PAPERSIZE
) && (devMode
->dmPaperSize
< DMPAPER_USER
))
669 if (wxThePrintPaperDatabase
)
671 wxPrintPaperType
* paper
= wxThePrintPaperDatabase
->FindPaperTypeByPlatformId(devMode
->dmPaperSize
);
674 m_paperId
= paper
->GetId();
675 m_paperSize
.x
= paper
->GetWidth() / 10;
676 m_paperSize
.y
= paper
->GetHeight() / 10;
680 // Shouldn't really get here
681 wxFAIL_MSG(wxT("Couldn't find paper size in paper database."));
683 m_paperId
= wxPAPER_NONE
;
690 // Shouldn't really get here
691 wxFAIL_MSG(wxT("Paper database wasn't initialized in wxPrintData::ConvertFromNative."));
693 m_paperId
= wxPAPER_NONE
;
698 else if ((devMode
->dmFields
& DM_PAPERWIDTH
) && (devMode
->dmFields
& DM_PAPERLENGTH
))
700 // DEVMODE is in tenths of a milimeter
701 m_paperSize
.x
= devMode
->dmPaperWidth
/ 10;
702 m_paperSize
.y
= devMode
->dmPaperLength
/ 10;
703 m_paperId
= wxPAPER_NONE
;
707 // Shouldn't really get here
708 wxFAIL_MSG(wxT("Couldn't find paper size from DEVMODE."));
712 m_paperId
= wxPAPER_NONE
;
718 if (devMode
->dmFields
& DM_DUPLEX
)
720 switch (devMode
->dmDuplex
)
722 case DMDUP_HORIZONTAL
: {
723 m_duplexMode
= wxDUPLEX_HORIZONTAL
; break;
725 case DMDUP_VERTICAL
: {
726 m_duplexMode
= wxDUPLEX_VERTICAL
; break;
729 case DMDUP_SIMPLEX
: {
730 m_duplexMode
= wxDUPLEX_SIMPLEX
; break;
735 m_duplexMode
= wxDUPLEX_SIMPLEX
;
739 if (devMode
->dmFields
& DM_PRINTQUALITY
)
741 switch (devMode
->dmPrintQuality
)
744 m_printQuality
= wxPRINT_QUALITY_MEDIUM
; break;
747 m_printQuality
= wxPRINT_QUALITY_LOW
; break;
750 m_printQuality
= wxPRINT_QUALITY_DRAFT
; break;
753 m_printQuality
= wxPRINT_QUALITY_HIGH
; break;
757 // TODO: if the printer fills in the resolution in DPI, how
758 // will the application know if it's high, low, draft etc.??
759 // wxFAIL_MSG("Warning: DM_PRINTQUALITY was not one of the standard values.");
760 m_printQuality
= devMode
->dmPrintQuality
; break;
766 m_printQuality
= wxPRINT_QUALITY_HIGH
;
768 GlobalUnlock(hDevMode
);
773 LPDEVNAMES lpDevNames
= (LPDEVNAMES
)GlobalLock(hDevNames
);
776 // TODO: Unicode-ification
779 // port is obsolete in WIN32
780 // m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
782 // Get the printer name
783 wxString printerName
= (LPTSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
785 // Not sure if we should check for this mismatch
786 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
788 if (printerName
!= wxT(""))
789 m_printerName
= printerName
;
791 GlobalUnlock(hDevNames
);
799 void wxPrintData::ConvertToNative()
803 (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
= m_printNoCopies
;
807 void wxPrintData::ConvertFromNative()
811 m_printNoCopies
= (**(THPrint
)m_macPrintSettings
).prJob
.iCopies
;
816 void wxPrintData::operator=(const wxPrintData
& data
)
821 m_macPrintSettings
= data
.m_macPrintSettings
;
822 HandToHand( (Handle
*) &m_macPrintSettings
);
825 m_printNoCopies
= data
.m_printNoCopies
;
826 m_printCollate
= data
.m_printCollate
;
827 m_printOrientation
= data
.m_printOrientation
;
828 m_printerName
= data
.m_printerName
;
829 m_colour
= data
.m_colour
;
830 m_duplexMode
= data
.m_duplexMode
;
831 m_printQuality
= data
.m_printQuality
;
832 m_paperId
= data
.m_paperId
;
833 m_paperSize
= data
.m_paperSize
;
835 // PostScript-specific data
836 m_printerCommand
= data
.m_printerCommand
;
837 m_previewCommand
= data
.m_previewCommand
;
838 m_printerOptions
= data
.m_printerOptions
;
839 m_filename
= data
.m_filename
;
840 m_afmPath
= data
.m_afmPath
;
841 m_printerScaleX
= data
.m_printerScaleX
;
842 m_printerScaleY
= data
.m_printerScaleY
;
843 m_printerTranslateX
= data
.m_printerTranslateX
;
844 m_printerTranslateY
= data
.m_printerTranslateY
;
845 m_printMode
= data
.m_printMode
;
848 // Is this data OK for showing the print dialog?
849 bool wxPrintData::Ok() const
852 ((wxPrintData
*)this)->ConvertToNative();
853 return (m_devMode
!= NULL
) ;
859 // ----------------------------------------------------------------------------
861 // ----------------------------------------------------------------------------
863 wxPrintDialogData::wxPrintDialogData()
866 m_printDlgData
= NULL
;
873 m_printAllPages
= FALSE
;
874 m_printCollate
= FALSE
;
875 m_printToFile
= FALSE
;
876 m_printSelection
= FALSE
;
877 m_printEnableSelection
= FALSE
;
878 m_printEnablePageNumbers
= TRUE
;
879 m_printEnablePrintToFile
= TRUE
;
880 m_printEnableHelp
= FALSE
;
881 m_printSetupDialog
= FALSE
;
884 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
888 m_printDlgData
= NULL
;
890 (*this) = dialogData
;
893 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
896 m_printDlgData
= NULL
;
903 m_printAllPages
= FALSE
;
904 m_printCollate
= FALSE
;
905 m_printToFile
= FALSE
;
906 m_printSelection
= FALSE
;
907 m_printEnableSelection
= FALSE
;
908 m_printEnablePageNumbers
= TRUE
;
909 m_printEnablePrintToFile
= TRUE
;
910 m_printEnableHelp
= FALSE
;
911 m_printSetupDialog
= FALSE
;
913 m_printData
= printData
;
916 wxPrintDialogData::~wxPrintDialogData()
919 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
920 if ( pd
&& pd
->hDevMode
)
921 GlobalFree(pd
->hDevMode
);
928 void wxPrintDialogData::ConvertToNative()
930 m_printData
.ConvertToNative();
932 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
937 memset( pd
, 0, sizeof(PRINTDLG
) );
938 m_printDlgData
= (void*) pd
;
940 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
942 pd
->lStructSize
= 66;
944 pd
->lStructSize
= sizeof(PRINTDLG
);
946 pd
->hwndOwner
= (HWND
)NULL
;
947 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
948 pd
->hDevNames
= NULL
; // Ditto
950 pd
->Flags
= PD_RETURNDEFAULT
;
954 // Pass the devmode data to the PRINTDLG structure, since it'll
955 // be needed when PrintDlg is called.
958 GlobalFree(pd
->hDevMode
);
961 // Pass the devnames data to the PRINTDLG structure, since it'll
962 // be needed when PrintDlg is called.
965 GlobalFree(pd
->hDevNames
);
968 pd
->hDevMode
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeData();
970 m_printData
.SetNativeData((void*) NULL
);
972 // Shouldn't assert; we should be able to test Ok-ness at a higher level
973 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
975 pd
->hDevNames
= (HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames();
977 m_printData
.SetNativeDataDevNames((void*) NULL
);
979 pd
->hDC
= (HDC
) NULL
;
980 pd
->nFromPage
= (WORD
)m_printFromPage
;
981 pd
->nToPage
= (WORD
)m_printToPage
;
982 pd
->nMinPage
= (WORD
)m_printMinPage
;
983 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
984 pd
->nCopies
= (WORD
)m_printNoCopies
;
986 pd
->Flags
= PD_RETURNDC
;
989 pd
->lStructSize
= 66;
991 pd
->lStructSize
= sizeof( PRINTDLG
);
994 pd
->hwndOwner
=(HWND
)NULL
;
995 // pd->hDevNames=(HANDLE)NULL;
996 pd
->hInstance
=(HINSTANCE
)NULL
;
997 pd
->lCustData
= (LPARAM
) NULL
;
998 pd
->lpfnPrintHook
= NULL
;
999 pd
->lpfnSetupHook
= NULL
;
1000 pd
->lpPrintTemplateName
= NULL
;
1001 pd
->lpSetupTemplateName
= NULL
;
1002 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
1003 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
1005 if ( m_printAllPages
)
1006 pd
->Flags
|= PD_ALLPAGES
;
1007 if ( m_printSelection
)
1008 pd
->Flags
|= PD_SELECTION
;
1009 if ( m_printCollate
)
1010 pd
->Flags
|= PD_COLLATE
;
1011 if ( m_printToFile
)
1012 pd
->Flags
|= PD_PRINTTOFILE
;
1013 if ( !m_printEnablePrintToFile
)
1014 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
1015 if ( !m_printEnableSelection
)
1016 pd
->Flags
|= PD_NOSELECTION
;
1017 if ( !m_printEnablePageNumbers
)
1018 pd
->Flags
|= PD_NOPAGENUMS
;
1019 if ( m_printEnableHelp
)
1020 pd
->Flags
|= PD_SHOWHELP
;
1021 if ( m_printSetupDialog
)
1022 pd
->Flags
|= PD_PRINTSETUP
;
1025 void wxPrintDialogData::ConvertFromNative()
1027 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1031 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1034 if (m_printData
.GetNativeData())
1036 // Make sure we don't leak memory
1037 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeData());
1039 m_printData
.SetNativeData((void*)(long) pd
->hDevMode
);
1040 pd
->hDevMode
= NULL
;
1043 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1046 if (m_printData
.GetNativeDataDevNames())
1048 // Make sure we don't leak memory
1049 GlobalFree((HGLOBAL
)(DWORD
) m_printData
.GetNativeDataDevNames());
1051 m_printData
.SetNativeDataDevNames((void*)(long) pd
->hDevNames
);
1052 pd
->hDevNames
= NULL
;
1055 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
1056 // into wxWindows form.
1057 m_printData
.ConvertFromNative();
1059 m_printFromPage
= pd
->nFromPage
;
1060 m_printToPage
= pd
->nToPage
;
1061 m_printMinPage
= pd
->nMinPage
;
1062 m_printMaxPage
= pd
->nMaxPage
;
1063 m_printNoCopies
= pd
->nCopies
;
1065 m_printAllPages
= ((pd
->Flags
& PD_ALLPAGES
) == PD_ALLPAGES
);
1066 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
1067 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
1068 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
1069 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
1070 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
1071 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
1072 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
1073 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
1075 /* port is obsolete in WIN32
1076 // Get the port name
1079 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
1081 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
1082 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
1083 GlobalUnlock(pd->hDevNames);
1085 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
1091 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
1093 if ( m_printDlgData
== NULL
)
1096 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
1098 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
1099 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1105 void wxPrintDialogData::ConvertToNative()
1109 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
= m_printFromPage
;
1110 (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
= m_printToPage
;
1111 m_printData
.ConvertToNative();
1115 void wxPrintDialogData::ConvertFromNative()
1119 m_printData
.ConvertFromNative();
1120 m_printFromPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iFstPage
;
1121 m_printToPage
= (**(THPrint
)m_printData
.m_macPrintSettings
).prJob
.iLstPage
;
1127 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
1129 m_printFromPage
= data
.m_printFromPage
;
1130 m_printToPage
= data
.m_printToPage
;
1131 m_printMinPage
= data
.m_printMinPage
;
1132 m_printMaxPage
= data
.m_printMaxPage
;
1133 m_printNoCopies
= data
.m_printNoCopies
;
1134 m_printAllPages
= data
.m_printAllPages
;
1135 m_printCollate
= data
.m_printCollate
;
1136 m_printToFile
= data
.m_printToFile
;
1137 m_printSelection
= data
.m_printSelection
;
1138 m_printEnableSelection
= data
.m_printEnableSelection
;
1139 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
1140 m_printEnableHelp
= data
.m_printEnableHelp
;
1141 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
1142 m_printSetupDialog
= data
.m_printSetupDialog
;
1144 m_printData
= data
.m_printData
;
1147 void wxPrintDialogData::operator=(const wxPrintData
& data
)
1152 // ----------------------------------------------------------------------------
1153 // wxPageSetupDialogData
1154 // ----------------------------------------------------------------------------
1156 wxPageSetupDialogData::wxPageSetupDialogData()
1158 #if defined(__WIN95__)
1159 m_pageSetupData
= NULL
;
1161 m_paperSize
= wxSize(0, 0);
1163 CalculatePaperSizeFromId();
1165 m_minMarginTopLeft
= wxPoint(0, 0);
1166 m_minMarginBottomRight
= wxPoint(0, 0);
1167 m_marginTopLeft
= wxPoint(0, 0);
1168 m_marginBottomRight
= wxPoint(0, 0);
1171 m_defaultMinMargins
= FALSE
;
1172 m_enableMargins
= TRUE
;
1173 m_enableOrientation
= TRUE
;
1174 m_enablePaper
= TRUE
;
1175 m_enablePrinter
= TRUE
;
1176 m_enableHelp
= FALSE
;
1177 m_getDefaultInfo
= FALSE
;
1180 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
1183 #if defined(__WIN95__)
1184 m_pageSetupData
= NULL
;
1186 (*this) = dialogData
;
1189 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
1191 #if defined(__WIN95__)
1192 m_pageSetupData
= NULL
;
1194 m_paperSize
= wxSize(0, 0);
1195 m_minMarginTopLeft
= wxPoint(0, 0);
1196 m_minMarginBottomRight
= wxPoint(0, 0);
1197 m_marginTopLeft
= wxPoint(0, 0);
1198 m_marginBottomRight
= wxPoint(0, 0);
1201 m_defaultMinMargins
= FALSE
;
1202 m_enableMargins
= TRUE
;
1203 m_enableOrientation
= TRUE
;
1204 m_enablePaper
= TRUE
;
1205 m_enablePrinter
= TRUE
;
1206 m_enableHelp
= FALSE
;
1207 m_getDefaultInfo
= FALSE
;
1209 m_printData
= printData
;
1211 // The wxPrintData paper size overrides these values, unless the size cannot
1213 CalculatePaperSizeFromId();
1216 wxPageSetupDialogData::~wxPageSetupDialogData()
1218 #if defined(__WIN95__) && defined(__WXMSW__)
1219 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
1220 if ( pd
&& pd
->hDevMode
)
1221 GlobalFree(pd
->hDevMode
);
1222 if ( pd
&& pd
->hDevNames
)
1223 GlobalFree(pd
->hDevNames
);
1229 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
1231 m_paperSize
= data
.m_paperSize
;
1232 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
1233 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
1234 m_marginTopLeft
= data
.m_marginTopLeft
;
1235 m_marginBottomRight
= data
.m_marginBottomRight
;
1236 m_defaultMinMargins
= data
.m_defaultMinMargins
;
1237 m_enableMargins
= data
.m_enableMargins
;
1238 m_enableOrientation
= data
.m_enableOrientation
;
1239 m_enablePaper
= data
.m_enablePaper
;
1240 m_enablePrinter
= data
.m_enablePrinter
;
1241 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
1242 m_enableHelp
= data
.m_enableHelp
;
1244 m_printData
= data
.m_printData
;
1249 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
1256 #if defined(__WIN95__)
1257 void wxPageSetupDialogData::ConvertToNative()
1259 m_printData
.ConvertToNative();
1261 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1263 if ( m_pageSetupData
== NULL
)
1265 pd
= new PAGESETUPDLG
;
1266 pd
->hDevMode
= NULL
;
1267 pd
->hDevNames
= NULL
;
1268 m_pageSetupData
= (void *)pd
;
1271 // Pass the devmode data (created in m_printData.ConvertToNative)
1272 // to the PRINTDLG structure, since it'll
1273 // be needed when PrintDlg is called.
1277 GlobalFree(pd
->hDevMode
);
1278 pd
->hDevMode
= NULL
;
1281 pd
->hDevMode
= (HGLOBAL
) m_printData
.GetNativeData();
1283 m_printData
.SetNativeData((void*) NULL
);
1285 // Shouldn't assert; we should be able to test Ok-ness at a higher level
1286 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
1288 // Pass the devnames data (created in m_printData.ConvertToNative)
1289 // to the PRINTDLG structure, since it'll
1290 // be needed when PrintDlg is called.
1294 GlobalFree(pd
->hDevNames
);
1295 pd
->hDevNames
= NULL
;
1298 pd
->hDevNames
= (HGLOBAL
) m_printData
.GetNativeDataDevNames();
1300 m_printData
.SetNativeDataDevNames((void*) NULL
);
1302 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
1304 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1306 if ( m_defaultMinMargins
)
1307 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
1308 if ( !m_enableMargins
)
1309 pd
->Flags
|= PSD_DISABLEMARGINS
;
1310 if ( !m_enableOrientation
)
1311 pd
->Flags
|= PSD_DISABLEORIENTATION
;
1312 if ( !m_enablePaper
)
1313 pd
->Flags
|= PSD_DISABLEPAPER
;
1314 if ( !m_enablePrinter
)
1315 pd
->Flags
|= PSD_DISABLEPRINTER
;
1316 if ( m_getDefaultInfo
)
1317 pd
->Flags
|= PSD_RETURNDEFAULT
;
1319 pd
->Flags
|= PSD_SHOWHELP
;
1321 // We want the units to be in hundredths of a millimetre
1322 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
1324 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
1325 pd
->hwndOwner
=(HWND
)NULL
;
1326 // pd->hDevNames=(HWND)NULL;
1327 pd
->hInstance
=(HINSTANCE
)NULL
;
1328 // PAGESETUPDLG is in hundreds of a mm
1329 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
1330 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
1332 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
1333 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
1334 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
1335 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
1337 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
1338 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
1339 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
1340 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
1343 pd
->lpfnPageSetupHook
= NULL
;
1344 pd
->lpfnPagePaintHook
= NULL
;
1345 pd
->hPageSetupTemplate
= NULL
;
1346 pd
->lpPageSetupTemplateName
= NULL
;
1351 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
1352 memset(devMode, 0, sizeof(DEVMODE));
1353 devMode->dmSize = sizeof(DEVMODE);
1354 devMode->dmOrientation = m_orientation;
1355 devMode->dmFields = DM_ORIENTATION;
1356 GlobalUnlock(pd->hDevMode);
1361 void wxPageSetupDialogData::ConvertFromNative()
1363 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1367 // Pass the devmode data back to the wxPrintData structure where it really belongs.
1370 if (m_printData
.GetNativeData())
1372 // Make sure we don't leak memory
1373 GlobalFree((HGLOBAL
) m_printData
.GetNativeData());
1375 m_printData
.SetNativeData((void*) pd
->hDevMode
);
1376 pd
->hDevMode
= NULL
;
1379 m_printData
.ConvertFromNative();
1381 // Pass the devnames data back to the wxPrintData structure where it really belongs.
1384 if (m_printData
.GetNativeDataDevNames())
1386 // Make sure we don't leak memory
1387 GlobalFree((HGLOBAL
) m_printData
.GetNativeDataDevNames());
1389 m_printData
.SetNativeDataDevNames((void*) pd
->hDevNames
);
1390 pd
->hDevNames
= NULL
;
1393 m_printData
.ConvertFromNative();
1395 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
1397 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
1398 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
1399 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
1400 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
1401 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
1402 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
1403 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
1405 // PAGESETUPDLG is in hundreds of a mm
1406 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
1407 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
1409 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
1410 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
1411 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
1412 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
1414 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
1415 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
1416 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
1417 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
1420 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
1422 if ( m_pageSetupData
== NULL
)
1425 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
1427 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
1428 pd
->hwndOwner
=(HWND
) win
->GetHWND();
1434 void wxPageSetupDialogData::ConvertToNative()
1436 m_printData
.ConvertToNative();
1437 // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
1440 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
= int( ((double) m_minMarginTopLeft
.x
)*mm2pt
);
1441 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
= int( ((double) m_minMarginTopLeft
.y
)*mm2pt
);
1443 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
)*mm2pt
);
1444 (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
)*mm2pt
);
1446 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.left
= 0;
1447 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.top
= 0;
1448 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
= int( ((double) m_paperSize
.x
- m_minMarginTopLeft
.x
- m_minMarginBottomRight
.x
)*mm2pt
);
1449 (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
= int( ((double) m_paperSize
.y
- m_minMarginTopLeft
.y
- m_minMarginBottomRight
.y
)*mm2pt
);
1453 void wxPageSetupDialogData::ConvertFromNative()
1455 m_printData
.ConvertFromNative ();
1459 m_paperSize
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1460 m_paperSize
.y
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1462 m_minMarginTopLeft
.x
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.left
) * pt2mm
;
1463 m_minMarginTopLeft
.y
= ((double) -(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.top
) * pt2mm
;
1465 m_minMarginBottomRight
.x
= ((double) (**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.right
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.right
) * pt2mm
;
1466 m_minMarginBottomRight
.y
= ((double)(**(THPrint
)m_printData
.m_macPrintSettings
).rPaper
.bottom
- (**(THPrint
)m_printData
.m_macPrintSettings
).prInfo
.rPage
.bottom
) * pt2mm
;
1468 // adjust minimal values
1469 //TODO add custom fields in dialog for margins
1471 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
1472 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
1474 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
1475 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
1477 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
1478 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
1480 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
1481 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
1486 // If a corresponding paper type is found in the paper database, will set the m_printData
1487 // paper size id member as well.
1488 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
1492 CalculateIdFromPaperSize();
1495 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
1496 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
1498 m_printData
.SetPaperId(id
);
1500 CalculatePaperSizeFromId();
1503 // Use paper size defined in this object to set the wxPrintData
1505 void wxPageSetupDialogData::CalculateIdFromPaperSize()
1507 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1508 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1510 wxSize sz
= GetPaperSize();
1512 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
1513 if (id
!= wxPAPER_NONE
)
1515 m_printData
.SetPaperId(id
);
1519 // Use paper id in wxPrintData to set this object's paper size
1520 void wxPageSetupDialogData::CalculatePaperSizeFromId()
1522 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
1523 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
1525 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
1527 // sz is in 10ths of a mm, while paper size is in mm
1528 m_paperSize
.x
= sz
.x
/ 10;
1529 m_paperSize
.y
= sz
.y
/ 10;
1532 #endif // wxUSE_PRINTING_ARCHITECTURE