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