]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/region.h
fixed outdated filenames
[wxWidgets.git] / include / wx / os2 / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose: wxRegion class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/15/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_REGION_H_
13 #define _WX_REGION_H_
14
15 #include "wx/list.h"
16 #include "wx/gdiobj.h"
17 #include "wx/gdicmn.h"
18
19 class WXDLLEXPORT wxRect;
20 class WXDLLEXPORT wxPoint;
21
22 enum wxRegionContain {
23 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
24 };
25
26 // So far, for internal use only
27 enum wxRegionOp { wxRGN_AND // Creates the intersection of the two combined regions.
28 ,wxRGN_COPY // Creates a copy of the region identified by hrgnSrc1.
29 ,wxRGN_DIFF // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
30 ,wxRGN_OR // Creates the union of two combined regions.
31 ,wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
32 };
33
34 class WXDLLEXPORT wxRegion : public wxGDIObject
35 {
36 public:
37 wxRegion( wxCoord x
38 ,wxCoord y
39 ,wxCoord vWidth
40 ,wxCoord vHeight
41 );
42 wxRegion( const wxPoint& rTopLeft
43 ,const wxPoint& rBottomRight
44 );
45 wxRegion(const wxRect& rRect);
46 wxRegion(WXHRGN hRegion, WXHDC hPS); // Hangs on to this region
47
48 wxRegion();
49 ~wxRegion();
50
51 //
52 // Copying
53 //
54 inline wxRegion(const wxRegion& rSrc)
55 { Ref(rSrc); }
56 inline wxRegion& operator = (const wxRegion& rSrc)
57 { Ref(rSrc); return (*this); }
58
59 //
60 // Modify region
61 //
62
63 //
64 // Clear current region
65 //
66 void Clear(void);
67
68 bool Offset( wxCoord x
69 ,wxCoord y
70 );
71
72 //
73 // Union rectangle or region with this.
74 //
75 inline bool Union( wxCoord x
76 ,wxCoord y
77 ,wxCoord vWidth
78 ,wxCoord vHeight
79 )
80 {
81 return Combine( x
82 ,y
83 ,vWidth
84 ,vHeight
85 ,wxRGN_OR
86 );
87 }
88 inline bool Union( const wxRect& rRect) { return Combine(rRect, wxRGN_OR); }
89 inline bool Union(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_OR); }
90
91 //
92 // Intersect rectangle or region with this.
93 //
94 inline bool Intersect( wxCoord x
95 ,wxCoord y
96 ,wxCoord vWidth
97 ,wxCoord vHeight
98 )
99 {
100 return Combine( x
101 ,y
102 ,vWidth
103 ,vHeight
104 ,wxRGN_AND
105 );
106 }
107 inline bool Intersect(const wxRect& rRect) { return Combine(rRect, wxRGN_AND); }
108 inline bool Intersect(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_AND); }
109
110 //
111 // Subtract rectangle or region from this:
112 // Combines the parts of 'this' that are not part of the second region.
113 //
114 inline bool Subtract( wxCoord x
115 ,wxCoord y
116 ,wxCoord vWidth
117 ,wxCoord vHeight
118 )
119 {
120 return Combine( x
121 ,y
122 ,vWidth
123 ,vHeight
124 ,wxRGN_DIFF
125 );
126 }
127 inline bool Subtract(const wxRect& rRect) { return Combine(rRect, wxRGN_DIFF); }
128 inline bool Subtract(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_DIFF); }
129
130 //
131 // XOR: the union of two combined regions except for any overlapping areas.
132 //
133 inline bool Xor( wxCoord x
134 ,wxCoord y
135 ,wxCoord vWidth
136 ,wxCoord vHeight
137 )
138 {
139 return Combine( x
140 ,y
141 ,vWidth
142 ,vHeight
143 ,wxRGN_XOR
144 );
145 }
146 inline bool Xor(const wxRect& rRect) { return Combine(rRect, wxRGN_XOR); }
147 inline bool Xor(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_XOR); }
148
149 //
150 // Information on region
151 // Outer bounds of region
152 //
153 void GetBox( wxCoord& rX
154 ,wxCoord& rY
155 ,wxCoord& rWidth
156 ,wxCoord& rHeight
157 ) const;
158 wxRect GetBox(void) const;
159
160 //
161 // Is region empty?
162 //
163 bool Empty(void) const;
164 inline bool IsEmpty() const { return Empty(); }
165
166 //
167 // Tests
168 // Does the region contain the point (x,y)?
169 //
170 wxRegionContain Contains( wxCoord lX
171 ,wxCoord lY
172 ) const;
173 //
174 // Does the region contain the point pt?
175 //
176 wxRegionContain Contains(const wxPoint& rPoint) const;
177
178 //
179 // Does the region contain the rectangle (x, y, w, h)?
180 //
181 wxRegionContain Contains( wxCoord x
182 ,wxCoord y
183 ,wxCoord lWidth
184 ,wxCoord lHeight
185 ) const;
186
187 //
188 // Does the region contain the rectangle rect?
189 //
190 wxRegionContain Contains(const wxRect& rRect) const;
191
192 //
193 // Internal
194 //
195 bool Combine( wxCoord x
196 ,wxCoord y
197 ,wxCoord vWidth
198 ,wxCoord vHeight
199 ,wxRegionOp eOp
200 );
201 bool Combine( const wxRegion& rRegion
202 ,wxRegionOp eOp
203 );
204 bool Combine( const wxRect& rRect
205 ,wxRegionOp eOp
206 );
207
208 //
209 // Get internal region handle
210 //
211 WXHRGN GetHRGN(void) const;
212 void SetPS(HPS hPS);
213
214 protected:
215 virtual wxObjectRefData* CreateData(void) const;
216 virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const;
217
218 friend class WXDLLEXPORT wxRegionIterator;
219 DECLARE_DYNAMIC_CLASS(wxRegion);
220
221 }; // end of CLASS wxRegion
222
223 class WXDLLEXPORT wxRegionIterator : public wxObject
224 {
225 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
226 public:
227 wxRegionIterator();
228 wxRegionIterator(const wxRegion& rRegion);
229 ~wxRegionIterator();
230
231 void Reset(void) { m_lCurrent = 0; }
232 void Reset(const wxRegion& rRegion);
233
234 operator bool (void) const { return m_lCurrent < m_lNumRects; }
235 bool HaveRects(void) const { return m_lCurrent < m_lNumRects; }
236
237 void operator ++ (void);
238 void operator ++ (int);
239
240 wxCoord GetX(void) const;
241 wxCoord GetY(void) const;
242 wxCoord GetW(void) const;
243 wxCoord GetWidth(void) const { return GetW(); }
244 wxCoord GetH(void) const;
245 wxCoord GetHeight(void) const { return GetH(); }
246 wxRect GetRect(void) const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
247
248 private:
249 long m_lCurrent;
250 long m_lNumRects;
251 wxRegion m_vRegion;
252 wxRect* m_pRects;
253 }; // end of wxRegionIterator
254
255 #endif
256 // _WX_REGION_H_