X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/87138c520ce5dc4d0268191074866e8bc300c984..5ea105e0ba20c15e4d83f829e1c4faeb0a4952f0:/src/generic/dcpsg.cpp diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 1d6dc9b7be..f21c2e82a9 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -315,6 +315,8 @@ wxPostScriptDC::wxPostScriptDC (const wxPrintData& printData) m_signY = -1; // default y-axis bottom up -> top down m_printData = printData; + + m_ok = TRUE; } wxPostScriptDC::~wxPostScriptDC () @@ -415,23 +417,23 @@ void wxPostScriptDC::Clear() wxFAIL_MSG( _T("wxPostScriptDC::Clear not implemented.") ); } -void wxPostScriptDC::FloodFill (long WXUNUSED(x), long WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) +void wxPostScriptDC::DoFloodFill (long WXUNUSED(x), long WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { wxFAIL_MSG( _T("wxPostScriptDC::FloodFill not implemented.") ); } -bool wxPostScriptDC::GetPixel (long WXUNUSED(x), long WXUNUSED(y), wxColour * WXUNUSED(col)) const +bool wxPostScriptDC::DoGetPixel (long WXUNUSED(x), long WXUNUSED(y), wxColour * WXUNUSED(col)) const { wxFAIL_MSG( _T("wxPostScriptDC::GetPixel not implemented.") ); return FALSE; } -void wxPostScriptDC::CrossHair (long WXUNUSED(x), long WXUNUSED(y)) +void wxPostScriptDC::DoCrossHair (long WXUNUSED(x), long WXUNUSED(y)) { wxFAIL_MSG( _T("wxPostScriptDC::CrossHair not implemented.") ); } -void wxPostScriptDC::DrawLine (long x1, long y1, long x2, long y2) +void wxPostScriptDC::DoDrawLine (long x1, long y1, long x2, long y2) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -450,7 +452,7 @@ void wxPostScriptDC::DrawLine (long x1, long y1, long x2, long y2) #define RAD2DEG 57.29577951308 -void wxPostScriptDC::DrawArc (long x1, long y1, long x2, long y2, long xc, long yc) +void wxPostScriptDC::DoDrawArc (long x1, long y1, long x2, long y2, long xc, long yc) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -513,7 +515,7 @@ void wxPostScriptDC::DrawArc (long x1, long y1, long x2, long y2, long xc, long CalcBoundingBox( xc+radius, yc+radius ); } -void wxPostScriptDC::DrawEllipticArc(long x,long y,long w,long h,double sa,double ea) +void wxPostScriptDC::DoDrawEllipticArc(long x,long y,long w,long h,double sa,double ea) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -555,7 +557,7 @@ void wxPostScriptDC::DrawEllipticArc(long x,long y,long w,long h,double sa,doubl } } -void wxPostScriptDC::DrawPoint (long x, long y) +void wxPostScriptDC::DoDrawPoint (long x, long y) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -571,7 +573,7 @@ void wxPostScriptDC::DrawPoint (long x, long y) CalcBoundingBox( x, y ); } -void wxPostScriptDC::DrawPolygon (int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle)) +void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle)) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -621,7 +623,7 @@ void wxPostScriptDC::DrawPolygon (int n, wxPoint points[], long xoffset, long yo } } -void wxPostScriptDC::DrawLines (int n, wxPoint points[], long xoffset, long yoffset) +void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], long xoffset, long yoffset) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -651,7 +653,7 @@ void wxPostScriptDC::DrawLines (int n, wxPoint points[], long xoffset, long yoff *m_pstream << "stroke\n"; } -void wxPostScriptDC::DrawRectangle (long x, long y, long width, long height) +void wxPostScriptDC::DoDrawRectangle (long x, long y, long width, long height) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -688,7 +690,7 @@ void wxPostScriptDC::DrawRectangle (long x, long y, long width, long height) } } -void wxPostScriptDC::DrawRoundedRectangle (long x, long y, long width, long height, double radius) +void wxPostScriptDC::DoDrawRoundedRectangle (long x, long y, long width, long height, double radius) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -749,7 +751,7 @@ void wxPostScriptDC::DrawRoundedRectangle (long x, long y, long width, long heig } } -void wxPostScriptDC::DrawEllipse (long x, long y, long width, long height) +void wxPostScriptDC::DoDrawEllipse (long x, long y, long width, long height) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -780,12 +782,12 @@ void wxPostScriptDC::DrawEllipse (long x, long y, long width, long height) } } -void wxPostScriptDC::DrawIcon( const wxIcon& icon, long x, long y ) +void wxPostScriptDC::DoDrawIcon( const wxIcon& icon, long x, long y ) { DrawBitmap( icon, x, y, TRUE ); } -void wxPostScriptDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool WXUNUSED(useMask) ) +void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool WXUNUSED(useMask) ) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -1045,7 +1047,7 @@ void wxPostScriptDC::SetBrush( const wxBrush& brush ) } } -void wxPostScriptDC::DrawText( const wxString& text, long x, long y, bool WXUNUSED(use16bit) ) +void wxPostScriptDC::DoDrawText( const wxString& text, long x, long y ) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -1090,7 +1092,7 @@ void wxPostScriptDC::DrawText( const wxString& text, long x, long y, bool WXUNUS *m_pstream << XLOG2DEV(x) << " " << YLOG2DEV(by) << " moveto\n"; *m_pstream << "("; - wxWX2MBbuf textbuf = text.mb_str(); + const wxWX2MBbuf textbuf = text.mb_str(); int len = strlen (textbuf); int i; for (i = 0; i < len; i++) @@ -1141,7 +1143,7 @@ void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function)) wxFAIL_MSG( _T("wxPostScriptDC::SetLogicalFunction not implemented.") ); } -void wxPostScriptDC::DrawSpline( wxList *points ) +void wxPostScriptDC::DoDrawSpline( wxList *points ) { wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); @@ -1197,7 +1199,7 @@ void wxPostScriptDC::DrawSpline( wxList *points ) *m_pstream << XLOG2DEV((long)c) << " " << YLOG2DEV((long)d) << " lineto stroke\n"; } -long wxPostScriptDC::GetCharWidth () +long wxPostScriptDC::GetCharWidth() const { // Chris Breeze: reasonable approximation using wxMODERN/Courier return (long) (GetCharHeight() * 72.0 / 120.0); @@ -1228,7 +1230,7 @@ void wxPostScriptDC::SetDeviceOrigin( long x, long y ) wxDC::SetDeviceOrigin( x, h-y ); } -void wxPostScriptDC::GetSize(int* width, int* height) const +void wxPostScriptDC::DoGetSize(int* width, int* height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1248,7 +1250,7 @@ void wxPostScriptDC::GetSize(int* width, int* height) const } } -void wxPostScriptDC::GetSizeMM(int *width, int *height) const +void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const { wxPaperSize id = m_printData.GetPaperId(); @@ -1335,7 +1337,7 @@ void wxPostScriptDC::EndDoc () *m_pstream << "%!PS-Adobe-2.0\n"; /* PostScript magic strings */ *m_pstream << "%%Title: " << m_title.mb_str() << "\n"; *m_pstream << "%%Creator: " << wxTheApp->argv[0] << "\n"; - *m_pstream << "%%CreationDate: " << wxNow() << "\n"; + *m_pstream << "%%CreationDate: " << wxNow().mb_str() << "\n"; wxChar userID[256]; if ( wxGetEmailAddress(userID, sizeof(userID)) ) @@ -1527,7 +1529,7 @@ void wxPostScriptDC::EndPage () *m_pstream << "showpage\n"; } -bool wxPostScriptDC::Blit( long xdest, long ydest, +bool wxPostScriptDC::DoBlit( long xdest, long ydest, long fwidth, long fheight, wxDC *source, long xsrc, long ysrc, @@ -1552,7 +1554,7 @@ bool wxPostScriptDC::Blit( long xdest, long ydest, return TRUE; } -long wxPostScriptDC::GetCharHeight() +long wxPostScriptDC::GetCharHeight() const { if (m_font.Ok()) return m_font.GetPointSize(); @@ -1561,8 +1563,7 @@ long wxPostScriptDC::GetCharHeight() } void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, - long *descent, long *externalLeading, wxFont *theFont, - bool WXUNUSED(use16) ) + long *descent, long *externalLeading, wxFont *theFont ) const { wxFont *fontToUse = theFont; @@ -1572,7 +1573,7 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, wxCHECK_RET( x, _T("GetTextExtent: x == NULL") ); wxCHECK_RET( y, _T("GetTextExtent: y == NULL") ); - wxWX2MBbuf strbuf = string.mb_str(); + const wxWX2MBbuf strbuf = string.mb_str(); #if !USE_AFM_FOR_POSTSCRIPT /* Provide a VERY rough estimate (avoid using it). @@ -1684,8 +1685,11 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, /* get the directory of the AFM files */ char afmName[256]; afmName[0] = 0; - wxString fmPath(m_printData.GetFontMetricPath()); - if (fmPath != "") strcpy( afmName, (const char*) fmPath ); + + if (!m_printData.GetFontMetricPath().IsEmpty()) + { + strcpy( afmName, m_printData.GetFontMetricPath().mb_str() ) + } /* 2. open and process the file / a short explanation of the AFM format: @@ -1706,7 +1710,26 @@ void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, strcat(afmName,name); strcat(afmName,".afm"); FILE *afmFile = fopen(afmName,"r"); - if ( afmFile==NULL ) + +#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"); + } +#endif + + if (afmFile==NULL) { wxLogDebug( "GetTextExtent: can't open AFM file '%s'\n", afmName ); wxLogDebug( " using approximate values\n");