]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/region.h
Added NSColor declarataion
[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
DW
8// Copyright: (c) David Webster
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"
18
19class WXDLLEXPORT wxRect;
20class WXDLLEXPORT wxPoint;
21
22enum wxRegionContain {
409c9842 23 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
0e320a79
DW
24};
25
26// So far, for internal use only
5a56a532
DW
27enum 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
34class WXDLLEXPORT wxRegion : public wxGDIObject
35{
0e320a79 36public:
5a56a532
DW
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);
19193a2c 46 wxRegion(WXHRGN hRegion, WXHDC hPS); // Hangs on to this region
409c9842
DW
47
48 wxRegion();
49 ~wxRegion();
50
5a56a532
DW
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); }
409c9842 58
5a56a532
DW
59 //
60 // Modify region
61 //
62
63 //
409c9842 64 // Clear current region
5a56a532
DW
65 //
66 void Clear(void);
409c9842 67
45e0dc94
DW
68 bool Offset( wxCoord x
69 ,wxCoord y
70 );
71
5a56a532 72 //
409c9842 73 // Union rectangle or region with this.
5a56a532
DW
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 //
409c9842 92 // Intersect rectangle or region with this.
5a56a532
DW
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 //
409c9842 111 // Subtract rectangle or region from this:
0e320a79 112 // Combines the parts of 'this' that are not part of the second region.
5a56a532
DW
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 //
409c9842 131 // XOR: the union of two combined regions except for any overlapping areas.
5a56a532
DW
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
409c9842 151 // Outer bounds of region
5a56a532
DW
152 //
153 void GetBox( wxCoord& rX
154 ,wxCoord& rY
155 ,wxCoord& rWidth
156 ,wxCoord& rHeight
157 ) const;
158 wxRect GetBox(void) const;
159
160 //
409c9842 161 // Is region empty?
5a56a532
DW
162 //
163 bool Empty(void) const;
0e320a79
DW
164 inline bool IsEmpty() const { return Empty(); }
165
5a56a532
DW
166 //
167 // Tests
409c9842 168 // Does the region contain the point (x,y)?
5a56a532
DW
169 //
170 wxRegionContain Contains( wxCoord lX
171 ,wxCoord lY
172 ) const;
4f5c180e
DW
173
174 //
175 // Convert the region to a B&W bitmap with the black pixels being inside
176 // the region.
177 //
178 wxBitmap ConvertToBitmap(void) const;
179
180 // Use the non-transparent pixels of a wxBitmap for the region to combine
181 // with this region. If the bitmap has a mask then it will be used,
182 // otherwise the colour to be treated as transparent may be specified,
183 // along with an optional tolerance value.
184 bool Union( const wxBitmap& rBmp
185 ,const wxColour& rTransColour = wxNullColour
186 ,int nTolerance = 0
187 );
188
5a56a532 189 //
409c9842 190 // Does the region contain the point pt?
5a56a532
DW
191 //
192 wxRegionContain Contains(const wxPoint& rPoint) const;
193
194 //
409c9842 195 // Does the region contain the rectangle (x, y, w, h)?
5a56a532
DW
196 //
197 wxRegionContain Contains( wxCoord x
198 ,wxCoord y
199 ,wxCoord lWidth
200 ,wxCoord lHeight
201 ) const;
202
203 //
409c9842 204 // Does the region contain the rectangle rect?
5a56a532
DW
205 //
206 wxRegionContain Contains(const wxRect& rRect) const;
207
208 //
209 // Internal
210 //
211 bool Combine( wxCoord x
212 ,wxCoord y
213 ,wxCoord vWidth
214 ,wxCoord vHeight
215 ,wxRegionOp eOp
216 );
217 bool Combine( const wxRegion& rRegion
218 ,wxRegionOp eOp
219 );
220 bool Combine( const wxRect& rRect
221 ,wxRegionOp eOp
222 );
223
224 //
409c9842 225 // Get internal region handle
5a56a532
DW
226 //
227 WXHRGN GetHRGN(void) const;
228 void SetPS(HPS hPS);
45e0dc94
DW
229
230protected:
231 virtual wxObjectRefData* CreateData(void) const;
107e4338
DW
232 virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const;
233
45e0dc94
DW
234 friend class WXDLLEXPORT wxRegionIterator;
235 DECLARE_DYNAMIC_CLASS(wxRegion);
236
5a56a532 237}; // end of CLASS wxRegion
0e320a79 238
5a56a532
DW
239class WXDLLEXPORT wxRegionIterator : public wxObject
240{
0e320a79
DW
241DECLARE_DYNAMIC_CLASS(wxRegionIterator);
242public:
409c9842 243 wxRegionIterator();
5a56a532 244 wxRegionIterator(const wxRegion& rRegion);
409c9842 245 ~wxRegionIterator();
0e320a79 246
5a56a532
DW
247 void Reset(void) { m_lCurrent = 0; }
248 void Reset(const wxRegion& rRegion);
0e320a79 249
5a56a532
DW
250 operator bool (void) const { return m_lCurrent < m_lNumRects; }
251 bool HaveRects(void) const { return m_lCurrent < m_lNumRects; }
0e320a79 252
5a56a532 253 void operator ++ (void);
409c9842 254 void operator ++ (int);
0e320a79 255
5a56a532
DW
256 wxCoord GetX(void) const;
257 wxCoord GetY(void) const;
258 wxCoord GetW(void) const;
259 wxCoord GetWidth(void) const { return GetW(); }
260 wxCoord GetH(void) const;
261 wxCoord GetHeight(void) const { return GetH(); }
262 wxRect GetRect(void) const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
0e320a79
DW
263
264private:
5a56a532
DW
265 long m_lCurrent;
266 long m_lNumRects;
267 wxRegion m_vRegion;
268 wxRect* m_pRects;
269}; // end of wxRegionIterator
0e320a79
DW
270
271#endif
409c9842 272 // _WX_REGION_H_