source: trunk/Include/Classes/System/Drawing/Point.ab@ 443

Last change on this file since 443 was 303, checked in by イグトランス (egtra), 17 years ago

フルコンパイルでのミスあぶり出し。註:修正は全て@300や@301以前に行われた。

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