2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
7 * Stephan Aßmus <superstippi@gmx.de>
16 IntRect::SetLeftTop(const IntPoint
& p
)
24 IntRect::SetRightBottom(const IntPoint
& p
)
32 IntRect::SetLeftBottom(const IntPoint
& p
)
40 IntRect::SetRightTop(const IntPoint
& p
)
48 IntRect::InsetBy(const IntPoint
& point
)
58 IntRect::InsetBy(int32 dx
, int32 dy
)
68 IntRect::InsetBySelf(const IntPoint
& point
)
76 IntRect::InsetBySelf(int32 dx
, int32 dy
)
84 IntRect::InsetByCopy(const IntPoint
& point
)
93 IntRect::InsetByCopy(int32 dx
, int32 dy
)
102 IntRect::OffsetBy(const IntPoint
& point
)
112 IntRect::OffsetBy(int32 dx
, int32 dy
)
122 IntRect::OffsetBySelf(const IntPoint
& point
)
130 IntRect::OffsetBySelf(int32 dx
, int32 dy
)
138 IntRect::OffsetByCopy(const IntPoint
& point
)
141 copy
.OffsetBy(point
);
147 IntRect::OffsetByCopy(int32 dx
, int32 dy
)
150 copy
.OffsetBy(dx
, dy
);
156 IntRect::OffsetTo(const IntPoint
& point
)
158 right
= (right
- left
) + point
.x
;
160 bottom
= (bottom
- top
) + point
.y
;
166 IntRect::OffsetTo(int32 x
, int32 y
)
168 right
= (right
- left
) + x
;
170 bottom
= (bottom
- top
) + y
;
176 IntRect::OffsetToSelf(const IntPoint
& point
)
184 IntRect::OffsetToSelf(int32 dx
, int32 dy
)
192 IntRect::OffsetToCopy(const IntPoint
& point
)
195 copy
.OffsetTo(point
);
201 IntRect::OffsetToCopy(int32 dx
, int32 dy
)
204 copy
.OffsetTo(dx
, dy
);
210 IntRect::PrintToStream() const
212 printf("IntRect(l:%" B_PRId32
", t:%" B_PRId32
", r:%" B_PRId32
", b:%"
213 B_PRId32
")\n", left
, top
, right
, bottom
);
218 IntRect::operator==(const IntRect
& rect
) const
220 return left
== rect
.left
&& right
== rect
.right
&&
221 top
== rect
.top
&& bottom
== rect
.bottom
;
226 IntRect::operator!=(const IntRect
& rect
) const
228 return !(*this == rect
);
233 IntRect::operator&(const IntRect
& rect
) const
235 return IntRect(max_c(left
, rect
.left
), max_c(top
, rect
.top
),
236 min_c(right
, rect
.right
), min_c(bottom
, rect
.bottom
));
241 IntRect::operator|(const IntRect
& rect
) const
243 return IntRect(min_c(left
, rect
.left
), min_c(top
, rect
.top
),
244 max_c(right
, rect
.right
), max_c(bottom
, rect
.bottom
));
249 IntRect::Intersects(const IntRect
& rect
) const
251 if (!IsValid() || !rect
.IsValid())
254 return !(rect
.left
> right
|| rect
.right
< left
255 || rect
.top
> bottom
|| rect
.bottom
< top
);
260 IntRect::Contains(const IntPoint
& point
) const
262 return point
.x
>= left
&& point
.x
<= right
263 && point
.y
>= top
&& point
.y
<= bottom
;
268 IntRect::Contains(const IntRect
& rect
) const
270 return rect
.left
>= left
&& rect
.right
<= right
271 && rect
.top
>= top
&& rect
.bottom
<= bottom
;