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
;
233 m_filename
= data
.m_filename
;
235 m_nativeData
= data
.GetNativeData();
236 m_nativeData
->m_ref
++;
239 m_nativePrintData
->CopyFrom( data
.m_nativePrintData
) ;
243 // Is this data OK for showing the print dialog?
244 bool wxPrintData::Ok() const
246 m_nativeData
->TransferFrom( *this );
248 return m_nativeData
->Ok();
251 // ----------------------------------------------------------------------------
253 // ----------------------------------------------------------------------------
255 wxPrintDialogData::wxPrintDialogData()
258 m_printDlgData
= NULL
;
265 m_printAllPages
= false;
266 m_printCollate
= false;
267 m_printToFile
= false;
268 m_printSelection
= false;
269 m_printEnableSelection
= false;
270 m_printEnablePageNumbers
= true;
272 wxPrintFactory
* factory
= wxPrintFactory::GetFactory();
273 m_printEnablePrintToFile
= ! factory
->HasOwnPrintToFile();
275 m_printEnableHelp
= false;
276 m_printSetupDialog
= false;
279 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
283 m_printDlgData
= NULL
;
285 (*this) = dialogData
;
288 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
291 m_printDlgData
= NULL
;
296 m_printMaxPage
= 9999;
298 m_printAllPages
= false;
299 m_printCollate
= false;
300 m_printToFile
= false;
301 m_printSelection
= false;
302 m_printEnableSelection
= false;
303 m_printEnablePageNumbers
= true;
304 m_printEnablePrintToFile
= true;
305 m_printEnableHelp
= false;
306 m_printSetupDialog
= false;
308 m_printData
= printData
;
311 wxPrintDialogData::~wxPrintDialogData()
314 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
315 if ( pd
&& pd
->hDevMode
)
316 GlobalFree(pd
->hDevMode
);
323 void wxPrintDialogData::ConvertToNative()
325 wxWindowsPrintNativeData
*data
=
326 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
327 data
->TransferFrom( m_printData
);
329 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
334 memset( pd
, 0, sizeof(PRINTDLG
) );
335 m_printDlgData
= (void*) pd
;
337 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
339 pd
->lStructSize
= 66;
341 pd
->lStructSize
= sizeof(PRINTDLG
);
343 pd
->hwndOwner
= (HWND
)NULL
;
344 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
345 pd
->hDevNames
= NULL
; // Ditto
347 pd
->Flags
= PD_RETURNDEFAULT
;
351 // Pass the devmode data to the PRINTDLG structure, since it'll
352 // be needed when PrintDlg is called.
355 GlobalFree(pd
->hDevMode
);
358 // Pass the devnames data to the PRINTDLG structure, since it'll
359 // be needed when PrintDlg is called.
362 GlobalFree(pd
->hDevNames
);
365 pd
->hDevMode
= (HGLOBAL
)(DWORD
) data
->GetDevMode();
367 data
->SetDevMode( (void*) NULL
);
369 // Shouldn't assert; we should be able to test Ok-ness at a higher level
370 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
372 pd
->hDevNames
= (HGLOBAL
)(DWORD
) data
->GetDevNames();
374 data
->SetDevNames( (void*) NULL
);
376 pd
->hDC
= (HDC
) NULL
;
377 pd
->nFromPage
= (WORD
)m_printFromPage
;
378 pd
->nToPage
= (WORD
)m_printToPage
;
379 pd
->nMinPage
= (WORD
)m_printMinPage
;
380 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
381 pd
->nCopies
= (WORD
)m_printNoCopies
;
383 pd
->Flags
= PD_RETURNDC
;
386 pd
->lStructSize
= 66;
388 pd
->lStructSize
= sizeof( PRINTDLG
);
391 pd
->hwndOwner
=(HWND
)NULL
;
392 // pd->hDevNames=(HANDLE)NULL;
393 pd
->hInstance
=(HINSTANCE
)NULL
;
394 pd
->lCustData
= (LPARAM
) NULL
;
395 pd
->lpfnPrintHook
= NULL
;
396 pd
->lpfnSetupHook
= NULL
;
397 pd
->lpPrintTemplateName
= NULL
;
398 pd
->lpSetupTemplateName
= NULL
;
399 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
400 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
402 if ( m_printAllPages
)
403 pd
->Flags
|= PD_ALLPAGES
;
404 if ( m_printSelection
)
405 pd
->Flags
|= PD_SELECTION
;
406 if ( m_printCollate
)
407 pd
->Flags
|= PD_COLLATE
;
409 pd
->Flags
|= PD_PRINTTOFILE
;
410 if ( !m_printEnablePrintToFile
)
411 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
412 if ( !m_printEnableSelection
)
413 pd
->Flags
|= PD_NOSELECTION
;
414 if ( !m_printEnablePageNumbers
)
415 pd
->Flags
|= PD_NOPAGENUMS
;
416 else if ( (!m_printAllPages
) && (!m_printSelection
) && (m_printFromPage
!= 0) && (m_printToPage
!= 0))
417 pd
->Flags
|= PD_PAGENUMS
;
418 if ( m_printEnableHelp
)
419 pd
->Flags
|= PD_SHOWHELP
;
420 if ( m_printSetupDialog
)
421 pd
->Flags
|= PD_PRINTSETUP
;
424 void wxPrintDialogData::ConvertFromNative()
426 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
430 wxWindowsPrintNativeData
*data
=
431 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
433 // Pass the devmode data back to the wxPrintData structure where it really belongs.
436 if (data
->GetDevMode())
438 // Make sure we don't leak memory
439 GlobalFree( (HGLOBAL
)(DWORD
) data
->GetDevMode() );
441 data
->SetDevMode( (void*)(long) pd
->hDevMode
);
445 // Pass the devnames data back to the wxPrintData structure where it really belongs.
448 if (data
->GetDevNames())
450 // Make sure we don't leak memory
451 GlobalFree((HGLOBAL
)(DWORD
) data
->GetDevNames());
453 data
->SetDevNames((void*)(long) pd
->hDevNames
);
454 pd
->hDevNames
= NULL
;
457 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
458 // into wxWidgets form.
459 data
->TransferTo( m_printData
);
461 m_printFromPage
= pd
->nFromPage
;
462 m_printToPage
= pd
->nToPage
;
463 m_printMinPage
= pd
->nMinPage
;
464 m_printMaxPage
= pd
->nMaxPage
;
465 m_printNoCopies
= pd
->nCopies
;
467 m_printAllPages
= (((pd
->Flags
& PD_PAGENUMS
) != PD_PAGENUMS
) && ((pd
->Flags
& PD_SELECTION
) != PD_SELECTION
));
468 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
469 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
470 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
471 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
472 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
473 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
474 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
475 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
477 /* port is obsolete in WIN32
481 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
483 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
484 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
485 GlobalUnlock(pd->hDevNames);
487 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
493 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
495 if ( m_printDlgData
== NULL
)
498 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
500 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
501 pd
->hwndOwner
=(HWND
) win
->GetHWND();
508 void wxPrintDialogData::ConvertToNative()
510 m_printData
.ConvertToNative();
511 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
514 void wxPrintDialogData::ConvertFromNative()
516 m_printData
.ConvertFromNative();
517 m_printData
.m_nativePrintData
->TransferTo( this ) ;
523 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
525 m_printFromPage
= data
.m_printFromPage
;
526 m_printToPage
= data
.m_printToPage
;
527 m_printMinPage
= data
.m_printMinPage
;
528 m_printMaxPage
= data
.m_printMaxPage
;
529 m_printNoCopies
= data
.m_printNoCopies
;
530 m_printAllPages
= data
.m_printAllPages
;
531 m_printCollate
= data
.m_printCollate
;
532 m_printToFile
= data
.m_printToFile
;
533 m_printSelection
= data
.m_printSelection
;
534 m_printEnableSelection
= data
.m_printEnableSelection
;
535 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
536 m_printEnableHelp
= data
.m_printEnableHelp
;
537 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
538 m_printSetupDialog
= data
.m_printSetupDialog
;
540 m_printData
= data
.m_printData
;
543 void wxPrintDialogData::operator=(const wxPrintData
& data
)
548 // ----------------------------------------------------------------------------
549 // wxPageSetupDialogData
550 // ----------------------------------------------------------------------------
552 wxPageSetupDialogData::wxPageSetupDialogData()
554 #if defined(__WIN95__)
555 m_pageSetupData
= NULL
;
557 m_paperSize
= wxSize(0, 0);
559 CalculatePaperSizeFromId();
561 m_minMarginTopLeft
= wxPoint(0, 0);
562 m_minMarginBottomRight
= wxPoint(0, 0);
563 m_marginTopLeft
= wxPoint(0, 0);
564 m_marginBottomRight
= wxPoint(0, 0);
567 m_defaultMinMargins
= false;
568 m_enableMargins
= true;
569 m_enableOrientation
= true;
570 m_enablePaper
= true;
571 m_enablePrinter
= true;
572 m_enableHelp
= false;
573 m_getDefaultInfo
= false;
576 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
579 #if defined(__WIN95__)
580 m_pageSetupData
= NULL
;
582 (*this) = dialogData
;
585 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
587 #if defined(__WIN95__)
588 m_pageSetupData
= NULL
;
590 m_paperSize
= wxSize(0, 0);
591 m_minMarginTopLeft
= wxPoint(0, 0);
592 m_minMarginBottomRight
= wxPoint(0, 0);
593 m_marginTopLeft
= wxPoint(0, 0);
594 m_marginBottomRight
= wxPoint(0, 0);
597 m_defaultMinMargins
= false;
598 m_enableMargins
= true;
599 m_enableOrientation
= true;
600 m_enablePaper
= true;
601 m_enablePrinter
= true;
602 m_enableHelp
= false;
603 m_getDefaultInfo
= false;
605 m_printData
= printData
;
607 // The wxPrintData paper size overrides these values, unless the size cannot
609 CalculatePaperSizeFromId();
612 wxPageSetupDialogData::~wxPageSetupDialogData()
614 #if defined(__WIN95__) && defined(__WXMSW__)
615 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
616 if ( pd
&& pd
->hDevMode
)
617 GlobalFree(pd
->hDevMode
);
618 if ( pd
&& pd
->hDevNames
)
619 GlobalFree(pd
->hDevNames
);
625 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
627 m_paperSize
= data
.m_paperSize
;
628 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
629 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
630 m_marginTopLeft
= data
.m_marginTopLeft
;
631 m_marginBottomRight
= data
.m_marginBottomRight
;
632 m_defaultMinMargins
= data
.m_defaultMinMargins
;
633 m_enableMargins
= data
.m_enableMargins
;
634 m_enableOrientation
= data
.m_enableOrientation
;
635 m_enablePaper
= data
.m_enablePaper
;
636 m_enablePrinter
= data
.m_enablePrinter
;
637 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
638 m_enableHelp
= data
.m_enableHelp
;
640 m_printData
= data
.m_printData
;
645 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
652 #if defined(__WIN95__)
653 void wxPageSetupDialogData::ConvertToNative()
655 wxWindowsPrintNativeData
*data
=
656 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
657 data
->TransferFrom( m_printData
);
659 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
661 if ( m_pageSetupData
== NULL
)
663 pd
= new PAGESETUPDLG
;
665 pd
->hDevNames
= NULL
;
666 m_pageSetupData
= (void *)pd
;
669 // Pass the devmode data (created in m_printData.ConvertToNative)
670 // to the PRINTDLG structure, since it'll
671 // be needed when PrintDlg is called.
675 GlobalFree(pd
->hDevMode
);
679 pd
->hDevMode
= (HGLOBAL
) data
->GetDevMode();
681 data
->SetDevMode( (void*) NULL
);
683 // Shouldn't assert; we should be able to test Ok-ness at a higher level
684 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
686 // Pass the devnames data (created in m_printData.ConvertToNative)
687 // to the PRINTDLG structure, since it'll
688 // be needed when PrintDlg is called.
692 GlobalFree(pd
->hDevNames
);
693 pd
->hDevNames
= NULL
;
696 pd
->hDevNames
= (HGLOBAL
) data
->GetDevNames();
698 data
->SetDevNames((void*) NULL
);
700 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
702 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
704 if ( m_defaultMinMargins
)
705 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
706 if ( !m_enableMargins
)
707 pd
->Flags
|= PSD_DISABLEMARGINS
;
708 if ( !m_enableOrientation
)
709 pd
->Flags
|= PSD_DISABLEORIENTATION
;
710 if ( !m_enablePaper
)
711 pd
->Flags
|= PSD_DISABLEPAPER
;
712 if ( !m_enablePrinter
)
713 pd
->Flags
|= PSD_DISABLEPRINTER
;
714 if ( m_getDefaultInfo
)
715 pd
->Flags
|= PSD_RETURNDEFAULT
;
717 pd
->Flags
|= PSD_SHOWHELP
;
719 // We want the units to be in hundredths of a millimetre
720 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
722 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
723 pd
->hwndOwner
=(HWND
)NULL
;
724 // pd->hDevNames=(HWND)NULL;
725 pd
->hInstance
=(HINSTANCE
)NULL
;
726 // PAGESETUPDLG is in hundreds of a mm
727 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
728 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
730 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
731 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
732 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
733 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
735 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
736 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
737 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
738 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
741 pd
->lpfnPageSetupHook
= NULL
;
742 pd
->lpfnPagePaintHook
= NULL
;
743 pd
->hPageSetupTemplate
= NULL
;
744 pd
->lpPageSetupTemplateName
= NULL
;
749 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
750 memset(devMode, 0, sizeof(DEVMODE));
751 devMode->dmSize = sizeof(DEVMODE);
752 devMode->dmOrientation = m_orientation;
753 devMode->dmFields = DM_ORIENTATION;
754 GlobalUnlock(pd->hDevMode);
759 void wxPageSetupDialogData::ConvertFromNative()
761 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
765 wxWindowsPrintNativeData
*data
=
766 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
768 // Pass the devmode data back to the wxPrintData structure where it really belongs.
771 if (data
->GetDevMode())
773 // Make sure we don't leak memory
774 GlobalFree((HGLOBAL
) data
->GetDevMode());
776 data
->SetDevMode( (void*) pd
->hDevMode
);
780 data
->TransferTo( m_printData
);
782 // Pass the devnames data back to the wxPrintData structure where it really belongs.
785 if (data
->GetDevNames())
787 // Make sure we don't leak memory
788 GlobalFree((HGLOBAL
) data
->GetDevNames());
790 data
->SetDevNames((void*) pd
->hDevNames
);
791 pd
->hDevNames
= NULL
;
794 data
->TransferTo( m_printData
);
796 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
798 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
799 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
800 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
801 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
802 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
803 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
804 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
806 // PAGESETUPDLG is in hundreds of a mm
807 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
808 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
810 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
811 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
812 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
813 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
815 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
816 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
817 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
818 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
821 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
823 if ( m_pageSetupData
== NULL
)
826 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
828 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
829 pd
->hwndOwner
=(HWND
) win
->GetHWND();
835 void wxPageSetupDialogData::ConvertToNative()
837 m_printData
.ConvertToNative();
838 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
841 void wxPageSetupDialogData::ConvertFromNative()
843 m_printData
.ConvertFromNative ();
844 m_paperSize
= m_printData
.GetPaperSize() ;
845 CalculateIdFromPaperSize();
846 m_printData
.m_nativePrintData
->TransferTo( this ) ;
847 // adjust minimal values
849 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
850 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
852 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
853 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
855 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
856 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
858 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
859 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
864 // If a corresponding paper type is found in the paper database, will set the m_printData
865 // paper size id member as well.
866 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
870 CalculateIdFromPaperSize();
873 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
874 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
876 m_printData
.SetPaperId(id
);
878 CalculatePaperSizeFromId();
881 // Use paper size defined in this object to set the wxPrintData
883 void wxPageSetupDialogData::CalculateIdFromPaperSize()
885 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
886 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
888 wxSize sz
= GetPaperSize();
890 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
891 if (id
!= wxPAPER_NONE
)
893 m_printData
.SetPaperId(id
);
897 // Use paper id in wxPrintData to set this object's paper size
898 void wxPageSetupDialogData::CalculatePaperSizeFromId()
900 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
901 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
903 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
905 // sz is in 10ths of a mm, while paper size is in mm
906 m_paperSize
.x
= sz
.x
/ 10;
907 m_paperSize
.y
= sz
.y
/ 10;
910 #endif // wxUSE_PRINTING_ARCHITECTURE