1 | ' Classes/System/Drawing/Point.ab
|
---|
2 |
|
---|
3 | #ifndef __SYSTEM_DRAWING_POINT_AB__
|
---|
4 | #define __SYSTEM_DRAWING_POINT_AB__
|
---|
5 |
|
---|
6 | #include <Classes/System/Drawing/Size.ab>
|
---|
7 | #include <Classes/System/Drawing/SizeF.ab>
|
---|
8 |
|
---|
9 | Class PointF
|
---|
10 | Public
|
---|
11 | Sub Point()
|
---|
12 | x = 0
|
---|
13 | y = 0
|
---|
14 | End Sub
|
---|
15 |
|
---|
16 | Sub Point(initX As Long, initY As Long)
|
---|
17 | x = initX
|
---|
18 | y = initY
|
---|
19 | End Sub
|
---|
20 |
|
---|
21 | Sub Point(ByRef pt As Point)
|
---|
22 | x = pt.x
|
---|
23 | y = pt.y
|
---|
24 | End Sub
|
---|
25 |
|
---|
26 | Sub Point(ByRef sz As Size)
|
---|
27 | x = sz.Width
|
---|
28 | y = sz.Height
|
---|
29 | End Sub
|
---|
30 |
|
---|
31 | Sub Point(dw As DWord)
|
---|
32 | x = LOWORD(dw)
|
---|
33 | y = HIWORD(dw)
|
---|
34 | End Sub
|
---|
35 |
|
---|
36 | Function X() As Long
|
---|
37 | Return x
|
---|
38 | End Function
|
---|
39 |
|
---|
40 | Sub X(newX As Long)
|
---|
41 | x = newX
|
---|
42 | End Sub
|
---|
43 |
|
---|
44 | Function Y() As Long
|
---|
45 | Return y
|
---|
46 | End Function
|
---|
47 |
|
---|
48 | Sub Y(newY As Long)
|
---|
49 | y = newY
|
---|
50 | End Sub
|
---|
51 |
|
---|
52 | Function IsEmpty() As BOOL
|
---|
53 | If x = 0 And y = 0 Then
|
---|
54 | Return _System_TRUE
|
---|
55 | Else
|
---|
56 | Return _System_FALSE
|
---|
57 | End If
|
---|
58 | End Function
|
---|
59 |
|
---|
60 | Sub Operator = (ByRef pt As Point)
|
---|
61 | x = pt.x
|
---|
62 | y = pt.y
|
---|
63 | End Sub
|
---|
64 |
|
---|
65 | Function Operator + (pt As Point) As Point
|
---|
66 | Return Add(pt)
|
---|
67 | End Function
|
---|
68 |
|
---|
69 | Function Operator + (sz As Size) As Point
|
---|
70 | Return Add(sz)
|
---|
71 | End Function
|
---|
72 |
|
---|
73 | Function Operator - (pt As Point) As Point
|
---|
74 | Return Substract(pt)
|
---|
75 | End Function
|
---|
76 |
|
---|
77 | Function Operator - (sz As Size) As Point
|
---|
78 | Return Substract(sz)
|
---|
79 | End Function
|
---|
80 |
|
---|
81 | Function Operator == (sz As Point) As BOOL
|
---|
82 | Return Equals(sz)
|
---|
83 | End Function
|
---|
84 |
|
---|
85 | Function Operator <> (sz As Point) As BOOL
|
---|
86 | Return Not Equals(sz)
|
---|
87 | End Function
|
---|
88 |
|
---|
89 | Function Add(pt As Point) As Point
|
---|
90 | Dim ret As Point(x + pt.x, y + pt.y)
|
---|
91 | Return ret
|
---|
92 | End Function
|
---|
93 |
|
---|
94 | Function Add(sz As Size) As Point
|
---|
95 | Dim ret As Point(x + sz.width, y + sz.height)
|
---|
96 | Return ret
|
---|
97 | End Function
|
---|
98 |
|
---|
99 | Function Offset(pt As Point) As Point
|
---|
100 | Dim ret As Point(x + pt.x, y + pt.y)
|
---|
101 | End Function
|
---|
102 |
|
---|
103 | Function Offset(dx As Long, dy As Long) As Point
|
---|
104 | Dim ret As Point(x + dx, y + dy)
|
---|
105 | End Function
|
---|
106 |
|
---|
107 | Function Substract(pt As Point) As Point
|
---|
108 | Dim ret As Point(x - pt.x, y - pt.y)
|
---|
109 | Return ret
|
---|
110 | End Function
|
---|
111 |
|
---|
112 | Function Substract(sz As Size) As Point
|
---|
113 | Dim ret As Point(x - sz.width, y - sz.height)
|
---|
114 | Return ret
|
---|
115 | End Function
|
---|
116 |
|
---|
117 | Function Equals(pt As Point) As BOOL
|
---|
118 | If x = pt.x And y = pt.y Then
|
---|
119 | Equals = _System_TRUE
|
---|
120 | Else
|
---|
121 | Equals = _System_FALSE
|
---|
122 | End If
|
---|
123 | End Function
|
---|
124 |
|
---|
125 | Static Function Ceiling(ptf As PointF) As Point
|
---|
126 | Dim pt As Size(Math.Ceiling(ptf.width), Math.Ceiling(ptf.height))
|
---|
127 | Return pt
|
---|
128 | End Function
|
---|
129 |
|
---|
130 | Static Function Round(ptf As PointF) As Point
|
---|
131 | Dim pt As Point(Math.Round(ptf.width), Math.Round(ptf.height))
|
---|
132 | Return pt
|
---|
133 | End Function
|
---|
134 |
|
---|
135 | Static Function Truncate(ptf As PointF) As Point
|
---|
136 | Dim pt As Point(Math.Truncate(ptf.width), Math.Truncate(ptf.height))
|
---|
137 | Return pt
|
---|
138 | End Function
|
---|
139 |
|
---|
140 | Private
|
---|
141 | x As Long
|
---|
142 | y As Long
|
---|
143 | End Class
|
---|
144 |
|
---|
145 | #endif '__SYSTEM_DRAWING_POINT_AB__
|
---|