X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f0a6b1cd6c8de8fc93fcd1ce0e9293fff965ceb8..1fd1922a49351a377bc6ef8f7e00f150112ee096:/src/generic/dcpsg.cpp diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 73ee7231f0..31fc945309 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -10,8 +10,7 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation -#pragma interface +#pragma implementation "dcpsg.h" #endif #include "wx/wxprec.h" @@ -37,7 +36,7 @@ #include "wx/image.h" #include "wx/log.h" #include "wx/generic/dcpsg.h" -#include "wx/generic/prntdlgg.h" +#include "wx/printdlg.h" #include "wx/button.h" #include "wx/stattext.h" #include "wx/radiobox.h" @@ -416,10 +415,10 @@ void wxPostScriptDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoo "%d %d lineto\n" "%d %d lineto\n" "closepath clip newpath\n", - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+w), YLOG2DEV(y), - XLOG2DEV(x+w), YLOG2DEV(y+h), - XLOG2DEV(x), YLOG2DEV(y+h) ); + LogicalToDeviceX(x), LogicalToDeviceY(y), + LogicalToDeviceX(x+w), LogicalToDeviceY(y), + LogicalToDeviceX(x+w), LogicalToDeviceY(y+h), + LogicalToDeviceX(x), LogicalToDeviceY(y+h) ); } @@ -441,9 +440,10 @@ void wxPostScriptDC::Clear() wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") ); } -void wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) +bool wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") ); + return FALSE; } bool wxPostScriptDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const @@ -470,8 +470,8 @@ void wxPostScriptDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) "%d %d moveto\n" "%d %d lineto\n" "stroke\n", - XLOG2DEV(x1), YLOG2DEV(y1), - XLOG2DEV(x2), YLOG2DEV (y2) ); + LogicalToDeviceX(x1), LogicalToDeviceY(y1), + LogicalToDeviceX(x2), LogicalToDeviceY (y2) ); CalcBoundingBox( x1, y1 ); CalcBoundingBox( x2, y2 ); @@ -521,8 +521,8 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, "%d %d lineto\n" "closepath\n" "fill\n", - XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL(radius), YLOG2DEVREL(radius), (wxCoord)alpha1, (wxCoord) alpha2, - XLOG2DEV(xc), YLOG2DEV(yc) ); + LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, + LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); CalcBoundingBox( xc-radius, yc-radius ); CalcBoundingBox( xc+radius, yc+radius ); @@ -538,8 +538,8 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, "%d %d lineto\n" "stroke\n" "fill\n", - XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL(radius), YLOG2DEVREL(radius), (wxCoord)alpha1, (wxCoord) alpha2, - XLOG2DEV(xc), YLOG2DEV(yc) ); + LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, + LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); CalcBoundingBox( xc-radius, yc-radius ); CalcBoundingBox( xc+radius, yc+radius ); @@ -568,7 +568,7 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d fprintf( m_pstream, "newpath\n" "%d %d %d %d %d %d true ellipticarc\n", - XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), (wxCoord)sa, (wxCoord)ea ); + LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea ); CalcBoundingBox( x ,y ); CalcBoundingBox( x+w, y+h ); @@ -581,7 +581,7 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d fprintf(m_pstream, "newpath\n" "%d %d %d %d %d %d false ellipticarc\n", - XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), (wxCoord)sa, (wxCoord)ea ); + LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea ); CalcBoundingBox( x ,y ); CalcBoundingBox( x+w, y+h ); @@ -601,8 +601,8 @@ void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y) "%d %d moveto\n" "%d %d lineto\n" "stroke\n", - XLOG2DEV(x), YLOG2DEV(y), - XLOG2DEV(x+1), YLOG2DEV(y) ); + LogicalToDeviceX(x), LogicalToDeviceY(y), + LogicalToDeviceX(x+1), LogicalToDeviceY(y) ); CalcBoundingBox( x, y ); } @@ -619,8 +619,8 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx fprintf( m_pstream, "newpath\n" ); - wxCoord xx = XLOG2DEV(points[0].x + xoffset); - wxCoord yy = YLOG2DEV(points[0].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[0].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[0].y + yoffset); fprintf( m_pstream, "%d %d moveto\n", xx, yy ); @@ -628,8 +628,8 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx for (int i = 1; i < n; i++) { - xx = XLOG2DEV(points[i].x + xoffset); - yy = YLOG2DEV(points[i].y + yoffset); + xx = LogicalToDeviceX(points[i].x + xoffset); + yy = LogicalToDeviceY(points[i].y + yoffset); fprintf( m_pstream, "%d %d lineto\n", xx, yy ); @@ -645,8 +645,8 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx fprintf( m_pstream, "newpath\n" ); - wxCoord xx = XLOG2DEV(points[0].x + xoffset); - wxCoord yy = YLOG2DEV(points[0].y + yoffset); + wxCoord xx = LogicalToDeviceX(points[0].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[0].y + yoffset); fprintf( m_pstream, "%d %d moveto\n", xx, yy ); @@ -654,8 +654,8 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx for (int i = 1; i < n; i++) { - xx = XLOG2DEV(points[i].x + xoffset); - yy = YLOG2DEV(points[i].y + yoffset); + xx = LogicalToDeviceX(points[i].x + xoffset); + yy = LogicalToDeviceY(points[i].y + yoffset); fprintf( m_pstream, "%d %d lineto\n", xx, yy ); @@ -680,19 +680,19 @@ void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCo int i; for ( i =0; i maxX ) { wxCoord tmp = minX; minX = maxX; maxX = tmp; } @@ -1957,7 +1957,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, lastStyle = Style; lastWeight = Weight; - char *name = (char*) NULL; + const char *name = NULL; switch (Family) { @@ -2034,10 +2034,8 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, - afmFile = fopen() may fail and in that case the next if branch MUST be executed - and it would not if there was "else" */ { - afmName = wxINSTALL_PREFIX; + afmName = wxGetDataDir(); afmName << wxFILE_SEP_PATH - << wxT("share") << wxFILE_SEP_PATH - << wxT("wx") << wxFILE_SEP_PATH #if defined(__LINUX__) || defined(__FREEBSD__) << wxT("gs_afm") << wxFILE_SEP_PATH #else @@ -2050,7 +2048,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, if (afmFile==NULL) { - wxLogDebug( wxT("GetTextExtent: can't open AFM file '%hs'"), afmName.c_str() ); + wxLogDebug( wxT("GetTextExtent: can't open AFM file '%s'"), afmName.c_str() ); wxLogDebug( wxT(" using approximate values")); for (int i=0; i<256; i++) lastWidths[i] = 500; /* an approximate value */ lastDescender = -150; /* dito. */ @@ -2073,7 +2071,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, if ((sscanf(line,"%s%d",descString,&lastDescender)!=2) || (strcmp(descString,"Descender")!=0)) { - wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad descender)"), afmName.c_str(),line ); + wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad descender)"), afmName.c_str(),line ); } } /* JC 1.) check for UnderlinePosition */ @@ -2082,7 +2080,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, if ((sscanf(line,"%s%lf",upString,&UnderlinePosition)!=2) || (strcmp(upString,"UnderlinePosition")!=0)) { - wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlinePosition)"), afmName.c_str(), line ); + wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlinePosition)"), afmName.c_str(), line ); } } /* JC 2.) check for UnderlineThickness */ @@ -2091,7 +2089,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, if ((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) || (strcmp(utString,"UnderlineThickness")!=0)) { - wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlineThickness)"), afmName.c_str(), line ); + wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad UnderlineThickness)"), afmName.c_str(), line ); } } /* JC 3.) check for EncodingScheme */ @@ -2100,11 +2098,11 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, if ((sscanf(line,"%s%s",utString,encString)!=2) || (strcmp(utString,"EncodingScheme")!=0)) { - wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad EncodingScheme)"), afmName.c_str(), line ); + wxLogDebug( wxT("AFM-file '%s': line '%s' has error (bad EncodingScheme)"), afmName.c_str(), line ); } else if (strncmp(encString, "AdobeStandardEncoding", 21)) { - wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (unsupported EncodingScheme %hs)"), + wxLogDebug( wxT("AFM-file '%s': line '%s' has error (unsupported EncodingScheme %s)"), afmName.c_str(),line, encString); } } @@ -2113,11 +2111,11 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, { if (sscanf(line,"%s%d%s%s%d",cString,&ascii,semiString,WXString,&cWidth)!=5) { - wxLogDebug(wxT("AFM-file '%hs': line '%hs' has an error (bad character width)"),afmName.c_str(),line); + wxLogDebug(wxT("AFM-file '%s': line '%s' has an error (bad character width)"),afmName.c_str(),line); } if(strcmp(cString,"C")!=0 || strcmp(semiString,";")!=0 || strcmp(WXString,"WX")!=0) { - wxLogDebug(wxT("AFM-file '%hs': line '%hs' has a format error"),afmName.c_str(),line); + wxLogDebug(wxT("AFM-file '%s': line '%s' has a format error"),afmName.c_str(),line); } /* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */ if (ascii>=0 && ascii<256) @@ -2151,9 +2149,9 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, // VS: dirty, but is there any better solution? double *pt; pt = (double*) &m_underlinePosition; - *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f; + *pt = LogicalToDeviceYRel((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f; pt = (double*) &m_underlineThickness; - *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f; + *pt = LogicalToDeviceYRel((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f; } @@ -2169,7 +2167,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, { if(lastWidths[*p]== INT_MIN) { - wxLogDebug(wxT("GetTextExtent: undefined width for character '%hc' (%d)"), *p,*p); + wxLogDebug(wxT("GetTextExtent: undefined width for character '%c' (%d)"), *p,*p); sum += lastWidths[' ']; /* assume space */ } else