- 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
-#ifdef TARGET_CARBON
-#else
- (**m_printData.m_macPrintInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt );
- (**m_printData.m_macPrintInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt );
-
- (**m_printData.m_macPrintInfo).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt );
- (**m_printData.m_macPrintInfo).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt );
-
- (**m_printData.m_macPrintInfo).prInfo.rPage.left = 0;
- (**m_printData.m_macPrintInfo).prInfo.rPage.top = 0;
- (**m_printData.m_macPrintInfo).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt );
- (**m_printData.m_macPrintInfo).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt );
-#endif
-}
-
-void wxPageSetupDialogData::ConvertFromNative()
-{
- m_printData.ConvertFromNative ();
-
-#ifdef TARGET_CARBON
-#else
- m_paperSize.x = ((double) (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).rPaper.left ) * pt2mm;
- m_paperSize.y = ((double) (**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).rPaper.top ) * pt2mm;
-
- m_minMarginTopLeft.x = ((double) -(**m_printData.m_macPrintInfo).rPaper.left ) * pt2mm;
- m_minMarginTopLeft.y = ((double) -(**m_printData.m_macPrintInfo).rPaper.top ) * pt2mm;
-
- m_minMarginBottomRight.x = ((double) (**m_printData.m_macPrintInfo).rPaper.right - (**m_printData.m_macPrintInfo).prInfo.rPage.right ) * pt2mm;
- m_minMarginBottomRight.y = ((double)(**m_printData.m_macPrintInfo).rPaper.bottom - (**m_printData.m_macPrintInfo).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;