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