1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common GDI data
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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"
41 #include "wx/prntbase.h"
42 #include "wx/printdlg.h"
45 #include "wx/fontdlg.h"
46 #endif // wxUSE_FONTDLG
48 #if wxUSE_PRINTING_ARCHITECTURE
50 #endif // wxUSE_PRINTING_ARCHITECTURE
52 #if defined(__WXMSW__) && !defined(__PALMOS__)
54 #include "wx/msw/private.h"
56 #ifndef __SMARTPHONE__ /* of WinCE */
60 #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__)
67 #include "wx/mac/private/print.h"
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 #define DMPAPER_USER 256
83 // ============================================================================
85 // ============================================================================
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
91 wxColourData::wxColourData()
94 m_dataColour
.Set(0,0,0);
95 // m_custColours are wxNullColours initially
98 wxColourData::wxColourData(const wxColourData
& data
)
104 wxColourData::~wxColourData()
108 void wxColourData::SetCustomColour(int i
, const wxColour
& colour
)
110 wxCHECK_RET( (i
>= 0 && i
< 16), _T("custom colour index out of range") );
112 m_custColours
[i
] = colour
;
115 wxColour
wxColourData::GetCustomColour(int i
)
117 wxCHECK_MSG( (i
>= 0 && i
< 16), wxColour(0,0,0),
118 _T("custom colour index out of range") );
120 return m_custColours
[i
];
123 void wxColourData::operator=(const wxColourData
& data
)
126 for (i
= 0; i
< 16; i
++)
127 m_custColours
[i
] = data
.m_custColours
[i
];
129 m_dataColour
= (wxColour
&)data
.m_dataColour
;
130 m_chooseFull
= data
.m_chooseFull
;
133 // ----------------------------------------------------------------------------
135 // ----------------------------------------------------------------------------
137 wxFontData::wxFontData()
139 // Intialize colour to black.
140 m_fontColour
= wxNullColour
;
143 m_allowSymbols
= true;
144 m_enableEffects
= true;
148 m_encoding
= wxFONTENCODING_SYSTEM
;
151 wxFontData::~wxFontData()
157 wxFontDialogBase::~wxFontDialogBase()
161 #endif // wxUSE_FONTDLG
163 #if wxUSE_PRINTING_ARCHITECTURE
164 // ----------------------------------------------------------------------------
166 // ----------------------------------------------------------------------------
168 wxPrintData::wxPrintData()
171 m_nativePrintData
= wxNativePrintData::Create() ;
173 m_bin
= wxPRINTBIN_DEFAULT
;
174 m_printMode
= wxPRINT_MODE_PRINTER
;
175 m_printOrientation
= wxPORTRAIT
;
177 m_printCollate
= false;
180 m_printerName
= wxT("");
182 m_duplexMode
= wxDUPLEX_SIMPLEX
;
183 m_printQuality
= wxPRINT_QUALITY_HIGH
;
184 m_paperId
= wxPAPER_A4
;
185 m_paperSize
= wxSize(210, 297);
187 m_nativeData
= wxPrintFactory::GetFactory()->CreatePrintNativeData();
190 wxPrintData::wxPrintData(const wxPrintData
& printData
)
196 wxPrintData::~wxPrintData()
198 m_nativeData
->m_ref
--;
199 if (m_nativeData
->m_ref
== 0)
203 delete m_nativePrintData
;
209 void wxPrintData::ConvertToNative()
211 m_nativePrintData
->TransferFrom( this ) ;
214 void wxPrintData::ConvertFromNative()
216 m_nativePrintData
->TransferTo( this ) ;
220 void wxPrintData::operator=(const wxPrintData
& data
)
222 m_printNoCopies
= data
.m_printNoCopies
;
223 m_printCollate
= data
.m_printCollate
;
224 m_printOrientation
= data
.m_printOrientation
;
225 m_printerName
= data
.m_printerName
;
226 m_colour
= data
.m_colour
;
227 m_duplexMode
= data
.m_duplexMode
;
228 m_printQuality
= data
.m_printQuality
;
229 m_paperId
= data
.m_paperId
;
230 m_paperSize
= data
.m_paperSize
;
232 m_printMode
= data
.m_printMode
;
234 m_nativeData
= data
.GetNativeData();
235 m_nativeData
->m_ref
++;
238 m_nativePrintData
->CopyFrom( data
.m_nativePrintData
) ;
242 // Is this data OK for showing the print dialog?
243 bool wxPrintData::Ok() const
245 m_nativeData
->TransferFrom( *this );
247 return m_nativeData
->Ok();
250 // ----------------------------------------------------------------------------
252 // ----------------------------------------------------------------------------
254 wxPrintDialogData::wxPrintDialogData()
257 m_printDlgData
= NULL
;
264 m_printAllPages
= false;
265 m_printCollate
= false;
266 m_printToFile
= false;
267 m_printSelection
= false;
268 m_printEnableSelection
= false;
269 m_printEnablePageNumbers
= true;
271 wxPrintFactory
* factory
= wxPrintFactory::GetFactory();
272 m_printEnablePrintToFile
= ! factory
->HasOwnPrintToFile();
274 m_printEnableHelp
= false;
275 m_printSetupDialog
= false;
278 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
282 m_printDlgData
= NULL
;
284 (*this) = dialogData
;
287 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
290 m_printDlgData
= NULL
;
295 m_printMaxPage
= 9999;
297 m_printAllPages
= false;
298 m_printCollate
= false;
299 m_printToFile
= false;
300 m_printSelection
= false;
301 m_printEnableSelection
= false;
302 m_printEnablePageNumbers
= true;
303 m_printEnablePrintToFile
= true;
304 m_printEnableHelp
= false;
305 m_printSetupDialog
= false;
307 m_printData
= printData
;
310 wxPrintDialogData::~wxPrintDialogData()
313 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
314 if ( pd
&& pd
->hDevMode
)
315 GlobalFree(pd
->hDevMode
);
322 void wxPrintDialogData::ConvertToNative()
324 wxWindowsPrintNativeData
*data
=
325 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
326 data
->TransferFrom( m_printData
);
328 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
333 memset( pd
, 0, sizeof(PRINTDLG
) );
334 m_printDlgData
= (void*) pd
;
336 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
338 pd
->lStructSize
= 66;
340 pd
->lStructSize
= sizeof(PRINTDLG
);
342 pd
->hwndOwner
= (HWND
)NULL
;
343 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
344 pd
->hDevNames
= NULL
; // Ditto
346 pd
->Flags
= PD_RETURNDEFAULT
;
350 // Pass the devmode data to the PRINTDLG structure, since it'll
351 // be needed when PrintDlg is called.
354 GlobalFree(pd
->hDevMode
);
357 // Pass the devnames data to the PRINTDLG structure, since it'll
358 // be needed when PrintDlg is called.
361 GlobalFree(pd
->hDevNames
);
364 pd
->hDevMode
= (HGLOBAL
)(DWORD
) data
->GetDevMode();
366 data
->SetDevMode( (void*) NULL
);
368 // Shouldn't assert; we should be able to test Ok-ness at a higher level
369 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
371 pd
->hDevNames
= (HGLOBAL
)(DWORD
) data
->GetDevNames();
373 data
->SetDevNames( (void*) NULL
);
375 pd
->hDC
= (HDC
) NULL
;
376 pd
->nFromPage
= (WORD
)m_printFromPage
;
377 pd
->nToPage
= (WORD
)m_printToPage
;
378 pd
->nMinPage
= (WORD
)m_printMinPage
;
379 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
380 pd
->nCopies
= (WORD
)m_printNoCopies
;
382 pd
->Flags
= PD_RETURNDC
;
385 pd
->lStructSize
= 66;
387 pd
->lStructSize
= sizeof( PRINTDLG
);
390 pd
->hwndOwner
=(HWND
)NULL
;
391 // pd->hDevNames=(HANDLE)NULL;
392 pd
->hInstance
=(HINSTANCE
)NULL
;
393 pd
->lCustData
= (LPARAM
) NULL
;
394 pd
->lpfnPrintHook
= NULL
;
395 pd
->lpfnSetupHook
= NULL
;
396 pd
->lpPrintTemplateName
= NULL
;
397 pd
->lpSetupTemplateName
= NULL
;
398 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
399 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
401 if ( m_printAllPages
)
402 pd
->Flags
|= PD_ALLPAGES
;
403 if ( m_printSelection
)
404 pd
->Flags
|= PD_SELECTION
;
405 if ( m_printCollate
)
406 pd
->Flags
|= PD_COLLATE
;
408 pd
->Flags
|= PD_PRINTTOFILE
;
409 if ( !m_printEnablePrintToFile
)
410 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
411 if ( !m_printEnableSelection
)
412 pd
->Flags
|= PD_NOSELECTION
;
413 if ( !m_printEnablePageNumbers
)
414 pd
->Flags
|= PD_NOPAGENUMS
;
415 else if ( (!m_printAllPages
) && (!m_printSelection
) && (m_printFromPage
!= 0) && (m_printToPage
!= 0))
416 pd
->Flags
|= PD_PAGENUMS
;
417 if ( m_printEnableHelp
)
418 pd
->Flags
|= PD_SHOWHELP
;
419 if ( m_printSetupDialog
)
420 pd
->Flags
|= PD_PRINTSETUP
;
423 void wxPrintDialogData::ConvertFromNative()
425 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
429 wxWindowsPrintNativeData
*data
=
430 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
432 // Pass the devmode data back to the wxPrintData structure where it really belongs.
435 if (data
->GetDevMode())
437 // Make sure we don't leak memory
438 GlobalFree( (HGLOBAL
)(DWORD
) data
->GetDevMode() );
440 data
->SetDevMode( (void*)(long) pd
->hDevMode
);
444 // Pass the devnames data back to the wxPrintData structure where it really belongs.
447 if (data
->GetDevNames())
449 // Make sure we don't leak memory
450 GlobalFree((HGLOBAL
)(DWORD
) data
->GetDevNames());
452 data
->SetDevNames((void*)(long) pd
->hDevNames
);
453 pd
->hDevNames
= NULL
;
456 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
457 // into wxWidgets form.
458 data
->TransferTo( m_printData
);
460 m_printFromPage
= pd
->nFromPage
;
461 m_printToPage
= pd
->nToPage
;
462 m_printMinPage
= pd
->nMinPage
;
463 m_printMaxPage
= pd
->nMaxPage
;
464 m_printNoCopies
= pd
->nCopies
;
466 m_printAllPages
= (((pd
->Flags
& PD_PAGENUMS
) != PD_PAGENUMS
) && ((pd
->Flags
& PD_SELECTION
) != PD_SELECTION
));
467 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
468 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
469 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
470 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
471 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
472 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
473 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
474 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
476 /* port is obsolete in WIN32
480 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
482 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
483 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
484 GlobalUnlock(pd->hDevNames);
486 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
492 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
494 if ( m_printDlgData
== NULL
)
497 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
499 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
500 pd
->hwndOwner
=(HWND
) win
->GetHWND();
507 void wxPrintDialogData::ConvertToNative()
509 m_printData
.ConvertToNative();
510 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
513 void wxPrintDialogData::ConvertFromNative()
515 m_printData
.ConvertFromNative();
516 m_printData
.m_nativePrintData
->TransferTo( this ) ;
522 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
524 m_printFromPage
= data
.m_printFromPage
;
525 m_printToPage
= data
.m_printToPage
;
526 m_printMinPage
= data
.m_printMinPage
;
527 m_printMaxPage
= data
.m_printMaxPage
;
528 m_printNoCopies
= data
.m_printNoCopies
;
529 m_printAllPages
= data
.m_printAllPages
;
530 m_printCollate
= data
.m_printCollate
;
531 m_printToFile
= data
.m_printToFile
;
532 m_printSelection
= data
.m_printSelection
;
533 m_printEnableSelection
= data
.m_printEnableSelection
;
534 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
535 m_printEnableHelp
= data
.m_printEnableHelp
;
536 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
537 m_printSetupDialog
= data
.m_printSetupDialog
;
539 m_printData
= data
.m_printData
;
542 void wxPrintDialogData::operator=(const wxPrintData
& data
)
547 // ----------------------------------------------------------------------------
548 // wxPageSetupDialogData
549 // ----------------------------------------------------------------------------
551 wxPageSetupDialogData::wxPageSetupDialogData()
553 #if defined(__WIN95__)
554 m_pageSetupData
= NULL
;
556 m_paperSize
= wxSize(0, 0);
558 CalculatePaperSizeFromId();
560 m_minMarginTopLeft
= wxPoint(0, 0);
561 m_minMarginBottomRight
= wxPoint(0, 0);
562 m_marginTopLeft
= wxPoint(0, 0);
563 m_marginBottomRight
= wxPoint(0, 0);
566 m_defaultMinMargins
= false;
567 m_enableMargins
= true;
568 m_enableOrientation
= true;
569 m_enablePaper
= true;
570 m_enablePrinter
= true;
571 m_enableHelp
= false;
572 m_getDefaultInfo
= false;
575 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
578 #if defined(__WIN95__)
579 m_pageSetupData
= NULL
;
581 (*this) = dialogData
;
584 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
586 #if defined(__WIN95__)
587 m_pageSetupData
= NULL
;
589 m_paperSize
= wxSize(0, 0);
590 m_minMarginTopLeft
= wxPoint(0, 0);
591 m_minMarginBottomRight
= wxPoint(0, 0);
592 m_marginTopLeft
= wxPoint(0, 0);
593 m_marginBottomRight
= wxPoint(0, 0);
596 m_defaultMinMargins
= false;
597 m_enableMargins
= true;
598 m_enableOrientation
= true;
599 m_enablePaper
= true;
600 m_enablePrinter
= true;
601 m_enableHelp
= false;
602 m_getDefaultInfo
= false;
604 m_printData
= printData
;
606 // The wxPrintData paper size overrides these values, unless the size cannot
608 CalculatePaperSizeFromId();
611 wxPageSetupDialogData::~wxPageSetupDialogData()
613 #if defined(__WIN95__) && defined(__WXMSW__)
614 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
615 if ( pd
&& pd
->hDevMode
)
616 GlobalFree(pd
->hDevMode
);
617 if ( pd
&& pd
->hDevNames
)
618 GlobalFree(pd
->hDevNames
);
624 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
626 m_paperSize
= data
.m_paperSize
;
627 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
628 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
629 m_marginTopLeft
= data
.m_marginTopLeft
;
630 m_marginBottomRight
= data
.m_marginBottomRight
;
631 m_defaultMinMargins
= data
.m_defaultMinMargins
;
632 m_enableMargins
= data
.m_enableMargins
;
633 m_enableOrientation
= data
.m_enableOrientation
;
634 m_enablePaper
= data
.m_enablePaper
;
635 m_enablePrinter
= data
.m_enablePrinter
;
636 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
637 m_enableHelp
= data
.m_enableHelp
;
639 m_printData
= data
.m_printData
;
644 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
651 #if defined(__WIN95__)
652 void wxPageSetupDialogData::ConvertToNative()
654 wxWindowsPrintNativeData
*data
=
655 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
656 data
->TransferFrom( m_printData
);
658 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
660 if ( m_pageSetupData
== NULL
)
662 pd
= new PAGESETUPDLG
;
664 pd
->hDevNames
= NULL
;
665 m_pageSetupData
= (void *)pd
;
668 // Pass the devmode data (created in m_printData.ConvertToNative)
669 // to the PRINTDLG structure, since it'll
670 // be needed when PrintDlg is called.
674 GlobalFree(pd
->hDevMode
);
678 pd
->hDevMode
= (HGLOBAL
) data
->GetDevMode();
680 data
->SetDevMode( (void*) NULL
);
682 // Shouldn't assert; we should be able to test Ok-ness at a higher level
683 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
685 // Pass the devnames data (created in m_printData.ConvertToNative)
686 // to the PRINTDLG structure, since it'll
687 // be needed when PrintDlg is called.
691 GlobalFree(pd
->hDevNames
);
692 pd
->hDevNames
= NULL
;
695 pd
->hDevNames
= (HGLOBAL
) data
->GetDevNames();
697 data
->SetDevNames((void*) NULL
);
699 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
701 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
703 if ( m_defaultMinMargins
)
704 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
705 if ( !m_enableMargins
)
706 pd
->Flags
|= PSD_DISABLEMARGINS
;
707 if ( !m_enableOrientation
)
708 pd
->Flags
|= PSD_DISABLEORIENTATION
;
709 if ( !m_enablePaper
)
710 pd
->Flags
|= PSD_DISABLEPAPER
;
711 if ( !m_enablePrinter
)
712 pd
->Flags
|= PSD_DISABLEPRINTER
;
713 if ( m_getDefaultInfo
)
714 pd
->Flags
|= PSD_RETURNDEFAULT
;
716 pd
->Flags
|= PSD_SHOWHELP
;
718 // We want the units to be in hundredths of a millimetre
719 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
721 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
722 pd
->hwndOwner
=(HWND
)NULL
;
723 // pd->hDevNames=(HWND)NULL;
724 pd
->hInstance
=(HINSTANCE
)NULL
;
725 // PAGESETUPDLG is in hundreds of a mm
726 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
727 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
729 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
730 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
731 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
732 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
734 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
735 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
736 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
737 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
740 pd
->lpfnPageSetupHook
= NULL
;
741 pd
->lpfnPagePaintHook
= NULL
;
742 pd
->hPageSetupTemplate
= NULL
;
743 pd
->lpPageSetupTemplateName
= NULL
;
748 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
749 memset(devMode, 0, sizeof(DEVMODE));
750 devMode->dmSize = sizeof(DEVMODE);
751 devMode->dmOrientation = m_orientation;
752 devMode->dmFields = DM_ORIENTATION;
753 GlobalUnlock(pd->hDevMode);
758 void wxPageSetupDialogData::ConvertFromNative()
760 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
764 wxWindowsPrintNativeData
*data
=
765 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
767 // Pass the devmode data back to the wxPrintData structure where it really belongs.
770 if (data
->GetDevMode())
772 // Make sure we don't leak memory
773 GlobalFree((HGLOBAL
) data
->GetDevMode());
775 data
->SetDevMode( (void*) pd
->hDevMode
);
779 data
->TransferTo( m_printData
);
781 // Pass the devnames data back to the wxPrintData structure where it really belongs.
784 if (data
->GetDevNames())
786 // Make sure we don't leak memory
787 GlobalFree((HGLOBAL
) data
->GetDevNames());
789 data
->SetDevNames((void*) pd
->hDevNames
);
790 pd
->hDevNames
= NULL
;
793 data
->TransferTo( m_printData
);
795 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
797 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
798 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
799 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
800 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
801 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
802 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
803 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
805 // PAGESETUPDLG is in hundreds of a mm
806 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
807 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
809 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
810 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
811 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
812 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
814 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
815 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
816 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
817 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
820 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
822 if ( m_pageSetupData
== NULL
)
825 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
827 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
828 pd
->hwndOwner
=(HWND
) win
->GetHWND();
834 void wxPageSetupDialogData::ConvertToNative()
836 m_printData
.ConvertToNative();
837 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
840 void wxPageSetupDialogData::ConvertFromNative()
842 m_printData
.ConvertFromNative ();
843 m_paperSize
= m_printData
.GetPaperSize() ;
844 CalculateIdFromPaperSize();
845 m_printData
.m_nativePrintData
->TransferTo( this ) ;
846 // adjust minimal values
848 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
849 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
851 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
852 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
854 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
855 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
857 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
858 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
863 // If a corresponding paper type is found in the paper database, will set the m_printData
864 // paper size id member as well.
865 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
869 CalculateIdFromPaperSize();
872 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
873 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
875 m_printData
.SetPaperId(id
);
877 CalculatePaperSizeFromId();
880 // Use paper size defined in this object to set the wxPrintData
882 void wxPageSetupDialogData::CalculateIdFromPaperSize()
884 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
885 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
887 wxSize sz
= GetPaperSize();
889 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
890 if (id
!= wxPAPER_NONE
)
892 m_printData
.SetPaperId(id
);
896 // Use paper id in wxPrintData to set this object's paper size
897 void wxPageSetupDialogData::CalculatePaperSizeFromId()
899 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
900 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
902 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
904 // sz is in 10ths of a mm, while paper size is in mm
905 m_paperSize
.x
= sz
.x
/ 10;
906 m_paperSize
.y
= sz
.y
/ 10;
909 #endif // wxUSE_PRINTING_ARCHITECTURE