]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/region.h
replaced unnecessary #include with a forward decl
[wxWidgets.git] / include / wx / msw / region.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
5549e9f7 2// Name: wx/msw/region.h
2bda0e17
KB
3// Purpose: wxRegion class
4// Author: Markus Holzem, Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
5549e9f7 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
2bda0e17
KB
14
15#ifdef __GNUG__
16#pragma interface "region.h"
17#endif
18
19#include "wx/list.h"
20#include "wx/gdiobj.h"
2432b92d 21#include "wx/gdicmn.h"
2bda0e17
KB
22
23class WXDLLEXPORT wxRect;
24class WXDLLEXPORT wxPoint;
25
5549e9f7
VZ
26enum wxRegionContain
27{
28 wxOutRegion = 0,
29 wxPartRegion = 1,
30 wxInRegion = 2
2bda0e17
KB
31};
32
33// So far, for internal use only
5549e9f7
VZ
34enum wxRegionOp
35{
36 wxRGN_AND, // Creates the intersection of the two combined regions.
37 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
38 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
39 wxRGN_OR, // Creates the union of two combined regions.
40 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
2bda0e17
KB
41};
42
5549e9f7
VZ
43class WXDLLEXPORT wxRegion : public wxGDIObject
44{
2bda0e17 45public:
5549e9f7 46 wxRegion();
9b1801c1 47 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
2bda0e17
KB
48 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
49 wxRegion(const wxRect& rect);
81d66cf3 50 wxRegion(WXHRGN hRegion); // Hangs on to this region
5549e9f7 51 wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
2bda0e17 52
5549e9f7 53 virtual ~wxRegion();
2bda0e17 54
5549e9f7
VZ
55 // Copying
56 wxRegion(const wxRegion& r)
57 { Ref(r); }
58 wxRegion& operator = (const wxRegion& r)
59 { Ref(r); return (*this); }
2bda0e17 60
5549e9f7 61 // Modify region
0fb067bb
VZ
62 // -------------
63
5549e9f7 64 // Clear current region
0fb067bb
VZ
65 void Clear();
66
67 // Move the region
68 bool Offset(wxCoord x, wxCoord y);
2bda0e17 69
5549e9f7 70 // Union rectangle or region with this.
0fb067bb
VZ
71 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
72 bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
73 bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
2bda0e17 74
5549e9f7 75 // Intersect rectangle or region with this.
0fb067bb
VZ
76 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
77 bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
78 bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
2bda0e17 79
5549e9f7 80 // Subtract rectangle or region from this:
2bda0e17 81 // Combines the parts of 'this' that are not part of the second region.
0fb067bb
VZ
82 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
83 bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
84 bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
5549e9f7
VZ
85
86 // XOR: the union of two combined regions except for any overlapping areas.
0fb067bb
VZ
87 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
88 bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
89 bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
5549e9f7
VZ
90
91 // Information on region
0fb067bb
VZ
92 // ---------------------
93
5549e9f7
VZ
94 // Outer bounds of region
95 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
96 wxRect GetBox(void) const ;
97
98 // Is region empty?
99 bool Empty(void) const;
2bda0e17
KB
100 inline bool IsEmpty(void) const { return Empty(); }
101
5549e9f7
VZ
102 // Tests
103 // Does the region contain the point (x,y)?
104 wxRegionContain Contains(wxCoord x, wxCoord 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(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
109 // Does the region contain the rectangle rect?
110 wxRegionContain Contains(const wxRect& rect) const;
2bda0e17
KB
111
112// Internal
5549e9f7
VZ
113 bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
114 bool Combine(const wxRegion& region, wxRegionOp op);
115 bool Combine(const wxRect& rect, wxRegionOp op);
a724d789
JS
116
117 // Get internal region handle
118 WXHRGN GetHRGN() const;
5549e9f7 119
0fb067bb 120protected:
02576308 121 virtual wxObjectRefData *CreateRefData() const;
b8027888 122 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
0fb067bb 123
5549e9f7 124 friend class WXDLLEXPORT wxRegionIterator;
0fb067bb
VZ
125
126 DECLARE_DYNAMIC_CLASS(wxRegion)
2bda0e17
KB
127};
128
5549e9f7
VZ
129class WXDLLEXPORT wxRegionIterator : public wxObject
130{
2bda0e17 131public:
5549e9f7
VZ
132 wxRegionIterator(void);
133 wxRegionIterator(const wxRegion& region);
134 ~wxRegionIterator(void);
2bda0e17 135
5549e9f7
VZ
136 void Reset(void) { m_current = 0; }
137 void Reset(const wxRegion& region);
2bda0e17 138
a3ef5bf5 139#ifndef __SALFORDC__
5549e9f7 140 operator bool (void) const { return (m_current < m_numRects); }
a3ef5bf5
JS
141#endif
142
5549e9f7 143 bool HaveRects(void) const { return (m_current < m_numRects); }
2bda0e17 144
5549e9f7
VZ
145 void operator ++ (void);
146 void operator ++ (int);
2bda0e17 147
5549e9f7
VZ
148 wxCoord GetX(void) const;
149 wxCoord GetY(void) const;
150 wxCoord GetW(void) const;
151 wxCoord GetWidth(void) const { return GetW(); }
152 wxCoord GetH(void) const;
153 wxCoord GetHeight(void) const { return GetH(); }
3572173c 154 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
2bda0e17
KB
155
156private:
5549e9f7
VZ
157 long m_current;
158 long m_numRects;
159 wxRegion m_region;
2bda0e17 160 wxRect* m_rects;
5549e9f7
VZ
161
162 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
2bda0e17
KB
163};
164
165#endif
5549e9f7 166 // _WX_REGION_H_