X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b4da152ea3ec3968fb2f304b6ed73e0279c19506..18dbdd3c2785b504c02ebf3739503a0183cae39b:/src/common/cmndata.cpp diff --git a/src/common/cmndata.cpp b/src/common/cmndata.cpp index 1483326154..0595eacc27 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 ///////////////////////////////////////////////////////////////////////////// @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "cmndata.h" #endif @@ -48,20 +48,23 @@ #endif // wxUSE_PRINTING_ARCHITECTURE #ifdef __WXMSW__ - #include + #include #include "wx/msw/private.h" - #if !defined(__WIN32__) - #include + #if defined(__WXWINCE__) && !wxUSE_SMARTPHONE #include - #endif // Win16 + #endif - #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__) + #if defined(__WATCOMC__) || defined(__SYMANTEC__) || defined(__SALFORDC__) #include #include #endif #endif // MSW +#ifdef __WXMAC__ + #include "wx/mac/private/print.h" +#endif + #if wxUSE_PRINTING_ARCHITECTURE IMPLEMENT_DYNAMIC_CLASS(wxPrintData, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxPrintDialogData, wxObject) @@ -71,23 +74,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontData, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) -#ifdef __WXMAC__ - #include "wx/mac/uma.h" - -#if defined(TARGET_CARBON) && !defined(__DARWIN__) -# if PM_USE_SESSION_APIS -# include -# endif -# include -#endif - -#ifndef __DARWIN__ - #include "Printing.h" -#endif - #define mm2pt 2.83464566929 - #define pt2mm 0.352777777778 -#endif // Mac - #ifndef DMPAPER_USER #define DMPAPER_USER 256 #endif @@ -104,10 +90,10 @@ wxColourData::wxColourData() { int i; for (i = 0; i < 16; i++) - custColours[i].Set(255, 255, 255); + m_custColours[i].Set(255, 255, 255); - chooseFull = FALSE; - dataColour.Set(0,0,0); + m_chooseFull = FALSE; + m_dataColour.Set(0,0,0); } wxColourData::wxColourData(const wxColourData& data) @@ -125,7 +111,7 @@ void wxColourData::SetCustomColour(int i, const wxColour& colour) if (i > 15 || i < 0) return; - custColours[i] = colour; + m_custColours[i] = colour; } wxColour wxColourData::GetCustomColour(int i) @@ -133,17 +119,17 @@ wxColour wxColourData::GetCustomColour(int i) if (i > 15 || i < 0) return wxColour(0,0,0); - return custColours[i]; + return m_custColours[i]; } void wxColourData::operator=(const wxColourData& data) { int i; for (i = 0; i < 16; i++) - custColours[i] = data.custColours[i]; + m_custColours[i] = data.m_custColours[i]; - dataColour = (wxColour&)data.dataColour; - chooseFull = data.chooseFull; + m_dataColour = (wxColour&)data.m_dataColour; + m_chooseFull = data.m_chooseFull; } // ---------------------------------------------------------------------------- @@ -153,13 +139,13 @@ void wxColourData::operator=(const wxColourData& data) wxFontData::wxFontData() { // Intialize colour to black. - fontColour = wxNullColour; + m_fontColour = wxNullColour; - showHelp = FALSE; - allowSymbols = TRUE; - enableEffects = TRUE; - minSize = 0; - maxSize = 0; + m_showHelp = FALSE; + m_allowSymbols = TRUE; + m_enableEffects = TRUE; + m_minSize = 0; + m_maxSize = 0; m_encoding = wxFONTENCODING_SYSTEM; } @@ -187,56 +173,7 @@ wxPrintData::wxPrintData() m_devMode = (void*) NULL; m_devNames = (void*) NULL; #elif defined( __WXMAC__ ) -#if TARGET_CARBON - m_macPageFormat = kPMNoPageFormat; - m_macPrintSettings = kPMNoPrintSettings; - m_macPrintSession = kPMNoReference ; - - #if PM_USE_SESSION_APIS - OSStatus err; - - err = PMCreateSession((PMPrintSession *)&m_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)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)m_macPrintSession, - (PMPrintSettings)m_macPrintSettings); - } - } - - #endif -#else - m_macPrintSettings = (THPrint) NewHandleClear( sizeof( TPrint ) ); - (**(THPrint)m_macPrintSettings).iPrVersion = 0; // something invalid - - (**(THPrint)m_macPrintSettings).prInfo.iHRes = 72; - (**(THPrint)m_macPrintSettings).prInfo.iVRes = 72; - Rect r1 = { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 }; - (**(THPrint)m_macPrintSettings).prInfo.rPage = r1;// must have its top left & (0,0) - - Rect r2 = { -18, -36, 8*72 - 18, 11*72 - 36 }; - (**(THPrint)m_macPrintSettings).rPaper = r2; - (**(THPrint)m_macPrintSettings).prStl.iPageV = 11 * 120 ; // 11 inches in 120th of an inch - (**(THPrint)m_macPrintSettings).prStl.iPageH = 8 * 120 ; // 8 inches in 120th of an inch -#endif + m_nativePrintData = wxNativePrintData::Create() ; #endif m_printOrientation = wxPORTRAIT; m_printNoCopies = 1; @@ -285,13 +222,7 @@ 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; - m_macPrintSession = kPMNoReference ; -#else - m_macPrintSettings = NULL; -#endif + m_nativePrintData = wxNativePrintData::Create() ; #endif (*this) = printData; } @@ -306,40 +237,7 @@ wxPrintData::~wxPrintData() if ( hDevNames ) GlobalFree(hDevNames); #elif defined(__WXMAC__) -#if TARGET_CARBON - if (m_macPageFormat != kPMNoPageFormat) - { - #if PM_USE_SESSION_APIS - (void)PMRelease(m_macPageFormat); - #else - (void)PMDisposePageFormat(m_macPageFormat); - #endif - m_macPageFormat = kPMNoPageFormat; - } - - if (m_macPrintSettings != kPMNoPrintSettings) - { - #if PM_USE_SESSION_APIS - (void)PMRelease(m_macPrintSettings); - #else - (void)PMDisposePrintSettings(m_macPrintSettings); - #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 -#endif + delete m_nativePrintData ; #endif } @@ -428,7 +326,11 @@ void wxPrintData::ConvertToNative() pd.lStructSize = 66; #else memset(&pd, 0, sizeof(PRINTDLG)); +#ifdef __WXWINCE__ + pd.cbStruct = sizeof(PRINTDLG); +#else pd.lStructSize = sizeof(PRINTDLG); +#endif #endif pd.hwndOwner = (HWND)NULL; @@ -783,51 +685,23 @@ void wxPrintData::ConvertFromNative() #endif #ifdef __WXMAC__ + void wxPrintData::ConvertToNative() { -#if TARGET_CARBON -#else - (**(THPrint)m_macPrintSettings).prJob.iCopies = m_printNoCopies; -#endif + m_nativePrintData->TransferFrom( this ) ; } void wxPrintData::ConvertFromNative() { -#if TARGET_CARBON -#else - m_printNoCopies = (**(THPrint)m_macPrintSettings).prJob.iCopies; -#endif + m_nativePrintData->TransferTo( this ) ; } + #endif 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 ); -#endif + m_nativePrintData->CopyFrom( data.m_nativePrintData ) ; #endif m_printNoCopies = data.m_printNoCopies; m_printCollate = data.m_printCollate; @@ -902,10 +776,10 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData) #ifdef __WXMSW__ m_printDlgData = NULL; #endif - m_printFromPage = 0; + m_printFromPage = 1; m_printToPage = 0; - m_printMinPage = 0; - m_printMaxPage = 0; + m_printMinPage = 1; + m_printMaxPage = 9999; m_printNoCopies = 1; m_printAllPages = FALSE; m_printCollate = FALSE; @@ -1023,6 +897,8 @@ void wxPrintDialogData::ConvertToNative() pd->Flags |= PD_NOSELECTION; if ( !m_printEnablePageNumbers ) pd->Flags |= PD_NOPAGENUMS; + else if ( (!m_printAllPages) && (!m_printSelection) && (m_printFromPage != 0) && (m_printToPage != 0)) + pd->Flags |= PD_PAGENUMS; if ( m_printEnableHelp ) pd->Flags |= PD_SHOWHELP; if ( m_printSetupDialog ) @@ -1069,7 +945,7 @@ void wxPrintDialogData::ConvertFromNative() m_printMaxPage = pd->nMaxPage; m_printNoCopies = pd->nCopies; - m_printAllPages = ((pd->Flags & PD_ALLPAGES) == PD_ALLPAGES); + m_printAllPages = (((pd->Flags & PD_PAGENUMS) != PD_PAGENUMS) && ((pd->Flags & PD_SELECTION) != PD_SELECTION)); m_printSelection = ((pd->Flags & PD_SELECTION) == PD_SELECTION); m_printCollate = ((pd->Flags & PD_COLLATE) == PD_COLLATE); m_printToFile = ((pd->Flags & PD_PRINTTOFILE) == PD_PRINTTOFILE); @@ -1109,25 +985,19 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win) #endif // MSW #ifdef __WXMAC__ + void wxPrintDialogData::ConvertToNative() { -#if TARGET_CARBON -#else - (**(THPrint)m_printData.m_macPrintSettings).prJob.iFstPage = m_printFromPage; - (**(THPrint)m_printData.m_macPrintSettings).prJob.iLstPage = m_printToPage; m_printData.ConvertToNative(); -#endif + m_printData.m_nativePrintData->TransferFrom( this ) ; } void wxPrintDialogData::ConvertFromNative() { -#if TARGET_CARBON -#else m_printData.ConvertFromNative(); - m_printFromPage = (**(THPrint)m_printData.m_macPrintSettings).prJob.iFstPage; - m_printToPage = (**(THPrint)m_printData.m_macPrintSettings).prJob.iLstPage; -#endif + m_printData.m_nativePrintData->TransferTo( this ) ; } + #endif @@ -1441,53 +1311,16 @@ void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win) 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 + m_printData.m_nativePrintData->TransferFrom( this ) ; } 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 + m_paperSize = m_printData.GetPaperSize() ; + CalculateIdFromPaperSize(); + m_printData.m_nativePrintData->TransferTo( this ) ; // adjust minimal values - //TODO add custom fields in dialog for margins if ( m_marginTopLeft.x < m_minMarginTopLeft.x ) m_marginTopLeft.x = m_minMarginTopLeft.x;