]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mgl/region.h
Some updates to the MSW install text
[wxWidgets.git] / include / wx / mgl / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose: wxRegion class
4 // Author: Vaclav Slavik
5 // Created: 2001/03/12
6 // RCS-ID: $Id$
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_REGION_H_
12 #define _WX_REGION_H_
13
14 #ifdef __GNUG__
15 #pragma interface "region.h"
16 #endif
17
18 #include "wx/list.h"
19 #include "wx/gdiobj.h"
20 #include "wx/gdicmn.h"
21 #include "wx/list.h"
22
23 class WXDLLEXPORT wxRect;
24 class WXDLLEXPORT wxPoint;
25 class MGLRegion;
26
27 enum wxRegionContain
28 {
29 wxOutRegion = 0,
30 wxPartRegion = 1,
31 wxInRegion = 2
32 };
33
34 class WXDLLEXPORT wxRegion : public wxGDIObject
35 {
36 DECLARE_DYNAMIC_CLASS(wxRegion);
37 friend class WXDLLEXPORT wxRegionIterator;
38
39 public:
40 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
41 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
42 wxRegion(const wxRect& rect);
43 wxRegion(const MGLRegion& region);
44
45 wxRegion();
46 ~wxRegion();
47
48 //# Copying
49 inline wxRegion(const wxRegion& r)
50 { Ref(r); }
51 inline wxRegion& operator = (const wxRegion& r)
52 { Ref(r); return (*this); }
53
54 //# Modify region
55 // Clear current region
56 void Clear(void);
57
58 // Union rectangle or region with this.
59 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
60 bool Union(const wxRect& rect) { return Union(rect.x, rect.y, rect.width, rect.height); }
61 bool Union(const wxRegion& region);
62
63 // Intersect rectangle or region with this.
64 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
65 bool Intersect(const wxRect& rect) { return Intersect(rect.x, rect.y, rect.width, rect.height); }
66 bool Intersect(const wxRegion& region);
67
68 // Subtract rectangle or region from this:
69 // Combines the parts of 'this' that are not part of the second region.
70 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
71 bool Subtract(const wxRect& rect) { return Subtract(rect.x, rect.y, rect.width, rect.height); }
72 bool Subtract(const wxRegion& region);
73
74 // XOR: the union of two combined regions except for any overlapping areas.
75 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
76 bool Xor(const wxRect& rect) { return Xor(rect.x, rect.y, rect.width, rect.height); }
77 bool Xor(const wxRegion& region);
78
79 //# Information on region
80 // Outer bounds of region
81 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
82 wxRect GetBox(void) const ;
83
84 // Is region empty?
85 bool Empty(void) const;
86 inline bool IsEmpty(void) const { return Empty(); }
87
88 //# Tests
89 // Does the region contain the point (x,y)?
90 wxRegionContain Contains(wxCoord x, wxCoord y) const;
91 // Does the region contain the point pt?
92 wxRegionContain Contains(const wxPoint& pt) const;
93 // Does the region contain the rectangle (x, y, w, h)?
94 wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
95 // Does the region contain the rectangle rect?
96 wxRegionContain Contains(const wxRect& rect) const;
97
98 // implementation from now on:
99 const MGLRegion& GetMGLRegion() const;
100
101 private:
102 void Unshare();
103 };
104
105
106 WX_DECLARE_EXPORTED_LIST(wxRect, wxRegionRectList);
107
108 class WXDLLEXPORT wxRegionIterator : public wxObject
109 {
110 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
111 public:
112 wxRegionIterator(void);
113 wxRegionIterator(const wxRegion& region);
114 ~wxRegionIterator(void);
115
116 void Reset(void) { m_currentNode = NULL; }
117 void Reset(const wxRegion& region);
118
119 #ifndef __SALFORDC__
120 operator bool (void) const { return (m_currentNode != NULL); }
121 #endif
122
123 bool HaveRects(void) const { return (m_currentNode != NULL); }
124
125 void operator ++ (void);
126 void operator ++ (int);
127
128 wxCoord GetX(void) const;
129 wxCoord GetY(void) const;
130 wxCoord GetW(void) const;
131 wxCoord GetWidth(void) const { return GetW(); }
132 wxCoord GetH(void) const;
133 wxCoord GetHeight(void) const { return GetH(); }
134 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
135
136 private:
137 wxRegionRectList m_rects;
138 wxRegionRectList::Node *m_currentNode;
139 };
140
141 #endif
142 // _WX_REGION_H_