Added wxRegion version of wxWindowDC::SetClippingRegion

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1098 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-12-02 20:02:01 +00:00
parent f66b7050e0
commit a724d7892d
12 changed files with 91 additions and 13 deletions

View File

@@ -2045,6 +2045,34 @@ void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
}
};
void wxWindowDC::SetClippingRegion( const wxRegion& region )
{
wxRect box = region.GetBox();
wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = (WXRegion) XCreateRegion ();
XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
SetDCClipping ();
// Needs to work differently for Pixmap: without this,
// there's a nasty (Display*) m_display bug. 8/12/94
if (m_window && m_window->GetBackingPixmap())
{
XRectangle rects[1];
rects[0].x = XLOG2DEV_2(box.x);
rects[0].y = YLOG2DEV_2(box.y);
rects[0].width = XLOG2DEVREL(box.width);
rects[0].height = YLOG2DEVREL(box.height);
XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
}
};
void wxWindowDC::DestroyClippingRegion(void)
{
wxDC::DestroyClippingRegion();

View File

@@ -206,9 +206,7 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
break ;
}
// TODO combine region
return FALSE;
return FALSE;
}
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)

View File

@@ -181,6 +181,22 @@ void wxDC::SetClippingRegion(long cx, long cy, long cw, long ch)
DoClipping((WXHDC) m_hDC);
}
void wxDC::SetClippingRegion(const wxRegion& region)
{
if (!region.GetHRGN())
return;
wxRect box = region.GetBox();
m_clipping = TRUE;
m_clipX1 = box.x;
m_clipY1 = box.y;
m_clipX2 = box.x + box.width;
m_clipY2 = box.y + box.height;
ExtSelectClipRgn((HDC) m_hDC, (HRGN) region.GetHRGN(), RGN_AND);
}
void wxDC::DoClipping(WXHDC dc)
{
if (m_clipping && dc)
@@ -194,11 +210,14 @@ void wxDC::DestroyClippingRegion(void)
{
if (m_clipping && m_hDC)
{
// TODO: this should restore the previous clipping region,
// so that OnPaint processing works correctly, and the update clipping region
// doesn't get destroyed after the first DestroyClippingRegion.
HRGN rgn = CreateRectRgn(0, 0, 32000, 32000);
SelectClipRgn((HDC) m_hDC, rgn);
DeleteObject(rgn);
}
m_clipping = FALSE;
}
m_clipping = FALSE;
}
bool wxDC::CanDrawBitmap(void) const

View File

@@ -288,6 +288,14 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
return Contains(x, y, w, h);
}
// Get internal region handle
WXHRGN wxRegion::GetHRGN() const
{
if (!m_refData)
return (WXHRGN) 0;
return (WXHRGN) M_REGION;
}
///////////////////////////////////////////////////////////////////////////////
// //
// wxRegionIterator //

View File

@@ -448,9 +448,20 @@ void wxWindowDC::SetPalette( const wxPalette& WXUNUSED(palette) )
void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
{
wxDC::SetClippingRegion( x, y, width, height );
// TODO
};
void wxWindowDC::SetClippingRegion( const wxRegion& region )
{
wxRect box = region.GetBox();
wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
// TODO
}
void wxWindowDC::DestroyClippingRegion(void)
{
wxDC::DestroyClippingRegion();