~mmach/netext73/wxwidgets3.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/geometry.h
// Purpose:     Common Geometry Classes
// Author:      Stefan Csomor
// Modified by:
// Created:     08/05/99
// Copyright:   (c) 1999 Stefan Csomor
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_GEOMETRY_H_
#define _WX_GEOMETRY_H_

#include "wx/defs.h"

#if wxUSE_GEOMETRY

#include "wx/utils.h"
#include "wx/gdicmn.h"
#include "wx/math.h"

class WXDLLIMPEXP_FWD_BASE wxDataInputStream;
class WXDLLIMPEXP_FWD_BASE wxDataOutputStream;

// clipping from Cohen-Sutherland

enum wxOutCode
{
    wxInside = 0x00 ,
    wxOutLeft = 0x01 ,
    wxOutRight = 0x02 ,
    wxOutTop = 0x08 ,
    wxOutBottom = 0x04
};

class WXDLLIMPEXP_CORE wxPoint2DInt
{
public :
    inline wxPoint2DInt();
    inline wxPoint2DInt( wxInt32 x , wxInt32 y );
    inline wxPoint2DInt( const wxPoint2DInt &pt );
    inline wxPoint2DInt( const wxPoint &pt );

    // noops for this class, just return the coords
    inline void GetFloor( wxInt32 *x , wxInt32 *y ) const;
    inline void GetRounded( wxInt32 *x , wxInt32 *y ) const;

    inline wxDouble GetVectorLength() const;
           wxDouble GetVectorAngle() const;
    inline void SetVectorLength( wxDouble length );
           void SetVectorAngle( wxDouble degrees );
           void SetPolarCoordinates( wxInt32 angle , wxInt32 length );
    // set the vector length to 1.0, preserving the angle
    inline void Normalize();

    inline wxDouble GetDistance( const wxPoint2DInt &pt ) const;
    inline wxDouble GetDistanceSquare( const wxPoint2DInt &pt ) const;
    inline wxInt32 GetDotProduct( const wxPoint2DInt &vec ) const;
    inline wxInt32 GetCrossProduct( const wxPoint2DInt &vec ) const;

    // the reflection of this point
    inline wxPoint2DInt operator-();

    inline wxPoint2DInt& operator=(const wxPoint2DInt& pt);
    inline wxPoint2DInt& operator+=(const wxPoint2DInt& pt);
    inline wxPoint2DInt& operator-=(const wxPoint2DInt& pt);
    inline wxPoint2DInt& operator*=(const wxPoint2DInt& pt);
    inline wxPoint2DInt& operator*=(wxDouble n);
    inline wxPoint2DInt& operator*=(wxInt32 n);
    inline wxPoint2DInt& operator/=(const wxPoint2DInt& pt);
    inline wxPoint2DInt& operator/=(wxDouble n);
    inline wxPoint2DInt& operator/=(wxInt32 n);
    inline operator wxPoint() const;
    inline bool operator==(const wxPoint2DInt& pt) const;
    inline bool operator!=(const wxPoint2DInt& pt) const;

#if wxUSE_STREAMS
    void WriteTo( wxDataOutputStream &stream ) const;
    void ReadFrom( wxDataInputStream &stream );
#endif // wxUSE_STREAMS

    wxInt32 m_x;
    wxInt32 m_y;
};

inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2);
inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2);
inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2);
inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt);
inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt);
inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n);
inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n);
inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2);
inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n);
inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n);

inline wxPoint2DInt::wxPoint2DInt()
{
    m_x = 0;
    m_y = 0;
}

inline wxPoint2DInt::wxPoint2DInt( wxInt32 x , wxInt32 y )
{
    m_x = x;
    m_y = y;
}

inline wxPoint2DInt::wxPoint2DInt( const wxPoint2DInt &pt )
{
    m_x = pt.m_x;
    m_y = pt.m_y;
}

inline wxPoint2DInt::wxPoint2DInt( const wxPoint &pt )
{
    m_x = pt.x;
    m_y = pt.y;
}

inline void wxPoint2DInt::GetFloor( wxInt32 *x , wxInt32 *y ) const
{
    if ( x )
        *x = m_x;
    if ( y )
        *y = m_y;
}

inline void wxPoint2DInt::GetRounded( wxInt32 *x , wxInt32 *y ) const
{
    GetFloor(x, y);
}

inline wxDouble wxPoint2DInt::GetVectorLength() const
{
    // cast needed MIPSpro compiler under SGI
    return sqrt( (double)(m_x)*(m_x) + (m_y)*(m_y) );
}

inline void wxPoint2DInt::SetVectorLength( wxDouble length )
{
    wxDouble before = GetVectorLength();
    m_x = (wxInt32)(m_x * length / before);
    m_y = (wxInt32)(m_y * length / before);
}

inline void wxPoint2DInt::Normalize()
{
    SetVectorLength( 1 );
}

inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const
{
    return sqrt( GetDistanceSquare( pt ) );
}

inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const
{
    return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) );
}

inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const
{
    return ( m_x * vec.m_x + m_y * vec.m_y );
}

inline wxInt32 wxPoint2DInt::GetCrossProduct( const wxPoint2DInt &vec ) const
{
    return ( m_x * vec.m_y - vec.m_x * m_y );
}

inline wxPoint2DInt::operator wxPoint() const
{
    return wxPoint( m_x, m_y);
}

inline wxPoint2DInt wxPoint2DInt::operator-()
{
    return wxPoint2DInt( -m_x, -m_y);
}

inline wxPoint2DInt& wxPoint2DInt::operator=(const wxPoint2DInt& pt)
{
    if (this != &pt)
    {
        m_x = pt.m_x;
        m_y = pt.m_y;
    }
    return *this;
}

inline wxPoint2DInt& wxPoint2DInt::operator+=(const wxPoint2DInt& pt)
{
    m_x = m_x + pt.m_x;
    m_y = m_y + pt.m_y;
    return *this;
}

inline wxPoint2DInt& wxPoint2DInt::operator-=(const wxPoint2DInt& pt)
{
    m_x = m_x - pt.m_x;
    m_y = m_y - pt.m_y;
    return *this;
}

inline wxPoint2DInt& wxPoint2DInt::operator*=(const wxPoint2DInt& pt)
{
    m_x = m_x * pt.m_x;
    m_y = m_y * pt.m_y;
    return *this;
}

inline wxPoint2DInt& wxPoint2DInt::operator/=(const wxPoint2DInt& pt)
{
    m_x = m_x / pt.m_x;
    m_y = m_y / pt.m_y;
    return *this;
}

inline bool wxPoint2DInt::operator==(const wxPoint2DInt& pt) const
{
    return m_x == pt.m_x && m_y == pt.m_y;
}

inline bool wxPoint2DInt::operator!=(const wxPoint2DInt& pt) const
{
    return m_x != pt.m_x || m_y != pt.m_y;
}

inline wxPoint2DInt operator+(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2)
{
    return wxPoint2DInt( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y );
}

inline wxPoint2DInt operator-(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2)
{
    return wxPoint2DInt( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y );
}


inline wxPoint2DInt operator*(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2)
{
    return wxPoint2DInt( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y );
}

inline wxPoint2DInt operator*(wxInt32 n , const wxPoint2DInt& pt)
{
    return wxPoint2DInt( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DInt operator*(wxDouble n , const wxPoint2DInt& pt)
{
    return wxPoint2DInt( static_cast<wxInt32>(pt.m_x * n) ,
        static_cast<wxInt32>(pt.m_y * n) );
}

inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxInt32 n)
{
    return wxPoint2DInt( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DInt operator*(const wxPoint2DInt& pt , wxDouble n)
{
    return wxPoint2DInt( static_cast<wxInt32>(pt.m_x * n) ,
        static_cast<wxInt32>(pt.m_y * n) );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt1 , const wxPoint2DInt& pt2)
{
    return wxPoint2DInt( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxInt32 n)
{
    return wxPoint2DInt( pt.m_x / n , pt.m_y / n );
}

inline wxPoint2DInt operator/(const wxPoint2DInt& pt , wxDouble n)
{
    return wxPoint2DInt( static_cast<wxInt32>(pt.m_x / n) ,
        static_cast<wxInt32>(pt.m_y / n) );
}

// wxPoint2Ds represent a point or a vector in a 2d coordinate system

class WXDLLIMPEXP_CORE wxPoint2DDouble
{
public :
    inline wxPoint2DDouble();
    inline wxPoint2DDouble( wxDouble x , wxDouble y );
    inline wxPoint2DDouble( const wxPoint2DDouble &pt );
    wxPoint2DDouble( const wxPoint2DInt &pt )
        { m_x = (wxDouble) pt.m_x ; m_y = (wxDouble) pt.m_y ; }
    wxPoint2DDouble( const wxPoint &pt )
        { m_x = (wxDouble) pt.x ; m_y = (wxDouble) pt.y ; }

    // two different conversions to integers, floor and rounding
    inline void GetFloor( wxInt32 *x , wxInt32 *y ) const;
    inline void GetRounded( wxInt32 *x , wxInt32 *y ) const;

    inline wxDouble GetVectorLength() const;
     wxDouble GetVectorAngle() const ;
    void SetVectorLength( wxDouble length );
    void SetVectorAngle( wxDouble degrees );
    void SetPolarCoordinates( wxDouble angle , wxDouble length );
    // set the vector length to 1.0, preserving the angle
    void Normalize();

    inline wxDouble GetDistance( const wxPoint2DDouble &pt ) const;
    inline wxDouble GetDistanceSquare( const wxPoint2DDouble &pt ) const;
    inline wxDouble GetDotProduct( const wxPoint2DDouble &vec ) const;
    inline wxDouble GetCrossProduct( const wxPoint2DDouble &vec ) const;

    // the reflection of this point
    inline wxPoint2DDouble operator-();

    inline wxPoint2DDouble& operator=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator+=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator-=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator*=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator*=(wxDouble n);
    inline wxPoint2DDouble& operator*=(wxInt32 n);
    inline wxPoint2DDouble& operator/=(const wxPoint2DDouble& pt);
    inline wxPoint2DDouble& operator/=(wxDouble n);
    inline wxPoint2DDouble& operator/=(wxInt32 n);

    inline bool operator==(const wxPoint2DDouble& pt) const;
    inline bool operator!=(const wxPoint2DDouble& pt) const;

    wxDouble m_x;
    wxDouble m_y;
};

inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt);
inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n);
inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n);
inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n);

inline wxPoint2DDouble::wxPoint2DDouble()
{
    m_x = 0.0;
    m_y = 0.0;
}

inline wxPoint2DDouble::wxPoint2DDouble( wxDouble x , wxDouble y )
{
    m_x = x;
    m_y = y;
}

inline wxPoint2DDouble::wxPoint2DDouble( const wxPoint2DDouble &pt )
{
    m_x = pt.m_x;
    m_y = pt.m_y;
}

inline void wxPoint2DDouble::GetFloor( wxInt32 *x , wxInt32 *y ) const
{
    *x = (wxInt32) floor( m_x );
    *y = (wxInt32) floor( m_y );
}

inline void wxPoint2DDouble::GetRounded( wxInt32 *x , wxInt32 *y ) const
{
    *x = (wxInt32) floor( m_x + 0.5 );
    *y = (wxInt32) floor( m_y + 0.5);
}

inline wxDouble wxPoint2DDouble::GetVectorLength() const
{
    return sqrt( (m_x)*(m_x) + (m_y)*(m_y) ) ;
}

inline void wxPoint2DDouble::SetVectorLength( wxDouble length )
{
    wxDouble before = GetVectorLength() ;
    m_x = (m_x * length / before) ;
    m_y = (m_y * length / before) ;
}

inline void wxPoint2DDouble::Normalize()
{
    SetVectorLength( 1 );
}

inline wxDouble wxPoint2DDouble::GetDistance( const wxPoint2DDouble &pt ) const
{
    return sqrt( GetDistanceSquare( pt ) );
}

inline wxDouble wxPoint2DDouble::GetDistanceSquare( const wxPoint2DDouble &pt ) const
{
    return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) );
}

inline wxDouble wxPoint2DDouble::GetDotProduct( const wxPoint2DDouble &vec ) const
{
    return ( m_x * vec.m_x + m_y * vec.m_y );
}

inline wxDouble wxPoint2DDouble::GetCrossProduct( const wxPoint2DDouble &vec ) const
{
    return ( m_x * vec.m_y - vec.m_x * m_y );
}

inline wxPoint2DDouble wxPoint2DDouble::operator-()
{
    return wxPoint2DDouble( -m_x, -m_y);
}

inline wxPoint2DDouble& wxPoint2DDouble::operator=(const wxPoint2DDouble& pt)
{
    if (this != &pt)
    {
        m_x = pt.m_x;
        m_y = pt.m_y;
    }
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator+=(const wxPoint2DDouble& pt)
{
    m_x = m_x + pt.m_x;
    m_y = m_y + pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator-=(const wxPoint2DDouble& pt)
{
    m_x = m_x - pt.m_x;
    m_y = m_y - pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator*=(const wxPoint2DDouble& pt)
{
    m_x = m_x * pt.m_x;
    m_y = m_y * pt.m_y;
    return *this;
}

inline wxPoint2DDouble& wxPoint2DDouble::operator/=(const wxPoint2DDouble& pt)
{
    m_x = m_x / pt.m_x;
    m_y = m_y / pt.m_y;
    return *this;
}

inline bool wxPoint2DDouble::operator==(const wxPoint2DDouble& pt) const
{
    return wxIsSameDouble(m_x, pt.m_x) && wxIsSameDouble(m_y, pt.m_y);
}

inline bool wxPoint2DDouble::operator!=(const wxPoint2DDouble& pt) const
{
    return !(*this == pt);
}

inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x + pt2.m_x , pt1.m_y + pt2.m_y );
}

inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x - pt2.m_x , pt1.m_y - pt2.m_y );
}


inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x * pt2.m_x , pt1.m_y * pt2.m_y );
}

inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n)
{
    return wxPoint2DDouble( pt.m_x * n , pt.m_y * n );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2)
{
    return wxPoint2DDouble( pt1.m_x / pt2.m_x , pt1.m_y / pt2.m_y );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n)
{
    return wxPoint2DDouble( pt.m_x / n , pt.m_y / n );
}

inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n)
{
    return wxPoint2DDouble( pt.m_x / n , pt.m_y / n );
}

// 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
// top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if
// left <= x < right  and top <= m_y < bottom , thus it is a half open interval.

class WXDLLIMPEXP_CORE wxRect2DDouble
{
public:
    wxRect2DDouble()
        { m_x = m_y = m_width = m_height = 0; }
    wxRect2DDouble(wxDouble x, wxDouble y, wxDouble w, wxDouble h)
        { m_x = x; m_y = y; m_width = w;  m_height = h; }
/*
    wxRect2DDouble(const wxPoint2DDouble& topLeft, const wxPoint2DDouble& bottomRight);
    wxRect2DDouble(const wxPoint2DDouble& pos, const wxSize& size);
    wxRect2DDouble(const wxRect2DDouble& rect);
*/
        // single attribute accessors

    wxPoint2DDouble GetPosition() const
        { return wxPoint2DDouble(m_x, m_y); }
    wxSize GetSize() const
        { return wxSize((int) m_width, (int) m_height); }

    // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their
        // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately

    inline wxDouble GetLeft() const { return m_x; }
    inline void SetLeft( wxDouble n ) { m_width += m_x - n; m_x = n; }
    inline void MoveLeftTo( wxDouble n ) { m_x = n; }
    inline wxDouble GetTop() const { return m_y; }
    inline void SetTop( wxDouble n ) { m_height += m_y - n; m_y = n; }
    inline void MoveTopTo( wxDouble n ) { m_y = n; }
    inline wxDouble GetBottom() const { return m_y + m_height; }
    inline void SetBottom( wxDouble n ) { m_height += n - (m_y+m_height);}
    inline void MoveBottomTo( wxDouble n ) { m_y = n - m_height; }
    inline wxDouble GetRight() const { return m_x + m_width; }
    inline void SetRight( wxDouble n ) { m_width += n - (m_x+m_width) ; }
    inline void MoveRightTo( wxDouble n ) { m_x = n - m_width; }

    inline wxPoint2DDouble GetLeftTop() const
        { return wxPoint2DDouble( m_x , m_y ); }
    inline void SetLeftTop( const wxPoint2DDouble &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; }
    inline void MoveLeftTopTo( const wxPoint2DDouble &pt )
        { m_x = pt.m_x; m_y = pt.m_y; }
    inline wxPoint2DDouble GetLeftBottom() const
        { return wxPoint2DDouble( m_x , m_y + m_height ); }
    inline void SetLeftBottom( const wxPoint2DDouble &pt )
        { m_width += m_x - pt.m_x; m_height += pt.m_y - (m_y+m_height) ; m_x = pt.m_x; }
    inline void MoveLeftBottomTo( const wxPoint2DDouble &pt )
        { m_x = pt.m_x; m_y = pt.m_y - m_height; }
    inline wxPoint2DDouble GetRightTop() const
        { return wxPoint2DDouble( m_x+m_width , m_y ); }
    inline void SetRightTop( const wxPoint2DDouble &pt )
        { m_width += pt.m_x - ( m_x + m_width ); m_height += m_y - pt.m_y; m_y = pt.m_y; }
    inline void MoveRightTopTo( const wxPoint2DDouble &pt )
        { m_x = pt.m_x - m_width; m_y = pt.m_y; }
    inline wxPoint2DDouble GetRightBottom() const
        { return wxPoint2DDouble( m_x+m_width , m_y + m_height ); }
    inline void SetRightBottom( const wxPoint2DDouble &pt )
        { m_width += pt.m_x - ( m_x + m_width ); m_height += pt.m_y - (m_y+m_height);}
    inline void MoveRightBottomTo( const wxPoint2DDouble &pt )
        { m_x = pt.m_x - m_width; m_y = pt.m_y - m_height; }
    inline wxPoint2DDouble GetCentre() const
        { return wxPoint2DDouble( m_x+m_width/2 , m_y+m_height/2 ); }
    inline void SetCentre( const wxPoint2DDouble &pt )
        { MoveCentreTo( pt ); }    // since this is impossible without moving...
    inline void MoveCentreTo( const wxPoint2DDouble &pt )
        { m_x += pt.m_x - (m_x+m_width/2) , m_y += pt.m_y -(m_y+m_height/2); }
    inline wxOutCode GetOutCode( const wxPoint2DDouble &pt ) const
        { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) +
                     ( ( pt.m_x > m_x + m_width ) ? wxOutRight : 0 ) +
                     ( ( pt.m_y < m_y ) ? wxOutTop : 0 )  +
                     ( ( pt.m_y > m_y + m_height ) ? wxOutBottom : 0 )); }
    inline wxOutCode GetOutcode(const wxPoint2DDouble &pt) const
        { return GetOutCode(pt) ; }
    inline bool Contains( const wxPoint2DDouble &pt ) const
        { return  GetOutCode( pt ) == wxInside; }
    inline bool Contains( const wxRect2DDouble &rect ) const
        { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) &&
                ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); }
    inline bool IsEmpty() const
        { return m_width <= 0 || m_height <= 0; }
    inline bool HaveEqualSize( const wxRect2DDouble &rect ) const
        { return wxIsSameDouble(rect.m_width, m_width) && wxIsSameDouble(rect.m_height, m_height); }

    inline void Inset( wxDouble x , wxDouble y )
        { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; }
    inline void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom  )
        { m_x += left; m_y += top; m_width -= left + right; m_height -= top + bottom;}
    inline void Offset( const wxPoint2DDouble &pt )
        { m_x += pt.m_x; m_y += pt.m_y; }

    void ConstrainTo( const wxRect2DDouble &rect );

    inline wxPoint2DDouble Interpolate( wxInt32 widthfactor , wxInt32 heightfactor )
        { return wxPoint2DDouble( m_x + m_width * widthfactor , m_y + m_height * heightfactor ); }

    static void Intersect( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest );
    inline void Intersect( const wxRect2DDouble &otherRect )
        { Intersect( *this , otherRect , this ); }
    inline wxRect2DDouble CreateIntersection( const wxRect2DDouble &otherRect ) const
        { wxRect2DDouble result; Intersect( *this , otherRect , &result); return result; }
    bool Intersects( const wxRect2DDouble &rect ) const;

    static void Union( const wxRect2DDouble &src1 , const wxRect2DDouble &src2 , wxRect2DDouble *dest );
    void Union( const wxRect2DDouble &otherRect )
        { Union( *this , otherRect , this ); }
    void Union( const wxPoint2DDouble &pt );
    inline wxRect2DDouble CreateUnion( const wxRect2DDouble &otherRect ) const
        { wxRect2DDouble result; Union( *this , otherRect , &result); return result; }

    inline void Scale( wxDouble f )
        { m_x *= f; m_y *= f; m_width *= f; m_height *= f;}
    inline void Scale( wxInt32 num , wxInt32 denum )
        { m_x *= ((wxDouble)num)/((wxDouble)denum); m_y *= ((wxDouble)num)/((wxDouble)denum);
                m_width *= ((wxDouble)num)/((wxDouble)denum); m_height *= ((wxDouble)num)/((wxDouble)denum);}

    wxRect2DDouble& operator = (const wxRect2DDouble& rect);
    inline bool operator == (const wxRect2DDouble& rect) const
        { return wxIsSameDouble(m_x, rect.m_x) && wxIsSameDouble(m_y, rect.m_y) && HaveEqualSize(rect); }
    inline bool operator != (const wxRect2DDouble& rect) const
        { return !(*this == rect); }

    wxDouble  m_x;
    wxDouble  m_y;
    wxDouble  m_width;
    wxDouble m_height;
};


// 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
// top left and bottom right corner, or by the top left corner and size. A point is contained within the rectangle if
// left <= x < right  and top <= m_y < bottom , thus it is a half open interval.

class WXDLLIMPEXP_CORE wxRect2DInt
{
public:
       wxRect2DInt() { m_x = m_y = m_width = m_height = 0; }
       wxRect2DInt( const wxRect& r ) { m_x = r.x ; m_y = r.y ; m_width = r.width ; m_height = r.height ; }
       wxRect2DInt(wxInt32 x, wxInt32 y, wxInt32 w, wxInt32 h) { m_x = x; m_y = y; m_width = w;  m_height = h; }
       wxRect2DInt(const wxPoint2DInt& topLeft, const wxPoint2DInt& bottomRight);
       inline wxRect2DInt(const wxPoint2DInt& pos, const wxSize& size);
       inline wxRect2DInt(const wxRect2DInt& rect);

        // single attribute accessors

       wxPoint2DInt GetPosition() const { return wxPoint2DInt(m_x, m_y); }
       wxSize GetSize() const { return wxSize(m_width, m_height); }

        // for the edge and corner accessors there are two setters counterparts, the Set.. functions keep the other corners at their
        // position whenever sensible, the Move.. functions keep the size of the rect and move the other corners appropriately

      inline wxInt32 GetLeft() const { return m_x; }
       inline void SetLeft( wxInt32 n ) { m_width += m_x - n; m_x = n; }
       inline void MoveLeftTo( wxInt32 n ) { m_x = n; }
       inline wxInt32 GetTop() const { return m_y; }
       inline void SetTop( wxInt32 n ) { m_height += m_y - n; m_y = n; }
       inline void MoveTopTo( wxInt32 n ) { m_y = n; }
       inline wxInt32 GetBottom() const { return m_y + m_height; }
       inline void SetBottom( wxInt32 n ) { m_height += n - (m_y+m_height);}
       inline void MoveBottomTo( wxInt32 n ) { m_y = n - m_height; }
       inline wxInt32 GetRight() const { return m_x + m_width; }
       inline void SetRight( wxInt32 n ) { m_width += n - (m_x+m_width) ; }
       inline void MoveRightTo( wxInt32 n ) { m_x = n - m_width; }

        inline wxPoint2DInt GetLeftTop() const { return wxPoint2DInt( m_x , m_y ); }
        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; }
        inline void MoveLeftTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x; m_y = pt.m_y; }
        inline wxPoint2DInt GetLeftBottom() const { return wxPoint2DInt( m_x , m_y + m_height ); }
        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; }
        inline void MoveLeftBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x; m_y = pt.m_y - m_height; }
        inline wxPoint2DInt GetRightTop() const { return wxPoint2DInt( m_x+m_width , m_y ); }
        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; }
        inline void MoveRightTopTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width; m_y = pt.m_y; }
        inline wxPoint2DInt GetRightBottom() const { return wxPoint2DInt( m_x+m_width , m_y + m_height ); }
        inline void SetRightBottom( const wxPoint2DInt &pt ) { m_width += pt.m_x - ( m_x + m_width ); m_height += pt.m_y - (m_y+m_height);}
        inline void MoveRightBottomTo( const wxPoint2DInt &pt ) { m_x = pt.m_x - m_width; m_y = pt.m_y - m_height; }
        inline wxPoint2DInt GetCentre() const { return wxPoint2DInt( m_x+m_width/2 , m_y+m_height/2 ); }
        inline void SetCentre( const wxPoint2DInt &pt ) { MoveCentreTo( pt ); }    // since this is impossible without moving...
        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); }
        inline wxOutCode GetOutCode( const wxPoint2DInt &pt ) const
            { return (wxOutCode) (( ( pt.m_x < m_x ) ? wxOutLeft : 0 ) +
                     ( ( pt.m_x >= m_x + m_width ) ? wxOutRight : 0 ) +
                     ( ( pt.m_y < m_y ) ? wxOutTop : 0 )  +
                     ( ( pt.m_y >= m_y + m_height ) ? wxOutBottom : 0 )); }
        inline wxOutCode GetOutcode( const wxPoint2DInt &pt ) const
            { return GetOutCode( pt ) ; }
        inline bool Contains( const wxPoint2DInt &pt ) const
            { return  GetOutCode( pt ) == wxInside; }
        inline bool Contains( const wxRect2DInt &rect ) const
            { return ( ( ( m_x <= rect.m_x ) && ( rect.m_x + rect.m_width <= m_x + m_width ) ) &&
                ( ( m_y <= rect.m_y ) && ( rect.m_y + rect.m_height <= m_y + m_height ) ) ); }
        inline bool IsEmpty() const
            { return ( m_width <= 0 || m_height <= 0 ); }
        inline bool HaveEqualSize( const wxRect2DInt &rect ) const
            { return ( rect.m_width == m_width && rect.m_height == m_height ); }

        inline void Inset( wxInt32 x , wxInt32 y ) { m_x += x; m_y += y; m_width -= 2 * x; m_height -= 2 * y; }
        inline void Inset( wxInt32 left , wxInt32 top ,wxInt32 right , wxInt32 bottom  )
            { m_x += left; m_y += top; m_width -= left + right; m_height -= top + bottom;}
        inline void Offset( const wxPoint2DInt &pt ) { m_x += pt.m_x; m_y += pt.m_y; }
        void ConstrainTo( const wxRect2DInt &rect );
        inline wxPoint2DInt Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ) { return wxPoint2DInt( m_x + m_width * widthfactor , m_y + m_height * heightfactor ); }

        static void Intersect( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest );
        inline void Intersect( const wxRect2DInt &otherRect ) { Intersect( *this , otherRect , this ); }
        inline wxRect2DInt CreateIntersection( const wxRect2DInt &otherRect ) const { wxRect2DInt result; Intersect( *this , otherRect , &result); return result; }
        bool Intersects( const wxRect2DInt &rect ) const;

        static void Union( const wxRect2DInt &src1 , const wxRect2DInt &src2 , wxRect2DInt *dest );
        void Union( const wxRect2DInt &otherRect )  { Union( *this , otherRect , this ); }
        void Union( const wxPoint2DInt &pt );
        inline wxRect2DInt CreateUnion( const wxRect2DInt &otherRect ) const { wxRect2DInt result; Union( *this , otherRect , &result); return result; }

        inline void Scale( wxInt32 f ) { m_x *= f; m_y *= f; m_width *= f; m_height *= f;}
        inline void Scale( wxInt32 num , wxInt32 denum )
            { m_x *= ((wxInt32)num)/((wxInt32)denum); m_y *= ((wxInt32)num)/((wxInt32)denum);
                m_width *= ((wxInt32)num)/((wxInt32)denum); m_height *= ((wxInt32)num)/((wxInt32)denum);}

       wxRect2DInt& operator = (const wxRect2DInt& rect);
       bool operator == (const wxRect2DInt& rect) const;
       bool operator != (const wxRect2DInt& rect) const;

#if wxUSE_STREAMS
       void WriteTo( wxDataOutputStream &stream ) const;
       void ReadFrom( wxDataInputStream &stream );
#endif // wxUSE_STREAMS

       wxInt32 m_x;
       wxInt32 m_y;
       wxInt32 m_width;
       wxInt32 m_height;
};

inline wxRect2DInt::wxRect2DInt( const wxRect2DInt &r )
{
    m_x = r.m_x;
    m_y = r.m_y;
    m_width = r.m_width;
    m_height = r.m_height;
}

inline wxRect2DInt::wxRect2DInt( const wxPoint2DInt &a , const wxPoint2DInt &b)
{
    m_x = wxMin( a.m_x , b.m_x );
    m_y = wxMin( a.m_y , b.m_y );
    m_width = abs( a.m_x - b.m_x );
    m_height = abs( a.m_y - b.m_y );
}

inline wxRect2DInt::wxRect2DInt( const wxPoint2DInt& pos, const wxSize& size)
{
    m_x = pos.m_x;
    m_y = pos.m_y;
    m_width = size.x;
    m_height = size.y;
}

inline bool wxRect2DInt::operator == (const wxRect2DInt& rect) const
{
    return (m_x==rect.m_x && m_y==rect.m_y &&
            m_width==rect.m_width && m_height==rect.m_height);
}

inline bool wxRect2DInt::operator != (const wxRect2DInt& rect) const
{
    return !(*this == rect);
}

class WXDLLIMPEXP_CORE wxTransform2D
{
public :
    virtual ~wxTransform2D() { }
    virtual void                    Transform( wxPoint2DInt* pt )const  = 0;
    virtual void                    Transform( wxRect2DInt* r ) const;
    virtual wxPoint2DInt    Transform( const wxPoint2DInt &pt ) const;
    virtual wxRect2DInt        Transform( const wxRect2DInt &r ) const ;

    virtual void                    InverseTransform( wxPoint2DInt* pt ) const  = 0;
    virtual void                    InverseTransform( wxRect2DInt* r ) const ;
    virtual wxPoint2DInt    InverseTransform( const wxPoint2DInt &pt ) const ;
    virtual wxRect2DInt        InverseTransform( const wxRect2DInt &r ) const ;
};


#endif // wxUSE_GEOMETRY

#endif // _WX_GEOMETRY_H_