Changeset 223 for Include/Classes/System/Drawing/Rectangle.ab
- Timestamp:
- Apr 30, 2007, 1:56:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Drawing/Rectangle.ab
r212 r223 4 4 #define __SYSTEM_DRAWING_RECTANGLE_AB__ 5 5 6 # include <Classes/System/Math.ab>7 # include <Classes/System/Drawing/RectangleF.ab>8 # include <Classes/System/Drawing/Point.ab>9 # include <Classes/System/Drawing/Size.ab>6 #require <Classes/System/Math.ab> 7 #require <Classes/System/Drawing/RectangleF.ab> 8 #require <Classes/System/Drawing/Point.ab> 9 #require <Classes/System/Drawing/Size.ab> 10 10 11 11 Class Rectangle … … 32 32 End Sub 33 33 34 Sub Rectangle(ByRef r As Rectangle)35 x = r.x36 y = r.y37 width = r.width38 height = r.height39 End Sub40 41 34 Sub Rectangle(ByRef r As RECT) 42 This = FromLTRB(r.left, r.top, r.right, r.bottom) 35 x = r.left 36 y = r.top 37 width = r.right - r.left 38 height = r.top - r.bottom 43 39 End Sub 44 40 … … 111 107 112 108 Function IsEmpty() As Boolean 113 If Width <= 0 Or Height <= 0 Then 114 IsEmpty = _System_TRUE 115 Else 116 IsEmpty = _System_FALSE 117 End If 118 End Function 119 /* 120 Function Operator = (rc As Rectangle) 121 With rc 122 x = .x 123 y = .y 124 width = .width 125 height = .height 126 End With 127 End Function 128 */ 109 Return Width <= 0 Or Height <= 0 110 End Function 111 129 112 Function Operator == (rc As Rectangle) 130 113 Return Equals(rc) … … 140 123 141 124 Function Equals(rc As Rectangle) As Boolean 142 If X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height Then 143 Return True 144 Else 145 Return False 146 End If 125 Return X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height 147 126 End Function 148 127 149 128 Override Function GetHashCode() As Long 150 Return x Xor _System_BSwap(y) Xor width Xor _System_BSwap(height)129 Return x As DWord Xor _System_BSwap(y As DWord) Xor width As DWord Xor _System_BSwap(height As DWord) 151 130 End Function 152 131 153 132 Static Function FromLTRB(l As Long, t As Long, r As Long, b As Long) As Rectangle 154 return New Rectangle(l, t, r - l, r - b)133 return New Rectangle(l, t, r - l, b - t) 155 134 End Function 156 135 157 136 Function Contains(x As Long, y As Long) As Boolean 158 If x >= X And x < X + Width And y >= Y And y < Y + Height Then 159 Return True 160 Else 161 Return False 162 End If 137 Return x >= X And x < X + Width And y >= Y And y < Y + Height 163 138 End Function 164 139 … … 168 143 169 144 Function Contains(rc As Rectangle) As Boolean 170 If X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom Then 171 Return True 172 Else 173 Return False 174 End If 145 Return X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom 175 146 End Function 176 147 … … 205 176 206 177 Function IntersectsWith(rc As Rectangle) As Boolean 207 IfLeft < rc.Right And _178 Return Left < rc.Right And _ 208 179 Top < rc.Bottom And _ 209 180 Right > rc.Left And _ 210 Bottom > rc.Top Then 211 Return True 212 Else 213 Return False 214 End If 181 Bottom > rc.Top 215 182 End Function 216 183
Note:
See TracChangeset
for help on using the changeset viewer.