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