Add wxGraphicsContext::GetClipBox() function

This method returns bounding box of the current clipping region.
Added declaration, documentation and implemented for GDI+, Direct2D, Cairo renderers.
This commit is contained in:
Artur Wieczorek
2016-08-21 20:57:39 +02:00
parent 1927a2f8a0
commit 480a003c00
7 changed files with 159 additions and 0 deletions

View File

@@ -364,6 +364,9 @@ public:
// resets the clipping to original extent
virtual void ResetClip();
// returns bounding box of the clipping region
virtual void GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) wxOVERRIDE;
virtual void * GetNativeContext();
virtual void StrokePath( const wxGraphicsPath& p );
@@ -1663,6 +1666,26 @@ void wxGDIPlusContext::ResetClip()
m_context->ResetClip();
}
void wxGDIPlusContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h)
{
RectF r;
m_context->SetPixelOffsetMode(PixelOffsetModeNone);
m_context->GetVisibleClipBounds(&r);
m_context->SetPixelOffsetMode(PixelOffsetModeHalf);
// Check if we have an empty clipping box.
if ( r.Width <= REAL_MIN || r.Height <= REAL_MIN )
r.X = r.Y = r.Width = r.Height = 0.0F;
if ( x )
*x = r.X;
if ( y )
*y = r.Y;
if ( w )
*w = r.Width;
if ( h )
*h = r.Height;
}
void wxGDIPlusContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
if (m_composition == wxCOMPOSITION_DEST)