source: branch/egtra-gdiplus/Classes/System/Drawing/PointF.ab@ 711

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

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

File size: 2.7 KB
RevLine 
[1]1' Classes/System/Drawing/PointF.ab
2
3#ifndef __SYSTEM_DRAWING_POINTF_AB__
4#define __SYSTEM_DRAWING_POINTF_AB__
5
[241]6#require <Classes/System/Drawing/Size.ab>
7#require <Classes/System/Drawing/SizeF.ab>
[1]8
[241]9Namespace System
10Namespace Drawing
11
[1]12Class PointF
13Public
14 Sub PointF()
15 x = 0
16 y = 0
17 End Sub
18
19 Sub PointF(initX As Single, initY As Single)
20 x = initX
21 y = initY
22 End Sub
23
[212]24 Sub PointF(pt As PointF)
[1]25 x = pt.x
26 y = pt.y
27 End Sub
28
[212]29 Sub PointF(sz As SizeF)
[1]30 x = sz.Width
31 y = sz.Height
32 End Sub
33
34 Function X() As Single
35 Return x
36 End Function
37
38 Sub X(newX As Single)
39 x = newX
40 End Sub
41
42 Function Y() As Single
43 Return y
44 End Function
45
46 Sub Y(newY As Single)
47 y = newY
48 End Sub
49
[104]50 Function IsEmpty() As Boolean
[212]51 Return x = 0 And y = 0
[1]52 End Function
[241]53
[1]54 Function Operator + (pt As PointF) As PointF
[27]55 Return Add(This, pt)
[1]56 End Function
57
58 Function Operator + (sz As Size) As PointF
[27]59 Return Add(This, sz)
[1]60 End Function
61
62 Function Operator + (sz As SizeF) As PointF
[27]63 Return Add(This, sz)
[1]64 End Function
65
66 Function Operator - (pt As PointF) As PointF
[27]67 Return Substract(This, pt)
[1]68 End Function
69
70 Function Operator - (sz As Size) As PointF
[27]71 Return Substract(This, sz)
[1]72 End Function
73
74 Function Operator - (sz As SizeF) As PointF
[27]75 Return Substract(This, sz)
[1]76 End Function
77
[104]78 Function Operator == (sz As PointF) As Boolean
[1]79 Return Equals(sz)
80 End Function
81
[104]82 Function Operator <> (sz As PointF) As Boolean
[1]83 Return Not Equals(sz)
84 End Function
85
[27]86 Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
87 Dim ret As PointF(pt1.x + pt2.x, pt1.y + pt2.y)
[1]88 Return ret
89 End Function
90
[27]91 Static Function Add(pt As PointF, sz As Size) As PointF
92 Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
[1]93 Return ret
94 End Function
95
[27]96 Static Function Add(pt As PointF, sz As SizeF) As PointF
97 Dim ret As PointF(pt.x + sz.Width, pt.y + sz.Height)
[1]98 Return ret
99 End Function
100
[77]101 Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
[27]102 Dim ret As PointF(pt1.x - pt2.x, pt1.y - pt2.y)
[1]103 Return ret
104 End Function
105
[27]106 Static Function Substract(pt As PointF, sz As Size) As PointF
107 Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
[1]108 Return ret
109 End Function
110
[27]111 Static Function Substract(pt As PointF, sz As SizeF) As PointF
112 Dim ret As PointF(pt.x - sz.Width, pt.y - sz.Height)
[1]113 Return ret
114 End Function
115
[104]116 Function Equals(pt As PointF) As Boolean
[212]117 Return x = pt.x And y = pt.y
[1]118 End Function
119
[166]120 Override Function GetHashCode() As Long
[212]121 Return (GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))) As Long
[166]122 End Function
123
[1]124Private
125 x As Single
126 y As Single
127End Class
128
[241]129End Namespace 'Drawing
130End Namespace 'System
131
[1]132#endif '__SYSTEM_DRAWING_POINTF_AB__
Note: See TracBrowser for help on using the repository browser.