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 private: 70 friend class BDirectWindow; 71 friend class BPrivate::ServerLink; 72 friend class BPrivate::LinkReceiver; 73 74 class Support; 75 friend class Support; 76 77 private: 78 BRegion(const clipping_rect& rect); 79 80 void _AdoptRegionData(BRegion& region); 81 bool _SetSize(long newSize); 82 83 clipping_rect _Convert(const BRect& rect) const; 84 clipping_rect _ConvertToInternal(const BRect& rect) const; 85 clipping_rect _ConvertToInternal( 86 const clipping_rect& rect) const; 87 88 private: 89 long fCount; 90 long fDataSize; 91 clipping_rect fBounds; 92 clipping_rect* fData; 93 }; 94 95 #endif // _REGION_H 96