' Classes/System/Drawing/Size.ab

Namespace System
Namespace Drawing

Class Size
Public
	Sub Size()
		width = 0
		height = 0
	End Sub

	Sub Size(initWidth As Long, initHeight As Long)
		width = initWidth
		height = initHeight
	End Sub

	Sub Size(sz As Size)
		width = sz.width
		height = sz.height
	End Sub

	Function Width() As Long
		Return width
	End Function

	Sub Width(w As Long)
		width = w
	End Sub

	Function Height() As Long
		Return height
	End Function

	Sub Height(h As Long)
		height = h
	End Sub

	Function Operator +(sz As Size) As Size
		Return New Size(width + sz.width, height + sz.height)
	End Function

	Function Operator -(sz As Size) As Size
		Return New Size(width - sz.width, height - sz.height)
	End Function

	Function Operator () As SizeF
		Return New SizeF(width, height)
	End Function

	Function Operator ==(sz As Size) As Boolean
		Return Equals(sz)
	End Function

	Function Operator <>(sz As Size) As Boolean
		Return Not Equals(sz)
	End Function

	Function Equals(sz As Size) As Boolean
		If width = sz.width And height = sz.height Then
			Equals = True
		Else
			Equals = False
		End If
	End Function

	Override Function GetHashCode() As Long
		Return width As DWord Xor _System_BSwap(height As DWord)
	End Function

	Function IsEmpty() As Boolean
		Return width = 0 And height = 0
	End Function

	Function Add(sz As Size) As Size
		Return This + sz
	End Function

	Function Subtract(sz As Size) As Size
		Return This - sz
	End Function

	Static Function Ceiling(szf As SizeF) As Size
		Return New Size(System.Math.Ceiling(szf.Width) As Long, System.Math.Ceiling(szf.Height) As Long)
	End Function

	Static Function Round(szf As SizeF) As Size
		Return New Size(System.Math.Round(szf.Width) As Long, System.Math.Round(szf.Height) As Long)
	End Function

	Static Function Truncate(szf As SizeF) As Size
		Return New Size(System.Math.Truncate(szf.Width) As Long, System.Math.Truncate(szf.Height) As Long)
	End Function

Private
	width As Long
	height As Long
End Class

End Namespace
End Namespace
