// clipping
// ---------------------------------------------------------------------------
-#define DO_SET_CLIPPING_BOX() \
-{ \
- RECT rect; \
- \
- GetClipBox(GetHdc(), &rect); \
- \
- m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \
- m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \
- m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \
- m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
+void wxDC::UpdateClipBox()
+{
+ RECT rect;
+ GetClipBox(GetHdc(), &rect);
+
+ m_clipX1 = (wxCoord) XDEV2LOG(rect.left);
+ m_clipY1 = (wxCoord) YDEV2LOG(rect.top);
+ m_clipX2 = (wxCoord) XDEV2LOG(rect.right);
+ m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom);
}
void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
// the region coords are always the device ones, so do the translation
// manually
+ //
+ // FIXME: possible +/-1 error here, to check!
HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x),
LogicalToDeviceY(y),
LogicalToDeviceX(x + w),
wxLogLastError(_T("SelectClipRgn"));
}
- DO_SET_CLIPPING_BOX()
+ UpdateClipBox();
}
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
{
- wxCHECK_RET( region.GetHRGN(), wxT("invalid clipping region") );
+ wxCHECK_RET( GetHrgnOf(region), wxT("invalid clipping region") );
m_clipping = TRUE;
#ifdef __WIN16__
- SelectClipRgn(GetHdc(), (HRGN) region.GetHRGN());
-#else
- ExtSelectClipRgn(GetHdc(), (HRGN) region.GetHRGN(), RGN_AND);
-#endif
+ SelectClipRgn(GetHdc(), GetHrgnOf(region));
+#else // Win32
+ ExtSelectClipRgn(GetHdc(), GetHrgnOf(region), RGN_AND);
+#endif // Win16/32
- DO_SET_CLIPPING_BOX()
+ UpdateClipBox();
}
void wxDC::DestroyClippingRegion()
SelectClipRgn(GetHdc(), rgn);
DeleteObject(rgn);
}
+
m_clipping = FALSE;
}