source: branch/egtra-gdiplus/Classes/System/Drawing/Size.ab

Last change on this file was 241, checked in by イグトランス (egtra), 18 years ago

GDI+に対して名前空間で囲ったものの、現在コンパイルできないため分岐させておく

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