-#if defined(__WIN95__)
-void wxPageSetupDialogData::ConvertToNative()
-{
- m_printData.ConvertToNative();
-
- PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData;
-
- if ( m_pageSetupData == NULL )
- {
- pd = new PAGESETUPDLG;
- pd->hDevMode = NULL;
- pd->hDevNames = 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);
-
- // Shouldn't assert; we should be able to test Ok-ness at a higher level
- //wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
-
- // Pass the devnames data (created in m_printData.ConvertToNative)
- // to the PRINTDLG structure, since it'll
- // be needed when PrintDlg is called.
-
- if (pd->hDevNames)
- {
- GlobalFree(pd->hDevNames);
- pd->hDevNames = NULL;
- }
-
- pd->hDevNames = (HGLOBAL) m_printData.GetNativeDataDevNames();
-
- m_printData.SetNativeDataDevNames((void*) NULL);
-
-// 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;
- // PAGESETUPDLG is in hundreds of a mm
- 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();
-
- // Pass the devnames data back to the wxPrintData structure where it really belongs.
- if (pd->hDevNames)
- {
- if (m_printData.GetNativeDataDevNames())
- {
- // Make sure we don't leak memory
- GlobalFree((HGLOBAL) m_printData.GetNativeDataDevNames());
- }
- m_printData.SetNativeDataDevNames((void*) pd->hDevNames);
- pd->hDevNames = 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);
-
- // PAGESETUPDLG is in hundreds of a mm
- 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 wxPageSetupDialogData::ConvertToNative()
-{
- m_printData.ConvertToNative();
- // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
-#if TARGET_CARBON
-#else
- (**(THPrint)m_printData.m_macPrintSettings).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt );
- (**(THPrint)m_printData.m_macPrintSettings).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt );
-
- (**(THPrint)m_printData.m_macPrintSettings).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt );
- (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt );
-
- (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.left = 0;
- (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.top = 0;
- (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt );
- (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt );
-#endif
-}
-
-void wxPageSetupDialogData::ConvertFromNative()
-{
- m_printData.ConvertFromNative ();
-
-#if TARGET_CARBON
- PMRect rPaper;
-
- OSStatus err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper);
- if ( err == noErr )
- {
- m_paperSize.x = (int)(((double) rPaper.right - rPaper.left ) * pt2mm);
- m_paperSize.y = (int)(((double) rPaper.bottom - rPaper.top ) * pt2mm);
-
- m_minMarginTopLeft.x = (int)(((double) - rPaper.left ) * pt2mm);
- m_minMarginTopLeft.y = (int)(((double) - rPaper.top ) * pt2mm);
-
-// m_minMarginBottomRight.x = ((double) rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
-// m_minMarginBottomRight.y = ((double)(**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
- }
-#else
- m_paperSize.x = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ) * pt2mm;
- m_paperSize.y = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ) * pt2mm;
-
- m_minMarginTopLeft.x = ((double) -(**(THPrint)m_printData.m_macPrintSettings).rPaper.left ) * pt2mm;
- m_minMarginTopLeft.y = ((double) -(**(THPrint)m_printData.m_macPrintSettings).rPaper.top ) * pt2mm;
-
- m_minMarginBottomRight.x = ((double) (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.right ) * pt2mm;
- m_minMarginBottomRight.y = ((double)(**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm;
-#endif
- // adjust minimal values
- //TODO add custom fields in dialog for margins
-
- if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
- m_marginTopLeft.x = m_minMarginTopLeft.x;
-
- if ( m_marginBottomRight.x < m_minMarginBottomRight.x )
- m_marginBottomRight.x = m_minMarginBottomRight.x;
-
- if ( m_marginTopLeft.y < m_minMarginTopLeft.y )
- m_marginTopLeft.y = m_minMarginTopLeft.y;
-
- if ( m_marginBottomRight.y < m_minMarginBottomRight.y )
- m_marginBottomRight.y = m_minMarginBottomRight.y;
-}
-#endif
-
-