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_printOrientation
= wxPORTRAIT
;
176 m_printCollate
= false;
179 m_printerName
= wxT("");
181 m_duplexMode
= wxDUPLEX_SIMPLEX
;
182 m_printQuality
= wxPRINT_QUALITY_HIGH
;
183 m_paperId
= wxPAPER_A4
;
184 m_paperSize
= wxSize(210, 297);
186 m_nativeData
= wxPrintFactory::GetFactory()->CreatePrintNativeData();
189 wxPrintData::wxPrintData(const wxPrintData
& printData
)
195 wxPrintData::~wxPrintData()
197 m_nativeData
->m_ref
--;
198 if (m_nativeData
->m_ref
== 0)
202 delete m_nativePrintData
;
208 void wxPrintData::ConvertToNative()
210 m_nativePrintData
->TransferFrom( this ) ;
213 void wxPrintData::ConvertFromNative()
215 m_nativePrintData
->TransferTo( this ) ;
219 void wxPrintData::operator=(const wxPrintData
& data
)
221 m_printNoCopies
= data
.m_printNoCopies
;
222 m_printCollate
= data
.m_printCollate
;
223 m_printOrientation
= data
.m_printOrientation
;
224 m_printerName
= data
.m_printerName
;
225 m_colour
= data
.m_colour
;
226 m_duplexMode
= data
.m_duplexMode
;
227 m_printQuality
= data
.m_printQuality
;
228 m_paperId
= data
.m_paperId
;
229 m_paperSize
= data
.m_paperSize
;
232 m_nativeData
= data
.GetNativeData();
233 m_nativeData
->m_ref
++;
236 m_nativePrintData
->CopyFrom( data
.m_nativePrintData
) ;
240 // Is this data OK for showing the print dialog?
241 bool wxPrintData::Ok() const
243 m_nativeData
->TransferFrom( *this );
245 return m_nativeData
->Ok();
248 // ----------------------------------------------------------------------------
250 // ----------------------------------------------------------------------------
252 wxPrintDialogData::wxPrintDialogData()
255 m_printDlgData
= NULL
;
262 m_printAllPages
= false;
263 m_printCollate
= false;
264 m_printToFile
= false;
265 m_printSelection
= false;
266 m_printEnableSelection
= false;
267 m_printEnablePageNumbers
= true;
268 m_printEnablePrintToFile
= true;
269 m_printEnableHelp
= false;
270 m_printSetupDialog
= false;
273 wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData
& dialogData
)
277 m_printDlgData
= NULL
;
279 (*this) = dialogData
;
282 wxPrintDialogData::wxPrintDialogData(const wxPrintData
& printData
)
285 m_printDlgData
= NULL
;
290 m_printMaxPage
= 9999;
292 m_printAllPages
= false;
293 m_printCollate
= false;
294 m_printToFile
= false;
295 m_printSelection
= false;
296 m_printEnableSelection
= false;
297 m_printEnablePageNumbers
= true;
298 m_printEnablePrintToFile
= true;
299 m_printEnableHelp
= false;
300 m_printSetupDialog
= false;
302 m_printData
= printData
;
305 wxPrintDialogData::~wxPrintDialogData()
308 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
309 if ( pd
&& pd
->hDevMode
)
310 GlobalFree(pd
->hDevMode
);
317 void wxPrintDialogData::ConvertToNative()
319 wxWindowsPrintNativeData
*data
=
320 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
321 data
->TransferFrom( m_printData
);
323 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
328 memset( pd
, 0, sizeof(PRINTDLG
) );
329 m_printDlgData
= (void*) pd
;
331 // GNU-WIN32 has the wrong size PRINTDLG - can't work out why.
333 pd
->lStructSize
= 66;
335 pd
->lStructSize
= sizeof(PRINTDLG
);
337 pd
->hwndOwner
= (HWND
)NULL
;
338 pd
->hDevMode
= NULL
; // Will be created by PrintDlg
339 pd
->hDevNames
= NULL
; // Ditto
341 pd
->Flags
= PD_RETURNDEFAULT
;
345 // Pass the devmode data to the PRINTDLG structure, since it'll
346 // be needed when PrintDlg is called.
349 GlobalFree(pd
->hDevMode
);
352 // Pass the devnames data to the PRINTDLG structure, since it'll
353 // be needed when PrintDlg is called.
356 GlobalFree(pd
->hDevNames
);
359 pd
->hDevMode
= (HGLOBAL
)(DWORD
) data
->GetDevMode();
361 data
->SetDevMode( (void*) NULL
);
363 // Shouldn't assert; we should be able to test Ok-ness at a higher level
364 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
366 pd
->hDevNames
= (HGLOBAL
)(DWORD
) data
->GetDevNames();
368 data
->SetDevNames( (void*) NULL
);
370 pd
->hDC
= (HDC
) NULL
;
371 pd
->nFromPage
= (WORD
)m_printFromPage
;
372 pd
->nToPage
= (WORD
)m_printToPage
;
373 pd
->nMinPage
= (WORD
)m_printMinPage
;
374 pd
->nMaxPage
= (WORD
)m_printMaxPage
;
375 pd
->nCopies
= (WORD
)m_printNoCopies
;
377 pd
->Flags
= PD_RETURNDC
;
380 pd
->lStructSize
= 66;
382 pd
->lStructSize
= sizeof( PRINTDLG
);
385 pd
->hwndOwner
=(HWND
)NULL
;
386 // pd->hDevNames=(HANDLE)NULL;
387 pd
->hInstance
=(HINSTANCE
)NULL
;
388 pd
->lCustData
= (LPARAM
) NULL
;
389 pd
->lpfnPrintHook
= NULL
;
390 pd
->lpfnSetupHook
= NULL
;
391 pd
->lpPrintTemplateName
= NULL
;
392 pd
->lpSetupTemplateName
= NULL
;
393 pd
->hPrintTemplate
= (HGLOBAL
) NULL
;
394 pd
->hSetupTemplate
= (HGLOBAL
) NULL
;
396 if ( m_printAllPages
)
397 pd
->Flags
|= PD_ALLPAGES
;
398 if ( m_printSelection
)
399 pd
->Flags
|= PD_SELECTION
;
400 if ( m_printCollate
)
401 pd
->Flags
|= PD_COLLATE
;
403 pd
->Flags
|= PD_PRINTTOFILE
;
404 if ( !m_printEnablePrintToFile
)
405 pd
->Flags
|= PD_DISABLEPRINTTOFILE
;
406 if ( !m_printEnableSelection
)
407 pd
->Flags
|= PD_NOSELECTION
;
408 if ( !m_printEnablePageNumbers
)
409 pd
->Flags
|= PD_NOPAGENUMS
;
410 else if ( (!m_printAllPages
) && (!m_printSelection
) && (m_printFromPage
!= 0) && (m_printToPage
!= 0))
411 pd
->Flags
|= PD_PAGENUMS
;
412 if ( m_printEnableHelp
)
413 pd
->Flags
|= PD_SHOWHELP
;
414 if ( m_printSetupDialog
)
415 pd
->Flags
|= PD_PRINTSETUP
;
418 void wxPrintDialogData::ConvertFromNative()
420 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
424 wxWindowsPrintNativeData
*data
=
425 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
427 // Pass the devmode data back to the wxPrintData structure where it really belongs.
430 if (data
->GetDevMode())
432 // Make sure we don't leak memory
433 GlobalFree( (HGLOBAL
)(DWORD
) data
->GetDevMode() );
435 data
->SetDevMode( (void*)(long) pd
->hDevMode
);
439 // Pass the devnames data back to the wxPrintData structure where it really belongs.
442 if (data
->GetDevNames())
444 // Make sure we don't leak memory
445 GlobalFree((HGLOBAL
)(DWORD
) data
->GetDevNames());
447 data
->SetDevNames((void*)(long) pd
->hDevNames
);
448 pd
->hDevNames
= NULL
;
451 // Now convert the DEVMODE object, passed down from the PRINTDLG object,
452 // into wxWidgets form.
453 data
->TransferTo( m_printData
);
455 m_printFromPage
= pd
->nFromPage
;
456 m_printToPage
= pd
->nToPage
;
457 m_printMinPage
= pd
->nMinPage
;
458 m_printMaxPage
= pd
->nMaxPage
;
459 m_printNoCopies
= pd
->nCopies
;
461 m_printAllPages
= (((pd
->Flags
& PD_PAGENUMS
) != PD_PAGENUMS
) && ((pd
->Flags
& PD_SELECTION
) != PD_SELECTION
));
462 m_printSelection
= ((pd
->Flags
& PD_SELECTION
) == PD_SELECTION
);
463 m_printCollate
= ((pd
->Flags
& PD_COLLATE
) == PD_COLLATE
);
464 m_printToFile
= ((pd
->Flags
& PD_PRINTTOFILE
) == PD_PRINTTOFILE
);
465 m_printEnablePrintToFile
= ((pd
->Flags
& PD_DISABLEPRINTTOFILE
) != PD_DISABLEPRINTTOFILE
);
466 m_printEnableSelection
= ((pd
->Flags
& PD_NOSELECTION
) != PD_NOSELECTION
);
467 m_printEnablePageNumbers
= ((pd
->Flags
& PD_NOPAGENUMS
) != PD_NOPAGENUMS
);
468 m_printEnableHelp
= ((pd
->Flags
& PD_SHOWHELP
) == PD_SHOWHELP
);
469 m_printSetupDialog
= ((pd
->Flags
& PD_PRINTSETUP
) == PD_PRINTSETUP
);
471 /* port is obsolete in WIN32
475 LPDEVNAMES lpDevNames = (LPDEVNAMES)GlobalLock(pd->hDevNames);
477 m_printData.SetPortName((LPSTR)lpDevNames + lpDevNames->wDriverOffset);
478 wxString devName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
479 GlobalUnlock(pd->hDevNames);
481 // wxASSERT_MSG( (m_printerName == "" || (devName == m_printerName)), "Printer name obtained from DEVMODE and DEVNAMES were different!");
487 void wxPrintDialogData::SetOwnerWindow(wxWindow
* win
)
489 if ( m_printDlgData
== NULL
)
492 if ( m_printDlgData
!= NULL
&& win
!= NULL
)
494 PRINTDLG
*pd
= (PRINTDLG
*) m_printDlgData
;
495 pd
->hwndOwner
=(HWND
) win
->GetHWND();
502 void wxPrintDialogData::ConvertToNative()
504 m_printData
.ConvertToNative();
505 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
508 void wxPrintDialogData::ConvertFromNative()
510 m_printData
.ConvertFromNative();
511 m_printData
.m_nativePrintData
->TransferTo( this ) ;
517 void wxPrintDialogData::operator=(const wxPrintDialogData
& data
)
519 m_printFromPage
= data
.m_printFromPage
;
520 m_printToPage
= data
.m_printToPage
;
521 m_printMinPage
= data
.m_printMinPage
;
522 m_printMaxPage
= data
.m_printMaxPage
;
523 m_printNoCopies
= data
.m_printNoCopies
;
524 m_printAllPages
= data
.m_printAllPages
;
525 m_printCollate
= data
.m_printCollate
;
526 m_printToFile
= data
.m_printToFile
;
527 m_printSelection
= data
.m_printSelection
;
528 m_printEnableSelection
= data
.m_printEnableSelection
;
529 m_printEnablePageNumbers
= data
.m_printEnablePageNumbers
;
530 m_printEnableHelp
= data
.m_printEnableHelp
;
531 m_printEnablePrintToFile
= data
.m_printEnablePrintToFile
;
532 m_printSetupDialog
= data
.m_printSetupDialog
;
534 m_printData
= data
.m_printData
;
537 void wxPrintDialogData::operator=(const wxPrintData
& data
)
542 // ----------------------------------------------------------------------------
543 // wxPageSetupDialogData
544 // ----------------------------------------------------------------------------
546 wxPageSetupDialogData::wxPageSetupDialogData()
548 #if defined(__WIN95__)
549 m_pageSetupData
= NULL
;
551 m_paperSize
= wxSize(0, 0);
553 CalculatePaperSizeFromId();
555 m_minMarginTopLeft
= wxPoint(0, 0);
556 m_minMarginBottomRight
= wxPoint(0, 0);
557 m_marginTopLeft
= wxPoint(0, 0);
558 m_marginBottomRight
= wxPoint(0, 0);
561 m_defaultMinMargins
= false;
562 m_enableMargins
= true;
563 m_enableOrientation
= true;
564 m_enablePaper
= true;
565 m_enablePrinter
= true;
566 m_enableHelp
= false;
567 m_getDefaultInfo
= false;
570 wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData
& dialogData
)
573 #if defined(__WIN95__)
574 m_pageSetupData
= NULL
;
576 (*this) = dialogData
;
579 wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData
& printData
)
581 #if defined(__WIN95__)
582 m_pageSetupData
= NULL
;
584 m_paperSize
= wxSize(0, 0);
585 m_minMarginTopLeft
= wxPoint(0, 0);
586 m_minMarginBottomRight
= wxPoint(0, 0);
587 m_marginTopLeft
= wxPoint(0, 0);
588 m_marginBottomRight
= wxPoint(0, 0);
591 m_defaultMinMargins
= false;
592 m_enableMargins
= true;
593 m_enableOrientation
= true;
594 m_enablePaper
= true;
595 m_enablePrinter
= true;
596 m_enableHelp
= false;
597 m_getDefaultInfo
= false;
599 m_printData
= printData
;
601 // The wxPrintData paper size overrides these values, unless the size cannot
603 CalculatePaperSizeFromId();
606 wxPageSetupDialogData::~wxPageSetupDialogData()
608 #if defined(__WIN95__) && defined(__WXMSW__)
609 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*)m_pageSetupData
;
610 if ( pd
&& pd
->hDevMode
)
611 GlobalFree(pd
->hDevMode
);
612 if ( pd
&& pd
->hDevNames
)
613 GlobalFree(pd
->hDevNames
);
619 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPageSetupDialogData
& data
)
621 m_paperSize
= data
.m_paperSize
;
622 m_minMarginTopLeft
= data
.m_minMarginTopLeft
;
623 m_minMarginBottomRight
= data
.m_minMarginBottomRight
;
624 m_marginTopLeft
= data
.m_marginTopLeft
;
625 m_marginBottomRight
= data
.m_marginBottomRight
;
626 m_defaultMinMargins
= data
.m_defaultMinMargins
;
627 m_enableMargins
= data
.m_enableMargins
;
628 m_enableOrientation
= data
.m_enableOrientation
;
629 m_enablePaper
= data
.m_enablePaper
;
630 m_enablePrinter
= data
.m_enablePrinter
;
631 m_getDefaultInfo
= data
.m_getDefaultInfo
;;
632 m_enableHelp
= data
.m_enableHelp
;
634 m_printData
= data
.m_printData
;
639 wxPageSetupDialogData
& wxPageSetupDialogData::operator=(const wxPrintData
& data
)
646 #if defined(__WIN95__)
647 void wxPageSetupDialogData::ConvertToNative()
649 wxWindowsPrintNativeData
*data
=
650 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
651 data
->TransferFrom( m_printData
);
653 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
655 if ( m_pageSetupData
== NULL
)
657 pd
= new PAGESETUPDLG
;
659 pd
->hDevNames
= NULL
;
660 m_pageSetupData
= (void *)pd
;
663 // Pass the devmode data (created in m_printData.ConvertToNative)
664 // to the PRINTDLG structure, since it'll
665 // be needed when PrintDlg is called.
669 GlobalFree(pd
->hDevMode
);
673 pd
->hDevMode
= (HGLOBAL
) data
->GetDevMode();
675 data
->SetDevMode( (void*) NULL
);
677 // Shouldn't assert; we should be able to test Ok-ness at a higher level
678 //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
680 // Pass the devnames data (created in m_printData.ConvertToNative)
681 // to the PRINTDLG structure, since it'll
682 // be needed when PrintDlg is called.
686 GlobalFree(pd
->hDevNames
);
687 pd
->hDevNames
= NULL
;
690 pd
->hDevNames
= (HGLOBAL
) data
->GetDevNames();
692 data
->SetDevNames((void*) NULL
);
694 // pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
696 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
698 if ( m_defaultMinMargins
)
699 pd
->Flags
|= PSD_DEFAULTMINMARGINS
;
700 if ( !m_enableMargins
)
701 pd
->Flags
|= PSD_DISABLEMARGINS
;
702 if ( !m_enableOrientation
)
703 pd
->Flags
|= PSD_DISABLEORIENTATION
;
704 if ( !m_enablePaper
)
705 pd
->Flags
|= PSD_DISABLEPAPER
;
706 if ( !m_enablePrinter
)
707 pd
->Flags
|= PSD_DISABLEPRINTER
;
708 if ( m_getDefaultInfo
)
709 pd
->Flags
|= PSD_RETURNDEFAULT
;
711 pd
->Flags
|= PSD_SHOWHELP
;
713 // We want the units to be in hundredths of a millimetre
714 pd
->Flags
|= PSD_INHUNDREDTHSOFMILLIMETERS
;
716 pd
->lStructSize
= sizeof( PAGESETUPDLG
);
717 pd
->hwndOwner
=(HWND
)NULL
;
718 // pd->hDevNames=(HWND)NULL;
719 pd
->hInstance
=(HINSTANCE
)NULL
;
720 // PAGESETUPDLG is in hundreds of a mm
721 pd
->ptPaperSize
.x
= m_paperSize
.x
* 100;
722 pd
->ptPaperSize
.y
= m_paperSize
.y
* 100;
724 pd
->rtMinMargin
.left
= m_minMarginTopLeft
.x
* 100;
725 pd
->rtMinMargin
.top
= m_minMarginTopLeft
.y
* 100;
726 pd
->rtMinMargin
.right
= m_minMarginBottomRight
.x
* 100;
727 pd
->rtMinMargin
.bottom
= m_minMarginBottomRight
.y
* 100;
729 pd
->rtMargin
.left
= m_marginTopLeft
.x
* 100;
730 pd
->rtMargin
.top
= m_marginTopLeft
.y
* 100;
731 pd
->rtMargin
.right
= m_marginBottomRight
.x
* 100;
732 pd
->rtMargin
.bottom
= m_marginBottomRight
.y
* 100;
735 pd
->lpfnPageSetupHook
= NULL
;
736 pd
->lpfnPagePaintHook
= NULL
;
737 pd
->hPageSetupTemplate
= NULL
;
738 pd
->lpPageSetupTemplateName
= NULL
;
743 DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
744 memset(devMode, 0, sizeof(DEVMODE));
745 devMode->dmSize = sizeof(DEVMODE);
746 devMode->dmOrientation = m_orientation;
747 devMode->dmFields = DM_ORIENTATION;
748 GlobalUnlock(pd->hDevMode);
753 void wxPageSetupDialogData::ConvertFromNative()
755 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
759 wxWindowsPrintNativeData
*data
=
760 (wxWindowsPrintNativeData
*) m_printData
.GetNativeData();
762 // Pass the devmode data back to the wxPrintData structure where it really belongs.
765 if (data
->GetDevMode())
767 // Make sure we don't leak memory
768 GlobalFree((HGLOBAL
) data
->GetDevMode());
770 data
->SetDevMode( (void*) pd
->hDevMode
);
774 data
->TransferTo( m_printData
);
776 // Pass the devnames data back to the wxPrintData structure where it really belongs.
779 if (data
->GetDevNames())
781 // Make sure we don't leak memory
782 GlobalFree((HGLOBAL
) data
->GetDevNames());
784 data
->SetDevNames((void*) pd
->hDevNames
);
785 pd
->hDevNames
= NULL
;
788 data
->TransferTo( m_printData
);
790 pd
->Flags
= PSD_MARGINS
|PSD_MINMARGINS
;
792 m_defaultMinMargins
= ((pd
->Flags
& PSD_DEFAULTMINMARGINS
) == PSD_DEFAULTMINMARGINS
);
793 m_enableMargins
= ((pd
->Flags
& PSD_DISABLEMARGINS
) != PSD_DISABLEMARGINS
);
794 m_enableOrientation
= ((pd
->Flags
& PSD_DISABLEORIENTATION
) != PSD_DISABLEORIENTATION
);
795 m_enablePaper
= ((pd
->Flags
& PSD_DISABLEPAPER
) != PSD_DISABLEPAPER
);
796 m_enablePrinter
= ((pd
->Flags
& PSD_DISABLEPRINTER
) != PSD_DISABLEPRINTER
);
797 m_getDefaultInfo
= ((pd
->Flags
& PSD_RETURNDEFAULT
) == PSD_RETURNDEFAULT
);
798 m_enableHelp
= ((pd
->Flags
& PSD_SHOWHELP
) == PSD_SHOWHELP
);
800 // PAGESETUPDLG is in hundreds of a mm
801 m_paperSize
.x
= pd
->ptPaperSize
.x
/ 100;
802 m_paperSize
.y
= pd
->ptPaperSize
.y
/ 100;
804 m_minMarginTopLeft
.x
= pd
->rtMinMargin
.left
/ 100;
805 m_minMarginTopLeft
.y
= pd
->rtMinMargin
.top
/ 100;
806 m_minMarginBottomRight
.x
= pd
->rtMinMargin
.right
/ 100;
807 m_minMarginBottomRight
.y
= pd
->rtMinMargin
.bottom
/ 100;
809 m_marginTopLeft
.x
= pd
->rtMargin
.left
/ 100;
810 m_marginTopLeft
.y
= pd
->rtMargin
.top
/ 100;
811 m_marginBottomRight
.x
= pd
->rtMargin
.right
/ 100;
812 m_marginBottomRight
.y
= pd
->rtMargin
.bottom
/ 100;
815 void wxPageSetupDialogData::SetOwnerWindow(wxWindow
* win
)
817 if ( m_pageSetupData
== NULL
)
820 if ( m_pageSetupData
!= NULL
&& win
!= NULL
)
822 PAGESETUPDLG
*pd
= (PAGESETUPDLG
*) m_pageSetupData
;
823 pd
->hwndOwner
=(HWND
) win
->GetHWND();
829 void wxPageSetupDialogData::ConvertToNative()
831 m_printData
.ConvertToNative();
832 m_printData
.m_nativePrintData
->TransferFrom( this ) ;
835 void wxPageSetupDialogData::ConvertFromNative()
837 m_printData
.ConvertFromNative ();
838 m_paperSize
= m_printData
.GetPaperSize() ;
839 CalculateIdFromPaperSize();
840 m_printData
.m_nativePrintData
->TransferTo( this ) ;
841 // adjust minimal values
843 if ( m_marginTopLeft
.x
< m_minMarginTopLeft
.x
)
844 m_marginTopLeft
.x
= m_minMarginTopLeft
.x
;
846 if ( m_marginBottomRight
.x
< m_minMarginBottomRight
.x
)
847 m_marginBottomRight
.x
= m_minMarginBottomRight
.x
;
849 if ( m_marginTopLeft
.y
< m_minMarginTopLeft
.y
)
850 m_marginTopLeft
.y
= m_minMarginTopLeft
.y
;
852 if ( m_marginBottomRight
.y
< m_minMarginBottomRight
.y
)
853 m_marginBottomRight
.y
= m_minMarginBottomRight
.y
;
858 // If a corresponding paper type is found in the paper database, will set the m_printData
859 // paper size id member as well.
860 void wxPageSetupDialogData::SetPaperSize(const wxSize
& sz
)
864 CalculateIdFromPaperSize();
867 // Sets the wxPrintData id, plus the paper width/height if found in the paper database.
868 void wxPageSetupDialogData::SetPaperSize(wxPaperSize id
)
870 m_printData
.SetPaperId(id
);
872 CalculatePaperSizeFromId();
875 // Use paper size defined in this object to set the wxPrintData
877 void wxPageSetupDialogData::CalculateIdFromPaperSize()
879 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
880 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
882 wxSize sz
= GetPaperSize();
884 wxPaperSize id
= wxThePrintPaperDatabase
->GetSize(wxSize(sz
.x
* 10, sz
.y
* 10));
885 if (id
!= wxPAPER_NONE
)
887 m_printData
.SetPaperId(id
);
891 // Use paper id in wxPrintData to set this object's paper size
892 void wxPageSetupDialogData::CalculatePaperSizeFromId()
894 wxASSERT_MSG( (wxThePrintPaperDatabase
!= (wxPrintPaperDatabase
*) NULL
),
895 wxT("wxThePrintPaperDatabase should not be NULL. Do not create global print dialog data objects.") );
897 wxSize sz
= wxThePrintPaperDatabase
->GetSize(m_printData
.GetPaperId());
899 // sz is in 10ths of a mm, while paper size is in mm
900 m_paperSize
.x
= sz
.x
/ 10;
901 m_paperSize
.y
= sz
.y
/ 10;
904 #endif // wxUSE_PRINTING_ARCHITECTURE