' Classes/System/Drawing/Point.ab #ifndef __SYSTEM_DRAWING_POINT_AB__ #define __SYSTEM_DRAWING_POINT_AB__ #include #include Class PointF Public Sub Point() x = 0 y = 0 End Sub Sub Point(initX As Long, initY As Long) x = initX y = initY End Sub Sub Point(ByRef pt As Point) x = pt.x y = pt.y End Sub Sub Point(ByRef sz As Size) x = sz.Width y = sz.Height End Sub Sub Point(dw As DWord) x = LOWORD(dw) y = HIWORD(dw) End Sub Function X() As Long Return x End Function Sub X(newX As Long) x = newX End Sub Function Y() As Long Return y End Function Sub Y(newY As Long) y = newY End Sub Function IsEmpty() As BOOL If x = 0 And y = 0 Then Return _System_TRUE Else Return _System_FALSE End If End Function Sub Operator = (ByRef pt As Point) x = pt.x y = pt.y End Sub Function Operator + (pt As Point) As Point Return Add(pt) End Function Function Operator + (sz As Size) As Point Return Add(sz) End Function Function Operator - (pt As Point) As Point Return Substract(pt) End Function Function Operator - (sz As Size) As Point Return Substract(sz) End Function Function Operator == (sz As Point) As BOOL Return Equals(sz) End Function Function Operator <> (sz As Point) As BOOL Return Not Equals(sz) End Function Function Add(pt As Point) As Point Dim ret As Point(x + pt.x, y + pt.y) Return ret End Function Function Add(sz As Size) As Point Dim ret As Point(x + sz.width, y + sz.height) Return ret End Function Function Offset(pt As Point) As Point Dim ret As Point(x + pt.x, y + pt.y) End Function Function Offset(dx As Long, dy As Long) As Point Dim ret As Point(x + dx, y + dy) End Function Function Substract(pt As Point) As Point Dim ret As Point(x - pt.x, y - pt.y) Return ret End Function Function Substract(sz As Size) As Point Dim ret As Point(x - sz.width, y - sz.height) Return ret End Function Function Equals(pt As Point) As BOOL If x = pt.x And y = pt.y Then Equals = _System_TRUE Else Equals = _System_FALSE End If End Function Static Function Ceiling(ptf As PointF) As Point Dim pt As Size(Math.Ceiling(ptf.width), Math.Ceiling(ptf.height)) Return pt End Function Static Function Round(ptf As PointF) As Point Dim pt As Point(Math.Round(ptf.width), Math.Round(ptf.height)) Return pt End Function Static Function Truncate(ptf As PointF) As Point Dim pt As Point(Math.Truncate(ptf.width), Math.Truncate(ptf.height)) Return pt End Function Private x As Long y As Long End Class #endif '__SYSTEM_DRAWING_POINT_AB__