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