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