2007-07-19 21:06:28 +04:00
|
|
|
/*
|
2009-08-27 15:12:41 +04:00
|
|
|
* Copyright 2007, Haiku, Inc. All rights reserved.
|
2007-07-19 21:06:28 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-10-23 17:54:44 +04:00
|
|
|
|
|
|
|
#ifndef _REGION_H
|
|
|
|
#define _REGION_H
|
|
|
|
|
|
|
|
#include <Rect.h>
|
|
|
|
|
2005-06-15 01:28:56 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
class ServerLink;
|
2006-04-01 20:56:10 +04:00
|
|
|
class LinkReceiver;
|
2005-06-15 01:28:56 +04:00
|
|
|
};
|
|
|
|
|
2006-04-01 20:56:10 +04:00
|
|
|
/* Integer rect used to define a clipping rectangle. All bounds are inclusive. */
|
2002-10-23 17:54:44 +04:00
|
|
|
/* Moved from DirectWindow.h */
|
|
|
|
typedef struct {
|
2005-06-15 01:28:56 +04:00
|
|
|
int32 left;
|
|
|
|
int32 top;
|
|
|
|
int32 right;
|
|
|
|
int32 bottom;
|
2002-10-23 17:54:44 +04:00
|
|
|
} clipping_rect;
|
|
|
|
|
|
|
|
|
|
|
|
class BRegion {
|
2009-04-10 03:47:17 +04:00
|
|
|
public:
|
2007-07-19 21:06:28 +04:00
|
|
|
BRegion();
|
|
|
|
BRegion(const BRegion& region);
|
|
|
|
BRegion(const BRect rect);
|
2009-04-21 15:26:11 +04:00
|
|
|
virtual ~BRegion();
|
2007-07-19 21:06:28 +04:00
|
|
|
|
2009-04-01 16:39:44 +04:00
|
|
|
BRegion& operator=(const BRegion& from);
|
|
|
|
bool operator==(const BRegion& other) const;
|
2007-07-19 21:06:28 +04:00
|
|
|
|
|
|
|
void Set(BRect newBounds);
|
|
|
|
void Set(clipping_rect newBounds);
|
|
|
|
|
|
|
|
BRect Frame() const;
|
|
|
|
clipping_rect FrameInt() const;
|
|
|
|
|
2008-07-28 22:50:07 +04:00
|
|
|
BRect RectAt(int32 index);
|
|
|
|
BRect RectAt(int32 index) const;
|
|
|
|
clipping_rect RectAtInt(int32 index);
|
|
|
|
clipping_rect RectAtInt(int32 index) const;
|
2007-07-19 21:06:28 +04:00
|
|
|
|
2008-07-28 22:50:07 +04:00
|
|
|
int32 CountRects();
|
|
|
|
int32 CountRects() const;
|
2007-07-19 21:06:28 +04:00
|
|
|
|
|
|
|
bool Intersects(BRect rect) const;
|
|
|
|
bool Intersects(clipping_rect rect) const;
|
|
|
|
|
|
|
|
bool Contains(BPoint point) const;
|
2008-07-28 22:50:07 +04:00
|
|
|
bool Contains(int32 x, int32 y);
|
|
|
|
bool Contains(int32 x, int32 y) const;
|
2007-07-19 21:06:28 +04:00
|
|
|
|
|
|
|
void PrintToStream() const;
|
|
|
|
|
2011-07-25 03:53:12 +04:00
|
|
|
void OffsetBy(const BPoint& point);
|
2007-07-19 21:06:28 +04:00
|
|
|
void OffsetBy(int32 x, int32 y);
|
|
|
|
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
void Include(BRect rect);
|
|
|
|
void Include(clipping_rect rect);
|
2009-04-21 15:26:11 +04:00
|
|
|
void Include(const BRegion* region);
|
2007-07-19 21:06:28 +04:00
|
|
|
|
|
|
|
void Exclude(BRect r);
|
|
|
|
void Exclude(clipping_rect r);
|
|
|
|
void Exclude(const BRegion* region);
|
|
|
|
|
|
|
|
void IntersectWith(const BRegion* region);
|
|
|
|
|
2008-01-11 16:42:21 +03:00
|
|
|
void ExclusiveInclude(const BRegion* region);
|
|
|
|
|
2009-04-10 03:47:17 +04:00
|
|
|
private:
|
2005-06-15 01:28:56 +04:00
|
|
|
friend class BDirectWindow;
|
|
|
|
friend class BPrivate::ServerLink;
|
2006-04-01 20:56:10 +04:00
|
|
|
friend class BPrivate::LinkReceiver;
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2007-07-19 21:06:28 +04:00
|
|
|
class Support;
|
|
|
|
friend class Support;
|
|
|
|
|
2009-04-10 03:47:17 +04:00
|
|
|
private:
|
2007-07-19 21:06:28 +04:00
|
|
|
BRegion(const clipping_rect& rect);
|
|
|
|
|
|
|
|
void _AdoptRegionData(BRegion& region);
|
2012-08-10 19:22:51 +04:00
|
|
|
bool _SetSize(int32 newSize);
|
2007-07-19 21:06:28 +04:00
|
|
|
|
|
|
|
clipping_rect _Convert(const BRect& rect) const;
|
|
|
|
clipping_rect _ConvertToInternal(const BRect& rect) const;
|
2007-07-19 21:16:54 +04:00
|
|
|
clipping_rect _ConvertToInternal(
|
|
|
|
const clipping_rect& rect) const;
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2009-04-10 03:47:17 +04:00
|
|
|
private:
|
2012-08-10 19:22:51 +04:00
|
|
|
int32 fCount;
|
|
|
|
int32 fDataSize;
|
2007-07-19 21:06:28 +04:00
|
|
|
clipping_rect fBounds;
|
|
|
|
clipping_rect* fData;
|
2002-10-23 17:54:44 +04:00
|
|
|
};
|
|
|
|
|
2007-07-19 21:06:28 +04:00
|
|
|
#endif // _REGION_H
|