]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/region.h
fixed bug with the caret positioning after SetValue() introduced by the last commit
[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 36DECLARE_DYNAMIC_CLASS(wxRegion);
409c9842 37 friend class WXDLLEXPORT wxRegionIterator;
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
409c9842
DW
49
50 wxRegion();
51 ~wxRegion();
52
5a56a532
DW
53 //
54 // Copying
55 //
56 inline wxRegion(const wxRegion& rSrc)
57 { Ref(rSrc); }
58 inline wxRegion& operator = (const wxRegion& rSrc)
59 { Ref(rSrc); return (*this); }
409c9842 60
5a56a532
DW
61 //
62 // Modify region
63 //
64
65 //
409c9842 66 // Clear current region
5a56a532
DW
67 //
68 void Clear(void);
409c9842 69
5a56a532 70 //
409c9842 71 // Union rectangle or region with this.
5a56a532
DW
72 //
73 inline bool Union( wxCoord x
74 ,wxCoord y
75 ,wxCoord vWidth
76 ,wxCoord vHeight
77 )
78 {
79 return Combine( x
80 ,y
81 ,vWidth
82 ,vHeight
83 ,wxRGN_OR
84 );
85 }
86 inline bool Union( const wxRect& rRect) { return Combine(rRect, wxRGN_OR); }
87 inline bool Union(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_OR); }
88
89 //
409c9842 90 // Intersect rectangle or region with this.
5a56a532
DW
91 //
92 inline bool Intersect( wxCoord x
93 ,wxCoord y
94 ,wxCoord vWidth
95 ,wxCoord vHeight
96 )
97 {
98 return Combine( x
99 ,y
100 ,vWidth
101 ,vHeight
102 ,wxRGN_AND
103 );
104 }
105 inline bool Intersect(const wxRect& rRect) { return Combine(rRect, wxRGN_AND); }
106 inline bool Intersect(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_AND); }
107
108 //
409c9842 109 // Subtract rectangle or region from this:
0e320a79 110 // Combines the parts of 'this' that are not part of the second region.
5a56a532
DW
111 //
112 inline bool Subtract( wxCoord x
113 ,wxCoord y
114 ,wxCoord vWidth
115 ,wxCoord vHeight
116 )
117 {
118 return Combine( x
119 ,y
120 ,vWidth
121 ,vHeight
122 ,wxRGN_DIFF
123 );
124 }
125 inline bool Subtract(const wxRect& rRect) { return Combine(rRect, wxRGN_DIFF); }
126 inline bool Subtract(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_DIFF); }
127
128 //
409c9842 129 // XOR: the union of two combined regions except for any overlapping areas.
5a56a532
DW
130 //
131 inline bool Xor( wxCoord x
132 ,wxCoord y
133 ,wxCoord vWidth
134 ,wxCoord vHeight
135 )
136 {
137 return Combine( x
138 ,y
139 ,vWidth
140 ,vHeight
141 ,wxRGN_XOR
142 );
143 }
144 inline bool Xor(const wxRect& rRect) { return Combine(rRect, wxRGN_XOR); }
145 inline bool Xor(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_XOR); }
146
147 //
148 // Information on region
409c9842 149 // Outer bounds of region
5a56a532
DW
150 //
151 void GetBox( wxCoord& rX
152 ,wxCoord& rY
153 ,wxCoord& rWidth
154 ,wxCoord& rHeight
155 ) const;
156 wxRect GetBox(void) const;
157
158 //
409c9842 159 // Is region empty?
5a56a532
DW
160 //
161 bool Empty(void) const;
0e320a79
DW
162 inline bool IsEmpty() const { return Empty(); }
163
5a56a532
DW
164 //
165 // Tests
409c9842 166 // Does the region contain the point (x,y)?
5a56a532
DW
167 //
168 wxRegionContain Contains( wxCoord lX
169 ,wxCoord lY
170 ) const;
171 //
409c9842 172 // Does the region contain the point pt?
5a56a532
DW
173 //
174 wxRegionContain Contains(const wxPoint& rPoint) const;
175
176 //
409c9842 177 // Does the region contain the rectangle (x, y, w, h)?
5a56a532
DW
178 //
179 wxRegionContain Contains( wxCoord x
180 ,wxCoord y
181 ,wxCoord lWidth
182 ,wxCoord lHeight
183 ) const;
184
185 //
409c9842 186 // Does the region contain the rectangle rect?
5a56a532
DW
187 //
188 wxRegionContain Contains(const wxRect& rRect) const;
189
190 //
191 // Internal
192 //
193 bool Combine( wxCoord x
194 ,wxCoord y
195 ,wxCoord vWidth
196 ,wxCoord vHeight
197 ,wxRegionOp eOp
198 );
199 bool Combine( const wxRegion& rRegion
200 ,wxRegionOp eOp
201 );
202 bool Combine( const wxRect& rRect
203 ,wxRegionOp eOp
204 );
205
206 //
409c9842 207 // Get internal region handle
5a56a532
DW
208 //
209 WXHRGN GetHRGN(void) const;
210 void SetPS(HPS hPS);
211}; // end of CLASS wxRegion
0e320a79 212
5a56a532
DW
213class WXDLLEXPORT wxRegionIterator : public wxObject
214{
0e320a79
DW
215DECLARE_DYNAMIC_CLASS(wxRegionIterator);
216public:
409c9842 217 wxRegionIterator();
5a56a532 218 wxRegionIterator(const wxRegion& rRegion);
409c9842 219 ~wxRegionIterator();
0e320a79 220
5a56a532
DW
221 void Reset(void) { m_lCurrent = 0; }
222 void Reset(const wxRegion& rRegion);
0e320a79 223
5a56a532
DW
224 operator bool (void) const { return m_lCurrent < m_lNumRects; }
225 bool HaveRects(void) const { return m_lCurrent < m_lNumRects; }
0e320a79 226
5a56a532 227 void operator ++ (void);
409c9842 228 void operator ++ (int);
0e320a79 229
5a56a532
DW
230 wxCoord GetX(void) const;
231 wxCoord GetY(void) const;
232 wxCoord GetW(void) const;
233 wxCoord GetWidth(void) const { return GetW(); }
234 wxCoord GetH(void) const;
235 wxCoord GetHeight(void) const { return GetH(); }
236 wxRect GetRect(void) const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
0e320a79
DW
237
238private:
5a56a532
DW
239 long m_lCurrent;
240 long m_lNumRects;
241 wxRegion m_vRegion;
242 wxRect* m_pRects;
243}; // end of wxRegionIterator
0e320a79
DW
244
245#endif
409c9842 246 // _WX_REGION_H_