]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/region.h
removed obsolete build files which are likely to confuse more than help people now
[wxWidgets.git] / include / wx / x11 / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose: wxRegion class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_REGION_H_
13 #define _WX_REGION_H_
14
15 #include "wx/list.h"
16 #include "wx/gdiobj.h"
17 #include "wx/gdicmn.h"
18
19 //-----------------------------------------------------------------------------
20 // classes
21 //-----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE wxRegion;
24
25 //-----------------------------------------------------------------------------
26 // constants
27 //-----------------------------------------------------------------------------
28
29 // So far, for internal use only
30 enum wxRegionOp
31 {
32 wxRGN_AND, // Creates the intersection of the two combined regions.
33 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
34 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
35 wxRGN_OR, // Creates the union of two combined regions.
36 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
37 };
38
39 // ----------------------------------------------------------------------------
40 // wxRegion
41 // ----------------------------------------------------------------------------
42
43 class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
44 {
45 public:
46 wxRegion() { }
47
48 wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
49 {
50 InitRect(x, y, w, h);
51 }
52
53 wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight )
54 {
55 InitRect(topLeft.x, topLeft.y,
56 bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
57 }
58
59 wxRegion( const wxRect& rect )
60 {
61 InitRect(rect.x, rect.y, rect.width, rect.height);
62 }
63
64 wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
65
66 wxRegion( const wxBitmap& bmp)
67 {
68 Union(bmp);
69 }
70 wxRegion( const wxBitmap& bmp,
71 const wxColour& transColour, int tolerance = 0)
72 {
73 Union(bmp, transColour, tolerance);
74 }
75
76 ~wxRegion();
77
78 bool Ok() const { return m_refData != NULL; }
79
80 bool operator == ( const wxRegion& region ) const;
81 bool operator != ( const wxRegion& region ) const { return !(*this == region); }
82
83 void Clear();
84
85 bool Offset( wxCoord x, wxCoord y );
86
87 bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
88 bool Union( const wxRect& rect );
89 bool Union( const wxRegion& region );
90
91 bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
92 bool Intersect( const wxRect& rect );
93 bool Intersect( const wxRegion& region );
94
95 bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
96 bool Subtract( const wxRect& rect );
97 bool Subtract( const wxRegion& region );
98
99 bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
100 bool Xor( const wxRect& rect );
101 bool Xor( const wxRegion& region );
102
103 void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
104 wxRect GetBox() const ;
105
106 bool Empty() const;
107 bool IsEmpty() const { return Empty(); }
108
109 wxRegionContain Contains( wxCoord x, wxCoord y ) const;
110 wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
111 wxRegionContain Contains(const wxPoint& pt) const;
112 wxRegionContain Contains(const wxRect& rect) const;
113
114 // Convert the region to a B&W bitmap with the white pixels being inside
115 // the region.
116 wxBitmap ConvertToBitmap() const;
117
118 // Use the non-transparent pixels of a wxBitmap for the region to combine
119 // with this region. First version takes transparency from bitmap's mask,
120 // second lets the user specify the colour to be treated as transparent
121 // along with an optional tolerance value.
122 // NOTE: implemented in common/rgncmn.cpp
123 bool Union(const wxBitmap& bmp);
124 bool Union(const wxBitmap& bmp,
125 const wxColour& transColour, int tolerance = 0);
126
127
128 public:
129 WXRegion *GetX11Region() const;
130
131 protected:
132 // ref counting code
133 virtual wxObjectRefData *CreateRefData() const;
134 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
135
136 // common part of ctors for a rectangle region
137 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
138
139 private:
140 DECLARE_DYNAMIC_CLASS(wxRegion)
141 };
142
143 // ----------------------------------------------------------------------------
144 // wxRegionIterator: decomposes a region into rectangles
145 // ----------------------------------------------------------------------------
146
147 class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
148 {
149 public:
150 wxRegionIterator();
151 wxRegionIterator(const wxRegion& region);
152
153 void Reset() { m_current = 0u; }
154 void Reset(const wxRegion& region);
155
156 operator bool () const;
157 bool HaveRects() const;
158
159 void operator ++ ();
160 void operator ++ (int);
161
162 wxCoord GetX() const;
163 wxCoord GetY() const;
164 wxCoord GetW() const;
165 wxCoord GetWidth() const { return GetW(); }
166 wxCoord GetH() const;
167 wxCoord GetHeight() const { return GetH(); }
168 wxRect GetRect() const;
169
170 private:
171 size_t m_current;
172 wxRegion m_region;
173
174 private:
175 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
176 };
177
178 #endif
179 // _WX_REGION_H_