]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcgraph.cpp
make wxMask pixmap member private
[wxWidgets.git] / src / common / dcgraph.cpp
index 812ca0e4edc4628208da3cec2c4caa196c89a453..2e57a41a2cb22789f2560202d9b49cf6e23eaff1 100644 (file)
@@ -187,13 +187,7 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
 {
     Init();
     wxGraphicsContext* context;
-#if wxUSE_CAIRO
-    wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
-    context = renderer->CreateContext(dc);
-#else
     context = wxGraphicsContext::Create(dc);
-#endif
-
     SetGraphicsContext( context );
 }
 
@@ -388,7 +382,10 @@ void wxGCDCImpl::SetTextForeground( const wxColour &col )
 {
     wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
 
-    if ( col != m_textForegroundColour )
+    // don't set m_textForegroundColour to an invalid colour as we'd crash
+    // later then (we use m_textForegroundColour.GetColor() without checking
+    // in a few places)
+    if ( col.IsOk() && col != m_textForegroundColour )
     {
         m_textForegroundColour = col;
         m_graphicContext->SetFont( m_font, m_textForegroundColour );
@@ -906,6 +903,7 @@ bool wxGCDCImpl::DoStretchBlit(
                    source->LogicalToDeviceY(ysrc),
                    source->LogicalToDeviceXRel(srcWidth),
                    source->LogicalToDeviceYRel(srcHeight));
+    const wxRect subrectOrig = subrect;
     // clip the subrect down to the size of the source DC
     wxRect clip;
     source->GetSize(&clip.width, &clip.height);
@@ -937,8 +935,19 @@ bool wxGCDCImpl::DoStretchBlit(
             if ( !useMask && blit.GetMask() )
                 blit.SetMask(NULL);
 
-            m_graphicContext->DrawBitmap( blit, xdest, ydest,
-                                          dstWidth, dstHeight);
+            double x = xdest;
+            double y = ydest;
+            double w = dstWidth;
+            double h = dstHeight;
+            // adjust dest rect if source rect is clipped
+            if (subrect.width != subrectOrig.width || subrect.height != subrectOrig.height)
+            {
+                x += (subrect.x - subrectOrig.x) / double(subrectOrig.width) * dstWidth;
+                y += (subrect.y - subrectOrig.y) / double(subrectOrig.height) * dstHeight;
+                w *= double(subrect.width) / subrectOrig.width;
+                h *= double(subrect.height) / subrectOrig.height;
+            }
+            m_graphicContext->DrawBitmap(blit, x, y, w, h);
         }
         else
         {