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