]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/region.h
#undef Yield
[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
VZ
61 // Modify region
62 // Clear current region
63 void Clear(void);
2bda0e17 64
5549e9f7
VZ
65 // Union rectangle or region with this.
66 inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
67 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
68 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
2bda0e17 69
5549e9f7
VZ
70 // Intersect rectangle or region with this.
71 inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
72 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
73 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
2bda0e17 74
5549e9f7 75 // Subtract rectangle or region from this:
2bda0e17 76 // Combines the parts of 'this' that are not part of the second region.
5549e9f7
VZ
77 inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
78 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
79 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
80
81 // XOR: the union of two combined regions except for any overlapping areas.
82 inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
83 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
84 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
85
86 // Information on region
87 // Outer bounds of region
88 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
89 wxRect GetBox(void) const ;
90
91 // Is region empty?
92 bool Empty(void) const;
2bda0e17
KB
93 inline bool IsEmpty(void) const { return Empty(); }
94
5549e9f7
VZ
95 // Tests
96 // Does the region contain the point (x,y)?
97 wxRegionContain Contains(wxCoord x, wxCoord y) const;
98 // Does the region contain the point pt?
99 wxRegionContain Contains(const wxPoint& pt) const;
100 // Does the region contain the rectangle (x, y, w, h)?
101 wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
102 // Does the region contain the rectangle rect?
103 wxRegionContain Contains(const wxRect& rect) const;
2bda0e17
KB
104
105// Internal
5549e9f7
VZ
106 bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
107 bool Combine(const wxRegion& region, wxRegionOp op);
108 bool Combine(const wxRect& rect, wxRegionOp op);
a724d789
JS
109
110 // Get internal region handle
111 WXHRGN GetHRGN() const;
5549e9f7
VZ
112
113 DECLARE_DYNAMIC_CLASS(wxRegion);
114 friend class WXDLLEXPORT wxRegionIterator;
2bda0e17
KB
115};
116
5549e9f7
VZ
117class WXDLLEXPORT wxRegionIterator : public wxObject
118{
2bda0e17 119public:
5549e9f7
VZ
120 wxRegionIterator(void);
121 wxRegionIterator(const wxRegion& region);
122 ~wxRegionIterator(void);
2bda0e17 123
5549e9f7
VZ
124 void Reset(void) { m_current = 0; }
125 void Reset(const wxRegion& region);
2bda0e17 126
a3ef5bf5 127#ifndef __SALFORDC__
5549e9f7 128 operator bool (void) const { return (m_current < m_numRects); }
a3ef5bf5
JS
129#endif
130
5549e9f7 131 bool HaveRects(void) const { return (m_current < m_numRects); }
2bda0e17 132
5549e9f7
VZ
133 void operator ++ (void);
134 void operator ++ (int);
2bda0e17 135
5549e9f7
VZ
136 wxCoord GetX(void) const;
137 wxCoord GetY(void) const;
138 wxCoord GetW(void) const;
139 wxCoord GetWidth(void) const { return GetW(); }
140 wxCoord GetH(void) const;
141 wxCoord GetHeight(void) const { return GetH(); }
3572173c 142 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
2bda0e17
KB
143
144private:
5549e9f7
VZ
145 long m_current;
146 long m_numRects;
147 wxRegion m_region;
2bda0e17 148 wxRect* m_rects;
5549e9f7
VZ
149
150 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
2bda0e17
KB
151};
152
153#endif
5549e9f7 154 // _WX_REGION_H_