]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/region.h
Upported combobox changes and another fix.
[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;
173 //
409c9842 174 // Does the region contain the point pt?
5a56a532
DW
175 //
176 wxRegionContain Contains(const wxPoint& rPoint) const;
177
178 //
409c9842 179 // Does the region contain the rectangle (x, y, w, h)?
5a56a532
DW
180 //
181 wxRegionContain Contains( wxCoord x
182 ,wxCoord y
183 ,wxCoord lWidth
184 ,wxCoord lHeight
185 ) const;
186
187 //
409c9842 188 // Does the region contain the rectangle rect?
5a56a532
DW
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 //
409c9842 209 // Get internal region handle
5a56a532
DW
210 //
211 WXHRGN GetHRGN(void) const;
212 void SetPS(HPS hPS);
45e0dc94
DW
213
214protected:
215 virtual wxObjectRefData* CreateData(void) const;
107e4338
DW
216 virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const;
217
45e0dc94
DW
218 friend class WXDLLEXPORT wxRegionIterator;
219 DECLARE_DYNAMIC_CLASS(wxRegion);
220
5a56a532 221}; // end of CLASS wxRegion
0e320a79 222
5a56a532
DW
223class WXDLLEXPORT wxRegionIterator : public wxObject
224{
0e320a79
DW
225DECLARE_DYNAMIC_CLASS(wxRegionIterator);
226public:
409c9842 227 wxRegionIterator();
5a56a532 228 wxRegionIterator(const wxRegion& rRegion);
409c9842 229 ~wxRegionIterator();
0e320a79 230
5a56a532
DW
231 void Reset(void) { m_lCurrent = 0; }
232 void Reset(const wxRegion& rRegion);
0e320a79 233
5a56a532
DW
234 operator bool (void) const { return m_lCurrent < m_lNumRects; }
235 bool HaveRects(void) const { return m_lCurrent < m_lNumRects; }
0e320a79 236
5a56a532 237 void operator ++ (void);
409c9842 238 void operator ++ (int);
0e320a79 239
5a56a532
DW
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()); }
0e320a79
DW
247
248private:
5a56a532
DW
249 long m_lCurrent;
250 long m_lNumRects;
251 wxRegion m_vRegion;
252 wxRect* m_pRects;
253}; // end of wxRegionIterator
0e320a79
DW
254
255#endif
409c9842 256 // _WX_REGION_H_