]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dc.cpp
compilation fixes (bug #672413)
[wxWidgets.git] / src / msw / dc.cpp
index e533015783809b3b5636c24a0e0ebd119e52e3c9..8a05efa95c76f6b68e7d0206eff9e4e6c8ea2ba5 100644 (file)
     #include <print.h>
 #endif
 
     #include <print.h>
 #endif
 
+/* Quaternary raster codes */
+#ifndef MAKEROP4
+#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
+#endif
+
 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
 
 // ---------------------------------------------------------------------------
 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
 
 // ---------------------------------------------------------------------------
@@ -127,6 +132,30 @@ private:
     bool m_changed;
 };
 
     bool m_changed;
 };
 
+// this class saves the old stretch blit mode during its life time
+class StretchBltModeChanger
+{
+public:
+    StretchBltModeChanger(HDC hdc, int mode)
+        : m_hdc(hdc)
+    {
+        m_modeOld = ::SetStretchBltMode(m_hdc, mode);
+        if ( !m_modeOld )
+            wxLogLastError(_T("SetStretchBltMode"));
+    }
+
+    ~StretchBltModeChanger()
+    {
+        if ( !::SetStretchBltMode(m_hdc, m_modeOld) )
+            wxLogLastError(_T("SetStretchBltMode"));
+    }
+
+private:
+    const HDC m_hdc;
+
+    int m_modeOld;
+};
+
 // ===========================================================================
 // implementation
 // ===========================================================================
 // ===========================================================================
 // implementation
 // ===========================================================================
@@ -1803,10 +1832,16 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
         if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
 #endif
         {
         if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
 #endif
         {
-           success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
-                            GetHdcOf(*source), xsrc, ysrc,
-                            (HBITMAP)mask->GetMaskBitmap(), xsrcMask, ysrcMask,
-                            MAKEROP4(dwRop, DSTCOPY)) != 0;
+           success = ::MaskBlt
+                       (
+                            GetHdc(),
+                            xdest, ydest, width, height,
+                            GetHdcOf(*source),
+                            xsrc, ysrc,
+                            (HBITMAP)mask->GetMaskBitmap(),
+                            xsrcMask, ysrcMask,
+                            MAKEROP4(dwRop, DSTCOPY)
+                        ) != 0;
         }
 
         if ( !success )
         }
 
         if ( !success )
@@ -1896,14 +1931,39 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest,
     }
     else // no mask, just BitBlt() it
     {
     }
     else // no mask, just BitBlt() it
     {
-        success = ::BitBlt(GetHdc(), xdest, ydest,
-                           (int)width, (int)height,
-                           GetHdcOf(*source), xsrc, ysrc, dwRop) != 0;
+        // use StretchBlt() if available
+        if ( ::GetDeviceCaps(GetHdc(), RASTERCAPS) & RC_STRETCHBLT )
+        {
+            StretchBltModeChanger changeMode(GetHdc(), COLORONCOLOR);
+
+            success = ::StretchBlt
+                        (
+                            GetHdc(),
+                            xdest, ydest, width, height,
+                            GetHdcOf(*source),
+                            xsrc, ysrc, width, height,
+                            dwRop
+                        ) != 0;
+        }
+        else
+        {
+            success = ::BitBlt
+                        (
+                            GetHdc(),
+                            xdest, ydest,
+                            (int)width, (int)height,
+                            GetHdcOf(*source),
+                            xsrc, ysrc,
+                            dwRop
+                        ) != 0;
+        }
+
         if ( !success )
         {
         if ( !success )
         {
-            wxLogLastError(wxT("BitBlt"));
+            wxLogLastError(wxT("BitBlt/StretchBlt"));
         }
     }
         }
     }
+
     ::SetTextColor(GetHdc(), old_textground);
     ::SetBkColor(GetHdc(), old_background);
 
     ::SetTextColor(GetHdc(), old_textground);
     ::SetBkColor(GetHdc(), old_background);
 
@@ -1975,25 +2035,6 @@ void wxDC::SetLogicalScale(double x, double y)
     m_logicalScaleY = y;
 }
 
     m_logicalScaleY = y;
 }
 
-#if WXWIN_COMPATIBILITY
-void wxDC::DoGetTextExtent(const wxString& string, float *x, float *y,
-                         float *descent, float *externalLeading,
-                         wxFont *theFont, bool use16bit) const
-{
-#ifdef __WXMICROWIN__
-    if (!GetHDC()) return;
-#endif
-
-    wxCoord x1, y1, descent1, externalLeading1;
-    GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
-    *x = x1; *y = y1;
-    if (descent)
-        *descent = descent1;
-    if (externalLeading)
-        *externalLeading = externalLeading1;
-}
-#endif
-
 #if wxUSE_DC_CACHEING
 
 /*
 #if wxUSE_DC_CACHEING
 
 /*
@@ -2108,12 +2149,12 @@ void wxDC::AddToDCCache(wxDCCacheEntry* entry)
 
 void wxDC::ClearCache()
 {
 
 void wxDC::ClearCache()
 {
-    sm_bitmapCache.DeleteContents(TRUE);
-    sm_bitmapCache.Clear();
-    sm_bitmapCache.DeleteContents(FALSE);
     sm_dcCache.DeleteContents(TRUE);
     sm_dcCache.Clear();
     sm_dcCache.DeleteContents(FALSE);
     sm_dcCache.DeleteContents(TRUE);
     sm_dcCache.Clear();
     sm_dcCache.DeleteContents(FALSE);
+    sm_bitmapCache.DeleteContents(TRUE);
+    sm_bitmapCache.Clear();
+    sm_bitmapCache.DeleteContents(FALSE);
 }
 
 // Clean up cache at app exit
 }
 
 // Clean up cache at app exit