|
1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\euser\us_graph.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "us_std.h" |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 EXPORT_C TBool TPoint::operator==(const TPoint& aPoint) const |
|
24 /** |
|
25 Compares two points for equality. |
|
26 |
|
27 For two points to be equal, both their x and y co-ordinate values must be |
|
28 equal. |
|
29 |
|
30 @param aPoint The point to be compared with this point. |
|
31 |
|
32 @return True, if the two points are equal; false, otherwise. |
|
33 */ |
|
34 { |
|
35 |
|
36 return(iX==aPoint.iX && iY==aPoint.iY); |
|
37 } |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 EXPORT_C TBool TPoint::operator!=(const TPoint& aPoint) const |
|
43 /** |
|
44 Compares two points for inequality. |
|
45 |
|
46 For two points to be unequal, either their x or their y co-ordinate values |
|
47 must be different. |
|
48 |
|
49 @param aPoint The point to be compared with this point. |
|
50 |
|
51 @return True, if the two points are unequal; false, otherwise. |
|
52 */ |
|
53 { |
|
54 |
|
55 return(iX!=aPoint.iX || iY!=aPoint.iY); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 EXPORT_C TPoint& TPoint::operator-=(const TPoint& aPoint) |
|
62 /** |
|
63 TPoint subtraction assignment operator. |
|
64 |
|
65 The operator subtracts the specified point from this point, and assigns the |
|
66 result back to this point. |
|
67 |
|
68 @param aPoint The point to be subtracted. |
|
69 |
|
70 @return A reference to this point object. |
|
71 */ |
|
72 { |
|
73 |
|
74 iX-=aPoint.iX; |
|
75 iY-=aPoint.iY; |
|
76 return(*this); |
|
77 } |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 EXPORT_C TPoint& TPoint::operator-=(const TSize& aSize) |
|
83 /** |
|
84 TSize subtraction assignment operator. |
|
85 |
|
86 The operator subtracts the specified TSize from this point, and assigns the |
|
87 result back to this point. |
|
88 |
|
89 The operation proceeds by: |
|
90 |
|
91 1. subtracting the width value of the TSize from the x co-ordinate value |
|
92 |
|
93 2. subtracting the height value of the TSize from the y co-ordinate value |
|
94 |
|
95 @param aSize The TSize to be subtracted. |
|
96 |
|
97 @return A reference to this point object. |
|
98 */ |
|
99 { |
|
100 |
|
101 iX-=aSize.iWidth; |
|
102 iY-=aSize.iHeight; |
|
103 return(*this); |
|
104 } |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 EXPORT_C TPoint& TPoint::operator+=(const TPoint& aPoint) |
|
110 /** |
|
111 TPoint addition assignment operator. |
|
112 |
|
113 The operator adds the specified point to this point, and assigns the result |
|
114 back to this point. |
|
115 |
|
116 @param aPoint The point to be added. |
|
117 |
|
118 @return A reference to this point object. |
|
119 */ |
|
120 { |
|
121 |
|
122 iX+=aPoint.iX; |
|
123 iY+=aPoint.iY; |
|
124 return(*this); |
|
125 } |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 EXPORT_C TPoint& TPoint::operator+=(const TSize& aSize) |
|
131 /** |
|
132 TSize addition assignment operator. |
|
133 |
|
134 The operator adds the specified TSize to this point, and assigns the result |
|
135 back to this point. |
|
136 |
|
137 The operation proceeds by: |
|
138 |
|
139 1. adding the width value of the TSize to the x co-ordinate value |
|
140 |
|
141 2. adding the height value of the TSize to the y co-ordinate value |
|
142 |
|
143 @param aSize The TSize to be added to this point. |
|
144 |
|
145 @return A reference to this point object. |
|
146 */ |
|
147 { |
|
148 |
|
149 iX+=aSize.iWidth; |
|
150 iY+=aSize.iHeight; |
|
151 return(*this); |
|
152 } |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 EXPORT_C TPoint TPoint::operator-(const TPoint& aPoint) const |
|
158 /** |
|
159 TPoint subtraction operator. |
|
160 |
|
161 The operator subtracts the specified point from this point, and returns the |
|
162 resulting value. |
|
163 |
|
164 @param aPoint The point to be subtracted from this point. |
|
165 |
|
166 @return The result of the operation. |
|
167 */ |
|
168 { |
|
169 |
|
170 TPoint ret=* this; |
|
171 ret-= aPoint; |
|
172 return(ret); |
|
173 } |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 EXPORT_C TPoint TPoint::operator-(const TSize& aSize) const |
|
179 /** |
|
180 TSize subtraction operator. |
|
181 |
|
182 The operator subtracts the specified TSize from this point, and returns the |
|
183 resulting value. |
|
184 |
|
185 The operation proceeds by: |
|
186 |
|
187 1. subtracting the width value of the TSize from the x co-ordinate value |
|
188 |
|
189 2. subtracting the height value of the TSize from the y co-ordinate value. |
|
190 |
|
191 @param aSize The TSize to be subtracted. |
|
192 |
|
193 @return The result of the operation. |
|
194 */ |
|
195 { |
|
196 |
|
197 TPoint ret=* this; |
|
198 ret-= aSize; |
|
199 return(ret); |
|
200 } |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 EXPORT_C TPoint TPoint::operator+(const TPoint& aPoint) const |
|
206 /** |
|
207 The operator adds the specified point to this point, and returns the resulting |
|
208 value. |
|
209 |
|
210 @param aPoint The point to be added to this point. |
|
211 |
|
212 @return The result of the operation. |
|
213 */ |
|
214 { |
|
215 |
|
216 TPoint ret=* this; |
|
217 ret+= aPoint; |
|
218 return(ret); |
|
219 } |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 EXPORT_C TPoint TPoint::operator+(const TSize& aSize) const |
|
225 /** |
|
226 TSize addition operator. |
|
227 |
|
228 The operator adds the specified TSize to this point, and returns the resulting |
|
229 value. |
|
230 |
|
231 The operation proceeds by: |
|
232 |
|
233 1. adding the width value of the TSize to the x co-ordinate value |
|
234 |
|
235 2. adding the height value of the TSize to the y co-ordinate value. |
|
236 |
|
237 @param aSize The TSize to be added to this TPoint. |
|
238 |
|
239 @return The result of the operation. |
|
240 */ |
|
241 { |
|
242 |
|
243 TPoint ret=* this; |
|
244 ret+= aSize; |
|
245 return(ret); |
|
246 } |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 EXPORT_C TPoint TPoint::operator-() const |
|
252 /** |
|
253 Unary minus operator. |
|
254 |
|
255 The operator returns the negation of this point. |
|
256 |
|
257 @return The result of the operation. |
|
258 */ |
|
259 { |
|
260 |
|
261 return TPoint(-iX,-iY); |
|
262 } |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 EXPORT_C void TPoint::SetXY(TInt aX,TInt aY) |
|
268 /** |
|
269 Sets the x and y co-ordinates for this point. |
|
270 |
|
271 @param aX The value to assign to the x co-ordinate. |
|
272 @param aY The value to assign to the y co-ordinate. |
|
273 */ |
|
274 { |
|
275 |
|
276 iX=aX; |
|
277 iY=aY; |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 EXPORT_C TSize TPoint::AsSize() const |
|
284 /** |
|
285 Gets the size of the rectangle whose top left hand corner is the origin of |
|
286 the screen co-ordinates and whose bottom right hand corner is this point. |
|
287 |
|
288 @return The co-ordinates of this point converted to a size. |
|
289 */ |
|
290 { |
|
291 return(TSize(iX,iY)); |
|
292 } |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 EXPORT_C TBool TPoint3D::operator==(const TPoint3D& aPoint3D) const |
|
299 /** |
|
300 Compares two 3D points(TPoint3D) for equality. |
|
301 |
|
302 For two TPoint3D to be equal, their x , y and zco-ordinate values must be |
|
303 equal. |
|
304 |
|
305 @param aPoint3D The point to be compared with this point. |
|
306 |
|
307 @return True, if the two points are equal; false, otherwise. |
|
308 */ |
|
309 { |
|
310 return(iX==aPoint3D.iX && iY==aPoint3D.iY && iZ==aPoint3D.iZ); |
|
311 } |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 EXPORT_C TBool TPoint3D::operator!=(const TPoint3D& aPoint3D) const |
|
317 /** |
|
318 Compares two 3D points for inequality. |
|
319 |
|
320 For two points to be unequal, their x or y or z co-ordinate values |
|
321 must be different. |
|
322 |
|
323 @param aPoint3D The point to be compared with this point. |
|
324 |
|
325 @return True, if the two points are unequal; false, otherwise. |
|
326 */ |
|
327 { |
|
328 return(iX!=aPoint3D.iX || iY!=aPoint3D.iY || iZ!=aPoint3D.iZ); |
|
329 } |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 EXPORT_C TPoint3D& TPoint3D::operator-=(const TPoint3D& aPoint3D) |
|
337 /** |
|
338 TPoint3D subtraction assignment operator. |
|
339 |
|
340 The operator subtracts the specified point from this point, and assigns the |
|
341 result back to this point. |
|
342 |
|
343 @param aPoint The point to be subtracted. |
|
344 |
|
345 @return A reference to this point object. |
|
346 */ |
|
347 { |
|
348 iX-=aPoint3D.iX; |
|
349 iY-=aPoint3D.iY; |
|
350 iZ-=aPoint3D.iZ; |
|
351 return(*this); |
|
352 } |
|
353 |
|
354 |
|
355 |
|
356 EXPORT_C TPoint3D& TPoint3D::operator-=(const TPoint& aPoint) |
|
357 |
|
358 /** |
|
359 TPoint subtraction assignment operator. |
|
360 |
|
361 The operator subtracts the specified TPoint from this point(TPoint3D), and assigns the |
|
362 result back to this point. |
|
363 |
|
364 The operation proceeds by |
|
365 subtracting x and y cordinates of the TPoin to this point and no changes to the Z-coordinatete value |
|
366 |
|
367 @param aPoint The aPoint to be subtracted. |
|
368 |
|
369 @return A reference to this point object. |
|
370 */ |
|
371 { |
|
372 iX-=aPoint.iX; |
|
373 iY-=aPoint.iY; |
|
374 //No Changes to the z co-ordinate |
|
375 return(*this); |
|
376 } |
|
377 |
|
378 |
|
379 |
|
380 EXPORT_C TPoint3D& TPoint3D::operator+=(const TPoint3D& aPoint3D) |
|
381 /** |
|
382 TPoint3D addition assignment operator. |
|
383 |
|
384 The operator adds the specified point to this point, and assigns the result |
|
385 back to this point. |
|
386 |
|
387 @param aPoint3D The point to be added. |
|
388 |
|
389 @return A reference to this point object. |
|
390 */ |
|
391 { |
|
392 iX+=aPoint3D.iX; |
|
393 iY+=aPoint3D.iY; |
|
394 iZ+=aPoint3D.iZ; |
|
395 return(*this); |
|
396 } |
|
397 |
|
398 EXPORT_C TPoint3D& TPoint3D::operator+=(const TPoint& aPoint) |
|
399 /** |
|
400 TPoint addition assignment operator. |
|
401 |
|
402 The operator adds the specified TPoint to this point, and assigns the result |
|
403 back to this point. |
|
404 |
|
405 The operation proceeds by: |
|
406 adding x and y cordinates of the TPoin to this point and no changes to the Z-coordinatete value |
|
407 |
|
408 @param aPoint The TPoint to be added to this point. |
|
409 |
|
410 @return A reference to this point object. |
|
411 */ |
|
412 { |
|
413 |
|
414 iX+=aPoint.iX; |
|
415 iY+=aPoint.iY; |
|
416 //No Changes to the z co-ordinate |
|
417 return(*this); |
|
418 } |
|
419 EXPORT_C TPoint3D TPoint3D::operator-(const TPoint3D& aPoint3D) const |
|
420 /** |
|
421 TPoint3D subtraction operator. |
|
422 |
|
423 The operator subtracts the specified point from this point, and returns the |
|
424 resulting value. |
|
425 |
|
426 @param aPoint3D The point to be subtracted from this point. |
|
427 |
|
428 @return the point(TPoint3D) which is the result of the operation. |
|
429 */ |
|
430 { |
|
431 |
|
432 TPoint3D ret=* this; |
|
433 ret-= aPoint3D; |
|
434 return(ret); |
|
435 } |
|
436 |
|
437 |
|
438 |
|
439 EXPORT_C TPoint3D TPoint3D::operator-(const TPoint& aPoint) const |
|
440 /** |
|
441 TPoint subtraction operator. |
|
442 |
|
443 The operator subtracts the specified TPoint from this point, and returns the |
|
444 resulting value. |
|
445 |
|
446 @param aPoint The TPoint to be subtracted. |
|
447 |
|
448 @return the point(TPoint3D) which is the result of the operation. |
|
449 */ |
|
450 { |
|
451 |
|
452 TPoint3D ret=* this; |
|
453 ret-= aPoint; |
|
454 return(ret); |
|
455 } |
|
456 |
|
457 |
|
458 EXPORT_C TPoint3D TPoint3D::operator+(const TPoint3D& aPoint3D) const |
|
459 /** |
|
460 The operator adds the specified point to this point, and returns the resulting |
|
461 value. |
|
462 |
|
463 @param aPoint3D The point to be added to this point. |
|
464 |
|
465 @return the point(TPoint3D) which is the result of the operation. |
|
466 */ |
|
467 { |
|
468 |
|
469 TPoint3D ret=* this; |
|
470 ret+= aPoint3D; |
|
471 return(ret); |
|
472 } |
|
473 |
|
474 EXPORT_C TPoint3D TPoint3D::operator+(const TPoint& aPoint) const |
|
475 /** |
|
476 TPoint addition operator. |
|
477 |
|
478 The operator adds the specified TPoint to this point, and returns the resulting |
|
479 value. |
|
480 |
|
481 @param aSize The TSize to be added to this TPoint. |
|
482 |
|
483 @return the point(TPoint3D) which is the result of the operation. |
|
484 */ |
|
485 { |
|
486 |
|
487 TPoint3D ret=* this; |
|
488 ret+= aPoint; |
|
489 return(ret); |
|
490 } |
|
491 |
|
492 |
|
493 EXPORT_C TPoint3D TPoint3D::operator-() const |
|
494 /** |
|
495 Unary minus operator. |
|
496 |
|
497 The operator returns the negation of this point. |
|
498 |
|
499 @return the point(TPoint3D) which is the result of Unary minus operation. |
|
500 */ |
|
501 { |
|
502 return TPoint3D(-iX,-iY,-iZ); |
|
503 } |
|
504 |
|
505 |
|
506 |
|
507 EXPORT_C void TPoint3D::SetXYZ(TInt aX,TInt aY,TInt aZ) |
|
508 /** |
|
509 Sets the x , y and z co-ordinates for this point. |
|
510 |
|
511 @param aX The value to assign to the x co-ordinate. |
|
512 @param aY The value to assign to the y co-ordinate. |
|
513 @param aZ The value to assign to the z co-ordinate. |
|
514 */ |
|
515 { |
|
516 iX=aX; |
|
517 iY=aY; |
|
518 iZ=aZ; |
|
519 } |
|
520 |
|
521 EXPORT_C void TPoint3D::SetPoint(const TPoint& aPoint) |
|
522 /* |
|
523 TPoint3D from TPoint, sets the Z co-ordinate to Zero |
|
524 @param aPoint The TPoint to add to this point |
|
525 */ |
|
526 { |
|
527 iX=aPoint.iX; |
|
528 iY=aPoint.iY; |
|
529 iZ=0; |
|
530 } |
|
531 |
|
532 |
|
533 EXPORT_C TPoint TPoint3D::AsPoint() const |
|
534 /** |
|
535 Gets Tpoint from Tpoint3D |
|
536 @return TPoint from X and Y cordinates of Tpoint3D |
|
537 */ |
|
538 { |
|
539 return(TPoint(iX,iY)); |
|
540 } |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 EXPORT_C TBool TSize::operator==(const TSize& aSize) const |
|
548 /** |
|
549 Compares this TSize with the specified TSize for equality. |
|
550 |
|
551 For two TSizes to be equal, both their width and height values must be equal. |
|
552 |
|
553 @param aSize The TSize to be compared with this TSize. |
|
554 |
|
555 @return True, if the two TSize are equal; false, otherwise. |
|
556 */ |
|
557 { |
|
558 return(iWidth==aSize.iWidth && iHeight==aSize.iHeight); |
|
559 } |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 EXPORT_C TBool TSize::operator!=(const TSize& aSize) const |
|
565 /** |
|
566 Compares two TSize for inequality. |
|
567 |
|
568 For two TSize to be unequal, either their width or height values must be different. |
|
569 |
|
570 @param aSize The TSize to be compared with this TSize. |
|
571 |
|
572 @return True, if the two TSize are unequal; false, otherwise. |
|
573 */ |
|
574 { |
|
575 return(iWidth!=aSize.iWidth || iHeight!=aSize.iHeight); |
|
576 } |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 EXPORT_C TSize& TSize::operator-=(const TSize& aSize) |
|
582 /** |
|
583 TSize subtraction assignment operator. |
|
584 |
|
585 The operator subtracts the specified TSize from this TSize, and assigns the |
|
586 result back to this TSize. |
|
587 |
|
588 @param aSize The TSize to be subtracted. |
|
589 |
|
590 @return A reference to this TSize object. |
|
591 */ |
|
592 { |
|
593 iWidth-=aSize.iWidth;iHeight-=aSize.iHeight;return(*this); |
|
594 } |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 EXPORT_C TSize& TSize::operator-=(const TPoint& aPoint) |
|
600 /** |
|
601 TPoint subtraction assignment operator. |
|
602 |
|
603 The operator subtracts the specified point from this TSize, and assigns the |
|
604 result back to this TSize. |
|
605 |
|
606 The operation proceeds by: |
|
607 |
|
608 1. subtracting the point's x co-ordinate value from the width |
|
609 |
|
610 2. subtracting the point's y co-ordinate value from the height. |
|
611 |
|
612 @param aPoint The point to be subtracted. |
|
613 |
|
614 @return A reference to this size object. |
|
615 */ |
|
616 { |
|
617 iWidth-=aPoint.iX;iHeight-=aPoint.iY;return(*this); |
|
618 } |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 EXPORT_C TSize& TSize::operator+=(const TSize& aSize) |
|
624 /** |
|
625 TSize addition assignment operator. |
|
626 |
|
627 The operator adds the specified TSize to this TSize, and assigns the result |
|
628 back to this TSize. |
|
629 |
|
630 @param aSize The TSize to be added. |
|
631 |
|
632 @return A reference to this size object. |
|
633 */ |
|
634 { |
|
635 iWidth+=aSize.iWidth;iHeight+=aSize.iHeight;return(*this); |
|
636 } |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 EXPORT_C TSize& TSize::operator+=(const TPoint& aPoint) |
|
642 /** |
|
643 TPoint addition assignment operator. |
|
644 |
|
645 The operator adds the specified point to this TSize, and assigns the result |
|
646 back to this TSize. |
|
647 |
|
648 The operation proceeds by: |
|
649 |
|
650 1. adding the point's x co-ordinate value to the width |
|
651 |
|
652 2. adding the point's y co-ordinate value to the height. |
|
653 |
|
654 @param aPoint The point to be added. |
|
655 |
|
656 @return A reference to this size object. |
|
657 */ |
|
658 { |
|
659 iWidth+=aPoint.iX;iHeight+=aPoint.iY;return(*this); |
|
660 } |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 EXPORT_C TSize TSize::operator-(const TSize& aSize) const |
|
666 /** |
|
667 TSize subtraction operator. |
|
668 |
|
669 This operator subtracts the specified TSize from this TSize, and returns the |
|
670 resulting value. |
|
671 |
|
672 @param aSize The TSize to be subtracted from this Tsize. |
|
673 |
|
674 @return The result of the operation. |
|
675 */ |
|
676 { |
|
677 TSize ret=* this; ret-= aSize ;return(ret); |
|
678 } |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 EXPORT_C TSize TSize::operator-(const TPoint& aPoint) const |
|
684 /** |
|
685 TPoint subtraction operator. |
|
686 |
|
687 This operator subtracts the specified point from this TSize, and returns the |
|
688 resulting value. |
|
689 |
|
690 The operation proceeds by: |
|
691 |
|
692 1. subtracting the x co-ordinate value from the width |
|
693 |
|
694 2. subtracting the y co-ordinate value from the height |
|
695 |
|
696 @param aPoint The point to be subtracted. |
|
697 |
|
698 @return The result of the operation. |
|
699 */ |
|
700 { |
|
701 TSize ret=* this; ret-= aPoint ;return(ret); |
|
702 } |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 EXPORT_C TSize TSize::operator+(const TSize& aSize) const |
|
708 /** |
|
709 TSize addition operator. |
|
710 |
|
711 This operator adds the specified TSize to this TSize, and returns the resulting |
|
712 value. |
|
713 |
|
714 @param aSize The TSize to be added to this Tsize. |
|
715 |
|
716 @return The result of the operation. |
|
717 */ |
|
718 { |
|
719 TSize ret=* this; ret+= aSize ;return(ret); |
|
720 } |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 EXPORT_C TSize TSize::operator+(const TPoint& aPoint) const |
|
726 /** |
|
727 TPoint addition operator. |
|
728 |
|
729 This operator adds the specified point to this TSize, and returns the resulting |
|
730 value. |
|
731 |
|
732 The operation proceeds by: |
|
733 |
|
734 1. adding the x co-ordinate value to the width |
|
735 |
|
736 2. adding the y co-ordinate value to the height |
|
737 |
|
738 @param aPoint The point to be added to this TSize. |
|
739 |
|
740 @return The result of the operation. |
|
741 */ |
|
742 { |
|
743 TSize ret=* this; ret+= aPoint ;return(ret); |
|
744 } |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 EXPORT_C TSize TSize::operator-() const |
|
750 /** |
|
751 Unary minus operator. |
|
752 |
|
753 The operator returns the negation of this TSize. |
|
754 |
|
755 @return The result of the operation. |
|
756 */ |
|
757 { |
|
758 |
|
759 return TSize(-iWidth,-iHeight); |
|
760 } |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 EXPORT_C void TSize::SetSize(TInt aWidth,TInt aHeight) |
|
766 /** |
|
767 Sets the width and height. |
|
768 |
|
769 @param aWidth The width value. |
|
770 @param aHeight The height value. |
|
771 */ |
|
772 { |
|
773 iWidth=aWidth;iHeight=aHeight; |
|
774 } |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 EXPORT_C TPoint TSize::AsPoint() const |
|
780 /** |
|
781 Gets a TPoint object whose co-ordinates are the width and height of this TSize. |
|
782 |
|
783 @return The co-ordinates of this TSize converted to a point. |
|
784 */ |
|
785 { |
|
786 return(TPoint(iWidth,iHeight)); |
|
787 } |
|
788 |
|
789 |
|
790 |
|
791 |
|
792 EXPORT_C TRect::TRect() : iTl(0,0),iBr(0,0) |
|
793 /** |
|
794 Constructs a default rectangle. |
|
795 |
|
796 This initialises the co-ordinates of its top |
|
797 left and bottom right corners to (0,0). |
|
798 */ |
|
799 {} |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 EXPORT_C TRect::TRect(TInt aAx,TInt aAy,TInt aBx,TInt aBy) : iTl(aAx,aAy),iBr(aBx,aBy) |
|
805 /** |
|
806 Constructs the rectangle, initialising its top left and bottom right hand corners |
|
807 with four TInt values. |
|
808 |
|
809 @param aAx The horizontal co-ordinate of the left hand side of the rectangle. |
|
810 @param aAy The vertical co-ordinate of the top of the rectangle. |
|
811 @param aBx The horizontal co-ordinate of the right hand side of the rectangle. |
|
812 @param aBy The vertical co-ordinate of the bottom of the rectangle. |
|
813 */ |
|
814 {} |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 EXPORT_C TRect::TRect(const TPoint& aPointA,const TPoint& aPointB) : iTl(aPointA),iBr(aPointB) |
|
820 /** |
|
821 Constructs the rectangle with two TPoints, corresponding to its top left and |
|
822 bottom right hand corners. |
|
823 |
|
824 @param aPointA The co-ordinates of the rectangle's top left hand corner. |
|
825 @param aPointB The co-ordinates of the rectangle's bottom right hand corner. |
|
826 */ |
|
827 {} |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 EXPORT_C TRect::TRect(const TPoint& aPoint,const TSize& aSize) : iTl(aPoint),iBr(aPoint+aSize) |
|
833 /** |
|
834 Constructs the rectangle with a TPoint for its top left corner, and a TSize |
|
835 for its width and height. |
|
836 |
|
837 @param aPoint The rectangle's top left hand corner. |
|
838 @param aSize The rectangle's width and height. |
|
839 */ |
|
840 {} |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 EXPORT_C TRect::TRect(const TSize& aSize) : iTl(0,0), iBr(aSize.iWidth, aSize.iHeight) |
|
846 /** |
|
847 Constructs the rectangle with a TSize. |
|
848 |
|
849 The co-ordinates of its top left hand corner are initialised to (0,0) and |
|
850 its width and height are initialised to the values contained in the argument. |
|
851 |
|
852 @param aSize The width and height of the rectangle. |
|
853 */ |
|
854 {} |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 EXPORT_C void TRect::SetRect(TInt aTlX,TInt aTlY,TInt aBrX,TInt aBrY) |
|
860 /** |
|
861 Sets the rectangle's position using four TInts. |
|
862 |
|
863 @param aTlX The horizontal co-ordinate of the left hand side of the rectangle. |
|
864 @param aTlY The vertical co-ordinate of the top of the rectangle. |
|
865 @param aBrX The horizontal co-ordinate of the right hand side of the rectangle. |
|
866 @param aBrY The vertical co-ordinate of the bottom of the rectangle. |
|
867 */ |
|
868 { |
|
869 iTl.iX=aTlX;iTl.iY=aTlY;iBr.iX=aBrX;iBr.iY=aBrY; |
|
870 } |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 EXPORT_C void TRect::SetRect(const TPoint& aPointTL,const TPoint& aPointBR) |
|
876 /** |
|
877 Sets the rectangle's position using two TPoints. |
|
878 |
|
879 @param aPointTL The co-ordinates of the rectangle's top left hand corner. |
|
880 @param aPointBR The co-ordinates of the rectangle's bottom right hand corner. |
|
881 */ |
|
882 { |
|
883 iTl=aPointTL;iBr=aPointBR; |
|
884 } |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 EXPORT_C void TRect::SetRect(const TPoint& aTL,const TSize& aSize) |
|
890 /** |
|
891 Sets the rectangle's position using a TPoint and a TSize. |
|
892 |
|
893 @param aTL The co-ordinates of the rectangle's top left hand corner. |
|
894 @param aSize The rectangle's width and height. |
|
895 */ |
|
896 { |
|
897 iTl=aTL;iBr=aTL+aSize; |
|
898 } |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 EXPORT_C void TRect::Shrink(TInt aDx,TInt aDy) |
|
904 /** |
|
905 Shrinks a rectangle using specified horizontal and vertical offsets. |
|
906 |
|
907 The offset values are added to the co-ordinates of its top left hand corner, |
|
908 and the same values are subtracted from the co-ordinates of its bottom right |
|
909 hand corner. The co-ordinates of the centre of the rectangle remain unchanged. |
|
910 If either value is negative, the rectangle expands in the corresponding direction. |
|
911 |
|
912 @param aDx The number of pixels by which to move the left and right hand sides |
|
913 of the rectangle. A positive value reduces the width, a negative |
|
914 value increases it. |
|
915 @param aDy The number of pixels by which to move the top and bottom of the |
|
916 rectangle. A positive value reduces the height, a negative value |
|
917 increases it. |
|
918 */ |
|
919 { |
|
920 Adjust(aDx,aDy); |
|
921 } |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 EXPORT_C void TRect::Shrink(const TSize& aSize) |
|
927 /** |
|
928 Shrinks a rectangle using a specified TSize offset. |
|
929 |
|
930 The rectangle shrinks by twice the value of the height and width specified |
|
931 in the TSize. The co-ordinates of the centre of the rectangle remain unchanged. |
|
932 If either value is negative, the rectangle expands in the |
|
933 corresponding direction. |
|
934 |
|
935 @param aSize The number of pixels by which to move the left and right hand |
|
936 sides of the rectangle (by aSize.iWidth) and the top and bottom |
|
937 (by aSize.iHeight). |
|
938 */ |
|
939 { |
|
940 Adjust(aSize.iWidth,aSize.iHeight); |
|
941 } |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 EXPORT_C void TRect::Resize(const TSize& aSize) |
|
947 /** |
|
948 Resizes a rectangle by adding a TSize offset. |
|
949 |
|
950 The offset is added to the co-ordinates of its bottom right hand corner. If |
|
951 either value in the TSize is negative, the rectangle shrinks in the |
|
952 corresponding direction. The co-ordinates of the rectangle's top left hand |
|
953 corner are unaffected. |
|
954 |
|
955 @param aSize The number of pixels by which to move the rectangle; the right |
|
956 hand side by aSize.iWidth and the bottom by aSize.iHeight. |
|
957 */ |
|
958 { |
|
959 iBr+=aSize; |
|
960 } |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 EXPORT_C void TRect::Resize(TInt aDx, TInt aDy) |
|
966 /** |
|
967 Resizes a rectangle by adding a horizontal and vertical offset. |
|
968 |
|
969 The offset is added to the co-ordinates of its bottom right hand corner. If |
|
970 either value is negative, the rectangle shrinks in the corresponding direction. |
|
971 The co-ordinates of the rectangle's top left hand corner are unaffected. |
|
972 |
|
973 @param aDx The number of pixels by which to move the right hand side of the |
|
974 rectangle. |
|
975 @param aDy The number of pixels by which to move the bottom of the rectangle. |
|
976 */ |
|
977 { |
|
978 iBr.iX+=aDx;iBr.iY+=aDy; |
|
979 } |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 EXPORT_C TBool TRect::operator==(const TRect &aRect) const |
|
985 /** |
|
986 Compares two rectangles for equality. |
|
987 |
|
988 For two rectangles to be equal, the co-ordinates of both their top left and |
|
989 bottom right hand corners must be equal. |
|
990 |
|
991 @param aRect The rectangle to compare with this rectangle. |
|
992 |
|
993 @return True, if the rectangles have the same co-ordinates; false, otherwise. |
|
994 */ |
|
995 { |
|
996 |
|
997 return(iTl==aRect.iTl && iBr==aRect.iBr); |
|
998 } |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 EXPORT_C TBool TRect::operator!=(const TRect &aRect) const |
|
1004 /** |
|
1005 Compares two rectangles for inequality. |
|
1006 |
|
1007 Two rectangles are unequal if any of their co-ordinates differ. |
|
1008 |
|
1009 @param aRect The rectangle to compare with this rectangle. |
|
1010 @return True, if the rectangles do not have the same co-ordinates; false, if |
|
1011 all co-ordinates are equal. |
|
1012 */ |
|
1013 { |
|
1014 |
|
1015 return(iTl!=aRect.iTl || iBr!=aRect.iBr); |
|
1016 } |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 EXPORT_C void TRect::Move(const TPoint &aOffset) |
|
1022 /** |
|
1023 Moves the rectangle by adding a TPoint offset. |
|
1024 |
|
1025 The offset is added to the co-ordinates of both its top left and bottom right |
|
1026 hand corners. The size of the rectangle is unchanged. |
|
1027 |
|
1028 @param aOffset The number of pixels to move the rectangle; horizontally by |
|
1029 aOffset.iX and vertically by aOffset.iY. |
|
1030 */ |
|
1031 { |
|
1032 |
|
1033 iTl+=aOffset; |
|
1034 iBr+=aOffset; |
|
1035 } |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 EXPORT_C void TRect::Move(TInt aDx,TInt aDy) |
|
1041 /** |
|
1042 Moves the rectangle by adding an x, y offset. |
|
1043 |
|
1044 The offset is added to the co-ordinates of both its top left and bottom right |
|
1045 hand corners. The size of the rectangle is unchanged. |
|
1046 |
|
1047 @param aDx The number of pixels to move the rectangle horizontally. If negative, |
|
1048 the rectangle moves leftwards. |
|
1049 @param aDy The number of pixels to move the rectangle vertically. If negative, |
|
1050 the rectangle moves upwards. |
|
1051 */ |
|
1052 { |
|
1053 |
|
1054 iTl.iX+=aDx; |
|
1055 iTl.iY+=aDy; |
|
1056 iBr.iX+=aDx; |
|
1057 iBr.iY+=aDy; |
|
1058 } |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 // private function, hence not exported |
|
1064 void TRect::Adjust(TInt aDx,TInt aDy) |
|
1065 // |
|
1066 // Adjust by a delta. |
|
1067 // |
|
1068 { |
|
1069 |
|
1070 iTl.iX+=aDx; |
|
1071 iTl.iY+=aDy; |
|
1072 iBr.iX-=aDx; |
|
1073 iBr.iY-=aDy; |
|
1074 } |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 EXPORT_C void TRect::Grow(TInt aDx,TInt aDy) |
|
1080 // |
|
1081 // Grow by a delta. |
|
1082 // |
|
1083 /** |
|
1084 Grows the rectangle using the specified horizontal and vertical offsets. |
|
1085 |
|
1086 The offset values are subtracted from the co-ordinates of its top left hand |
|
1087 corner, and the same values are added to the co-ordinates of its bottom right |
|
1088 hand corner. The co-ordinates of the centre of the rectangle remain unchanged. |
|
1089 If either value is negative, the rectangle shrinks in the corresponding direction. |
|
1090 |
|
1091 @param aDx The number of pixels by which to move the left and right hand sides |
|
1092 of the rectangle. A positive value increases the width, a negative |
|
1093 value reduces it. |
|
1094 @param aDy The number of pixels by which to move the top and bottom of the |
|
1095 rectangle. A positive value increases the height, a negative |
|
1096 value reduces it. |
|
1097 */ |
|
1098 { |
|
1099 |
|
1100 iTl.iX-=aDx; |
|
1101 iTl.iY-=aDy; |
|
1102 iBr.iX+=aDx; |
|
1103 iBr.iY+=aDy; |
|
1104 } |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 EXPORT_C void TRect::Grow(const TSize &aSize) |
|
1110 // |
|
1111 // Grow by a size. |
|
1112 // |
|
1113 /** |
|
1114 Grows a rectangle using the specified TSize offset. |
|
1115 |
|
1116 The rectangle grows by twice the value of the height and width specified in |
|
1117 the TSize. The co-ordinates of the centre of the rectangle remain unchanged. |
|
1118 If either value is negative, the rectangle shrinks in the |
|
1119 corresponding direction. |
|
1120 |
|
1121 @param aSize The number of pixels by which to move the left and right hand |
|
1122 sides of the rectangle (by aSize.iWidth) and the top and bottom |
|
1123 (by aSize.iHeight). |
|
1124 */ |
|
1125 { |
|
1126 |
|
1127 iTl-=aSize; |
|
1128 iBr+=aSize; |
|
1129 } |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 EXPORT_C void TRect::BoundingRect(const TRect &aRect) |
|
1135 // |
|
1136 // Union of this and aRect, a union is defined as the minimum rectangle that encloses |
|
1137 // both source rectangles |
|
1138 // |
|
1139 /** |
|
1140 Gets the minimal rectangle which bounds both this rectangle and the specified |
|
1141 rectangle, and assigns it to this rectangle. |
|
1142 |
|
1143 @param aRect The rectangle to use with this rectangle to get the minimal bounding |
|
1144 rectangle. |
|
1145 */ |
|
1146 { |
|
1147 |
|
1148 if (iTl.iX>aRect.iTl.iX) |
|
1149 iTl.iX=aRect.iTl.iX; |
|
1150 if (iTl.iY>aRect.iTl.iY) |
|
1151 iTl.iY=aRect.iTl.iY; |
|
1152 if (iBr.iX<aRect.iBr.iX) |
|
1153 iBr.iX=aRect.iBr.iX; |
|
1154 if (iBr.iY<aRect.iBr.iY) |
|
1155 iBr.iY=aRect.iBr.iY; |
|
1156 } |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 EXPORT_C TBool TRect::IsEmpty() const |
|
1162 // |
|
1163 // True if the rectangle is empty. |
|
1164 // |
|
1165 /** |
|
1166 Tests whether the rectangle is empty. |
|
1167 |
|
1168 @return True, if empty; false, if not. |
|
1169 */ |
|
1170 { |
|
1171 |
|
1172 return(iTl.iX>=iBr.iX || iTl.iY>=iBr.iY); |
|
1173 } |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 EXPORT_C void TRect::Intersection(const TRect &aRect) |
|
1179 // |
|
1180 // Intersect this with aRect. |
|
1181 // |
|
1182 /** |
|
1183 Gets the area of intersection between this rectangle and the specified |
|
1184 rectangle, and assigns it to this rectangle. |
|
1185 |
|
1186 It is usual to call TRect::Intersects() first to verify whether the two rectangles |
|
1187 intersect. If the two rectangles do not intersect, then, on return, this rectangle |
|
1188 is set to be empty. |
|
1189 |
|
1190 @param aRect The rectangle to be used with this rectangle to get the area |
|
1191 of intersection. |
|
1192 |
|
1193 @see TRect::Intersects |
|
1194 */ |
|
1195 { |
|
1196 |
|
1197 if (iTl.iX<aRect.iTl.iX) |
|
1198 iTl.iX=aRect.iTl.iX; |
|
1199 if (iTl.iY<aRect.iTl.iY) |
|
1200 iTl.iY=aRect.iTl.iY; |
|
1201 if (iBr.iX>aRect.iBr.iX) |
|
1202 iBr.iX=aRect.iBr.iX; |
|
1203 if (iBr.iY>aRect.iBr.iY) |
|
1204 iBr.iY=aRect.iBr.iY; |
|
1205 } |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 EXPORT_C TBool TRect::Intersects(const TRect &aRect) const |
|
1211 // |
|
1212 // If aRect Intersects with this return True. |
|
1213 // |
|
1214 /** |
|
1215 Tests whether this rectangle overlaps with the specified rectangle. |
|
1216 |
|
1217 Two rectangles overlap if any point is located within both rectangles. There |
|
1218 is no intersection if two adjacent sides touch without overlapping, or if |
|
1219 either rectangle is empty. |
|
1220 |
|
1221 @param aRect The rectangle to compare with this rectangle for an intersection. |
|
1222 |
|
1223 @return True, if the two rectangles overlap; false, if there is no overlap. |
|
1224 */ |
|
1225 { |
|
1226 |
|
1227 return(!(IsEmpty() || aRect.IsEmpty() || iBr.iX<=aRect.iTl.iX || iBr.iY<=aRect.iTl.iY || iTl.iX>=aRect.iBr.iX || iTl.iY>=aRect.iBr.iY)); |
|
1228 } |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 EXPORT_C void TRect::Normalize() |
|
1234 // |
|
1235 // Make the conditions top left bottom right true. |
|
1236 // |
|
1237 /** |
|
1238 Ensures that the rectangle's width and height have positive values. |
|
1239 |
|
1240 For example, if the rectangle's co-ordinates are such that the top is below |
|
1241 the bottom, or the right hand side is to the left of the left hand side, normalisation |
|
1242 swaps the co-ordinates of the top and bottom or of the left and right. |
|
1243 */ |
|
1244 { |
|
1245 |
|
1246 if (iTl.iX>iBr.iX) |
|
1247 { |
|
1248 TInt temp=iTl.iX; |
|
1249 iTl.iX=iBr.iX; |
|
1250 iBr.iX=temp; |
|
1251 } |
|
1252 if (iTl.iY>iBr.iY) |
|
1253 { |
|
1254 TInt temp=iTl.iY; |
|
1255 iTl.iY=iBr.iY; |
|
1256 iBr.iY=temp; |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 EXPORT_C TBool TRect::Contains(const TPoint &aPoint) const |
|
1264 /** |
|
1265 Tests whether a point is located within the rectangle. |
|
1266 |
|
1267 Note that a point located on the top or left hand side of the rectangle is |
|
1268 within the rectangle. A point located on the right hand side or bottom is |
|
1269 considered to be outside the rectangle. |
|
1270 |
|
1271 @param aPoint The point to be tested. |
|
1272 |
|
1273 @return True, if the point is within the rectangle; false, otherwise. |
|
1274 */ |
|
1275 { |
|
1276 if (aPoint.iX<iTl.iX || aPoint.iX>=iBr.iX || aPoint.iY<iTl.iY || aPoint.iY>=iBr.iY) |
|
1277 return(EFalse); |
|
1278 return(ETrue); |
|
1279 } |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 EXPORT_C TSize TRect::Size() const |
|
1285 /** |
|
1286 Gets the size of the rectangle. |
|
1287 |
|
1288 @return The size of the rectangle. |
|
1289 */ |
|
1290 { |
|
1291 return((iBr-iTl).AsSize()); |
|
1292 } |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 EXPORT_C TInt TRect::Width() const |
|
1298 /** |
|
1299 Gets the width of the rectangle. |
|
1300 |
|
1301 @return The width of the rectangle. |
|
1302 */ |
|
1303 { |
|
1304 return(iBr.iX-iTl.iX); |
|
1305 } |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 EXPORT_C TInt TRect::Height() const |
|
1311 /** |
|
1312 Gets the height of the rectangle. |
|
1313 |
|
1314 @return The height of the rectangle. |
|
1315 */ |
|
1316 { |
|
1317 return(iBr.iY-iTl.iY); |
|
1318 } |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 EXPORT_C TBool TRect::IsNormalized() const |
|
1324 /** |
|
1325 Tests whether the rectangle is normalised. |
|
1326 |
|
1327 A rectangle is normalised when its width and height are both zero or greater. |
|
1328 |
|
1329 @return True, if normalised; false, if not. |
|
1330 */ |
|
1331 { |
|
1332 return((iBr.iX>=iTl.iX) && (iBr.iY>=iTl.iY)); |
|
1333 } |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 EXPORT_C TPoint TRect::Center() const |
|
1339 /** |
|
1340 Gets the point at the centre of the rectangle. |
|
1341 |
|
1342 @return The point at the centre of the rectangle. |
|
1343 */ |
|
1344 { |
|
1345 return(TPoint((iTl.iX+iBr.iX)/2,(iTl.iY+iBr.iY)/2)); |
|
1346 } |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 EXPORT_C void TRect::SetSize(const TSize &aSize) |
|
1352 /** |
|
1353 Sets the size of the rectangle. |
|
1354 |
|
1355 Only the co-ordinates of the bottom right hand corner of the rectangle are |
|
1356 affected. |
|
1357 |
|
1358 @param aSize The new width is aSize.iWidth. The new height is aSize.iHeight. |
|
1359 */ |
|
1360 { |
|
1361 iBr=iTl+aSize; |
|
1362 } |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 EXPORT_C void TRect::SetWidth(TInt aWidth) |
|
1368 /** |
|
1369 Sets the width of the rectangle. |
|
1370 |
|
1371 Only the position of the rectangle's right hand side is affected. |
|
1372 |
|
1373 @param aWidth The new width of the rectangle. |
|
1374 */ |
|
1375 { |
|
1376 iBr.iX=iTl.iX+aWidth; |
|
1377 } |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 EXPORT_C void TRect::SetHeight(TInt aHeight) |
|
1383 /** |
|
1384 Sets the height of the rectangle. |
|
1385 |
|
1386 Only the position of the bottom of the rectangle is affected. |
|
1387 |
|
1388 @param aHeight The new height of the rectangle. |
|
1389 */ |
|
1390 { |
|
1391 iBr.iY=iTl.iY+aHeight; |
|
1392 } |