]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/dcpsg.cpp
font encoding support
[wxWidgets.git] / src / generic / dcpsg.cpp
index 9202e61e128798db7360fc155ad5d76a10426da9..e3025e3f243cbfe6072412200401f1ad96f16310 100644 (file)
@@ -564,7 +564,7 @@ void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y)
     CalcBoundingBox( x, y );
 }
 
-void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle))
+void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
 {
     wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
 
@@ -597,7 +597,7 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx
         }
 
         if ( m_pstream )
-            fprintf( m_pstream, "fill\n" );
+            fprintf( m_pstream, (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n"));
     }
 
     if (m_pen.GetStyle () != wxTRANSPARENT)
@@ -634,6 +634,72 @@ 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)
+{
+    wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") );
+
+    if (n <= 0) return;
+
+    if (m_brush.GetStyle () != wxTRANSPARENT)
+    {
+        SetBrush( m_brush );
+
+        fprintf( m_pstream, "newpath\n" );
+
+        int ofs = 0;
+        for (int i = 0; i < n; ofs += start[i++])
+        {
+            wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset);
+            wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset);
+
+            fprintf( m_pstream, "%d %d moveto\n", xx, yy );
+
+            CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );
+
+            for (int j = 1; j < start[i]; j++)
+            {
+                xx = LogicalToDeviceX(points[ofs+j].x + xoffset);
+                yy = LogicalToDeviceY(points[ofs+j].y + yoffset);
+
+                fprintf( m_pstream, "%d %d lineto\n", xx, yy );
+
+                CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
+            }
+        }
+        fprintf( m_pstream, (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n"));
+    }
+
+    if (m_pen.GetStyle () != wxTRANSPARENT)
+    {
+        SetPen( m_pen );
+
+        fprintf( m_pstream, "newpath\n" );
+
+        int ofs = 0;
+        for (int i = 0; i < n; ofs += start[i++])
+        {
+            wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset);
+            wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset);
+
+            fprintf( m_pstream, "%d %d moveto\n", xx, yy );
+
+            CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );
+
+            for (int j = 1; j < start[i]; j++)
+            {
+                xx = LogicalToDeviceX(points[ofs+j].x + xoffset);
+                yy = LogicalToDeviceY(points[ofs+j].y + yoffset);
+
+                fprintf( m_pstream, "%d %d lineto\n", xx, yy );
+
+                CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
+            }
+        }
+        fprintf( m_pstream, "closepath\n" );
+        fprintf( m_pstream, "stroke\n" );
+    }
+}
+
 void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
 {
     wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@@ -725,11 +791,7 @@ void wxPostScriptDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width
     {
         // Now, a negative radius is interpreted to mean
         // 'the proportion of the smallest X or Y dimension'
-        double smallest = 0.0;
-        if (width < height)
-            smallest = width;
-        else
-            smallest = height;
+        double smallest = width < height ? width : height;
         radius =  (-radius * smallest);
     }
 
@@ -962,8 +1024,6 @@ void wxPostScriptDC::SetFont( const wxFont& font )
         case wxSCRIPT:
         {
             name = "/ZapfChancery-MediumItalic";
-            Style  = wxNORMAL;
-            Weight = wxNORMAL;
             break;
         }
         case wxSWISS:
@@ -1046,7 +1106,8 @@ void wxPostScriptDC::SetPen( const wxPen& pen )
     static const char *wxCoord_dashed = "[4 8] 2";
     static const char *dotted_dashed = "[6 6 2 6] 4";
 
-    const char *psdash = (char *) NULL;
+    const char *psdash;
+
     switch (m_pen.GetStyle())
     {
         case wxDOT:           psdash = dotted;         break;
@@ -1651,7 +1712,8 @@ void wxPostScriptDC::DoDrawSpline( wxList *points )
     CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
     CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
 
-       while ((node = node->GetNext()))
+  node = node->GetNext();
+       while (node)
     {
         q = (wxPoint *)node->GetData();
 
@@ -1673,6 +1735,8 @@ void wxPostScriptDC::DoDrawSpline( wxList *points )
 
         CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
         CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
+
+        node = node->GetNext();
     }
 
     /*
@@ -2194,7 +2258,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
         lastStyle =  Style;
         lastWeight = Weight;
 
-        const wxChar *name = NULL;
+        const wxChar *name;
 
         switch (Family)
         {
@@ -2218,8 +2282,7 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
             case wxSCRIPT:
             {
                 name = wxT("Zapf.afm");
-                Style = wxNORMAL;
-                Weight = wxNORMAL;
+                break;
             }
             case wxSWISS:
             default: