1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/region.h
3 // Purpose: wxRegion class
4 // Author: Markus Holzem, Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "region.h"
20 #include "wx/gdiobj.h"
21 #include "wx/gdicmn.h"
23 class WXDLLEXPORT wxRect
;
24 class WXDLLEXPORT wxPoint
;
33 // So far, for internal use only
36 wxRGN_AND
, // Creates the intersection of the two combined regions.
37 wxRGN_COPY
, // Creates a copy of the region identified by hrgnSrc1.
38 wxRGN_DIFF
, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
39 wxRGN_OR
, // Creates the union of two combined regions.
40 wxRGN_XOR
// Creates the union of two combined regions except for any overlapping areas.
43 class WXDLLEXPORT wxRegion
: public wxGDIObject
47 wxRegion(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
48 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
49 wxRegion(const wxRect
& rect
);
50 wxRegion(WXHRGN hRegion
); // Hangs on to this region
51 wxRegion(size_t n
, const wxPoint
*points
, int fillStyle
= wxODDEVEN_RULE
);
56 wxRegion(const wxRegion
& r
)
58 wxRegion
& operator = (const wxRegion
& r
)
59 { Ref(r
); return (*this); }
64 // Clear current region
68 bool Offset(wxCoord x
, wxCoord y
);
70 // Union rectangle or region with this.
71 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_OR
); }
72 bool Union(const wxRect
& rect
) { return Combine(rect
, wxRGN_OR
); }
73 bool Union(const wxRegion
& region
) { return Combine(region
, wxRGN_OR
); }
75 // Intersect rectangle or region with this.
76 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_AND
); }
77 bool Intersect(const wxRect
& rect
) { return Combine(rect
, wxRGN_AND
); }
78 bool Intersect(const wxRegion
& region
) { return Combine(region
, wxRGN_AND
); }
80 // Subtract rectangle or region from this:
81 // Combines the parts of 'this' that are not part of the second region.
82 bool Subtract(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_DIFF
); }
83 bool Subtract(const wxRect
& rect
) { return Combine(rect
, wxRGN_DIFF
); }
84 bool Subtract(const wxRegion
& region
) { return Combine(region
, wxRGN_DIFF
); }
86 // XOR: the union of two combined regions except for any overlapping areas.
87 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_XOR
); }
88 bool Xor(const wxRect
& rect
) { return Combine(rect
, wxRGN_XOR
); }
89 bool Xor(const wxRegion
& region
) { return Combine(region
, wxRGN_XOR
); }
91 // Information on region
92 // ---------------------
94 // Outer bounds of region
95 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
&w
, wxCoord
&h
) const;
96 wxRect
GetBox(void) const ;
99 bool Empty(void) const;
100 inline bool IsEmpty(void) const { return Empty(); }
103 // Does the region contain the point (x,y)?
104 wxRegionContain
Contains(wxCoord x
, wxCoord y
) const;
105 // Does the region contain the point pt?
106 wxRegionContain
Contains(const wxPoint
& pt
) const;
107 // Does the region contain the rectangle (x, y, w, h)?
108 wxRegionContain
Contains(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) const;
109 // Does the region contain the rectangle rect?
110 wxRegionContain
Contains(const wxRect
& rect
) const;
113 bool Combine(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, wxRegionOp op
);
114 bool Combine(const wxRegion
& region
, wxRegionOp op
);
115 bool Combine(const wxRect
& rect
, wxRegionOp op
);
117 // Get internal region handle
118 WXHRGN
GetHRGN() const;
121 virtual wxObjectRefData
*CreateRefData() const;
122 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
124 friend class WXDLLEXPORT wxRegionIterator
;
126 DECLARE_DYNAMIC_CLASS(wxRegion
)
129 class WXDLLEXPORT wxRegionIterator
: public wxObject
132 wxRegionIterator(void);
133 wxRegionIterator(const wxRegion
& region
);
134 ~wxRegionIterator(void);
136 void Reset(void) { m_current
= 0; }
137 void Reset(const wxRegion
& region
);
140 operator bool (void) const { return (m_current
< m_numRects
); }
143 bool HaveRects(void) const { return (m_current
< m_numRects
); }
145 void operator ++ (void);
146 void operator ++ (int);
148 wxCoord
GetX(void) const;
149 wxCoord
GetY(void) const;
150 wxCoord
GetW(void) const;
151 wxCoord
GetWidth(void) const { return GetW(); }
152 wxCoord
GetH(void) const;
153 wxCoord
GetHeight(void) const { return GetH(); }
154 wxRect
GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
162 DECLARE_DYNAMIC_CLASS(wxRegionIterator
);