2 * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 * John Scipione, jscipione@gmail.com
19 BRect::SetLeftTop(const BPoint point
)
27 BRect::SetRightBottom(const BPoint point
)
35 BRect::SetLeftBottom(const BPoint point
)
43 BRect::SetRightTop(const BPoint point
)
51 BRect::InsetBy(BPoint point
)
61 BRect::InsetBy(float dx
, float dy
)
71 BRect::InsetBySelf(BPoint point
)
79 BRect::InsetBySelf(float dx
, float dy
)
87 BRect::InsetByCopy(BPoint point
) const
96 BRect::InsetByCopy(float dx
, float dy
) const
105 BRect::OffsetBy(BPoint point
)
115 BRect::OffsetBy(float dx
, float dy
)
125 BRect::OffsetBySelf(BPoint point
)
133 BRect::OffsetBySelf(float dx
, float dy
)
141 BRect::OffsetByCopy(BPoint point
) const
144 copy
.OffsetBy(point
);
150 BRect::OffsetByCopy(float dx
, float dy
) const
153 copy
.OffsetBy(dx
, dy
);
159 BRect::OffsetTo(BPoint point
)
161 right
= (right
- left
) + point
.x
;
163 bottom
= (bottom
- top
) + point
.y
;
169 BRect::OffsetTo(float x
, float y
)
171 right
= (right
- left
) + x
;
173 bottom
= (bottom
- top
) + y
;
179 BRect::OffsetToSelf(BPoint point
)
187 BRect::OffsetToSelf(float x
, float y
)
195 BRect::OffsetToCopy(BPoint point
) const
198 copy
.OffsetTo(point
);
204 BRect::OffsetToCopy(float x
, float y
) const
213 BRect::PrintToStream() const
215 printf("BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f)\n", left
, top
, right
, bottom
);
220 BRect::operator==(BRect other
) const
222 return left
== other
.left
&& right
== other
.right
&&
223 top
== other
.top
&& bottom
== other
.bottom
;
228 BRect::operator!=(BRect other
) const
230 return !(*this == other
);
235 BRect::operator&(BRect other
) const
237 return BRect(std::max(left
, other
.left
), std::max(top
, other
.top
),
238 std::min(right
, other
.right
), std::min(bottom
, other
.bottom
));
243 BRect::operator|(BRect other
) const
245 return BRect(std::min(left
, other
.left
), std::min(top
, other
.top
),
246 std::max(right
, other
.right
), std::max(bottom
, other
.bottom
));
251 BRect::Intersects(BRect rect
) const
253 if (!IsValid() || !rect
.IsValid())
256 return !(rect
.left
> right
|| rect
.right
< left
257 || rect
.top
> bottom
|| rect
.bottom
< top
);
262 BRect::Contains(BPoint point
) const
264 return point
.x
>= left
&& point
.x
<= right
265 && point
.y
>= top
&& point
.y
<= bottom
;
270 BRect::Contains(BRect rect
) const
272 return rect
.left
>= left
&& rect
.right
<= right
273 && rect
.top
>= top
&& rect
.bottom
<= bottom
;
277 // #pragma mark - BeOS compatibility only
282 InsetByCopy__5BRectG6BPoint(BRect
* self
, BPoint point
)
291 InsetByCopy__5BRectff(BRect
* self
, float dx
, float dy
)
294 copy
.InsetBy(dx
, dy
);
300 OffsetByCopy__5BRectG6BPoint(BRect
* self
, BPoint point
)
303 copy
.OffsetBy(point
);
309 OffsetByCopy__5BRectff(BRect
* self
, float dx
, float dy
)
312 copy
.OffsetBy(dx
, dy
);
318 OffsetToCopy__5BRectG6BPoint(BRect
* self
, BPoint point
)
321 copy
.OffsetTo(point
);
327 OffsetToCopy__5BRectff(BRect
* self
, float dx
, float dy
)
330 copy
.OffsetTo(dx
, dy
);
336 // TODO: remove this when new GCC 4 packages have to be built anyway
340 _ZN5BRect11InsetByCopyE6BPoint(BRect
* self
, BPoint point
)
349 _ZN5BRect11InsetByCopyEff(BRect
* self
, float dx
, float dy
)
352 copy
.InsetBy(dx
, dy
);
358 _ZN5BRect12OffsetByCopyE6BPoint(BRect
* self
, BPoint point
)
361 copy
.OffsetBy(point
);
367 _ZN5BRect12OffsetByCopyEff(BRect
* self
, float dx
, float dy
)
370 copy
.OffsetBy(dx
, dy
);
376 _ZN5BRect12OffsetToCopyE6BPoint(BRect
* self
, BPoint point
)
379 copy
.OffsetTo(point
);
385 _ZN5BRect12OffsetToCopyEff(BRect
* self
, float dx
, float dy
)
388 copy
.OffsetTo(dx
, dy
);
393 #endif // __GNUC__ >= 4