1 /* 2 * Copyright 2007, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _REGION_H 7 #define _REGION_H 8 9 #include <Rect.h> 10 11 namespace BPrivate { 12 class ServerLink; 13 class LinkReceiver; 14 }; 15 16 /* Integer rect used to define a clipping rectangle. All bounds are inclusive. */ 17 /* Moved from DirectWindow.h */ 18 typedef struct { 19 int32 left; 20 int32 top; 21 int32 right; 22 int32 bottom; 23 } clipping_rect; 24 25 26 class BRegion { 27 public: 28 BRegion(); 29 BRegion(const BRegion& region); 30 BRegion(const BRect rect); 31 virtual ~BRegion(); 32 33 BRegion& operator=(const BRegion& from); 34 bool operator==(const BRegion& other) const; 35 36 void Set(BRect newBounds); 37 void Set(clipping_rect newBounds); 38 39 BRect Frame() const; 40 clipping_rect FrameInt() const; 41 42 BRect RectAt(int32 index); 43 BRect RectAt(int32 index) const; 44 clipping_rect RectAtInt(int32 index); 45 clipping_rect RectAtInt(int32 index) const; 46 47 int32 CountRects(); 48 int32 CountRects() const; 49 50 bool Intersects(BRect rect) const; 51 bool Intersects(clipping_rect rect) const; 52 53 bool Contains(BPoint point) const; 54 bool Contains(int32 x, int32 y); 55 bool Contains(int32 x, int32 y) const; 56 57 void PrintToStream() const; 58 59 void OffsetBy(const BPoint& point); 60 void OffsetBy(int32 x, int32 y); 61 62 void MakeEmpty(); 63 64 void Include(BRect rect); 65 void Include(clipping_rect rect); 66 void Include(const BRegion* region); 67 68 void Exclude(BRect r); 69 void Exclude(clipping_rect r); 70 void Exclude(const BRegion* region); 71 72 void IntersectWith(const BRegion* region); 73 74 void ExclusiveInclude(const BRegion* region); 75 76 private: 77 friend class BDirectWindow; 78 friend class BPrivate::ServerLink; 79 friend class BPrivate::LinkReceiver; 80 81 class Support; 82 friend class Support; 83 84 private: 85 BRegion(const clipping_rect& rect); 86 87 void _AdoptRegionData(BRegion& region); 88 bool _SetSize(int32 newSize); 89 90 clipping_rect _Convert(const BRect& rect) const; 91 clipping_rect _ConvertToInternal(const BRect& rect) const; 92 clipping_rect _ConvertToInternal( 93 const clipping_rect& rect) const; 94 95 private: 96 int32 fCount; 97 int32 fDataSize; 98 clipping_rect fBounds; 99 clipping_rect* fData; 100 }; 101 102 #endif // _REGION_H 103