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