X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/244e5e34c25377e326ce11b3d497a1fd76cbc1ad..abb492ba039cc5fcc0a5e9b1b1193995365501b3:/src/generic/dcpsg.cpp diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index c65d6c658e..0cfafaaabc 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -355,12 +355,12 @@ void wxPostScriptDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoo m_clipping = TRUE; - PsPrintf( wxT("gsave\n newpath\n" - "%d %d moveto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "closepath clip newpath\n"), + PsPrintf( wxT("gsave\n newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("closepath clip newpath\n"), LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x+w), LogicalToDeviceY(y), LogicalToDeviceX(x+w), LogicalToDeviceY(y+h), @@ -413,10 +413,10 @@ void wxPostScriptDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) SetPen( m_pen ); - PsPrintf( wxT("newpath\n" - "%d %d moveto\n" - "%d %d lineto\n" - "stroke\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("stroke\n"), LogicalToDeviceX(x1), LogicalToDeviceY(y1), LogicalToDeviceX(x2), LogicalToDeviceY (y2) ); @@ -462,11 +462,11 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, { SetBrush( m_brush ); - PsPrintf( wxT("newpath\n" - "%d %d %d %d %d %d ellipse\n" - "%d %d lineto\n" - "closepath\n" - "fill\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d ellipse\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("fill\n"), LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); @@ -478,11 +478,11 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, { SetPen( m_pen ); - PsPrintf( wxT("newpath\n" - "%d %d %d %d %d %d ellipse\n" - "%d %d lineto\n" - "stroke\n" - "fill\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d ellipse\n") + wxT("%d %d lineto\n") + wxT("stroke\n") + wxT("fill\n"), LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2, LogicalToDeviceX(xc), LogicalToDeviceY(yc) ); @@ -510,8 +510,8 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d { SetBrush( m_brush ); - PsPrintf( wxT("newpath\n" - "%d %d %d %d %d %d true ellipticarc\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d true ellipticarc\n"), LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea ); @@ -524,8 +524,8 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d { SetPen( m_pen ); - PsPrintf( wxT("newpath\n" - "%d %d %d %d %d %d false ellipticarc\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d %d %d false ellipticarc\n"), LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea ); @@ -543,10 +543,10 @@ void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y) SetPen (m_pen); - PsPrintf( wxT("newpath\n" - "%d %d moveto\n" - "%d %d lineto\n" - "stroke\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("stroke\n"), LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x+1), LogicalToDeviceY(y) ); @@ -613,7 +613,7 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx } } -void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxPostScriptDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -626,7 +626,7 @@ void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wx PsPrint( "newpath\n" ); int ofs = 0; - for (int i = 0; i < n; ofs += start[i++]) + for (int i = 0; i < n; ofs += count[i++]) { wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); @@ -635,7 +635,7 @@ void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wx CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); - for (int j = 1; j < start[i]; j++) + for (int j = 1; j < count[i]; j++) { xx = LogicalToDeviceX(points[ofs+j].x + xoffset); yy = LogicalToDeviceY(points[ofs+j].y + yoffset); @@ -655,7 +655,7 @@ void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wx PsPrint( "newpath\n" ); int ofs = 0; - for (int i = 0; i < n; ofs += start[i++]) + for (int i = 0; i < n; ofs += count[i++]) { wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); @@ -664,7 +664,7 @@ void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wx CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); - for (int j = 1; j < start[i]; j++) + for (int j = 1; j < count[i]; j++) { xx = LogicalToDeviceX(points[ofs+j].x + xoffset); yy = LogicalToDeviceY(points[ofs+j].y + yoffset); @@ -695,8 +695,8 @@ void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCo CalcBoundingBox( LogicalToDeviceX(points[i].x+xoffset), LogicalToDeviceY(points[i].y+yoffset)); } - PsPrintf( wxT("newpath\n" - "%d %d moveto\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n"), LogicalToDeviceX(points[0].x+xoffset), LogicalToDeviceY(points[0].y+yoffset) ); @@ -718,13 +718,13 @@ void wxPostScriptDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoo { SetBrush( m_brush ); - PsPrintf( wxT("newpath\n" - "%d %d moveto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "closepath\n" - "fill\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("fill\n"), LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x + width), LogicalToDeviceY(y), LogicalToDeviceX(x + width), LogicalToDeviceY(y + height), @@ -738,13 +738,13 @@ void wxPostScriptDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoo { SetPen (m_pen); - PsPrintf( wxT("newpath\n" - "%d %d moveto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "%d %d lineto\n" - "closepath\n" - "stroke\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("stroke\n"), LogicalToDeviceX(x), LogicalToDeviceY(y), LogicalToDeviceX(x + width), LogicalToDeviceY(y), LogicalToDeviceX(x + width), LogicalToDeviceY(y + height), @@ -774,17 +774,17 @@ void wxPostScriptDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width SetBrush( m_brush ); /* Draw rectangle anticlockwise */ - PsPrintf( wxT("newpath\n" - "%d %d %d 90 180 arc\n" - "%d %d moveto\n" - "%d %d %d 180 270 arc\n" - "%d %d lineto\n" - "%d %d %d 270 0 arc\n" - "%d %d lineto\n" - "%d %d %d 0 90 arc\n" - "%d %d lineto\n" - "closepath\n" - "fill\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d 90 180 arc\n") + wxT("%d %d moveto\n") + wxT("%d %d %d 180 270 arc\n") + wxT("%d %d lineto\n") + wxT("%d %d %d 270 0 arc\n") + wxT("%d %d lineto\n") + wxT("%d %d %d 0 90 arc\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("fill\n"), LogicalToDeviceX(x + rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad), LogicalToDeviceX(x), LogicalToDeviceY(y + rad), LogicalToDeviceX(x + rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad), @@ -803,17 +803,17 @@ void wxPostScriptDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width SetPen (m_pen); /* Draw rectangle anticlockwise */ - PsPrintf( wxT("newpath\n" - "%d %d %d 90 180 arc\n" - "%d %d moveto\n" - "%d %d %d 180 270 arc\n" - "%d %d lineto\n" - "%d %d %d 270 0 arc\n" - "%d %d lineto\n" - "%d %d %d 0 90 arc\n" - "%d %d lineto\n" - "closepath\n" - "stroke\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d 90 180 arc\n") + wxT("%d %d moveto\n") + wxT("%d %d %d 180 270 arc\n") + wxT("%d %d lineto\n") + wxT("%d %d %d 270 0 arc\n") + wxT("%d %d lineto\n") + wxT("%d %d %d 0 90 arc\n") + wxT("%d %d lineto\n") + wxT("closepath\n") + wxT("stroke\n"), LogicalToDeviceX(x + rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad), LogicalToDeviceX(x), LogicalToDeviceY(y + rad), LogicalToDeviceX(x + rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad), @@ -836,9 +836,9 @@ void wxPostScriptDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord { SetBrush (m_brush); - PsPrintf( wxT("newpath\n" - "%d %d %d %d 0 360 ellipse\n" - "fill\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d 0 360 ellipse\n") + wxT("fill\n"), LogicalToDeviceX(x + width / 2), LogicalToDeviceY(y + height / 2), LogicalToDeviceXRel(width / 2), LogicalToDeviceYRel(height / 2) ); @@ -850,9 +850,9 @@ void wxPostScriptDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord { SetPen (m_pen); - PsPrintf( wxT("newpath\n" - "%d %d %d %d 0 360 ellipse\n" - "stroke\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d %d %d 0 360 ellipse\n") + wxT("stroke\n"), LogicalToDeviceX(x + width / 2), LogicalToDeviceY(y + height / 2), LogicalToDeviceXRel(width / 2), LogicalToDeviceYRel(height / 2) ); @@ -888,18 +888,18 @@ void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, wxCoord xx = LogicalToDeviceX(x); wxCoord yy = LogicalToDeviceY(y + bitmap.GetHeight()); - PsPrintf( wxT("/origstate save def\n" - "20 dict begin\n" - "/pix %d string def\n" - "/grays %d string def\n" - "/npixels 0 def\n" - "/rgbindx 0 def\n" - "%d %d translate\n" - "%d %d scale\n" - "%d %d 8\n" - "[%d 0 0 %d 0 %d]\n" - "{currentfile pix readhexstring pop}\n" - "false 3 colorimage\n"), + PsPrintf( wxT("/origstate save def\n") + wxT("20 dict begin\n") + wxT("/pix %d string def\n") + wxT("/grays %d string def\n") + wxT("/npixels 0 def\n") + wxT("/rgbindx 0 def\n") + wxT("%d %d translate\n") + wxT("%d %d scale\n") + wxT("%d %d 8\n") + wxT("[%d 0 0 %d 0 %d]\n") + wxT("{currentfile pix readhexstring pop}\n") + wxT("false 3 colorimage\n"), w, w, xx, yy, ww, hh, w, h, w, -h, h ); unsigned char* data = image.GetData(); @@ -1011,6 +1011,10 @@ void wxPostScriptDC::SetFont( const wxFont& font ) } } + // We may legitimately call SetFont before BeginDoc + if (!m_pstream) + return; + PsPrint( name ); PsPrint( " reencodeISO def\n" ); PsPrint( name ); @@ -1634,9 +1638,9 @@ void wxPostScriptDC::DoDrawSpline( wxList *points ) #endif (double)(y1 + d) / 2; - PsPrintf( wxT("newpath\n" - "%d %d moveto\n" - "%d %d lineto\n"), + PsPrintf( wxT("newpath\n") + wxT("%d %d moveto\n") + wxT("%d %d lineto\n"), LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1), LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) ); @@ -1673,8 +1677,8 @@ void wxPostScriptDC::DoDrawSpline( wxList *points ) next-to-last and last point respectively, in the point list */ - PsPrintf( wxT("%d %d lineto\n" - "stroke\n"), + PsPrintf( wxT("%d %d lineto\n") + wxT("stroke\n"), LogicalToDeviceX((wxCoord)c), LogicalToDeviceY((wxCoord)d) ); } @@ -1775,7 +1779,7 @@ bool wxPostScriptDC::StartDoc( const wxString& message ) { wxCHECK_MSG( m_ok, FALSE, wxT("invalid postscript dc") ); - if ( m_printData.GetPrintMode() == wxPRINT_MODE_FILE ) + if ( m_printData.GetPrintMode() != wxPRINT_MODE_STREAM ) { if (m_printData.GetFilename() == wxT("")) {