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); }
62 // Clear current region
65 // Union rectangle or region with this.
66 inline bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_OR
); }
67 inline bool Union(const wxRect
& rect
) { return Combine(rect
, wxRGN_OR
); }
68 inline bool Union(const wxRegion
& region
) { return Combine(region
, wxRGN_OR
); }
70 // Intersect rectangle or region with this.
71 inline bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_AND
); }
72 inline bool Intersect(const wxRect
& rect
) { return Combine(rect
, wxRGN_AND
); }
73 inline bool Intersect(const wxRegion
& region
) { return Combine(region
, wxRGN_AND
); }
75 // Subtract rectangle or region from this:
76 // Combines the parts of 'this' that are not part of the second region.
77 inline bool Subtract(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_DIFF
); }
78 inline bool Subtract(const wxRect
& rect
) { return Combine(rect
, wxRGN_DIFF
); }
79 inline bool Subtract(const wxRegion
& region
) { return Combine(region
, wxRGN_DIFF
); }
81 // XOR: the union of two combined regions except for any overlapping areas.
82 inline bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) { return Combine(x
, y
, width
, height
, wxRGN_XOR
); }
83 inline bool Xor(const wxRect
& rect
) { return Combine(rect
, wxRGN_XOR
); }
84 inline bool Xor(const wxRegion
& region
) { return Combine(region
, wxRGN_XOR
); }
86 // Information on region
87 // Outer bounds of region
88 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
&w
, wxCoord
&h
) const;
89 wxRect
GetBox(void) const ;
92 bool Empty(void) const;
93 inline bool IsEmpty(void) const { return Empty(); }
96 // Does the region contain the point (x,y)?
97 wxRegionContain
Contains(wxCoord x
, wxCoord y
) const;
98 // Does the region contain the point pt?
99 wxRegionContain
Contains(const wxPoint
& pt
) const;
100 // Does the region contain the rectangle (x, y, w, h)?
101 wxRegionContain
Contains(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) const;
102 // Does the region contain the rectangle rect?
103 wxRegionContain
Contains(const wxRect
& rect
) const;
106 bool Combine(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
, wxRegionOp op
);
107 bool Combine(const wxRegion
& region
, wxRegionOp op
);
108 bool Combine(const wxRect
& rect
, wxRegionOp op
);
110 // Get internal region handle
111 WXHRGN
GetHRGN() const;
113 DECLARE_DYNAMIC_CLASS(wxRegion
);
114 friend class WXDLLEXPORT wxRegionIterator
;
117 class WXDLLEXPORT wxRegionIterator
: public wxObject
120 wxRegionIterator(void);
121 wxRegionIterator(const wxRegion
& region
);
122 ~wxRegionIterator(void);
124 void Reset(void) { m_current
= 0; }
125 void Reset(const wxRegion
& region
);
128 operator bool (void) const { return (m_current
< m_numRects
); }
131 bool HaveRects(void) const { return (m_current
< m_numRects
); }
133 void operator ++ (void);
134 void operator ++ (int);
136 wxCoord
GetX(void) const;
137 wxCoord
GetY(void) const;
138 wxCoord
GetW(void) const;
139 wxCoord
GetWidth(void) const { return GetW(); }
140 wxCoord
GetH(void) const;
141 wxCoord
GetHeight(void) const { return GetH(); }
142 wxRect
GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
150 DECLARE_DYNAMIC_CLASS(wxRegionIterator
);