]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
use wxBusyCursor class instead of wxBeginBusyCursor and several (mismatched and thus...
[wxWidgets.git] / src / msw / dc.cpp
index 914bfa6fb3a3d79f248eb3713a1cdcdc0f373039..0dc13d5a1f171185ae2eb8809a8f57f4829ecd3f 100644 (file)
@@ -572,7 +572,7 @@ bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
     }
 
     CalcBoundingBox(x, y);
-    
+
     return success;
 #endif
 }
@@ -630,7 +630,12 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1,
                      wxCoord xc, wxCoord yc)
 {
 #ifdef __WXWINCE__
-    // FIXME: emulate Arc
+    // Slower emulation since WinCE doesn't support Pie and Arc
+    double r = sqrt( (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc) );
+    double sa = acos((x1-xc)/r)/M_PI*180; // between 0 and 180
+    if( y1>yc ) sa = -sa; // below center
+    double ea = atan2(yc-y2, x2-xc)/M_PI*180;
+    DoDrawEllipticArcRot( xc-r, yc-r, 2*r, 2*r, sa, ea );
 #else
 
 #ifdef __WXMICROWIN__
@@ -788,6 +793,50 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffs
     }
 }
 
+void
+wxDC::DoDrawPolyPolygon(int n,
+                        int start[],
+                        wxPoint points[],
+                        wxCoord xoffset,
+                        wxCoord yoffset,
+                        int fillStyle)
+{
+#ifdef __WXMICROWIN__
+    if (!GetHDC()) return;
+#endif
+
+    wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
+    int i, cnt;
+    for (i = cnt = 0; i < n; i++)
+        cnt += start[i];
+
+    // Do things less efficiently if we have offsets
+    if (xoffset != 0 || yoffset != 0)
+    {
+        POINT *cpoints = new POINT[cnt];
+        for (i = 0; i < cnt; i++)
+        {
+            cpoints[i].x = (int)(points[i].x + xoffset);
+            cpoints[i].y = (int)(points[i].y + yoffset);
+
+            CalcBoundingBox(cpoints[i].x, cpoints[i].y);
+        }
+        int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
+        (void)PolyPolygon(GetHdc(), cpoints, start, n);
+        SetPolyFillMode(GetHdc(),prev);
+        delete[] cpoints;
+    }
+    else
+    {
+        for (i = 0; i < cnt; i++)
+            CalcBoundingBox(points[i].x, points[i].y);
+
+        int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING);
+        (void)PolyPolygon(GetHdc(), (POINT*) points, start, n);
+        SetPolyFillMode(GetHdc(),prev);
+    }
+}
+
 void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
 {
 #ifdef __WXMICROWIN__
@@ -873,11 +922,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h
 
     if (radius < 0.0)
     {
-        double smallest = 0.0;
-        if (width < height)
-            smallest = width;
-        else
-            smallest = height;
+        double smallest = (width < height) ? width : height;
         radius = (- radius * smallest);
     }
 
@@ -921,7 +966,7 @@ void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
 {
 #ifdef __WXWINCE__
-    // FIXME
+    DoDrawEllipticArcRot( x, y, w, h, sa, ea );
 #else
 
 #ifdef __WXMICROWIN__
@@ -1427,8 +1472,7 @@ void wxDC::SetBrush(const wxBrush& brush)
 
         if ( m_brush.GetResourceHandle() )
         {
-            HBRUSH b = 0;
-            b = (HBRUSH) ::SelectObject(GetHdc(), (HBRUSH)m_brush.GetResourceHandle());
+            HBRUSH b = (HBRUSH) ::SelectObject(GetHdc(), (HBRUSH)m_brush.GetResourceHandle());
             if (!m_oldBrush)
                 m_oldBrush = (WXHBRUSH) b;
         }
@@ -1864,7 +1908,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
         ::SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() );
     }
 
-    DWORD dwRop = SRCCOPY;
+    DWORD dwRop;
     switch (rop)
     {
         case wxXOR:          dwRop = SRCINVERT;        break;
@@ -2021,10 +2065,19 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
             {
                 StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
 
+                // Figure out what co-ordinate system we're supposed to specify
+                // ysrc in.
+                const LONG hDIB = ds.dsBmih.biHeight;
+                if ( hDIB > 0 )
+                {
+                    // reflect ysrc
+                    ysrc = hDIB - (ysrc + height);
+                }
+
                 if ( ::StretchDIBits(GetHdc(),
                                      xdest, ydest,
                                      width, height,
-                                     0, 0,
+                                     xsrc, ysrc,
                                      width, height,
                                      ds.dsBm.bmBits,
                                      (LPBITMAPINFO)&ds.dsBmih,
@@ -2042,8 +2095,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
         }
 
         if ( !success && (caps & RC_STRETCHBLT) )
+#endif
+        // __WXWINCE__
         {
+#ifndef __WXWINCE__
             StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+#endif
 
             if ( !::StretchBlt
                     (
@@ -2081,8 +2138,6 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
                 success = TRUE;
             }
         }
-#endif
-        // __WXWINCE__
     }
 
     ::SetTextColor(GetHdc(), old_textground);