X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aece0491ee47ba60c8bf7ed8f8482e39d1c5cc59..9841339c74917270e36def49a00a0415efe3683e:/src/generic/dcpsg.cpp diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 8fb105fc8f..88e3377174 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1358,16 +1358,23 @@ void wxPostScriptDC::DoGetSize(int* width, int* height) const if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); + int w = 595; + int h = 842; if (paper) { - if (width) *width = paper->GetSizeDeviceUnits().x; - if (height) *height = paper->GetSizeDeviceUnits().y; + w = paper->GetSizeDeviceUnits().x; + h = paper->GetSizeDeviceUnits().y; } - else + + if (m_printData.GetOrientation() == wxLANDSCAPE) { - if (width) *width = 595; - if (height) *height = 842; + int tmp = w; + w = h; + h = tmp; } + + if (width) *width = w; + if (height) *height = h; } void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const @@ -1378,16 +1385,23 @@ void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); + int w = 210; + int h = 297; if (paper) { - if (width) *width = paper->GetWidth() / 10; - if (height) *height = paper->GetHeight() / 10; + w = paper->GetWidth() / 10; + h = paper->GetHeight() / 10; } - else + + if (m_printData.GetOrientation() == wxLANDSCAPE) { - if (width) *width = 210; - if (height) *height = 297; + int tmp = w; + w = h; + h = tmp; } + + if (width) *width = w; + if (height) *height = h; } // Resolution in pixels per logical inch @@ -1461,7 +1475,7 @@ void wxPostScriptDC::EndDoc () fprintf( m_pstream, "%%!PS-Adobe-2.0\n" ); // PostScript magic strings fprintf( m_pstream, "%%%%Title: %s\n", (const char *)m_title.mb_str() ); - fprintf( m_pstream, "%%%%Creator: %s\n", (const char*)wxConvLibc.cWX2MB(wxTheApp->argv[0]) ); + fprintf( m_pstream, "%%%%Creator: %s\n", (const char*)wxConvCurrent->cWX2MB(wxTheApp->argv[0]) ); fprintf( m_pstream, "%%%%CreationDate: %s\n", (const char *)wxNow().mb_str() ); wxChar userID[256]; @@ -1598,6 +1612,7 @@ void wxPostScriptDC::StartPage() fprintf( m_pstream, "%%%%Page: %d\n", wxPageNumber++ ); + // What is this one supposed to do? RR. // *m_pstream << "matrix currentmatrix\n"; // Added by Chris Breeze @@ -1606,11 +1621,6 @@ void wxPostScriptDC::StartPage() // transformation and so we need to reset the origin // (and rotate the page for landscape printing) -/* - m_scaleFactor = 1.0; - m_logicalOriginX = 0; - m_logicalOriginY = 0; -*/ // Output scaling long translate_x, translate_y; double scale_x, scale_y; @@ -1623,16 +1633,17 @@ void wxPostScriptDC::StartPage() if (m_printData.GetOrientation() == wxLANDSCAPE) { -// translate_y -= m_maxY; -// fprintf( m_pstream, "90 rotate\n" ); - - printf( "Hi.\n" ); + int h; + GetSize( (int*) NULL, &h ); + translate_y -= h; + fprintf( m_pstream, "90 rotate\n" ); - fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" ); + // I copied this one from a PostScript tutorial, but to no avail. RR. +// fprintf( m_pstream, "90 rotate llx neg ury nef translate\n" ); } -// fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y ); -// fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y ); + fprintf( m_pstream, "%.8f %.8f scale\n", scale_x, scale_y ); + fprintf( m_pstream, "%ld %ld translate\n", translate_x, translate_y ); } void wxPostScriptDC::EndPage () @@ -1686,7 +1697,7 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, const wxWX2MBbuf strbuf = string.mb_str(); -#if !USE_AFM_FOR_POSTSCRIPT +#if !wxUSE_AFM_FOR_POSTSCRIPT /* Provide a VERY rough estimate (avoid using it). * Produces accurate results for mono-spaced font * such as Courier (aka wxMODERN) */ @@ -1747,6 +1758,9 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, static int lastWeight= INT_MIN; static int lastDescender = INT_MIN; static int lastWidths[256]; /* widths of the characters */ + + double UnderlinePosition = 0.0; + double UnderlineThickness = 0.0; /* get actual parameters */ const int Family = fontToUse->GetFamily(); @@ -1780,7 +1794,7 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "TimesBoO"; else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "TimesBo"; else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "TimesO"; - else if name = "TimesRo"; /* no typo */ + else name = "TimesRo"; } break; default: @@ -1799,7 +1813,7 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, if (!m_printData.GetFontMetricPath().IsEmpty()) { - strcpy( afmName, m_printData.GetFontMetricPath().fn_str() ) + strcpy( afmName, m_printData.GetFontMetricPath().fn_str() ); } /* 2. open and process the file @@ -1823,21 +1837,21 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, FILE *afmFile = fopen(afmName,"r"); #ifdef __UNIX__ - if (afmFile==NULL) - { - strcpy( afmName, "/usr/local/share/wx/gs_afm/" ); - strcat(afmName,name); - strcat(afmName,".afm"); - FILE *afmFile = fopen(afmName,"r"); - } - - if (afmFile==NULL) - { - strcpy( afmName, "/usr/share/wx/gs_afm/" ); - strcat(afmName,name); - strcat(afmName,".afm"); - FILE *afmFile = fopen(afmName,"r"); - } + if (afmFile==NULL) + { + strcpy( afmName, "/usr/local/share/wx/gs_afm/" ); + strcat(afmName,name); + strcat(afmName,".afm"); + afmFile = fopen(afmName,"r"); + } + + if (afmFile==NULL) + { + strcpy( afmName, "/usr/share/wx/gs_afm/" ); + strcat(afmName,name); + strcat(afmName,".afm"); + afmFile = fopen(afmName,"r"); + } #endif if (afmFile==NULL) @@ -1940,14 +1954,20 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, } /* JC: calculate UnderlineThickness/UnderlinePosition */ - m_underlinePosition = m_underlinePosition * fontToUse->GetPointSize() / 1000.0f; - m_underlineThickness = m_underlineThickness * fontToUse->GetPointSize() / 1000.0f * m_scaleFactor; + { + // VS: dirty, but is there any better solution? + double *pt; + pt = (double*) &m_underlinePosition; + *pt = UnderlinePosition * fontToUse->GetPointSize() / 1000.0f; + pt = (double*) &m_underlineThickness; + *pt = UnderlineThickness * fontToUse->GetPointSize() / 1000.0f * m_scaleFactor; + } /* 3. now the font metrics are read in, calc size this / is done by adding the widths of the characters in the / string. they are given in 1/1000 of the size! */ - long widthSum=0; + double widthSum=0; long height=Size; /* by default */ unsigned char *p; for(p=(unsigned char *)strbuf; *p; p++) @@ -1955,22 +1975,22 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, if(lastWidths[*p]== INT_MIN) { wxLogDebug("GetTextExtent: undefined width for character '%c' (%d)\n", *p,*p); - widthSum += (long)(lastWidths[' ']/1000.0F * Size); /* assume space */ + widthSum += /*(long)*/(lastWidths[' ']/1000.0F * Size); /* assume space */ } else { - widthSum += (long)((lastWidths[*p]/1000.0F)*Size); + widthSum += /*(long)*/((lastWidths[*p]/1000.0F)*Size); } } /* add descender to height (it is usually a negative value) */ - if (lastDescender!=INT_MIN) + if (lastDescender != INT_MIN) { height += (long)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */ } /* return size values */ - *x = widthSum; + *x = (long)widthSum; *y = height; /* return other parameters */