#include "wx/icon.h"
#endif
+#include "wx/settings.h"
#include "wx/dcprint.h"
#include <string.h>
m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
}
-void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
+void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
m_clipping = TRUE;
- IntersectClipRect(GetHdc(), XLOG2DEV(cx), YLOG2DEV(cy),
- XLOG2DEV(cx + cw), YLOG2DEV(cy + ch));
- DO_SET_CLIPPING_BOX()
+
+ // the region coords are always the device ones, so do the translation
+ // manually
+ HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x),
+ LogicalToDeviceY(y),
+ LogicalToDeviceX(x + w),
+ LogicalToDeviceY(y + h));
+ if ( !hrgn )
+ {
+ wxLogLastError(_T("CreateRectRgn"));
+ }
+ else
+ {
+ if ( ::SelectClipRgn(GetHdc(), hrgn) == ERROR )
+ {
+ wxLogLastError(_T("SelectClipRgn"));
+ }
+
+ DO_SET_CLIPPING_BOX()
+ }
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
if ( useMask )
{
#ifdef __WIN32__
- HDC hdcMem = ::CreateCompatibleDC(GetHdc());
- ::SelectObject(hdcMem, GetHbitmapOf(bmp));
-
// use MaskBlt() with ROP which doesn't do anything to dst in the mask
// points
- bool ok = ::MaskBlt(GetHdc(), x, y, width, height,
+ // On some systems, MaskBlt succeeds yet is much much slower
+ // than the wxWindows fall-back implementation. So we need
+ // to be able to switch this on and off at runtime.
+ bool ok = FALSE;
+ if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0)
+ {
+ HDC hdcMem = ::CreateCompatibleDC(GetHdc());
+ ::SelectObject(hdcMem, GetHbitmapOf(bmp));
+
+ ok = ::MaskBlt(GetHdc(), x, y, width, height,
hdcMem, 0, 0,
hbmpMask, 0, 0,
MAKEROP4(SRCCOPY, DSTCOPY)) != 0;
- ::DeleteDC(hdcMem);
+ ::DeleteDC(hdcMem);
+ }
if ( !ok )
#endif // Win32
SetROP2(GetHdc(), rop);
}
-bool wxDC::StartDoc(const wxString& message)
+bool wxDC::StartDoc(const wxString& WXUNUSED(message))
{
// We might be previewing, so return TRUE to let it continue.
return TRUE;
return FALSE;
}
- bool success;
+ bool success = FALSE;
if (useMask)
{
// transparent, so use "DSTCOPY" ROP for the mask points (the usual
// meaning of fg and bg is inverted which corresponds to wxWin notion
// of the mask which is also contrary to the Windows one)
- success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
+
+ // On some systems, MaskBlt succeeds yet is much much slower
+ // than the wxWindows fall-back implementation. So we need
+ // to be able to switch this on and off at runtime.
+ if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0)
+ {
+ success = ::MaskBlt(GetHdc(), xdest, ydest, width, height,
GetHdcOf(*source), xsrc, ysrc,
(HBITMAP)mask->GetMaskBitmap(), xsrc, ysrc,
MAKEROP4(dwRop, DSTCOPY)) != 0;
+ }
if ( !success )
#endif // Win32