2007-07-19 21:06:28 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2007, Haiku. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-10-23 17:54:44 +04:00
|
|
|
|
|
|
|
#ifndef _REGION_H
|
|
|
|
#define _REGION_H
|
|
|
|
|
|
|
|
#include <BeBuild.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 {
|
2007-07-19 21:06:28 +04:00
|
|
|
public:
|
|
|
|
BRegion();
|
|
|
|
BRegion(const BRegion& region);
|
|
|
|
BRegion(const BRect rect);
|
|
|
|
virtual ~BRegion();
|
|
|
|
|
|
|
|
BRegion &operator=(const BRegion &from);
|
|
|
|
|
|
|
|
void Set(BRect newBounds);
|
|
|
|
void Set(clipping_rect newBounds);
|
|
|
|
|
|
|
|
BRect Frame() const;
|
|
|
|
clipping_rect FrameInt() const;
|
|
|
|
|
|
|
|
BRect RectAt(int32 index) /*const*/;
|
|
|
|
clipping_rect RectAtInt(int32 index) /*const*/;
|
|
|
|
|
|
|
|
int32 CountRects() /*const*/;
|
|
|
|
|
|
|
|
bool Intersects(BRect rect) const;
|
|
|
|
bool Intersects(clipping_rect rect) const;
|
|
|
|
|
|
|
|
bool Contains(BPoint point) const;
|
|
|
|
bool Contains(int32 x, int32 y) /*const*/;
|
|
|
|
|
|
|
|
void PrintToStream() const;
|
|
|
|
|
|
|
|
void OffsetBy(int32 x, int32 y);
|
|
|
|
|
|
|
|
void MakeEmpty();
|
|
|
|
|
|
|
|
void Include(BRect rect);
|
|
|
|
void Include(clipping_rect rect);
|
|
|
|
void Include(const BRegion*);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2007-07-19 21:06:28 +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;
|
|
|
|
|
|
|
|
private:
|
|
|
|
BRegion(const clipping_rect& rect);
|
|
|
|
|
|
|
|
void _AdoptRegionData(BRegion& region);
|
|
|
|
bool _SetSize(long newSize);
|
|
|
|
|
|
|
|
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
|
|
|
|
2007-07-19 21:06:28 +04:00
|
|
|
private:
|
|
|
|
long fCount;
|
|
|
|
long fDataSize;
|
|
|
|
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
|