1 | ' Classes/System/Drawing/PointF.ab
|
---|
2 |
|
---|
3 | #ifndef __SYSTEM_DRAWING_POINTF_AB__
|
---|
4 | #define __SYSTEM_DRAWING_POINTF_AB__
|
---|
5 |
|
---|
6 | #include <Classes/System/Drawing/Size.ab>
|
---|
7 | #include <Classes/System/Drawing/SizeF.ab>
|
---|
8 |
|
---|
9 | Class PointF
|
---|
10 | Public
|
---|
11 | Sub PointF()
|
---|
12 | x = 0
|
---|
13 | y = 0
|
---|
14 | End Sub
|
---|
15 |
|
---|
16 | Sub PointF(initX As Single, initY As Single)
|
---|
17 | x = initX
|
---|
18 | y = initY
|
---|
19 | End Sub
|
---|
20 |
|
---|
21 | Sub PointF(pt As PointF)
|
---|
22 | x = pt.x
|
---|
23 | y = pt.y
|
---|
24 | End Sub
|
---|
25 |
|
---|
26 | Sub PointF(sz As SizeF)
|
---|
27 | x = sz.Width
|
---|
28 | y = sz.Height
|
---|
29 | End Sub
|
---|
30 |
|
---|
31 | Function X() As Single
|
---|
32 | Return x
|
---|
33 | End Function
|
---|
34 |
|
---|
35 | Sub X(newX As Single)
|
---|
36 | x = newX
|
---|
37 | End Sub
|
---|
38 |
|
---|
39 | Function Y() As Single
|
---|
40 | Return y
|
---|
41 | End Function
|
---|
42 |
|
---|
43 | Sub Y(newY As Single)
|
---|
44 | y = newY
|
---|
45 | End Sub
|
---|
46 |
|
---|
47 | Function IsEmpty() As Boolean
|
---|
48 | Return x = 0 And y = 0
|
---|
49 | End Function
|
---|
50 |
|
---|
51 | Function Operator + (pt As PointF) As PointF
|
---|
52 | Return Add(This, pt)
|
---|
53 | End Function
|
---|
54 |
|
---|
55 | Function Operator + (sz As Size) As PointF
|
---|
56 | Return Add(This, sz)
|
---|
57 | End Function
|
---|
58 |
|
---|
59 | Function Operator + (sz As SizeF) As PointF
|
---|
60 | Return Add(This, sz)
|
---|
61 | End Function
|
---|
62 |
|
---|
63 | Function Operator - (pt As PointF) As PointF
|
---|
64 | Return Substract(This, pt)
|
---|
65 | End Function
|
---|
66 |
|
---|
67 | Function Operator - (sz As Size) As PointF
|
---|
68 | Return Substract(This, sz)
|
---|
69 | End Function
|
---|
70 |
|
---|
71 | Function Operator - (sz As SizeF) As PointF
|
---|
72 | Return Substract(This, sz)
|
---|
73 | End Function
|
---|
74 |
|
---|
75 | Function Operator == (sz As PointF) As Boolean
|
---|
76 | Return Equals(sz)
|
---|
77 | End Function
|
---|
78 |
|
---|
79 | Function Operator <> (sz As PointF) As Boolean
|
---|
80 | Return Not Equals(sz)
|
---|
81 | End Function
|
---|
82 |
|
---|
83 | Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
|
---|
84 | Dim ret As PointF(pt1.x + pt2.x, pt1.y + pt2.y)
|
---|
85 | Return ret
|
---|
86 | End Function
|
---|
87 |
|
---|
88 | Static Function Add(pt As PointF, sz As Size) As PointF
|
---|
89 | Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
|
---|
90 | Return ret
|
---|
91 | End Function
|
---|
92 |
|
---|
93 | Static Function Add(pt As PointF, sz As SizeF) As PointF
|
---|
94 | Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
|
---|
95 | Return ret
|
---|
96 | End Function
|
---|
97 |
|
---|
98 | Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
|
---|
99 | Dim ret As PointF(pt1.x - pt2.x, pt1.y - pt2.y)
|
---|
100 | Return ret
|
---|
101 | End Function
|
---|
102 |
|
---|
103 | Static Function Substract(pt As PointF, sz As Size) As PointF
|
---|
104 | Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
|
---|
105 | Return ret
|
---|
106 | End Function
|
---|
107 |
|
---|
108 | Static Function Substract(pt As PointF, sz As SizeF) As PointF
|
---|
109 | Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
|
---|
110 | Return ret
|
---|
111 | End Function
|
---|
112 |
|
---|
113 | Function Equals(pt As PointF) As Boolean
|
---|
114 | Return x = pt.x And y = pt.y
|
---|
115 | End Function
|
---|
116 |
|
---|
117 | Override Function GetHashCode() As Long
|
---|
118 | Return (GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))) As Long
|
---|
119 | End Function
|
---|
120 |
|
---|
121 | Private
|
---|
122 | x As Single
|
---|
123 | y As Single
|
---|
124 | End Class
|
---|
125 |
|
---|
126 | #endif '__SYSTEM_DRAWING_POINTF_AB__
|
---|