' Classes/System/Drawing/SizeF.ab

#ifndef __SYSTEM_DRAWING_SIZEF_AB__
#define __SYSTEM_DRAWING_SIZEF_AB__

#include <Classes/System/Drawing/Size.ab>
#include <Classes/System/Drawing/PointF.ab>

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

	Sub SizeF(initWidth As Single, initHeight As Single)
		width = initWidth
		height = initHeight
	End Sub

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

	Function Width() As Single
		Return width
	End Function

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

	Function Height() As Single
		Return height
	End Function

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

	Function Operator +(sz As SizeF) As SizeF
		Dim ret As SizeF(width + sz.width, height + sz.height)
		Return ret
	End Function

	Function Operator -(sz As SizeF) As SizeF
		Dim ret As SizeF(width - sz.width, height - sz.height)
		Return ret
	End Function

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

	Function Operator <>(sz As SizeF) As Boolean
		Return Not Equals(sz)
	End Function
/*
	Sub Operator =(ByRef sz As SizeF)
		width = sz.width
		height = sz.height
	End Sub
*/
	Function Equals(sz As SizeF) As Boolean
		Return width = sz.width And height = sz.height
	End Function

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

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

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

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

	Function ToSize() As Size
		Return Size.Round(This)
	End Function

	Function ToPointF() As PointF
		Dim pt As PointF(width, height)
		Return pt
	End Function
Private
	width As Single
	height As Single
End Class

#endif '__SYSTEM_DRAWING_SIZEF_AB__
