]> git.saurik.com Git - wxWidgets.git/blob - include/wx/stubs/region.h
Added configure option --with-dmalloc to use the dmalloc memory debugging library.
[wxWidgets.git] / include / wx / stubs / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose: wxRegion class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_REGION_H_
13 #define _WX_REGION_H_
14
15 #ifdef __GNUG__
16 #pragma interface "region.h"
17 #endif
18
19 #include "wx/list.h"
20 #include "wx/gdiobj.h"
21
22 class WXDLLEXPORT wxRect;
23 class WXDLLEXPORT wxPoint;
24
25 enum wxRegionContain {
26 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
27 };
28
29 // So far, for internal use only
30 enum wxRegionOp {
31 wxRGN_AND, // Creates the intersection of the two combined regions.
32 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
33 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
34 wxRGN_OR, // Creates the union of two combined regions.
35 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
36 };
37
38 class WXDLLEXPORT wxRegion : public wxGDIObject {
39 DECLARE_DYNAMIC_CLASS(wxRegion);
40 friend class WXDLLEXPORT wxRegionIterator;
41 public:
42 wxRegion(long x, long y, long w, long h);
43 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
44 wxRegion(const wxRect& rect);
45 wxRegion();
46 ~wxRegion();
47
48 //# Copying
49 inline wxRegion(const wxRegion& r)
50 { Ref(r); }
51 inline wxRegion& operator = (const wxRegion& r)
52 { Ref(r); return (*this); }
53
54 //# Modify region
55 // Clear current region
56 void Clear();
57
58 // Union rectangle or region with this.
59 inline bool Union(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_OR); }
60 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
61 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
62
63 // Intersect rectangle or region with this.
64 inline bool Intersect(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_AND); }
65 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
66 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
67
68 // Subtract rectangle or region from this:
69 // Combines the parts of 'this' that are not part of the second region.
70 inline bool Subtract(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_DIFF); }
71 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
72 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
73
74 // XOR: the union of two combined regions except for any overlapping areas.
75 inline bool Xor(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_XOR); }
76 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
77 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
78
79 //# Information on region
80 // Outer bounds of region
81 void GetBox(long& x, long& y, long&w, long &h) const;
82 wxRect GetBox() const ;
83
84 // Is region empty?
85 bool Empty() const;
86 inline bool IsEmpty() const { return Empty(); }
87
88 //# Tests
89 // Does the region contain the point (x,y)?
90 wxRegionContain Contains(long x, long y) const;
91 // Does the region contain the point pt?
92 wxRegionContain Contains(const wxPoint& pt) const;
93 // Does the region contain the rectangle (x, y, w, h)?
94 wxRegionContain Contains(long x, long y, long w, long h) const;
95 // Does the region contain the rectangle rect?
96 wxRegionContain Contains(const wxRect& rect) const;
97
98 // Internal
99 bool Combine(long x, long y, long width, long height, wxRegionOp op);
100 bool Combine(const wxRegion& region, wxRegionOp op);
101 bool Combine(const wxRect& rect, wxRegionOp op);
102 };
103
104 class WXDLLEXPORT wxRegionIterator : public wxObject {
105 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
106 public:
107 wxRegionIterator();
108 wxRegionIterator(const wxRegion& region);
109 ~wxRegionIterator();
110
111 void Reset() { m_current = 0; }
112 void Reset(const wxRegion& region);
113
114 operator bool () const { return m_current < m_numRects; }
115 bool HaveRects() const { return m_current < m_numRects; }
116
117 void operator ++ ();
118 void operator ++ (int);
119
120 long GetX() const;
121 long GetY() const;
122 long GetW() const;
123 long GetWidth() const { return GetW(); }
124 long GetH() const;
125 long GetHeight() const { return GetH(); }
126
127 private:
128 long m_current;
129 long m_numRects;
130 wxRegion m_region;
131 wxRect* m_rects;
132 };
133
134 #endif
135 // _WX_REGION_H_