added a new header file to encapsulate compiler-specific stuff.
[newos.git] / apps / window_server / Region.h
blob19b435d5079d6dcc88c9ea83e1b535a511b45f9c
1 #ifndef _REGION_H
2 #define _REGION_H
4 #include <win/Rect.h>
5 #include "assert.h"
7 using namespace os::gui;
9 const int COORD_MAX = 0x7ffffff0;
11 class Region {
12 public:
14 Region();
15 ~Region();
16 Region(const Region&);
17 Region& Clear();
18 Region& Include(const Rect&);
19 Region& Include(const Region&);
20 Region& Exclude(const Rect&);
21 Region& Exclude(const Region&);
22 Region& Invert();
23 Region& Intersect(const Region&);
24 bool Intersects(const Rect&) const;
25 Region& Translate(int x, int y);
26 Region& ConstrainTo(const Rect&);
27 Region& SetTo(const Region&);
28 Region& operator=(const Region&);
30 const bool FindRect(int x, int y, Rect &outRect) const;
32 Rect Bounds() const;
33 inline bool Valid() const;
34 inline int CountRects() const;
35 const Rect& RectAt(int index) const;
37 void Dump() const;
39 private:
41 void AddRect(const Rect&);
42 void RemoveRect(int index);
43 void Consolidate();
45 // Assumes there are no overlaps
46 void AddRegionRects(const Region&);
48 void AllocSpace(int numRects);
50 void BeginOperation();
51 void EndOperation();
53 Rect *fRects;
54 int fNumRects;
55 int fOpLevel;
58 inline int Region::CountRects() const
60 return fNumRects;
63 inline const Rect& Region::RectAt(int index) const
65 ASSERT(index < fNumRects);
66 return fRects[index];
70 inline bool Region::Valid() const
72 return fNumRects > 0;
76 #endif