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