X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d610b90ffb5c212b429c717ebae5f605fc5fac7..5c737c4c37eb7d0687e06e005678299fe8557bc4:/src/common/cmndata.cpp diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 90ec1c14a4..de57dda478 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -40,7 +40,7 @@ #include "wx/log.h" // For compatibility -#if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__)) && wxUSE_POSTSCRIPT +#if (defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXPM__) || defined(__WXMAC__)) && wxUSE_POSTSCRIPT #define wxCOMPATIBILITY_WITH_PRINTSETUPDATA 1 #endif @@ -86,6 +86,10 @@ #define pt2mm 0.352777777778 #endif // Mac +#ifndef DMPAPER_USER + #define DMPAPER_USER 256 +#endif + // ============================================================================ // implementation // ============================================================================ @@ -172,8 +176,12 @@ wxPrintData::wxPrintData() m_devMode = (void*) NULL; m_devNames = (void*) NULL; #elif defined( __WXMAC__ ) +#if TARGET_CARBON + m_macPageFormat = kPMNoPageFormat; + m_macPrintSettings = kPMNoPrintSettings; +#else m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ; - (**m_macPrintInfo).iPrVersion = 0; // something invalid + (**m_macPrintInfo).iPrVersion = 0; // something invalid (**m_macPrintInfo).prInfo.iHRes = 72; (**m_macPrintInfo).prInfo.iVRes = 72; @@ -182,16 +190,9 @@ wxPrintData::wxPrintData() Rect r2 = { -18, -36, 8*72 - 18, 11*72 - 36 } ; (**m_macPrintInfo).rPaper = r2; - (**m_macPrintInfo).prStl.iPageV = 11 * 120 ; // 11 inches in 120th of an inch - (**m_macPrintInfo).prStl.iPageH = 8 * 120 ; // 8 inches in 120th of an inch -/* - UMAPrOpen() ; - m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ; - ::PrintDefault( m_macPrintInfo ) ; - OSErr err = PrError() ; - UMAPrClose() ; - wxASSERT( err == noErr ) ; -*/ + (**m_macPrintInfo).prStl.iPageV = 11 * 120 ; // 11 inches in 120th of an inch + (**m_macPrintInfo).prStl.iPageH = 8 * 120 ; // 8 inches in 120th of an inch +#endif #endif m_printOrientation = wxPORTRAIT; m_printNoCopies = 1; @@ -224,16 +225,12 @@ wxPrintData::wxPrintData(const wxPrintData& printData) m_devMode = (void*) NULL; m_devNames = (void*) NULL; #elif defined( __WXMAC__ ) +#if TARGET_CARBON + m_macPageFormat = kPMNoPageFormat; + m_macPrintSettings = kPMNoPrintSettings; +#else m_macPrintInfo = NULL ; - /* - (THPrint) NewHandleClear( sizeof( TPrint ) ) ; - UMAPrOpen() ; - m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ; - ::PrintDefault( m_macPrintInfo ) ; - OSErr err = PrError() ; - UMAPrClose() ; - wxASSERT( err == noErr ) ; - */ +#endif #endif (*this) = printData; } @@ -248,8 +245,22 @@ wxPrintData::~wxPrintData() if ( hDevNames ) GlobalFree(hDevNames); #elif defined(__WXMAC__) +#if TARGET_CARBON + if (m_macPageFormat != kPMNoPageFormat) + { + (void)PMDisposePageFormat(m_macPageFormat); + m_macPageFormat = kPMNoPageFormat; + } + + if (m_macPrintSettings != kPMNoPrintSettings) + { + (void)PMDisposePrintSettings(m_macPrintSettings); + m_macPrintSettings = kPMNoPrintSettings; + } +#else wxASSERT( m_macPrintInfo ) ; -// ::DisposeHandle( (Handle) m_macPrintInfo ) ; + // we should perhaps delete +#endif #endif } @@ -432,8 +443,10 @@ void wxPrintData::ConvertToNative() if (m_paperId == wxPAPER_NONE) { + // DEVMODE is in tenths of a milimeter devMode->dmPaperWidth = m_paperSize.x * 10; devMode->dmPaperLength = m_paperSize.y * 10; + devMode->dmPaperSize = DMPAPER_USER; devMode->dmFields |= DM_PAPERWIDTH; devMode->dmFields |= DM_PAPERLENGTH; } @@ -576,7 +589,11 @@ void wxPrintData::ConvertFromNative() #ifndef __WXWINE__ //// Paper size - if (devMode->dmFields & DM_PAPERSIZE) + // We don't know size of user defined paper and some buggy drivers + // set both DM_PAPERSIZE and DM_PAPERWIDTH & DM_PAPERLENGTH. Since + // dmPaperSize >= DMPAPER_USER wouldn't be in wxWin's database, this + // code wouldn't set m_paperSize correctly. + if ((devMode->dmFields & DM_PAPERSIZE) && (devMode->dmPaperSize < DMPAPER_USER)) { if (wxThePrintPaperDatabase) { @@ -609,6 +626,7 @@ void wxPrintData::ConvertFromNative() } else if ((devMode->dmFields & DM_PAPERWIDTH) && (devMode->dmFields & DM_PAPERLENGTH)) { + // DEVMODE is in tenths of a milimeter m_paperSize.x = devMode->dmPaperWidth / 10; m_paperSize.y = devMode->dmPaperLength / 10; m_paperId = wxPAPER_NONE; @@ -709,20 +727,29 @@ void wxPrintData::ConvertFromNative() #ifdef __WXMAC__ void wxPrintData::ConvertToNative() { +#ifdef TARGET_CARBON +#else (**m_macPrintInfo).prJob.iCopies = m_printNoCopies ; +#endif } void wxPrintData::ConvertFromNative() { +#ifdef TARGET_CARBON +#else m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ; +#endif } #endif void wxPrintData::operator=(const wxPrintData& data) { #ifdef __WXMAC__ +#ifdef TARGET_CARBON +#else m_macPrintInfo = data.m_macPrintInfo ; HandToHand( (Handle*) &m_macPrintInfo ) ; +#endif #endif m_printNoCopies = data.m_printNoCopies; m_printCollate = data.m_printCollate; @@ -892,11 +919,11 @@ void wxPrintDialogData::ConvertToNative() m_printData.SetNativeDataDevNames((void*) NULL); pd->hDC = (HDC) NULL; - pd->nFromPage = (UINT)m_printFromPage; - pd->nToPage = (UINT)m_printToPage; - pd->nMinPage = (UINT)m_printMinPage; - pd->nMaxPage = (UINT)m_printMaxPage; - pd->nCopies = (UINT)m_printNoCopies; + pd->nFromPage = (WORD)m_printFromPage; + pd->nToPage = (WORD)m_printToPage; + pd->nMinPage = (WORD)m_printMinPage; + pd->nMaxPage = (WORD)m_printMaxPage; + pd->nCopies = (WORD)m_printNoCopies; pd->Flags = PD_RETURNDC ; @@ -919,7 +946,7 @@ void wxPrintDialogData::ConvertToNative() if ( m_printAllPages ) pd->Flags |= PD_ALLPAGES; - if ( m_printAllPages ) + if ( m_printSelection ) pd->Flags |= PD_SELECTION; if ( m_printCollate ) pd->Flags |= PD_COLLATE; @@ -1019,16 +1046,22 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win) #ifdef __WXMAC__ void wxPrintDialogData::ConvertToNative() { +#ifdef TARGET_CARBON +#else (**m_printData.m_macPrintInfo).prJob.iFstPage = m_printFromPage ; (**m_printData.m_macPrintInfo).prJob.iLstPage = m_printToPage ; m_printData.ConvertToNative() ; +#endif } void wxPrintDialogData::ConvertFromNative() { +#ifdef TARGET_CARBON +#else m_printData.ConvertFromNative() ; m_printFromPage = (**m_printData.m_macPrintInfo).prJob.iFstPage ; m_printToPage = (**m_printData.m_macPrintInfo).prJob.iLstPage ; +#endif } #endif @@ -1228,7 +1261,7 @@ void wxPageSetupDialogData::ConvertToNative() 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; @@ -1305,6 +1338,7 @@ void wxPageSetupDialogData::ConvertFromNative() 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; @@ -1337,6 +1371,8 @@ 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 ) ; @@ -1347,12 +1383,15 @@ void wxPageSetupDialogData::ConvertToNative() (**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 ; @@ -1361,7 +1400,7 @@ void wxPageSetupDialogData::ConvertFromNative() 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