1 | ' Classes/System/Drawing/SizeF.ab
|
---|
2 |
|
---|
3 | #ifndef __SYSTEM_DRAWING_SIZEF_AB__
|
---|
4 | #define __SYSTEM_DRAWING_SIZEF_AB__
|
---|
5 |
|
---|
6 | #include <Classes/System/Drawing/Size.ab>
|
---|
7 | #include <Classes/System/Drawing/PointF.ab>
|
---|
8 |
|
---|
9 | Class SizeF
|
---|
10 | Public
|
---|
11 | Sub SizeF()
|
---|
12 | width = 0
|
---|
13 | height = 0
|
---|
14 | End Sub
|
---|
15 |
|
---|
16 | Sub SizeF(initWidth As Single, initHeight As Single)
|
---|
17 | width = initWidth
|
---|
18 | height = initHeight
|
---|
19 | End Sub
|
---|
20 |
|
---|
21 | Sub SizeF(ByRef sz As SizeF)
|
---|
22 | width = sz.width
|
---|
23 | height = sz.height
|
---|
24 | End Sub
|
---|
25 |
|
---|
26 | Function Width() As Single
|
---|
27 | Return width
|
---|
28 | End Function
|
---|
29 |
|
---|
30 | Sub Width(w As Single)
|
---|
31 | width = w
|
---|
32 | End Sub
|
---|
33 |
|
---|
34 | Function Height() As Single
|
---|
35 | Return height
|
---|
36 | End Function
|
---|
37 |
|
---|
38 | Sub Height(h As Single)
|
---|
39 | height = h
|
---|
40 | End Sub
|
---|
41 |
|
---|
42 | Function Operator +(sz As SizeF) As SizeF
|
---|
43 | Dim ret As SizeF(width + sz.width, height + sz.height)
|
---|
44 | Return ret
|
---|
45 | End Function
|
---|
46 |
|
---|
47 | Function Operator -(sz As SizeF) As SizeF
|
---|
48 | Dim ret As SizeF(width - sz.width, height - sz.height)
|
---|
49 | Return ret
|
---|
50 | End Function
|
---|
51 |
|
---|
52 | Function Operator ==(sz As SizeF) As Boolean
|
---|
53 | Return Equals(sz)
|
---|
54 | End Function
|
---|
55 |
|
---|
56 | Function Operator <>(sz As SizeF) As Boolean
|
---|
57 | Return Not Equals(sz)
|
---|
58 | End Function
|
---|
59 |
|
---|
60 | Sub Operator =(ByRef sz As SizeF)
|
---|
61 | width = sz.width
|
---|
62 | height = sz.height
|
---|
63 | End Sub
|
---|
64 |
|
---|
65 | Function Equals(sz As SizeF) As Boolean
|
---|
66 | If width = sz.width And height = sz.height Then
|
---|
67 | Equals = _System_TRUE
|
---|
68 | Else
|
---|
69 | Equals = _System_FALSE
|
---|
70 | End If
|
---|
71 | End Function
|
---|
72 |
|
---|
73 | Override Function GetHashCode() As Long
|
---|
74 | Return VarPtr(GetDWord(width)) Xor _System_BSwap(VarPtr(GetDWord(height)))
|
---|
75 |
|
---|
76 | Function IsEmpty() As Boolean
|
---|
77 | If width = 0 And height = 0 Then
|
---|
78 | Empty = _System_TRUE
|
---|
79 | Else
|
---|
80 | Empty = _System_FALSE
|
---|
81 | End If
|
---|
82 | End Function
|
---|
83 |
|
---|
84 | Function Add(sz As Size) As Size
|
---|
85 | Return This + sz
|
---|
86 | End Function
|
---|
87 |
|
---|
88 | Function Subtract(sz As SizeF) As SizeF
|
---|
89 | Return This - sz
|
---|
90 | End Function
|
---|
91 |
|
---|
92 | Function ToSize() As Size
|
---|
93 | Return Size.Round(This)
|
---|
94 | End Function
|
---|
95 |
|
---|
96 | Function ToPointF() As PointF
|
---|
97 | Dim pt As PointF(width, height)
|
---|
98 | Return pt
|
---|
99 | End Function
|
---|
100 | Private
|
---|
101 | width As Single
|
---|
102 | height As Single
|
---|
103 | End Class
|
---|
104 |
|
---|
105 | #endif '__SYSTEM_DRAWING_SIZEF_AB__
|
---|