wxDC::SetClippingRegion() in wxMSW works like in wxGTK, i.e. combines the given region with the old one (also documented this behaviour as the correct one)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13967 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -57,6 +57,9 @@ wxMSW:
|
|||||||
style to avoid it, wxFRAME_FLOAT_ON_PARENT style is now obsolete and has no
|
style to avoid it, wxFRAME_FLOAT_ON_PARENT style is now obsolete and has no
|
||||||
effect
|
effect
|
||||||
|
|
||||||
|
- all overloads of wxDC::SetClippingRegion() combine the given region with the
|
||||||
|
previously selected one instead of replacing it
|
||||||
|
|
||||||
Unix ports:
|
Unix ports:
|
||||||
|
|
||||||
- You should use `wx-config --cxxflags` in your makefiles instead of
|
- You should use `wx-config --cxxflags` in your makefiles instead of
|
||||||
|
@@ -788,11 +788,21 @@ whether text will be drawn with a background colour or not.
|
|||||||
|
|
||||||
\func{void}{SetClippingRegion}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
|
\func{void}{SetClippingRegion}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
|
||||||
|
|
||||||
|
\func{void}{SetClippingRegion}{\param{const wxPoint\& }{pt}, \param{const wxSize\& }{sz}}
|
||||||
|
|
||||||
|
\func{void}{SetClippingRegion}{\param{const wxRect\&}{ rect}}
|
||||||
|
|
||||||
\func{void}{SetClippingRegion}{\param{const wxRegion\&}{ region}}
|
\func{void}{SetClippingRegion}{\param{const wxRegion\&}{ region}}
|
||||||
|
|
||||||
Sets the clipping region for the DC. The clipping region is an area
|
Sets the clipping region for this device context to the intersection of the
|
||||||
to which drawing is restricted. Possible uses for the clipping region are for clipping text
|
given region described by the parameters of this method and the previously set
|
||||||
or for speeding up window redraws when only a known area of the screen is damaged.
|
clipping region. You should call
|
||||||
|
\helpref{DestroyClippingRegion}{wxdcdestroyclippingregion} if you want to set
|
||||||
|
the clipping region exactly to the region specified.
|
||||||
|
|
||||||
|
The clipping region is an area to which drawing is restricted. Possible uses
|
||||||
|
for the clipping region are for clipping text or for speeding up window redraws
|
||||||
|
when only a known area of the screen is damaged.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
|
@@ -235,6 +235,9 @@ protected:
|
|||||||
// common part of DoDrawText() and DoDrawRotatedText()
|
// common part of DoDrawText() and DoDrawRotatedText()
|
||||||
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
|
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
|
||||||
|
|
||||||
|
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
|
||||||
|
void SetClippingHrgn(WXHRGN hrgn);
|
||||||
|
|
||||||
// MSW-specific member variables
|
// MSW-specific member variables
|
||||||
int m_windowExtX;
|
int m_windowExtX;
|
||||||
int m_windowExtY;
|
int m_windowExtY;
|
||||||
|
@@ -279,7 +279,7 @@ void wxDC::UpdateClipBox()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClipBox(GetHdc(), &rect);
|
::GetClipBox(GetHdc(), &rect);
|
||||||
|
|
||||||
m_clipX1 = (wxCoord) XDEV2LOG(rect.left);
|
m_clipX1 = (wxCoord) XDEV2LOG(rect.left);
|
||||||
m_clipY1 = (wxCoord) YDEV2LOG(rect.top);
|
m_clipY1 = (wxCoord) YDEV2LOG(rect.top);
|
||||||
@@ -287,14 +287,50 @@ void wxDC::UpdateClipBox()
|
|||||||
m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom);
|
m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
|
||||||
|
void wxDC::SetClippingHrgn(WXHRGN hrgn)
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( hrgn, wxT("invalid clipping region") );
|
||||||
|
|
||||||
#ifdef __WXMICROWIN__
|
#ifdef __WXMICROWIN__
|
||||||
if (!GetHDC()) return;
|
if (!GetHdc()) return;
|
||||||
#endif
|
#endif // __WXMICROWIN__
|
||||||
|
|
||||||
|
// note that we combine the new clipping region with the existing one: this
|
||||||
|
// is compatible with what the other ports do and is the documented
|
||||||
|
// behaviour now (starting with 2.3.3)
|
||||||
|
#ifdef __WIN16__
|
||||||
|
RECT rectClip;
|
||||||
|
if ( !::GetClipBox(GetHdc(), &rectClip) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
HRGN hrgnDest = ::CreateRectRgn(0, 0, 0, 0);
|
||||||
|
HRGN hrgnClipOld = ::CreateRectRgn(rectClip.left, rectClip.top,
|
||||||
|
rectClip.right, rectClip.bottom);
|
||||||
|
|
||||||
|
if ( ::CombineRgn(hrgnDest, hrgnClipOld, (HRGN)hrgn, RGN_AND) != ERROR )
|
||||||
|
{
|
||||||
|
::SelectClipRgn(GetHdc(), hrgnDest);
|
||||||
|
}
|
||||||
|
|
||||||
|
::DeleteObject(hrgnClipOld);
|
||||||
|
::DeleteObject(hrgnDest);
|
||||||
|
#else // Win32
|
||||||
|
if ( ::ExtSelectClipRgn(GetHdc(), (HRGN)hrgn, RGN_AND) == ERROR )
|
||||||
|
{
|
||||||
|
wxLogLastError(_T("ExtSelectClipRgn"));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // Win16/32
|
||||||
|
|
||||||
m_clipping = TRUE;
|
m_clipping = TRUE;
|
||||||
|
|
||||||
|
UpdateClipBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||||
|
{
|
||||||
// the region coords are always the device ones, so do the translation
|
// the region coords are always the device ones, so do the translation
|
||||||
// manually
|
// manually
|
||||||
//
|
//
|
||||||
@@ -309,33 +345,15 @@ void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ::SelectClipRgn(GetHdc(), hrgn) == ERROR )
|
SetClippingHrgn((WXHRGN)hrgn);
|
||||||
{
|
|
||||||
wxLogLastError(_T("SelectClipRgn"));
|
|
||||||
}
|
|
||||||
DeleteObject(hrgn);
|
|
||||||
|
|
||||||
UpdateClipBox();
|
::DeleteObject(hrgn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
|
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
|
||||||
{
|
{
|
||||||
#ifdef __WXMICROWIN__
|
SetClippingHrgn(region.GetHRGN());
|
||||||
if (!GetHDC()) return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxCHECK_RET( GetHrgnOf(region), wxT("invalid clipping region") );
|
|
||||||
|
|
||||||
m_clipping = TRUE;
|
|
||||||
|
|
||||||
#ifdef __WIN16__
|
|
||||||
SelectClipRgn(GetHdc(), GetHrgnOf(region));
|
|
||||||
#else // Win32
|
|
||||||
ExtSelectClipRgn(GetHdc(), GetHrgnOf(region), RGN_AND);
|
|
||||||
#endif // Win16/32
|
|
||||||
|
|
||||||
UpdateClipBox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DestroyClippingRegion()
|
void wxDC::DestroyClippingRegion()
|
||||||
@@ -347,11 +365,12 @@ void wxDC::DestroyClippingRegion()
|
|||||||
if (m_clipping && m_hDC)
|
if (m_clipping && m_hDC)
|
||||||
{
|
{
|
||||||
// TODO: this should restore the previous clipping region,
|
// TODO: this should restore the previous clipping region,
|
||||||
// so that OnPaint processing works correctly, and the update clipping region
|
// so that OnPaint processing works correctly, and the update
|
||||||
// doesn't get destroyed after the first DestroyClippingRegion.
|
// clipping region doesn't get destroyed after the first
|
||||||
|
// DestroyClippingRegion.
|
||||||
HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
|
HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
|
||||||
SelectClipRgn(GetHdc(), rgn);
|
::SelectClipRgn(GetHdc(), rgn);
|
||||||
DeleteObject(rgn);
|
::DeleteObject(rgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_clipping = FALSE;
|
m_clipping = FALSE;
|
||||||
|
Reference in New Issue
Block a user