source: Include/Classes/System/Drawing/Point.ab@ 106

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

Boolean対応ほか微修正

File size: 2.9 KB
RevLine 
[1]1' Classes/System/Drawing/Point.ab
2
3#ifndef __SYSTEM_DRAWING_POINT_AB__
4#define __SYSTEM_DRAWING_POINT_AB__
5
[27]6#include <Classes/System/Drawing/PointF.ab>
[1]7#include <Classes/System/Drawing/Size.ab>
8#include <Classes/System/Drawing/SizeF.ab>
9
[11]10Class Point
[1]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(ByRef pt As Point)
23 x = pt.x
24 y = pt.y
25 End Sub
26
27 Sub Point(ByRef sz As Size)
28 x = sz.Width
29 y = sz.Height
30 End Sub
31
32 Sub Point(dw As DWord)
33 x = LOWORD(dw)
34 y = HIWORD(dw)
35 End Sub
36
37 Function X() As Long
38 Return x
39 End Function
40
41 Sub X(newX As Long)
42 x = newX
43 End Sub
44
45 Function Y() As Long
46 Return y
47 End Function
48
49 Sub Y(newY As Long)
50 y = newY
51 End Sub
52
[104]53 Function IsEmpty() As Boolean
[1]54 If x = 0 And y = 0 Then
55 Return _System_TRUE
56 Else
57 Return _System_FALSE
58 End If
59 End Function
60
61 Sub Operator = (ByRef pt As Point)
62 x = pt.x
63 y = pt.y
64 End Sub
65
66 Function Operator + (pt As Point) As Point
[27]67 Return Add(This, pt)
[1]68 End Function
69
70 Function Operator + (sz As Size) As Point
[27]71 Return Add(This, sz)
[1]72 End Function
73
74 Function Operator - (pt As Point) As Point
[27]75 Return Substract(This, pt)
[1]76 End Function
77
78 Function Operator - (sz As Size) As Point
[27]79 Return Substract(This, sz)
[1]80 End Function
81
[104]82 Function Operator == (sz As Point) As Boolean
[1]83 Return Equals(sz)
84 End Function
85
[104]86 Function Operator <> (sz As Point) As Boolean
[1]87 Return Not Equals(sz)
88 End Function
89
[27]90 Static Function Add(pt1 As Point, pt2 As Point) As Point
91 Dim ret As Point(pt1.x + pt2.x, pt1.y + pt2.y)
[1]92 Return ret
93 End Function
94
[27]95 Static Function Add(pt As Point, sz As Size) As Point
96 Dim ret As Point(pt.x + sz.Width, pt.y + sz.Height)
[1]97 Return ret
98 End Function
99
[29]100 Function Offset(pt As Point) As Point
[1]101 Dim ret As Point(x + pt.x, y + pt.y)
[27]102 Return ret
[1]103 End Function
104
[27]105 Sub Offset(dx As Long, dy As Long)
106 x += dx
107 y += dy
[29]108 End Sub
[1]109
[27]110 Static Function Substract(pt1 As Point, pt2 As Point) As Point
111 Dim ret As Point(pt1.x - pt2.x, pt1.y - pt2.y)
[1]112 Return ret
113 End Function
114
[27]115 Static Function Substract(pt As Point, sz As Size) As Point
116 Dim ret As Point(pt.x - sz.Width, pt.y - sz.Height)
[1]117 Return ret
118 End Function
119
[104]120 Function Equals(pt As Point) As Boolean
[1]121 If x = pt.x And y = pt.y Then
122 Equals = _System_TRUE
123 Else
124 Equals = _System_FALSE
125 End If
126 End Function
127
128 Static Function Ceiling(ptf As PointF) As Point
129 Dim pt As Size(Math.Ceiling(ptf.width), Math.Ceiling(ptf.height))
130 Return pt
131 End Function
132
133 Static Function Round(ptf As PointF) As Point
134 Dim pt As Point(Math.Round(ptf.width), Math.Round(ptf.height))
135 Return pt
136 End Function
137
138 Static Function Truncate(ptf As PointF) As Point
139 Dim pt As Point(Math.Truncate(ptf.width), Math.Truncate(ptf.height))
140 Return pt
141 End Function
142
143Private
144 x As Long
145 y As Long
146End Class
147
148#endif '__SYSTEM_DRAWING_POINT_AB__
Note: See TracBrowser for help on using the repository browser.