]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/os2/region.h
Missing exports.
[wxWidgets.git] / include / wx / os2 / region.h
... / ...
CommitLineData
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#include "wx/bitmap.h"
19#include "wx/os2/private.h"
20
21class WXDLLEXPORT wxRect;
22class WXDLLEXPORT wxPoint;
23
24// So far, for internal use only
25enum wxRegionOp { wxRGN_AND // Creates the intersection of the two combined regions.
26 ,wxRGN_COPY // Creates a copy of the region identified by hrgnSrc1.
27 ,wxRGN_DIFF // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
28 ,wxRGN_OR // Creates the union of two combined regions.
29 ,wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
30 };
31
32class WXDLLEXPORT wxRegion : public wxGDIObject
33{
34public:
35 wxRegion( wxCoord x
36 ,wxCoord y
37 ,wxCoord vWidth
38 ,wxCoord vHeight
39 );
40 wxRegion( const wxPoint& rTopLeft
41 ,const wxPoint& rBottomRight
42 );
43 wxRegion(const wxRect& rRect);
44 wxRegion(WXHRGN hRegion, WXHDC hPS); // Hangs on to this region
45 wxRegion( const wxBitmap& bmp)
46 {
47 Union(bmp);
48 }
49 wxRegion( const wxBitmap& bmp,
50 const wxColour& transColour, int tolerance = 0)
51 {
52 Union(bmp, transColour, tolerance);
53 }
54
55 wxRegion();
56 ~wxRegion();
57
58 //
59 // Modify region
60 //
61
62 //
63 // Clear current region
64 //
65 void Clear(void);
66
67 bool Offset( wxCoord x
68 ,wxCoord y
69 );
70
71 //
72 // Union rectangle or region with this.
73 //
74 inline bool Union( wxCoord x
75 ,wxCoord y
76 ,wxCoord vWidth
77 ,wxCoord vHeight
78 )
79 {
80 return Combine( x
81 ,y
82 ,vWidth
83 ,vHeight
84 ,wxRGN_OR
85 );
86 }
87 inline bool Union( const wxRect& rRect) { return Combine(rRect, wxRGN_OR); }
88 inline bool Union(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_OR); }
89
90 //
91 // Intersect rectangle or region with this.
92 //
93 inline bool Intersect( wxCoord x
94 ,wxCoord y
95 ,wxCoord vWidth
96 ,wxCoord vHeight
97 )
98 {
99 return Combine( x
100 ,y
101 ,vWidth
102 ,vHeight
103 ,wxRGN_AND
104 );
105 }
106 inline bool Intersect(const wxRect& rRect) { return Combine(rRect, wxRGN_AND); }
107 inline bool Intersect(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_AND); }
108
109 //
110 // Subtract rectangle or region from this:
111 // Combines the parts of 'this' that are not part of the second region.
112 //
113 inline bool Subtract( wxCoord x
114 ,wxCoord y
115 ,wxCoord vWidth
116 ,wxCoord vHeight
117 )
118 {
119 return Combine( x
120 ,y
121 ,vWidth
122 ,vHeight
123 ,wxRGN_DIFF
124 );
125 }
126 inline bool Subtract(const wxRect& rRect) { return Combine(rRect, wxRGN_DIFF); }
127 inline bool Subtract(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_DIFF); }
128
129 //
130 // XOR: the union of two combined regions except for any overlapping areas.
131 //
132 inline bool Xor( wxCoord x
133 ,wxCoord y
134 ,wxCoord vWidth
135 ,wxCoord vHeight
136 )
137 {
138 return Combine( x
139 ,y
140 ,vWidth
141 ,vHeight
142 ,wxRGN_XOR
143 );
144 }
145 inline bool Xor(const wxRect& rRect) { return Combine(rRect, wxRGN_XOR); }
146 inline bool Xor(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_XOR); }
147
148 //
149 // Information on region
150 // Outer bounds of region
151 //
152 void GetBox( wxCoord& rX
153 ,wxCoord& rY
154 ,wxCoord& rWidth
155 ,wxCoord& rHeight
156 ) const;
157 wxRect GetBox(void) const;
158
159 //
160 // Is region empty?
161 //
162 bool Empty(void) const;
163 inline bool IsEmpty() const { return Empty(); }
164
165 //
166 // Tests
167 // Does the region contain the point (x,y)?
168 //
169 inline wxRegionContain Contains( wxCoord lX, wxCoord lY ) const{
170 return Contains( wxPoint( lX, lY ) );
171 }
172 //
173 // Convert the region to a B&W bitmap with the black pixels being inside
174 // the region.
175 //
176 wxBitmap ConvertToBitmap(void) const;
177
178 // Use the non-transparent pixels of a wxBitmap for the region to combine
179 // with this region. First version takes transparency from bitmap's mask,
180 // second lets the user specify the colour to be treated as transparent
181 // along with an optional tolerance value.
182 // NOTE: implemented in common/rgncmn.cpp
183 bool Union(const wxBitmap& bmp);
184 bool Union(const wxBitmap& bmp,
185 const wxColour& transColour, int tolerance = 0);
186
187 //
188 // Does the region contain the point pt?
189 //
190 wxRegionContain Contains(const wxPoint& rPoint) const;
191
192 //
193 // Does the region contain the rectangle (x, y, w, h)?
194 //
195 wxRegionContain Contains( wxCoord x
196 ,wxCoord y
197 ,wxCoord lWidth
198 ,wxCoord lHeight
199 ) const;
200
201 //
202 // Does the region contain the rectangle rect?
203 //
204 inline wxRegionContain Contains(const wxRect& rRect) const{
205 return Contains( rRect.x, rRect.y,
206 rRect.GetWidth(), rRect.GetHeight());
207 }
208
209 //
210 // Internal
211 //
212 bool Combine( wxCoord x
213 ,wxCoord y
214 ,wxCoord vWidth
215 ,wxCoord vHeight
216 ,wxRegionOp eOp
217 );
218 bool Combine( const wxRegion& rRegion
219 ,wxRegionOp eOp
220 );
221 bool Combine( const wxRect& rRect
222 ,wxRegionOp eOp
223 );
224
225 //
226 // Get internal region handle
227 //
228 WXHRGN GetHRGN(void) const;
229 void SetPS(HPS hPS);
230
231protected:
232 virtual wxObjectRefData* CreateData(void) const;
233 virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const;
234
235 friend class WXDLLEXPORT wxRegionIterator;
236 DECLARE_DYNAMIC_CLASS(wxRegion);
237
238}; // end of CLASS wxRegion
239
240class WXDLLEXPORT wxRegionIterator : public wxObject
241{
242DECLARE_DYNAMIC_CLASS(wxRegionIterator);
243public:
244 wxRegionIterator();
245 wxRegionIterator(const wxRegion& rRegion);
246 ~wxRegionIterator();
247
248 void Reset(void) { m_lCurrent = 0; }
249 void Reset(const wxRegion& rRegion);
250
251 operator bool (void) const { return m_lCurrent < m_lNumRects; }
252 bool HaveRects(void) const { return m_lCurrent < m_lNumRects; }
253
254 void operator ++ (void);
255 void operator ++ (int);
256
257 wxCoord GetX(void) const;
258 wxCoord GetY(void) const;
259 wxCoord GetW(void) const;
260 wxCoord GetWidth(void) const { return GetW(); }
261 wxCoord GetH(void) const;
262 wxCoord GetHeight(void) const { return GetH(); }
263 wxRect GetRect(void) const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
264
265private:
266 long m_lCurrent;
267 long m_lNumRects;
268 wxRegion m_vRegion;
269 wxRect* m_pRects;
270}; // end of wxRegionIterator
271
272#endif
273 // _WX_REGION_H_