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