/////////////////////////////////////////////////////////////////////////////
-// Name: rgncmn.cpp
+// Name: src/common/rgncmn.cpp
// Purpose: Methods of wxRegion that have a generic implementation
// Author: Robin Dunn
// Modified by:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "rgncmn.h"
-#endif
-
+// ============================================================================
+// declarations
+// ============================================================================
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/region.h"
-#include "wx/bitmap.h"
-#if wxUSE_IMAGE
-#include "wx/image.h"
-#endif
-#include "wx/dcmemory.h"
+#ifndef WX_PRECOMP
+ #include "wx/dcmemory.h"
+ #include "wx/bitmap.h"
+ #include "wx/image.h"
+#endif //WX_PRECOMP
+
+// ============================================================================
+// wxRegionBase implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// region comparision
+// ----------------------------------------------------------------------------
-//---------------------------------------------------------------------------
+bool wxRegionBase::IsEqual(const wxRegion& region) const
+{
+ if ( m_refData == region.GetRefData() )
+ {
+ // regions are identical, hence equal
+ return true;
+ }
+
+ if ( !m_refData || !region.GetRefData() )
+ {
+ // one, but not both, of the regions is invalid
+ return false;
+ }
+ return DoIsEqual(region);
+}
+// ----------------------------------------------------------------------------
+// region to/from bitmap conversions
+// ----------------------------------------------------------------------------
-wxBitmap wxRegion::ConvertToBitmap() const
+wxBitmap wxRegionBase::ConvertToBitmap() const
{
wxRect box = GetBox();
wxBitmap bmp(box.GetRight(), box.GetBottom());
dc.SelectObject(bmp);
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
- dc.SetClippingRegion(*this);
+ dc.SetClippingRegion(*wx_static_cast(const wxRegion *, this));
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
dc.SelectObject(wxNullBitmap);
return bmp;
}
-//---------------------------------------------------------------------------
-
#if wxUSE_IMAGE
-static bool DoRegionUnion(wxRegion& region,
+
+static bool DoRegionUnion(wxRegionBase& region,
const wxImage& image,
unsigned char loR,
unsigned char loG,
}
-bool wxRegion::Union(const wxBitmap& bmp)
+bool wxRegionBase::Union(const wxBitmap& bmp)
{
if (bmp.GetMask())
{
}
}
-bool wxRegion::Union(const wxBitmap& bmp,
- const wxColour& transColour,
- int tolerance)
+bool wxRegionBase::Union(const wxBitmap& bmp,
+ const wxColour& transColour,
+ int tolerance)
{
wxImage image = bmp.ConvertToImage();
return DoRegionUnion(*this, image,
tolerance);
}
-#else
-
-bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp))
-{
- // No wxImage support
- return false;
-}
-
-bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp),
- const wxColour& WXUNUSED(transColour),
- int WXUNUSED(tolerance))
-{
- // No wxImage support
- return false;
-}
-
-#endif
-
-//---------------------------------------------------------------------------
+#endif // wxUSE_IMAGE