1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/region.h
3 // Purpose: generic wxRegion class
4 // Author: David Elliott
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_REGION_H__
13 #define _WX_GENERIC_REGION_H__
15 #include "wx/gdiobj.h"
16 #include "wx/gdicmn.h"
18 class WXDLLEXPORT wxRect
;
19 class WXDLLEXPORT wxPoint
;
27 class WXDLLEXPORT wxRegionGeneric
: public wxGDIObject
29 // DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
30 friend class WXDLLEXPORT wxRegionIteratorGeneric
;
32 wxRegionGeneric(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
);
33 wxRegionGeneric(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
34 wxRegionGeneric(const wxRect
& rect
);
38 bool Ok() const { return m_refData
!= NULL
; }
40 bool operator == ( const wxRegionGeneric
& region
) const;
41 bool operator != ( const wxRegionGeneric
& region
) const { return !(*this == region
); }
44 // Clear current region
48 bool Offset(wxCoord x
, wxCoord y
);
50 // Union rectangle or region with this.
51 bool Union(long x
, long y
, long width
, long height
)
52 { return Union(wxRect(x
,y
,width
,height
)); }
53 bool Union(const wxRect
& rect
);
54 bool Union(const wxRegionGeneric
& region
);
56 // Intersect rectangle or region with this.
57 bool Intersect(long x
, long y
, long width
, long height
)
58 { return Intersect(wxRect(x
,y
,width
,height
)); }
59 bool Intersect(const wxRect
& rect
);
60 bool Intersect(const wxRegionGeneric
& region
);
62 // Subtract rectangle or region from this:
63 // Combines the parts of 'this' that are not part of the second region.
64 bool Subtract(long x
, long y
, long width
, long height
)
65 { return Subtract(wxRect(x
,y
,width
,height
)); }
66 bool Subtract(const wxRect
& rect
);
67 bool Subtract(const wxRegionGeneric
& region
);
69 // XOR: the union of two combined regions except for any overlapping areas.
70 bool Xor(long x
, long y
, long width
, long height
);
71 bool Xor(const wxRect
& rect
);
72 bool Xor(const wxRegionGeneric
& region
);
74 //# Information on region
75 // Outer bounds of region
76 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
&w
, wxCoord
&h
) const;
77 wxRect
GetBox() const;
81 inline bool IsEmpty() const { return Empty(); }
84 // Does the region contain the point (x,y)?
85 wxRegionContain
Contains(long x
, long y
) const;
86 // Does the region contain the point pt?
87 wxRegionContain
Contains(const wxPoint
& pt
) const;
88 // Does the region contain the rectangle (x, y, w, h)?
89 wxRegionContain
Contains(long x
, long y
, long w
, long h
) const;
90 // Does the region contain the rectangle rect?
91 wxRegionContain
Contains(const wxRect
& rect
) const;
94 virtual wxObjectRefData
*CreateRefData() const;
95 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
98 class WXDLLEXPORT wxRegionIteratorGeneric
: public wxObject
100 // DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
102 wxRegionIteratorGeneric();
103 wxRegionIteratorGeneric(const wxRegionGeneric
& region
);
104 wxRegionIteratorGeneric(const wxRegionIteratorGeneric
& iterator
);
105 ~wxRegionIteratorGeneric();
107 wxRegionIteratorGeneric
& operator=(const wxRegionIteratorGeneric
& iterator
);
109 void Reset() { m_current
= 0; }
110 void Reset(const wxRegionGeneric
& region
);
112 operator bool () const { return HaveRects(); }
113 bool HaveRects() const;
115 wxRegionIteratorGeneric
& operator++();
116 wxRegionIteratorGeneric
operator++(int);
121 long GetWidth() const { return GetW(); }
123 long GetHeight() const { return GetH(); }
124 wxRect
GetRect() const;
127 wxRegionGeneric m_region
;
130 #endif //ndef _WX_GENERIC_REGION_H__