X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eba330067e87ccec9c8af7bd8b1023044e6d39e3..4b1f929cc3421e43409f7d62260bf9ba0ffc75ab:/src/common/cmndata.cpp diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 3c46f26ba2..45718f159f 100644 --- a/src/common/cmndata.cpp +++ b/src/common/cmndata.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -56,11 +56,6 @@ #include #endif // Win16 - #ifdef __WXWINE__ - #include - #include - #endif - #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__) #include #include @@ -158,7 +153,7 @@ void wxColourData::operator=(const wxColourData& data) wxFontData::wxFontData() { // Intialize colour to black. - fontColour.Set(0, 0, 0); + fontColour = wxNullColour; showHelp = FALSE; allowSymbols = TRUE; @@ -195,37 +190,38 @@ wxPrintData::wxPrintData() #if TARGET_CARBON m_macPageFormat = kPMNoPageFormat; m_macPrintSettings = kPMNoPrintSettings; + m_macPrintSession = kPMNoReference ; #if PM_USE_SESSION_APIS - PMPrintSession macPrintSession = kPMNoReference; OSStatus err; + + err = PMCreateSession((PMPrintSession *)&m_macPrintSession) ; - err = ::UMAPrOpen(&macPrintSession) ; if ( err == noErr ) - { + { err = PMCreatePageFormat((PMPageFormat *)&m_macPageFormat); - + // Note that PMPageFormat is not session-specific, but calling // PMSessionDefaultPageFormat assigns values specific to the printer // associated with the current printing session. if ((err == noErr) && (m_macPageFormat != kPMNoPageFormat)) { - err = PMSessionDefaultPageFormat((PMPrintSession)macPrintSession, + err = PMSessionDefaultPageFormat((PMPrintSession)m_macPrintSession, (PMPageFormat)m_macPageFormat); } - + err = PMCreatePrintSettings((PMPrintSettings *)&m_macPrintSettings); - + // Note that PMPrintSettings is not session-specific, but calling // PMSessionDefaultPrintSettings assigns values specific to the printer // associated with the current printing session. if ((err == noErr) && (m_macPrintSettings != kPMNoPrintSettings)) { - err = PMSessionDefaultPrintSettings((PMPrintSession)macPrintSession, + err = PMSessionDefaultPrintSettings((PMPrintSession)m_macPrintSession, (PMPrintSettings)m_macPrintSettings); } } - ::UMAPrClose(&macPrintSession) ; + #endif #else m_macPrintSettings = (THPrint) NewHandleClear( sizeof( TPrint ) ); @@ -247,7 +243,7 @@ wxPrintData::wxPrintData() m_printCollate = FALSE; // New, 24/3/99 - m_printerName = ""; + m_printerName = wxT(""); m_colour = TRUE; m_duplexMode = wxDUPLEX_SIMPLEX; m_printQuality = wxPRINT_QUALITY_HIGH; @@ -292,6 +288,7 @@ wxPrintData::wxPrintData(const wxPrintData& printData) #if TARGET_CARBON m_macPageFormat = kPMNoPageFormat; m_macPrintSettings = kPMNoPrintSettings; + m_macPrintSession = kPMNoReference ; #else m_macPrintSettings = NULL; #endif @@ -329,7 +326,16 @@ wxPrintData::~wxPrintData() #endif m_macPrintSettings = kPMNoPrintSettings; } - + + if ( m_macPrintSession != kPMNoReference ) + { + #if PM_USE_SESSION_APIS + (void)PMRelease(m_macPrintSession); + #else + (void)PMDisposePrintSession(m_macPrintSession); + #endif + m_macPrintSession = kPMNoReference; + } #else wxASSERT( m_macPrintSettings ); // we should perhaps delete @@ -474,10 +480,7 @@ void wxPrintData::ConvertToNative() //// Orientation -#ifndef __WXWINE__ devMode->dmOrientation = m_printOrientation; -#endif - devMode->dmFields = DM_ORIENTATION; //// Collation @@ -509,7 +512,6 @@ void wxPrintData::ConvertToNative() devMode->dmFields |= DM_COLOR; -#ifndef __WXWINE__ //// Paper size if (m_paperId == wxPAPER_NONE) @@ -533,7 +535,6 @@ void wxPrintData::ConvertToNative() } } } -#endif //// Duplex @@ -602,12 +603,10 @@ void wxPrintData::ConvertFromNative() { LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode); -#ifndef __WXWINE__ //// Orientation if (devMode->dmFields & DM_ORIENTATION) m_printOrientation = devMode->dmOrientation; -#endif //// Collation @@ -632,17 +631,7 @@ void wxPrintData::ConvertFromNative() if (devMode->dmDeviceName[0] != 0) { - // TODO: make this Unicode compatible - char buf[32]; - int i = 0; - while (devMode->dmDeviceName[i] != 0) - { - buf[i] = devMode->dmDeviceName[i]; - i ++; - } - buf[i] = 0; - - m_printerName = buf; + m_printerName = devMode->dmDeviceName; } //// Colour @@ -657,7 +646,6 @@ void wxPrintData::ConvertFromNative() else m_colour = TRUE; -#ifndef __WXWINE__ //// Paper size // We don't know size of user defined paper and some buggy drivers @@ -711,7 +699,6 @@ void wxPrintData::ConvertFromNative() m_paperSize.y = 0; m_paperId = wxPAPER_NONE; } -#endif //// Duplex @@ -817,6 +804,26 @@ void wxPrintData::operator=(const wxPrintData& data) { #ifdef __WXMAC__ #if TARGET_CARBON + if ( m_macPrintSettings != kPMNoPrintSettings ) + { + PMRelease( m_macPrintSettings ) ; + m_macPrintSettings = kPMNoPrintSettings ; + } + if ( data.m_macPrintSettings != kPMNoPrintSettings ) + { + m_macPrintSettings = data.m_macPrintSettings ; + PMRetain( m_macPrintSettings ) ; + } + if ( m_macPageFormat != kPMNoPageFormat ) + { + PMRelease( m_macPageFormat ) ; + m_macPageFormat = kPMNoPageFormat ; + } + if ( data.m_macPageFormat != kPMNoPageFormat ) + { + m_macPageFormat = data.m_macPageFormat ; + PMRetain( m_macPageFormat ) ; + } #else m_macPrintSettings = data.m_macPrintSettings; HandToHand( (Handle*) &m_macPrintSettings ); @@ -1455,6 +1462,20 @@ 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;