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

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

Boolean対応ほか微修正

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