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