]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/region.h
wxProp now intercepts EVT_TEXT_ENTER instead of EVT_TEXT
[wxWidgets.git] / include / wx / msw / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose: wxRegion class
4 // Author: Markus Holzem, Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
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(WXHRGN hRegion); // Hangs on to this region
46
47 wxRegion(void);
48 ~wxRegion(void);
49
50 //# Copying
51 inline wxRegion(const wxRegion& r)
52 { Ref(r); }
53 inline wxRegion& operator = (const wxRegion& r)
54 { Ref(r); return (*this); }
55
56 //# Modify region
57 // Clear current region
58 void Clear(void);
59
60 // Union rectangle or region with this.
61 inline bool Union(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_OR); }
62 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
63 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
64
65 // Intersect rectangle or region with this.
66 inline bool Intersect(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_AND); }
67 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
68 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
69
70 // Subtract rectangle or region from this:
71 // Combines the parts of 'this' that are not part of the second region.
72 inline bool Subtract(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_DIFF); }
73 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
74 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
75
76 // XOR: the union of two combined regions except for any overlapping areas.
77 inline bool Xor(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_XOR); }
78 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
79 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
80
81 //# Information on region
82 // Outer bounds of region
83 void GetBox(long& x, long& y, long&w, long &h) const;
84 wxRect GetBox(void) const ;
85
86 // Is region empty?
87 bool Empty(void) const;
88 inline bool IsEmpty(void) const { return Empty(); }
89
90 //# Tests
91 // Does the region contain the point (x,y)?
92 wxRegionContain Contains(long x, long y) const;
93 // Does the region contain the point pt?
94 wxRegionContain Contains(const wxPoint& pt) const;
95 // Does the region contain the rectangle (x, y, w, h)?
96 wxRegionContain Contains(long x, long y, long w, long h) const;
97 // Does the region contain the rectangle rect?
98 wxRegionContain Contains(const wxRect& rect) const;
99
100 // Internal
101 bool Combine(long x, long y, long width, long height, wxRegionOp op);
102 bool Combine(const wxRegion& region, wxRegionOp op);
103 bool Combine(const wxRect& rect, wxRegionOp op);
104 };
105
106 class WXDLLEXPORT wxRegionIterator : public wxObject {
107 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
108 public:
109 wxRegionIterator(void);
110 wxRegionIterator(const wxRegion& region);
111 ~wxRegionIterator(void);
112
113 void Reset(void) { m_current = 0; }
114 void Reset(const wxRegion& region);
115
116 operator bool (void) const { return m_current < m_numRects; }
117 bool HaveRects(void) const { return m_current < m_numRects; }
118
119 void operator ++ (void);
120 void operator ++ (int);
121
122 long GetX(void) const;
123 long GetY(void) const;
124 long GetW(void) const;
125 long GetWidth(void) const { return GetW(); }
126 long GetH(void) const;
127 long GetHeight(void) const { return GetH(); }
128
129 private:
130 long m_current;
131 long m_numRects;
132 wxRegion m_region;
133 wxRect* m_rects;
134 };
135
136 #endif
137 // _WX_REGION_H_