- m_printData.ConvertToNative();
-
- PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData;
-
- if ( m_pageSetupData == NULL )
- {
- pd = new PAGESETUPDLG;
- pd->hDevMode = NULL;
- m_pageSetupData = (void *)pd;
- }
-
- // Pass the devmode data (created in m_printData.ConvertToNative)
- // to the PRINTDLG structure, since it'll
- // be needed when PrintDlg is called.
-
- if (pd->hDevMode)
- {
- GlobalFree(pd->hDevMode);
- pd->hDevMode = NULL;
- }
-
- pd->hDevMode = (HGLOBAL) m_printData.GetNativeData();
-
- m_printData.SetNativeData((void*) NULL);
-
- wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
-
-// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
-
- pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
-
- if ( m_defaultMinMargins )
- pd->Flags |= PSD_DEFAULTMINMARGINS;
- if ( !m_enableMargins )
- pd->Flags |= PSD_DISABLEMARGINS;
- if ( !m_enableOrientation )
- pd->Flags |= PSD_DISABLEORIENTATION;
- if ( !m_enablePaper )
- pd->Flags |= PSD_DISABLEPAPER;
- if ( !m_enablePrinter )
- pd->Flags |= PSD_DISABLEPRINTER;
- if ( m_getDefaultInfo )
- pd->Flags |= PSD_RETURNDEFAULT;
- if ( m_enableHelp )
- pd->Flags |= PSD_SHOWHELP;
-
- // We want the units to be in hundredths of a millimetre
- pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
-
- pd->lStructSize = sizeof( PAGESETUPDLG );
- pd->hwndOwner=(HWND)NULL;
- pd->hDevNames=(HWND)NULL;
- pd->hInstance=(HINSTANCE)NULL;
-
- pd->ptPaperSize.x = m_paperSize.x * 100;
- pd->ptPaperSize.y = m_paperSize.y * 100;
-
- pd->rtMinMargin.left = m_minMarginTopLeft.x * 100;
- pd->rtMinMargin.top = m_minMarginTopLeft.y * 100;
- pd->rtMinMargin.right = m_minMarginBottomRight.x * 100;
- pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100;
-
- pd->rtMargin.left = m_marginTopLeft.x * 100;
- pd->rtMargin.top = m_marginTopLeft.y * 100;
- pd->rtMargin.right = m_marginBottomRight.x * 100;
- pd->rtMargin.bottom = m_marginBottomRight.y * 100;
-
- pd->lCustData = 0;
- pd->lpfnPageSetupHook = NULL;
- pd->lpfnPagePaintHook = NULL;
- pd->hPageSetupTemplate = NULL;
- pd->lpPageSetupTemplateName = NULL;
-
-/*
- if ( pd->hDevMode )
- {
- DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
- memset(devMode, 0, sizeof(DEVMODE));
- devMode->dmSize = sizeof(DEVMODE);
- devMode->dmOrientation = m_orientation;
- devMode->dmFields = DM_ORIENTATION;
- GlobalUnlock(pd->hDevMode);
- }
-*/
-}
-
-void wxPageSetupDialogData::ConvertFromNative()
-{
- PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
- if ( !pd )
- return;
-
- // Pass the devmode data back to the wxPrintData structure where it really belongs.
- if (pd->hDevMode)
- {
- if (m_printData.GetNativeData())
- {
- // Make sure we don't leak memory
- GlobalFree((HGLOBAL) m_printData.GetNativeData());
- }
- m_printData.SetNativeData((void*) pd->hDevMode);
- pd->hDevMode = NULL;
- }
-
- m_printData.ConvertFromNative();
-
- pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
-
- m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS);
- m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS);
- m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION);
- m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER);
- m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER);
- m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT);
- m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP);
-
- m_paperSize.x = pd->ptPaperSize.x / 100;
- m_paperSize.y = pd->ptPaperSize.y / 100;
-
- m_minMarginTopLeft.x = pd->rtMinMargin.left / 100;
- m_minMarginTopLeft.y = pd->rtMinMargin.top / 100;
- m_minMarginBottomRight.x = pd->rtMinMargin.right / 100;
- m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100;
-
- m_marginTopLeft.x = pd->rtMargin.left / 100 ;
- m_marginTopLeft.y = pd->rtMargin.top / 100 ;
- m_marginBottomRight.x = pd->rtMargin.right / 100 ;
- m_marginBottomRight.y = pd->rtMargin.bottom / 100 ;
-}
-
-void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
-{
- if ( m_pageSetupData == NULL )
- ConvertToNative();
-
- if ( m_pageSetupData != NULL && win != NULL)
- {
- PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData ;
- pd->hwndOwner=(HWND) win->GetHWND();
- }
-}
-#endif // Win95
-
-#ifdef __WXMAC__
-void wxPageSetupData::ConvertToNative()
-{
- if ( !m_macPageSetupInfo )
- {
- m_macPageSetupInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
- if ( m_macPageSetupInfo )
- {
- ::PrintDefault( m_macPageSetupInfo ) ;
- }
- }
- if ( m_macPageSetupInfo )
- {
- // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
- (**m_macPageSetupInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt ) ;
- (**m_macPageSetupInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt ) ;
-
- (**m_macPageSetupInfo).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt ) ;
- (**m_macPageSetupInfo).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt ) ;
-
- (**m_macPageSetupInfo).prInfo.rPage.left = 0 ;
- (**m_macPageSetupInfo).prInfo.rPage.top = 0 ;
- (**m_macPageSetupInfo).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt ) ;
- (**m_macPageSetupInfo).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt ) ;
-
- //TODO add custom fields in dialog for margins
-
- }
-}