]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/region.h
FIXME: Complete stubs or other cruft necessary to make wxCocoa build
[wxWidgets.git] / include / wx / cocoa / 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 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "region.h"
17 #endif
18
19 #include "wx/list.h"
20 #include "wx/gdiobj.h"
21 #include "wx/gdicmn.h"
22
23 class WXDLLEXPORT wxRect;
24 class WXDLLEXPORT wxPoint;
25
26 enum wxRegionContain {
27 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
28 };
29
30 // So far, for internal use only
31 enum wxRegionOp {
32 wxRGN_AND, // Creates the intersection of the two combined regions.
33 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
34 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
35 wxRGN_OR, // Creates the union of two combined regions.
36 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
37 };
38
39 class WXDLLEXPORT wxRegion : public wxGDIObject {
40 DECLARE_DYNAMIC_CLASS(wxRegion);
41 friend class WXDLLEXPORT wxRegionIterator;
42 public:
43 wxRegion(long x, long y, long w, long h);
44 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
45 wxRegion(const wxRect& rect);
46 wxRegion();
47 ~wxRegion();
48
49 //# Copying
50 wxRegion(const wxRegion& r)
51 : wxGDIObject()
52 { Ref(r); }
53 wxRegion& operator = (const wxRegion& r)
54 { Ref(r); return (*this); }
55
56 //# Modify region
57 // Clear current region
58 void Clear();
59
60 // Union rectangle or region with this.
61 bool Union(long x, long y, long width, long height)
62 { return Combine(x, y, width, height, wxRGN_OR); }
63 bool Union(const wxRect& rect)
64 { return Combine(rect, wxRGN_OR); }
65 bool Union(const wxRegion& region)
66 { return Combine(region, wxRGN_OR); }
67
68 // Intersect rectangle or region with this.
69 bool Intersect(long x, long y, long width, long height)
70 { return Combine(x, y, width, height, wxRGN_AND); }
71 bool Intersect(const wxRect& rect)
72 { return Combine(rect, wxRGN_AND); }
73 bool Intersect(const wxRegion& region)
74 { return Combine(region, wxRGN_AND); }
75
76 // Subtract rectangle or region from this:
77 // Combines the parts of 'this' that are not part of the second region.
78 bool Subtract(long x, long y, long width, long height)
79 { return Combine(x, y, width, height, wxRGN_DIFF); }
80 bool Subtract(const wxRect& rect)
81 { return Combine(rect, wxRGN_DIFF); }
82 bool Subtract(const wxRegion& region)
83 { return Combine(region, wxRGN_DIFF); }
84
85 // XOR: the union of two combined regions except for any overlapping areas.
86 bool Xor(long x, long y, long width, long height)
87 { return Combine(x, y, width, height, wxRGN_XOR); }
88 bool Xor(const wxRect& rect)
89 { return Combine(rect, wxRGN_XOR); }
90 bool Xor(const wxRegion& region)
91 { return Combine(region, wxRGN_XOR); }
92
93 //# Information on region
94 // Outer bounds of region
95 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
96 wxRect GetBox() const ;
97
98 // Is region empty?
99 bool Empty() const;
100 inline bool IsEmpty() const { return Empty(); }
101
102 //# Tests
103 // Does the region contain the point (x,y)?
104 wxRegionContain Contains(long x, long y) const;
105 // Does the region contain the point pt?
106 wxRegionContain Contains(const wxPoint& pt) const;
107 // Does the region contain the rectangle (x, y, w, h)?
108 wxRegionContain Contains(long x, long y, long w, long h) const;
109 // Does the region contain the rectangle rect?
110 wxRegionContain Contains(const wxRect& rect) const;
111
112 // Internal
113 bool Combine(long x, long y, long width, long height, wxRegionOp op);
114 bool Combine(const wxRegion& region, wxRegionOp op);
115 bool Combine(const wxRect& rect, wxRegionOp op);
116 };
117
118 class WXDLLEXPORT wxRegionIterator : public wxObject
119 {
120 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
121
122 public:
123 wxRegionIterator();
124 wxRegionIterator(const wxRegion& region);
125 wxRegionIterator(const wxRegionIterator& iterator);
126 ~wxRegionIterator();
127
128 wxRegionIterator& operator=(const wxRegionIterator& iterator);
129
130 void Reset() { m_current = 0; }
131 void Reset(const wxRegion& region);
132
133 operator bool () const { return m_current < m_numRects; }
134 bool HaveRects() const { return m_current < m_numRects; }
135
136 wxRegionIterator& operator++();
137 wxRegionIterator operator++(int);
138
139 long GetX() const;
140 long GetY() const;
141 long GetW() const;
142 long GetWidth() const { return GetW(); }
143 long GetH() const;
144 long GetHeight() const { return GetH(); }
145 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
146 private:
147 void SetRects(long numRects, wxRect *rects);
148
149 long m_current;
150 long m_numRects;
151 wxRegion m_region;
152 wxRect* m_rects;
153 };
154
155 #endif
156 // _WX_REGION_H_