source: branch/egtra-gdiplus/Classes/System/Drawing/SizeF.ab@ 653

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

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

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