]>
Commit | Line | Data |
---|---|---|
72e7876b | 1 | ///////////////////////////////////////////////////////////////////////////// |
11e82c1b | 2 | // Name: wx/geometry.h |
72e7876b SC |
3 | // Purpose: Common Geometry Classes |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 08/05/99 | |
5ccb95f6 | 7 | // RCS-ID: $Id$ |
11e82c1b | 8 | // Copyright: (c) 1999 Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
72e7876b SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
c3a4297c VZ |
12 | #ifndef _WX_GEOMETRY_H_ |
13 | #define _WX_GEOMETRY_H_ | |
72e7876b | 14 | |
510fc784 | 15 | #include "wx/defs.h" |
c3a4297c | 16 | |
c3a4297c VZ |
17 | #if wxUSE_GEOMETRY |
18 | ||
510fc784 RR |
19 | #include "wx/utils.h" |
20 | #include "wx/gdicmn.h" | |
19edb09c | 21 | #include "wx/math.h" |
510fc784 | 22 | |
b5dbe15d VS |
23 | class WXDLLIMPEXP_FWD_BASE wxDataInputStream; |
24 | class WXDLLIMPEXP_FWD_BASE wxDataOutputStream; | |
72e7876b SC |
25 | |
26 | // clipping from Cohen-Sutherland | |
27 | ||
28 | enum wxOutCode | |
29 | { | |
c3a4297c VZ |
30 | wxInside = 0x00 , |
31 | wxOutLeft = 0x01 , | |
32 | wxOutRight = 0x02 , | |
33 | wxOutTop = 0x08 , | |
f91de7da | 34 | wxOutBottom = 0x04 |
11e82c1b | 35 | }; |
72e7876b | 36 | |
53a2db12 | 37 | class WXDLLIMPEXP_CORE wxPoint2DInt |
e2aa719c SC |
38 | { |
39 | public : | |
40 | inline wxPoint2DInt(); | |
41 | inline wxPoint2DInt( wxInt32 x , wxInt32 y ); | |
42 | inline wxPoint2DInt( const wxPoint2DInt &pt ); | |
43 | inline wxPoint2DInt( const wxPoint &pt ); | |
44 | ||
45 | // noops for this class, just return the coords | |
2b5f62a0 VZ |
46 | inline void GetFloor( wxInt32 *x , wxInt32 *y ) const; |
47 | inline void GetRounded( wxInt32 *x , wxInt32 *y ) const; | |
e2aa719c | 48 | |
2b5f62a0 VZ |
49 | inline wxDouble GetVectorLength() const; |
50 | wxDouble GetVectorAngle() const; | |
e2aa719c SC |
51 | inline void SetVectorLength( wxDouble length ); |
52 | void SetVectorAngle( wxDouble degrees ); | |
53 | void SetPolarCoordinates( wxInt32 angle , wxInt32 length ); | |
54 | // set the vector length to 1.0, preserving the angle | |
55 | inline void Normalize(); | |
56 | ||
57 | inline wxDouble GetDistance( const wxPoint2DInt &pt ) const; | |
58 | inline wxDouble GetDistanceSquare( const wxPoint2DInt &pt ) const; | |
59 | inline wxInt32 GetDotProduct( const wxPoint2DInt &vec ) const; | |
60 | inline wxInt32 GetCrossProduct( const wxPoint2DInt &vec ) const; | |
61 | ||
62 | // the reflection of this point | |
63 | inline wxPoint2DInt operator-(); | |
64 | ||
65 | inline wxPoint2DInt& operator=(const wxPoint2DInt& pt); | |
66 | inline wxPoint2DInt& operator+=(const wxPoint2DInt& pt); | |
67 | inline wxPoint2DInt& operator-=(const wxPoint2DInt& pt); | |
68 | inline wxPoint2DInt& operator*=(const wxPoint2DInt& pt); | |
69 | inline wxPoint2DInt& operator*=(wxDouble n); | |
70 | inline wxPoint2DInt& operator*=(wxInt32 n); | |
71 | inline wxPoint2DInt& operator/=(const wxPoint2DInt& pt); | |
72 | inline wxPoint2DInt& operator/=(wxDouble n); | |
73 | inline wxPoint2DInt& operator/=(wxInt32 n); | |
74 | inline operator wxPoint() const; | |
75 | inline bool operator==(const wxPoint2DInt& pt) const; | |
76 | inline bool operator!=(const wxPoint2DInt& pt) const; | |
77 | ||
e30285ab | 78 | #if wxUSE_STREAMS |
e2aa719c SC |
79 | void WriteTo( wxDataOutputStream &stream ) const; |
80 | void ReadFrom( wxDataInputStream &stream ); | |
e30285ab | 81 | #endif // wxUSE_STREAMS |
e2aa719c SC |
82 | |
83 | wxInt32 m_x; | |
84 | wxInt32 m_y; | |
85 | }; | |
86 | ||
295272bd VZ |
87 | inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); |
88 | inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); | |
89 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); | |
90 | inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt); | |
91 | inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt); | |
92 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n); | |
93 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n); | |
94 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2); | |
95 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n); | |
96 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n); | |
e2aa719c SC |
97 | |
98 | inline wxPoint2DInt::wxPoint2DInt() | |
99 | { | |
100 | m_x = 0; | |
101 | m_y = 0; | |
102 | } | |
103 | ||
104 | inline wxPoint2DInt::wxPoint2DInt( wxInt32 x , wxInt32 y ) | |
105 | { | |
106 | m_x = x; | |
107 | m_y = y; | |
108 | } | |
109 | ||
110 | inline wxPoint2DInt::wxPoint2DInt( const wxPoint2DInt &pt ) | |
111 | { | |
112 | m_x = pt.m_x; | |
113 | m_y = pt.m_y; | |
114 | } | |
115 | ||
116 | inline wxPoint2DInt::wxPoint2DInt( const wxPoint &pt ) | |
117 | { | |
118 | m_x = pt.x; | |
119 | m_y = pt.y; | |
120 | } | |
121 | ||
2b5f62a0 | 122 | inline void wxPoint2DInt::GetFloor( wxInt32 *x , wxInt32 *y ) const |
e2aa719c SC |
123 | { |
124 | if ( x ) | |
125 | *x = m_x; | |
126 | if ( y ) | |
127 | *y = m_y; | |
128 | } | |
129 | ||
2b5f62a0 | 130 | inline void wxPoint2DInt::GetRounded( wxInt32 *x , wxInt32 *y ) const |
e2aa719c SC |
131 | { |
132 | GetFloor(x, y); | |
133 | } | |
134 | ||
2b5f62a0 | 135 | inline wxDouble wxPoint2DInt::GetVectorLength() const |
e2aa719c SC |
136 | { |
137 | // cast needed MIPSpro compiler under SGI | |
138 | return sqrt( (double)(m_x)*(m_x) + (m_y)*(m_y) ); | |
139 | } | |
140 | ||
141 | inline void wxPoint2DInt::SetVectorLength( wxDouble length ) | |
142 | { | |
143 | wxDouble before = GetVectorLength(); | |
144 | m_x = (wxInt32)(m_x * length / before); | |
145 | m_y = (wxInt32)(m_y * length / before); | |
146 | } | |
147 | ||
148 | inline void wxPoint2DInt::Normalize() | |
149 | { | |
150 | SetVectorLength( 1 ); | |
151 | } | |
152 | ||
153 | inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const | |
154 | { | |
155 | return sqrt( GetDistanceSquare( pt ) ); | |
156 | } | |
157 | ||
158 | inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const | |
159 | { | |
160 | return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ); | |
161 | } | |
162 | ||
163 | inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const | |
164 | { | |
165 | return ( m_x * vec.m_x + m_y * vec.m_y ); | |
166 | } | |
167 | ||
168 | inline wxInt32 wxPoint2DInt::GetCrossProduct( const wxPoint2DInt &vec ) const | |
169 | { | |
170 | return ( m_x * vec.m_y - vec.m_x * m_y ); | |
171 | } | |
172 | ||
173 | inline wxPoint2DInt::operator wxPoint() const | |
174 | { | |
175 | return wxPoint( m_x, m_y); | |
176 | } | |
177 | ||
178 | inline wxPoint2DInt wxPoint2DInt::operator-() | |
179 | { | |
180 | return wxPoint2DInt( -m_x, -m_y); | |
181 | } | |
182 | ||
183 | inline wxPoint2DInt& wxPoint2DInt::operator=(const wxPoint2DInt& pt) | |
184 | { | |
7c562ad9 PC |
185 | if (this != &pt) |
186 | { | |
187 | m_x = pt.m_x; | |
188 | m_y = pt.m_y; | |
189 | } | |
e2aa719c SC |
190 | return *this; |
191 | } | |
192 | ||
193 | inline wxPoint2DInt& wxPoint2DInt::operator+=(const wxPoint2DInt& pt) | |
194 | { | |
195 | m_x = m_x + pt.m_x; | |
196 | m_y = m_y + pt.m_y; | |
197 | return *this; | |
198 | } | |
199 | ||
200 | inline wxPoint2DInt& wxPoint2DInt::operator-=(const wxPoint2DInt& pt) | |
201 | { | |
202 | m_x = m_x - pt.m_x; | |
203 | m_y = m_y - pt.m_y; | |
204 | return *this; | |
205 | } | |
206 | ||
207 | inline wxPoint2DInt& wxPoint2DInt::operator*=(const wxPoint2DInt& pt) | |
208 | { | |
209 | m_x = m_x + pt.m_x; | |
210 | m_y = m_y + pt.m_y; | |
211 | return *this; | |
212 | } | |
213 | ||
214 | inline wxPoint2DInt& wxPoint2DInt::operator/=(const wxPoint2DInt& pt) | |
215 | { | |
216 | m_x = m_x - pt.m_x; | |
217 | m_y = m_y - pt.m_y; | |
218 | return *this; | |
219 | } | |
220 | ||
221 | inline bool wxPoint2DInt::operator==(const wxPoint2DInt& pt) const | |
222 | { | |
223 | return m_x == pt.m_x && m_y == pt.m_y; | |
224 | } | |
225 | ||
226 | inline bool wxPoint2DInt::operator!=(const wxPoint2DInt& pt) const | |
227 | { | |
228 | return m_x != pt.m_x || m_y != pt.m_y; | |
229 | } | |
230 | ||
231 | inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
232 | { | |
233 | return wxPoint2DInt( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y ); | |
234 | } | |
235 | ||
236 | inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
237 | { | |
238 | return wxPoint2DInt( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y ); | |
239 | } | |
240 | ||
241 | ||
242 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
243 | { | |
244 | return wxPoint2DInt( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y ); | |
245 | } | |
246 | ||
247 | inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt) | |
248 | { | |
249 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ); | |
250 | } | |
251 | ||
252 | inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt) | |
253 | { | |
254 | return wxPoint2DInt( (int) (pt.m_x * n) , (int) (pt.m_y * n) ); | |
255 | } | |
256 | ||
257 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n) | |
258 | { | |
259 | return wxPoint2DInt( pt.m_x * n , pt.m_y * n ); | |
260 | } | |
261 | ||
262 | inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n) | |
263 | { | |
264 | return wxPoint2DInt( (int) (pt.m_x * n) , (int) (pt.m_y * n) ); | |
265 | } | |
266 | ||
267 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2) | |
268 | { | |
269 | return wxPoint2DInt( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y ); | |
270 | } | |
271 | ||
272 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n) | |
273 | { | |
274 | return wxPoint2DInt( pt.m_x / n , pt.m_y / n ); | |
275 | } | |
276 | ||
277 | inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n) | |
278 | { | |
279 | return wxPoint2DInt( (int) (pt.m_x / n) , (int) (pt.m_y / n) ); | |
280 | } | |
281 | ||
f91de7da | 282 | // wxPoint2Ds represent a point or a vector in a 2d coordinate system |
72e7876b | 283 | |
53a2db12 | 284 | class WXDLLIMPEXP_CORE wxPoint2DDouble |
72e7876b SC |
285 | { |
286 | public : | |
11e82c1b VZ |
287 | inline wxPoint2DDouble(); |
288 | inline wxPoint2DDouble( wxDouble x , wxDouble y ); | |
289 | inline wxPoint2DDouble( const wxPoint2DDouble &pt ); | |
5d3e7b52 WS |
290 | wxPoint2DDouble( const wxPoint2DInt &pt ) |
291 | { m_x = (wxDouble) pt.m_x ; m_y = (wxDouble) pt.m_y ; } | |
292 | wxPoint2DDouble( const wxPoint &pt ) | |
293 | { m_x = (wxDouble) pt.x ; m_y = (wxDouble) pt.y ; } | |
11e82c1b VZ |
294 | |
295 | // two different conversions to integers, floor and rounding | |
2b5f62a0 VZ |
296 | inline void GetFloor( wxInt32 *x , wxInt32 *y ) const; |
297 | inline void GetRounded( wxInt32 *x , wxInt32 *y ) const; | |
11e82c1b | 298 | |
e2aa719c SC |
299 | inline wxDouble GetVectorLength() const; |
300 | wxDouble GetVectorAngle() const ; | |
11e82c1b VZ |
301 | void SetVectorLength( wxDouble length ); |
302 | void SetVectorAngle( wxDouble degrees ); | |
303 | void SetPolarCoordinates( wxDouble angle , wxDouble length ); | |
304 | // set the vector length to 1.0, preserving the angle | |
305 | void Normalize(); | |
306 | ||
2b5f62a0 VZ |
307 | inline wxDouble GetDistance( const wxPoint2DDouble &pt ) const; |
308 | inline wxDouble GetDistanceSquare( const wxPoint2DDouble &pt ) const; | |
309 | inline wxDouble GetDotProduct( const wxPoint2DDouble &vec ) const; | |
310 | inline wxDouble GetCrossProduct( const wxPoint2DDouble &vec ) const; | |
11e82c1b VZ |
311 | |
312 | // the reflection of this point | |
313 | inline wxPoint2DDouble operator-(); | |
314 | ||
315 | inline wxPoint2DDouble& operator=(const wxPoint2DDouble& pt); | |
316 | inline wxPoint2DDouble& operator+=(const wxPoint2DDouble& pt); | |
317 | inline wxPoint2DDouble& operator-=(const wxPoint2DDouble& pt); | |
318 | inline wxPoint2DDouble& operator*=(const wxPoint2DDouble& pt); | |
319 | inline wxPoint2DDouble& operator*=(wxDouble n); | |
320 | inline wxPoint2DDouble& operator*=(wxInt32 n); | |
321 | inline wxPoint2DDouble& operator/=(const wxPoint2DDouble& pt); | |
322 | inline wxPoint2DDouble& operator/=(wxDouble n); | |
323 | inline wxPoint2DDouble& operator/=(wxInt32 n); | |
324 | ||
325 | inline bool operator==(const wxPoint2DDouble& pt) const; | |
326 | inline bool operator!=(const wxPoint2DDouble& pt) const; | |
327 | ||
328 | wxDouble m_x; | |
329 | wxDouble m_y; | |
330 | }; | |
c3a4297c | 331 | |
90350682 VZ |
332 | inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); |
333 | inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); | |
334 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); | |
335 | inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt); | |
336 | inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt); | |
337 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n); | |
338 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n); | |
339 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); | |
340 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n); | |
341 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n); | |
72e7876b | 342 | |
f91de7da DW |
343 | inline wxPoint2DDouble::wxPoint2DDouble() |
344 | { | |
11e82c1b VZ |
345 | m_x = 0.0; |
346 | m_y = 0.0; | |
72e7876b SC |
347 | } |
348 | ||
f91de7da DW |
349 | inline wxPoint2DDouble::wxPoint2DDouble( wxDouble x , wxDouble y ) |
350 | { | |
11e82c1b VZ |
351 | m_x = x; |
352 | m_y = y; | |
f91de7da | 353 | } |
72e7876b | 354 | |
f91de7da DW |
355 | inline wxPoint2DDouble::wxPoint2DDouble( const wxPoint2DDouble &pt ) |
356 | { | |
11e82c1b VZ |
357 | m_x = pt.m_x; |
358 | m_y = pt.m_y; | |
72e7876b SC |
359 | } |
360 | ||
2b5f62a0 | 361 | inline void wxPoint2DDouble::GetFloor( wxInt32 *x , wxInt32 *y ) const |
f91de7da | 362 | { |
11e82c1b VZ |
363 | *x = (wxInt32) floor( m_x ); |
364 | *y = (wxInt32) floor( m_y ); | |
72e7876b SC |
365 | } |
366 | ||
2b5f62a0 | 367 | inline void wxPoint2DDouble::GetRounded( wxInt32 *x , wxInt32 *y ) const |
f91de7da | 368 | { |
11e82c1b VZ |
369 | *x = (wxInt32) floor( m_x + 0.5 ); |
370 | *y = (wxInt32) floor( m_y + 0.5); | |
f91de7da DW |
371 | } |
372 | ||
e2aa719c SC |
373 | inline wxDouble wxPoint2DDouble::GetVectorLength() const |
374 | { | |
375 | return sqrt( (m_x)*(m_x) + (m_y)*(m_y) ) ; | |
376 | } | |
377 | ||
5d3e7b52 | 378 | inline void wxPoint2DDouble::SetVectorLength( wxDouble length ) |
e2aa719c SC |
379 | { |
380 | wxDouble before = GetVectorLength() ; | |
381 | m_x = (m_x * length / before) ; | |
382 | m_y = (m_y * length / before) ; | |
383 | } | |
384 | ||
9821258b SC |
385 | inline void wxPoint2DDouble::Normalize() |
386 | { | |
387 | SetVectorLength( 1 ); | |
388 | } | |
389 | ||
2b5f62a0 | 390 | inline wxDouble wxPoint2DDouble::GetDistance( const wxPoint2DDouble &pt ) const |
f91de7da DW |
391 | { |
392 | return sqrt( GetDistanceSquare( pt ) ); | |
72e7876b SC |
393 | } |
394 | ||
2b5f62a0 | 395 | inline wxDouble wxPoint2DDouble::GetDistanceSquare( const wxPoint2DDouble &pt ) const |
f91de7da | 396 | { |
11e82c1b | 397 | return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ); |
f91de7da | 398 | } |
72e7876b | 399 | |
2b5f62a0 | 400 | inline wxDouble wxPoint2DDouble::GetDotProduct( const wxPoint2DDouble &vec ) const |
f91de7da | 401 | { |
11e82c1b | 402 | return ( m_x * vec.m_x + m_y * vec.m_y ); |
72e7876b SC |
403 | } |
404 | ||
2b5f62a0 | 405 | inline wxDouble wxPoint2DDouble::GetCrossProduct( const wxPoint2DDouble &vec ) const |
f91de7da | 406 | { |
11e82c1b | 407 | return ( m_x * vec.m_y - vec.m_x * m_y ); |
f91de7da | 408 | } |
72e7876b | 409 | |
f91de7da DW |
410 | inline wxPoint2DDouble wxPoint2DDouble::operator-() |
411 | { | |
c3a4297c | 412 | return wxPoint2DDouble( -m_x, -m_y); |
72e7876b SC |
413 | } |
414 | ||
415 | inline wxPoint2DDouble& wxPoint2DDouble::operator=(const wxPoint2DDouble& pt) | |
f91de7da | 416 | { |
7c562ad9 PC |
417 | if (this != &pt) |
418 | { | |
419 | m_x = pt.m_x; | |
420 | m_y = pt.m_y; | |
421 | } | |
11e82c1b | 422 | return *this; |
72e7876b SC |
423 | } |
424 | ||
f91de7da | 425 | inline wxPoint2DDouble& wxPoint2DDouble::operator+=(const wxPoint2DDouble& pt) |
72e7876b | 426 | { |
11e82c1b | 427 | m_x = m_x + pt.m_x; |
f91de7da | 428 | m_y = m_y + pt.m_y; |
11e82c1b | 429 | return *this; |
72e7876b SC |
430 | } |
431 | ||
f91de7da DW |
432 | inline wxPoint2DDouble& wxPoint2DDouble::operator-=(const wxPoint2DDouble& pt) |
433 | { | |
11e82c1b | 434 | m_x = m_x - pt.m_x; |
f91de7da | 435 | m_y = m_y - pt.m_y; |
11e82c1b | 436 | return *this; |
72e7876b SC |
437 | } |
438 | ||
f91de7da DW |
439 | inline wxPoint2DDouble& wxPoint2DDouble::operator*=(const wxPoint2DDouble& pt) |
440 | { | |
11e82c1b | 441 | m_x = m_x * pt.m_x; |
f91de7da | 442 | m_y = m_y * pt.m_y; |
11e82c1b | 443 | return *this; |
72e7876b SC |
444 | } |
445 | ||
f91de7da DW |
446 | inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt) |
447 | { | |
11e82c1b | 448 | m_x = m_x / pt.m_x; |
da052901 | 449 | m_y = m_y / pt.m_y; |
11e82c1b | 450 | return *this; |
72e7876b SC |
451 | } |
452 | ||
f91de7da DW |
453 | inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const |
454 | { | |
c77a6796 | 455 | return wxIsSameDouble(m_x, pt.m_x) && wxIsSameDouble(m_y, pt.m_y); |
72e7876b SC |
456 | } |
457 | ||
f91de7da DW |
458 | inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const |
459 | { | |
c77a6796 | 460 | return !(*this == pt); |
72e7876b SC |
461 | } |
462 | ||
f91de7da | 463 | inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) |
72e7876b | 464 | { |
11e82c1b | 465 | return wxPoint2DDouble( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y ); |
72e7876b SC |
466 | } |
467 | ||
f91de7da | 468 | inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) |
72e7876b | 469 | { |
11e82c1b | 470 | return wxPoint2DDouble( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y ); |
72e7876b SC |
471 | } |
472 | ||
473 | ||
f91de7da | 474 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) |
72e7876b | 475 | { |
11e82c1b | 476 | return wxPoint2DDouble( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y ); |
72e7876b SC |
477 | } |
478 | ||
f91de7da | 479 | inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt) |
72e7876b | 480 | { |
11e82c1b | 481 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ); |
72e7876b SC |
482 | } |
483 | ||
f91de7da | 484 | inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt) |
72e7876b | 485 | { |
11e82c1b | 486 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ); |
72e7876b SC |
487 | } |
488 | ||
f91de7da | 489 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n) |
72e7876b | 490 | { |
11e82c1b | 491 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ); |
72e7876b SC |
492 | } |
493 | ||
f91de7da | 494 | inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n) |
72e7876b | 495 | { |
11e82c1b | 496 | return wxPoint2DDouble( pt.m_x * n , pt.m_y * n ); |
72e7876b SC |
497 | } |
498 | ||
f91de7da | 499 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2) |
72e7876b | 500 | { |
11e82c1b | 501 | return wxPoint2DDouble( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y ); |
72e7876b SC |
502 | } |
503 | ||
f91de7da | 504 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n) |
72e7876b | 505 | { |
11e82c1b | 506 | return wxPoint2DDouble( pt.m_x / n , pt.m_y / n ); |
72e7876b SC |
507 | } |
508 | ||
f91de7da | 509 | inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n) |
72e7876b | 510 | { |
11e82c1b | 511 | return wxPoint2DDouble( pt.m_x / n , pt.m_y / n ); |
72e7876b SC |
512 | } |
513 | ||
f91de7da | 514 | // wxRect2Ds are a axis-aligned rectangles, each side of the rect is parallel to the x- or m_y- axis. The rectangle is either defined by the |
72e7876b | 515 | // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if |
f91de7da | 516 | // left <= x < right and top <= m_y < bottom , thus it is a half open interval. |
72e7876b | 517 | |
53a2db12 | 518 | class WXDLLIMPEXP_CORE wxRect2DDouble |
72e7876b SC |
519 | { |
520 | public: | |
f91de7da | 521 | wxRect2DDouble() |
11e82c1b | 522 | { m_x = m_y = m_width = m_height = 0; } |
6c7873e1 | 523 | wxRect2DDouble(wxDouble x, wxDouble y, wxDouble w, wxDouble h) |
11e82c1b | 524 | { m_x = x; m_y = y; m_width = w; m_height = h; } |
6c7873e1 RR |
525 | /* |
526 | wxRect2DDouble(const wxPoint2DDouble& topLeft, const wxPoint2DDouble& bottomRight); | |
527 | wxRect2DDouble(const wxPoint2DDouble& pos, const wxSize& size); | |
528 | wxRect2DDouble(const wxRect2DDouble& rect); | |
529 | */ | |
c3a4297c VZ |
530 | // single attribute accessors |
531 | ||
f91de7da | 532 | inline wxPoint2DDouble GetPosition() |
6c7873e1 RR |
533 | { return wxPoint2DDouble(m_x, m_y); } |
534 | inline wxSize GetSize() | |
7a5e6267 | 535 | { return wxSize((int) m_width, (int) m_height); } |
c3a4297c | 536 | |
d13b34d3 DS |
537 | // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their |
538 | // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately | |
c3a4297c | 539 | |
6c7873e1 | 540 | inline wxDouble GetLeft() const { return m_x; } |
11e82c1b VZ |
541 | inline void SetLeft( wxDouble n ) { m_width += m_x - n; m_x = n; } |
542 | inline void MoveLeftTo( wxDouble n ) { m_x = n; } | |
6c7873e1 | 543 | inline wxDouble GetTop() const { return m_y; } |
11e82c1b VZ |
544 | inline void SetTop( wxDouble n ) { m_height += m_y - n; m_y = n; } |
545 | inline void MoveTopTo( wxDouble n ) { m_y = n; } | |
6c7873e1 | 546 | inline wxDouble GetBottom() const { return m_y + m_height; } |
11e82c1b VZ |
547 | inline void SetBottom( wxDouble n ) { m_height += n - (m_y+m_height);} |
548 | inline void MoveBottomTo( wxDouble n ) { m_y = n - m_height; } | |
6c7873e1 | 549 | inline wxDouble GetRight() const { return m_x + m_width; } |
11e82c1b VZ |
550 | inline void SetRight( wxDouble n ) { m_width += n - (m_x+m_width) ; } |
551 | inline void MoveRightTo( wxDouble n ) { m_x = n - m_width; } | |
6c7873e1 RR |
552 | |
553 | inline wxPoint2DDouble GetLeftTop() const | |
11e82c1b | 554 | { return wxPoint2DDouble( m_x , m_y ); } |
6c7873e1 | 555 | inline void SetLeftTop( const wxPoint2DDouble &pt ) |
11e82c1b | 556 | { m_width += m_x - pt.m_x; m_height += m_y - pt.m_y; m_x = pt.m_x; m_y = pt.m_y; } |
6c7873e1 | 557 | inline void MoveLeftTopTo( const wxPoint2DDouble &pt ) |
11e82c1b | 558 | { m_x = pt.m_x; m_y = pt.m_y; } |
6c7873e1 | 559 | inline wxPoint2DDouble GetLeftBottom() const |
11e82c1b | 560 | { return wxPoint2DDouble( m_x , m_y + m_height ); } |
6c7873e1 | 561 | inline void SetLeftBottom( const wxPoint2DDouble &pt ) |
11e82c1b | 562 | { m_width += m_x - pt.m_x; m_height += pt.m_y - (m_y+m_height) ; m_x = pt.m_x; } |
6c7873e1 | 563 | inline void MoveLeftBottomTo( const wxPoint2DDouble &pt ) |
11e82c1b | 564 | { m_x = pt.m_x; m_y = pt.m_y - m_height; } |
6c7873e1 | 565 | inline wxPoint2DDouble GetRightTop() const |
11e82c1b | 566 | { return wxPoint2DDouble( m_x+m_width , m_y ); } |
6c7873e1 | 567 | inline void SetRightTop( const wxPoint2DDouble &pt ) |
11e82c1b | 568 | { m_width += pt.m_x - ( m_x + m_width ); m_height += m_y - pt.m_y; m_y = pt.m_y; } |
6c7873e1 | 569 | inline void MoveRightTopTo( const wxPoint2DDouble &pt ) |
11e82c1b | 570 | { m_x = pt.m_x - m_width; m_y = pt.m_y; } |
6c7873e1 | 571 | inline wxPoint2DDouble GetRightBottom() const |
11e82c1b | 572 | { return wxPoint2DDouble( m_x+m_width , m_y + m_height ); } |
6c7873e1 | 573 | inline void SetRightBottom( const wxPoint2DDouble &pt ) |
11e82c1b | 574 | { m_width += pt.m_x - ( m_x + m_width ); m_height += pt.m_y - (m_y+m_height);} |
6c7873e1 | 575 | inline void MoveRightBottomTo( const wxPoint2DDouble &pt ) |
11e82c1b | 576 | { m_x = pt.m_x - m_width; m_y = pt.m_y - m_height; } |
6c7873e1 | 577 | inline wxPoint2DDouble GetCentre() const |
11e82c1b | 578 | { return wxPoint2DDouble( m_x+m_width/2 , m_y+m_height/2 ); } |
6c7873e1 | 579 | inline void SetCentre( const wxPoint2DDouble &pt ) |
11e82c1b | 580 | { MoveCentreTo( pt ); } // since this is impossible without moving... |
6c7873e1 | 581 | inline void MoveCentreTo( const wxPoint2DDouble &pt ) |
11e82c1b | 582 | { m_x += pt.m_x - (m_x+m_width/2) , m_y += pt.m_y -(m_y+m_height/2); } |
0624ce56 | 583 | inline wxOutCode GetOutCode( const wxPoint2DDouble &pt ) const |
6c7873e1 | 584 | { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) + |
1b2a04da | 585 | ( ( pt.m_x > m_x + m_width ) ? wxOutRight : 0 ) + |
c3a4297c | 586 | ( ( pt.m_y < m_y ) ? wxOutTop : 0 ) + |
1b2a04da | 587 | ( ( pt.m_y > m_y + m_height ) ? wxOutBottom : 0 )); } |
5d3e7b52 WS |
588 | inline wxOutCode GetOutcode(const wxPoint2DDouble &pt) const |
589 | { return GetOutCode(pt) ; } | |
f91de7da | 590 | inline bool Contains( const wxPoint2DDouble &pt ) const |
0624ce56 | 591 | { return GetOutCode( pt ) == wxInside; } |
f91de7da DW |
592 | inline bool Contains( const wxRect2DDouble &rect ) const |
593 | { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) && | |
11e82c1b | 594 | ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); } |
f91de7da | 595 | inline bool IsEmpty() const |
c77a6796 | 596 | { return m_width <= 0 || m_height <= 0; } |
f91de7da | 597 | inline bool HaveEqualSize( const wxRect2DDouble &rect ) const |
c77a6796 | 598 | { return wxIsSameDouble(rect.m_width, m_width) && wxIsSameDouble(rect.m_height, m_height); } |
f91de7da | 599 | |
6c7873e1 | 600 | inline void Inset( wxDouble x , wxDouble y ) |
11e82c1b | 601 | { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; } |
f91de7da | 602 | inline void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom ) |
11e82c1b | 603 | { m_x += left; m_y += top; m_width -= left + right; m_height -= top + bottom;} |
6c7873e1 | 604 | inline void Offset( const wxPoint2DDouble &pt ) |
11e82c1b | 605 | { m_x += pt.m_x; m_y += pt.m_y; } |
f91de7da | 606 | |
6c7873e1 | 607 | void ConstrainTo( const wxRect2DDouble &rect ); |
f91de7da | 608 | |
6c7873e1 | 609 | inline wxPoint2DDouble Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ) |
11e82c1b | 610 | { return wxPoint2DDouble( m_x + m_width * widthfactor , m_y + m_height * heightfactor ); } |
6c7873e1 | 611 | |
11e82c1b | 612 | static void Intersect( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest ); |
6c7873e1 | 613 | inline void Intersect( const wxRect2DDouble &otherRect ) |
11e82c1b | 614 | { Intersect( *this , otherRect , this ); } |
6c7873e1 | 615 | inline wxRect2DDouble CreateIntersection( const wxRect2DDouble &otherRect ) const |
11e82c1b VZ |
616 | { wxRect2DDouble result; Intersect( *this , otherRect , &result); return result; } |
617 | bool Intersects( const wxRect2DDouble &rect ) const; | |
6c7873e1 | 618 | |
11e82c1b | 619 | static void Union( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest ); |
6c7873e1 | 620 | void Union( const wxRect2DDouble &otherRect ) |
11e82c1b VZ |
621 | { Union( *this , otherRect , this ); } |
622 | void Union( const wxPoint2DDouble &pt ); | |
6c7873e1 | 623 | inline wxRect2DDouble CreateUnion( const wxRect2DDouble &otherRect ) const |
11e82c1b | 624 | { wxRect2DDouble result; Union( *this , otherRect , &result); return result; } |
6c7873e1 RR |
625 | |
626 | inline void Scale( wxDouble f ) | |
11e82c1b | 627 | { m_x *= f; m_y *= f; m_width *= f; m_height *= f;} |
f91de7da | 628 | inline void Scale( wxInt32 num , wxInt32 denum ) |
11e82c1b VZ |
629 | { m_x *= ((wxDouble)num)/((wxDouble)denum); m_y *= ((wxDouble)num)/((wxDouble)denum); |
630 | m_width *= ((wxDouble)num)/((wxDouble)denum); m_height *= ((wxDouble)num)/((wxDouble)denum);} | |
c3a4297c | 631 | |
6c7873e1 | 632 | wxRect2DDouble& operator = (const wxRect2DDouble& rect); |
fbfb8bcc | 633 | inline bool operator == (const wxRect2DDouble& rect) const |
c77a6796 | 634 | { return wxIsSameDouble(m_x, rect.m_x) && wxIsSameDouble(m_y, rect.m_y) && HaveEqualSize(rect); } |
fbfb8bcc | 635 | inline bool operator != (const wxRect2DDouble& rect) const |
7dc85fe2 | 636 | { return !(*this == rect); } |
c3a4297c | 637 | |
6c7873e1 | 638 | wxDouble m_x; |
11e82c1b | 639 | wxDouble m_y; |
6c7873e1 RR |
640 | wxDouble m_width; |
641 | wxDouble m_height; | |
72e7876b SC |
642 | }; |
643 | ||
72e7876b | 644 | |
f91de7da | 645 | // wxRect2Ds are a axis-aligned rectangles, each side of the rect is parallel to the x- or m_y- axis. The rectangle is either defined by the |
72e7876b | 646 | // top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if |
f91de7da | 647 | // left <= x < right and top <= m_y < bottom , thus it is a half open interval. |
72e7876b | 648 | |
53a2db12 | 649 | class WXDLLIMPEXP_CORE wxRect2DInt |
72e7876b SC |
650 | { |
651 | public: | |
11e82c1b | 652 | wxRect2DInt() { m_x = m_y = m_width = m_height = 0; } |
e2aa719c | 653 | wxRect2DInt( const wxRect& r ) { m_x = r.x ; m_y = r.y ; m_width = r.width ; m_height = r.height ; } |
11e82c1b | 654 | wxRect2DInt(wxInt32 x, wxInt32 y, wxInt32 w, wxInt32 h) { m_x = x; m_y = y; m_width = w; m_height = h; } |
c3a4297c | 655 | wxRect2DInt(const wxPoint2DInt& topLeft, const wxPoint2DInt& bottomRight); |
f91de7da DW |
656 | inline wxRect2DInt(const wxPoint2DInt& pos, const wxSize& size); |
657 | inline wxRect2DInt(const wxRect2DInt& rect); | |
c3a4297c VZ |
658 | |
659 | // single attribute accessors | |
660 | ||
661 | inline wxPoint2DInt GetPosition() { return wxPoint2DInt(m_x, m_y); } | |
662 | inline wxSize GetSize() { return wxSize(m_width, m_height); } | |
663 | ||
d13b34d3 DS |
664 | // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their |
665 | // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately | |
c3a4297c VZ |
666 | |
667 | inline wxInt32 GetLeft() const { return m_x; } | |
11e82c1b VZ |
668 | inline void SetLeft( wxInt32 n ) { m_width += m_x - n; m_x = n; } |
669 | inline void MoveLeftTo( wxInt32 n ) { m_x = n; } | |
c3a4297c | 670 | inline wxInt32 GetTop() const { return m_y; } |
11e82c1b VZ |
671 | inline void SetTop( wxInt32 n ) { m_height += m_y - n; m_y = n; } |
672 | inline void MoveTopTo( wxInt32 n ) { m_y = n; } | |
c3a4297c | 673 | inline wxInt32 GetBottom() const { return m_y + m_height; } |
11e82c1b VZ |
674 | inline void SetBottom( wxInt32 n ) { m_height += n - (m_y+m_height);} |
675 | inline void MoveBottomTo( wxInt32 n ) { m_y = n - m_height; } | |
c3a4297c | 676 | inline wxInt32 GetRight() const { return m_x + m_width; } |
11e82c1b VZ |
677 | inline void SetRight( wxInt32 n ) { m_width += n - (m_x+m_width) ; } |
678 | inline void MoveRightTo( wxInt32 n ) { m_x = n - m_width; } | |
679 | ||
680 | inline wxPoint2DInt GetLeftTop() const { return wxPoint2DInt( m_x , m_y ); } | |
681 | inline void SetLeftTop( const wxPoint2DInt &pt ) { m_width += m_x - pt.m_x; m_height += m_y - pt.m_y; m_x = pt.m_x; m_y = pt.m_y; } | |
682 | inline void MoveLeftTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x; m_y = pt.m_y; } | |
683 | inline wxPoint2DInt GetLeftBottom() const { return wxPoint2DInt( m_x , m_y + m_height ); } | |
684 | inline void SetLeftBottom( const wxPoint2DInt &pt ) { m_width += m_x - pt.m_x; m_height += pt.m_y - (m_y+m_height) ; m_x = pt.m_x; } | |
685 | inline void MoveLeftBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x; m_y = pt.m_y - m_height; } | |
686 | inline wxPoint2DInt GetRightTop() const { return wxPoint2DInt( m_x+m_width , m_y ); } | |
687 | inline void SetRightTop( const wxPoint2DInt &pt ) { m_width += pt.m_x - ( m_x + m_width ); m_height += m_y - pt.m_y; m_y = pt.m_y; } | |
688 | inline void MoveRightTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width; m_y = pt.m_y; } | |
689 | inline wxPoint2DInt GetRightBottom() const { return wxPoint2DInt( m_x+m_width , m_y + m_height ); } | |
690 | inline void SetRightBottom( const wxPoint2DInt &pt ) { m_width += pt.m_x - ( m_x + m_width ); m_height += pt.m_y - (m_y+m_height);} | |
691 | inline void MoveRightBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width; m_y = pt.m_y - m_height; } | |
692 | inline wxPoint2DInt GetCentre() const { return wxPoint2DInt( m_x+m_width/2 , m_y+m_height/2 ); } | |
693 | inline void SetCentre( const wxPoint2DInt &pt ) { MoveCentreTo( pt ); } // since this is impossible without moving... | |
694 | inline void MoveCentreTo( const wxPoint2DInt &pt ) { m_x += pt.m_x - (m_x+m_width/2) , m_y += pt.m_y -(m_y+m_height/2); } | |
0624ce56 | 695 | inline wxOutCode GetOutCode( const wxPoint2DInt &pt ) const |
c3a4297c VZ |
696 | { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) + |
697 | ( ( pt.m_x >= m_x + m_width ) ? wxOutRight : 0 ) + | |
698 | ( ( pt.m_y < m_y ) ? wxOutTop : 0 ) + | |
11e82c1b | 699 | ( ( pt.m_y >= m_y + m_height ) ? wxOutBottom : 0 )); } |
5d3e7b52 WS |
700 | inline wxOutCode GetOutcode( const wxPoint2DInt &pt ) const |
701 | { return GetOutCode( pt ) ; } | |
f91de7da | 702 | inline bool Contains( const wxPoint2DInt &pt ) const |
0624ce56 | 703 | { return GetOutCode( pt ) == wxInside; } |
f91de7da DW |
704 | inline bool Contains( const wxRect2DInt &rect ) const |
705 | { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) && | |
11e82c1b | 706 | ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); } |
f91de7da | 707 | inline bool IsEmpty() const |
11e82c1b | 708 | { return ( m_width <= 0 || m_height <= 0 ); } |
f91de7da | 709 | inline bool HaveEqualSize( const wxRect2DInt &rect ) const |
11e82c1b | 710 | { return ( rect.m_width == m_width && rect.m_height == m_height ); } |
f91de7da | 711 | |
11e82c1b | 712 | inline void Inset( wxInt32 x , wxInt32 y ) { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; } |
f91de7da | 713 | inline void Inset( wxInt32 left , wxInt32 top ,wxInt32 right , wxInt32 bottom ) |
11e82c1b VZ |
714 | { m_x += left; m_y += top; m_width -= left + right; m_height -= top + bottom;} |
715 | inline void Offset( const wxPoint2DInt &pt ) { m_x += pt.m_x; m_y += pt.m_y; } | |
716 | void ConstrainTo( const wxRect2DInt &rect ); | |
717 | inline wxPoint2DInt Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ) { return wxPoint2DInt( m_x + m_width * widthfactor , m_y + m_height * heightfactor ); } | |
718 | ||
719 | static void Intersect( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest ); | |
720 | inline void Intersect( const wxRect2DInt &otherRect ) { Intersect( *this , otherRect , this ); } | |
721 | inline wxRect2DInt CreateIntersection( const wxRect2DInt &otherRect ) const { wxRect2DInt result; Intersect( *this , otherRect , &result); return result; } | |
722 | bool Intersects( const wxRect2DInt &rect ) const; | |
723 | ||
724 | static void Union( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest ); | |
725 | void Union( const wxRect2DInt &otherRect ) { Union( *this , otherRect , this ); } | |
726 | void Union( const wxPoint2DInt &pt ); | |
727 | inline wxRect2DInt CreateUnion( const wxRect2DInt &otherRect ) const { wxRect2DInt result; Union( *this , otherRect , &result); return result; } | |
728 | ||
729 | inline void Scale( wxInt32 f ) { m_x *= f; m_y *= f; m_width *= f; m_height *= f;} | |
f91de7da | 730 | inline void Scale( wxInt32 num , wxInt32 denum ) |
11e82c1b VZ |
731 | { m_x *= ((wxInt32)num)/((wxInt32)denum); m_y *= ((wxInt32)num)/((wxInt32)denum); |
732 | m_width *= ((wxInt32)num)/((wxInt32)denum); m_height *= ((wxInt32)num)/((wxInt32)denum);} | |
c3a4297c VZ |
733 | |
734 | wxRect2DInt& operator = (const wxRect2DInt& rect); | |
cd501207 JS |
735 | bool operator == (const wxRect2DInt& rect) const; |
736 | bool operator != (const wxRect2DInt& rect) const; | |
c3a4297c | 737 | |
e30285ab | 738 | #if wxUSE_STREAMS |
cd501207 JS |
739 | void WriteTo( wxDataOutputStream &stream ) const; |
740 | void ReadFrom( wxDataInputStream &stream ); | |
e30285ab | 741 | #endif // wxUSE_STREAMS |
c3a4297c | 742 | |
11e82c1b | 743 | wxInt32 m_x; |
cd501207 JS |
744 | wxInt32 m_y; |
745 | wxInt32 m_width; | |
746 | wxInt32 m_height; | |
72e7876b SC |
747 | }; |
748 | ||
f91de7da DW |
749 | inline wxRect2DInt::wxRect2DInt( const wxRect2DInt &r ) |
750 | { | |
11e82c1b VZ |
751 | m_x = r.m_x; |
752 | m_y = r.m_y; | |
753 | m_width = r.m_width; | |
754 | m_height = r.m_height; | |
f91de7da DW |
755 | } |
756 | ||
757 | inline wxRect2DInt::wxRect2DInt( const wxPoint2DInt &a , const wxPoint2DInt &b) | |
758 | { | |
11e82c1b VZ |
759 | m_x = wxMin( a.m_x , b.m_x ); |
760 | m_y = wxMin( a.m_y , b.m_y ); | |
761 | m_width = abs( a.m_x - b.m_x ); | |
762 | m_height = abs( a.m_y - b.m_y ); | |
f91de7da | 763 | } |
72e7876b | 764 | |
c2fa4af4 SC |
765 | inline wxRect2DInt::wxRect2DInt( const wxPoint2DInt& pos, const wxSize& size) |
766 | { | |
767 | m_x = pos.m_x; | |
768 | m_y = pos.m_y; | |
769 | m_width = size.x; | |
770 | m_height = size.y; | |
771 | } | |
772 | ||
cd501207 | 773 | inline bool wxRect2DInt::operator == (const wxRect2DInt& rect) const |
5d3e7b52 WS |
774 | { |
775 | return (m_x==rect.m_x && m_y==rect.m_y && | |
cd501207 JS |
776 | m_width==rect.m_width && m_height==rect.m_height); |
777 | } | |
778 | ||
779 | inline bool wxRect2DInt::operator != (const wxRect2DInt& rect) const | |
780 | { | |
781 | return !(*this == rect); | |
782 | } | |
783 | ||
72e7876b SC |
784 | class wxTransform2D |
785 | { | |
786 | public : | |
ed62f740 | 787 | virtual ~wxTransform2D() { } |
11e82c1b VZ |
788 | virtual void Transform( wxPoint2DInt* pt )const = 0; |
789 | virtual void Transform( wxRect2DInt* r ) const; | |
790 | virtual wxPoint2DInt Transform( const wxPoint2DInt &pt ) const; | |
791 | virtual wxRect2DInt Transform( const wxRect2DInt &r ) const ; | |
c3a4297c VZ |
792 | |
793 | virtual void InverseTransform( wxPoint2DInt* pt ) const = 0; | |
11e82c1b VZ |
794 | virtual void InverseTransform( wxRect2DInt* r ) const ; |
795 | virtual wxPoint2DInt InverseTransform( const wxPoint2DInt &pt ) const ; | |
796 | virtual wxRect2DInt InverseTransform( const wxRect2DInt &r ) const ; | |
797 | }; | |
72e7876b | 798 | |
f91de7da | 799 | inline void wxTransform2D::Transform( wxRect2DInt* r ) const |
11e82c1b | 800 | { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom(); Transform( &a ); Transform( &b ); *r = wxRect2DInt( a , b ); } |
72e7876b | 801 | |
f91de7da | 802 | inline wxPoint2DInt wxTransform2D::Transform( const wxPoint2DInt &pt ) const |
11e82c1b | 803 | { wxPoint2DInt res = pt; Transform( &res ); return res; } |
72e7876b | 804 | |
f91de7da | 805 | inline wxRect2DInt wxTransform2D::Transform( const wxRect2DInt &r ) const |
11e82c1b | 806 | { wxRect2DInt res = r; Transform( &res ); return res; } |
72e7876b | 807 | |
f91de7da | 808 | inline void wxTransform2D::InverseTransform( wxRect2DInt* r ) const |
11e82c1b | 809 | { wxPoint2DInt a = r->GetLeftTop() , b = r->GetRightBottom(); InverseTransform( &a ); InverseTransform( &b ); *r = wxRect2DInt( a , b ); } |
72e7876b | 810 | |
f91de7da | 811 | inline wxPoint2DInt wxTransform2D::InverseTransform( const wxPoint2DInt &pt ) const |
11e82c1b | 812 | { wxPoint2DInt res = pt; InverseTransform( &res ); return res; } |
72e7876b | 813 | |
f91de7da | 814 | inline wxRect2DInt wxTransform2D::InverseTransform( const wxRect2DInt &r ) const |
11e82c1b | 815 | { wxRect2DInt res = r; InverseTransform( &res ); return res; } |
72e7876b | 816 | |
c3a4297c VZ |
817 | |
818 | #endif // wxUSE_GEOMETRY | |
819 | ||
820 | #endif // _WX_GEOMETRY_H_ |