1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxRegion class
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 #pragma interface "region.h"
19 #include "wx/gdiobj.h"
20 #include "wx/gdicmn.h"
23 class WXDLLEXPORT wxRect
;
24 class WXDLLEXPORT wxPoint
;
34 class WXDLLEXPORT wxRegion
: public wxGDIObject
36 DECLARE_DYNAMIC_CLASS(wxRegion
);
37 friend class WXDLLEXPORT wxRegionIterator
;
40 wxRegion(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
41 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
42 wxRegion(const wxRect
& rect
);
43 wxRegion(const MGLRegion
& region
);
49 inline wxRegion(const wxRegion
& r
)
51 inline wxRegion
& operator = (const wxRegion
& r
)
52 { Ref(r
); return (*this); }
55 // Clear current region
58 bool Offset(wxCoord x
, wxCoord y
);
60 // Union rectangle or region with this.
61 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
62 bool Union(const wxRect
& rect
) { return Union(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
63 bool Union(const wxRegion
& region
);
65 // Intersect rectangle or region with this.
66 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
67 bool Intersect(const wxRect
& rect
) { return Intersect(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
68 bool Intersect(const wxRegion
& region
);
70 // Subtract rectangle or region from this:
71 // Combines the parts of 'this' that are not part of the second region.
72 bool Subtract(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
73 bool Subtract(const wxRect
& rect
) { return Subtract(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
74 bool Subtract(const wxRegion
& region
);
76 // XOR: the union of two combined regions except for any overlapping areas.
77 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
78 bool Xor(const wxRect
& rect
) { return Xor(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
79 bool Xor(const wxRegion
& region
);
81 //# Information on region
82 // Outer bounds of region
83 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
&w
, wxCoord
&h
) const;
84 wxRect
GetBox(void) const ;
87 bool Empty(void) const;
88 inline bool IsEmpty(void) const { return Empty(); }
91 // Does the region contain the point (x,y)?
92 wxRegionContain
Contains(wxCoord x
, wxCoord y
) const;
93 // Does the region contain the point pt?
94 wxRegionContain
Contains(const wxPoint
& pt
) const;
95 // Does the region contain the rectangle (x, y, w, h)?
96 wxRegionContain
Contains(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
) const;
97 // Does the region contain the rectangle rect?
98 wxRegionContain
Contains(const wxRect
& rect
) const;
100 // implementation from now on:
101 const MGLRegion
& GetMGLRegion() const;
105 virtual wxObjectRefData
*CreateRefData() const;
106 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
110 WX_DECLARE_EXPORTED_LIST(wxRect
, wxRegionRectList
);
112 class WXDLLEXPORT wxRegionIterator
: public wxObject
114 DECLARE_DYNAMIC_CLASS(wxRegionIterator
);
116 wxRegionIterator(void);
117 wxRegionIterator(const wxRegion
& region
);
118 ~wxRegionIterator(void);
120 void Reset(void) { m_currentNode
= NULL
; }
121 void Reset(const wxRegion
& region
);
124 operator bool (void) const { return (m_currentNode
!= NULL
); }
127 bool HaveRects(void) const { return (m_currentNode
!= NULL
); }
129 void operator ++ (void);
130 void operator ++ (int);
132 wxCoord
GetX(void) const;
133 wxCoord
GetY(void) const;
134 wxCoord
GetW(void) const;
135 wxCoord
GetWidth(void) const { return GetW(); }
136 wxCoord
GetH(void) const;
137 wxCoord
GetHeight(void) const { return GetH(); }
138 wxRect
GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
141 wxRegionRectList m_rects
;
142 wxRegionRectList::Node
*m_currentNode
;