+#if wxUSE_IMAGE
+ // Use the non-transparent pixels of a wxBitmap for the region to combine
+ // with this region. First version takes transparency from bitmap's mask,
+ // second lets the user specify the colour to be treated as transparent
+ // along with an optional tolerance value.
+ // NOTE: implemented in common/rgncmn.cpp
+ bool Union(const wxBitmap& bmp);
+ bool Union(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0);
+#endif // wxUSE_IMAGE
+
+ // Intersect rectangle or region with this one.
+ bool Intersect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
+ { return Intersect(wxRect(x, y, w, h)); }
+ bool Intersect(const wxRect& rect);
+ bool Intersect(const wxRegion& region)
+ { return DoIntersect(region); }
+
+ // Subtract rectangle or region from this:
+ // Combines the parts of 'this' that are not part of the second region.
+ bool Subtract(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
+ { return Subtract(wxRect(x, y, w, h)); }
+ bool Subtract(const wxRect& rect);
+ bool Subtract(const wxRegion& region)
+ { return DoSubtract(region); }
+
+ // XOR: the union of two combined regions except for any overlapping areas.
+ bool Xor(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
+ { return Xor(wxRect(x, y, w, h)); }
+ bool Xor(const wxRect& rect);
+ bool Xor(const wxRegion& region)
+ { return DoXor(region); }
+
+
+ // Convert the region to a B&W bitmap with the white pixels being inside
+ // the region.
+ wxBitmap ConvertToBitmap() const;
+
+protected:
+ virtual bool DoIsEqual(const wxRegion& region) const = 0;
+ virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const = 0;
+ virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const = 0;
+ virtual wxRegionContain DoContainsRect(const wxRect& rect) const = 0;
+
+ virtual bool DoOffset(wxCoord x, wxCoord y) = 0;
+
+ virtual bool DoUnionWithRect(const wxRect& rect) = 0;
+ virtual bool DoUnionWithRegion(const wxRegion& region) = 0;
+
+ virtual bool DoIntersect(const wxRegion& region) = 0;
+ virtual bool DoSubtract(const wxRegion& region) = 0;
+ virtual bool DoXor(const wxRegion& region) = 0;
+};
+
+// some ports implement a generic Combine() function while others only
+// implement individual wxRegion operations, factor out the common code for the
+// ports with Combine() in this class
+#if defined(__WXPALMOS__) || \
+ defined(__WXMSW__) || \
+ defined(__WXMAC__) || \
+ defined(__WXPM__)
+
+#define wxHAS_REGION_COMBINE
+
+class WXDLLEXPORT wxRegionWithCombine : public wxRegionBase
+{
+public:
+ // these methods are not part of public API as they're not implemented on
+ // all ports
+ bool Combine(wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxRegionOp op);
+ bool Combine(const wxRect& rect, wxRegionOp op);
+ bool Combine(const wxRegion& region, wxRegionOp op)
+ { return DoCombine(region, op); }
+
+
+protected:
+ // the real Combine() method, to be defined in the derived class
+ virtual bool DoCombine(const wxRegion& region, wxRegionOp op) = 0;
+
+ // implement some wxRegionBase pure virtuals in terms of Combine()
+ virtual bool DoUnionWithRect(const wxRect& rect)
+ { return Combine(rect, wxRGN_OR); }
+ virtual bool DoUnionWithRegion(const wxRegion& region)
+ { return Combine(region, wxRGN_OR); }
+
+ virtual bool DoIntersect(const wxRegion& region)
+ { return Combine(region, wxRGN_AND); }
+ virtual bool DoSubtract(const wxRegion& region)
+ { return Combine(region, wxRGN_DIFF); }
+ virtual bool DoXor(const wxRegion& region)
+ { return Combine(region, wxRGN_XOR); }
+};
+
+#endif // ports with wxRegion::Combine()
+
+#if defined(__WXPALMOS__)
+ #include "wx/palmos/region.h"
+#elif defined(__WXMSW__)
+ #include "wx/msw/region.h"
+#elif defined(__WXGTK20__)
+ #include "wx/gtk/region.h"
+#elif defined(__WXGTK__)
+ #include "wx/gtk1/region.h"
+#elif defined(__WXMOTIF__) || defined(__WXX11__)
+ #include "wx/x11/region.h"
+#elif defined(__WXMGL__)
+ #include "wx/mgl/region.h"
+#elif defined(__WXDFB__)
+ #include "wx/dfb/region.h"
+#elif defined(__WXMAC__)
+ #include "wx/mac/region.h"
+#elif defined(__WXCOCOA__)
+ #include "wx/cocoa/region.h"
+#elif defined(__WXPM__)
+ #include "wx/os2/region.h"