]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/region.h
cleanup - fixed warnings, reformatting
[wxWidgets.git] / include / wx / gtk1 / region.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
8ef94bfc 2// Name: wx/gtk1/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
c89f5c02 83 bool Ok() const { return m_refData != NULL; }
c801d85f 84
fbfb8bcc
VZ
85 bool operator == ( const wxRegion& region ) const;
86 bool operator != ( const wxRegion& region ) const { return !(*this == region); }
5fc7ede9 87
07818da8 88 void Clear();
9fe4c99c 89
35917d22 90 bool Offset( wxCoord x, wxCoord y );
c801d85f 91
5fc7ede9 92 bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
93 bool Union( const wxRect& rect );
94 bool Union( const wxRegion& region );
95
5fc7ede9 96 bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
97 bool Intersect( const wxRect& rect );
98 bool Intersect( const wxRegion& region );
99
5fc7ede9 100 bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
101 bool Subtract( const wxRect& rect );
102 bool Subtract( const wxRegion& region );
103
5fc7ede9 104 bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
105 bool Xor( const wxRect& rect );
106 bool Xor( const wxRegion& region );
107
5fc7ede9 108 void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
07818da8 109 wxRect GetBox() const ;
c801d85f 110
07818da8
VZ
111 bool Empty() const;
112 bool IsEmpty() const { return Empty(); }
c801d85f 113
5fc7ede9
VZ
114 wxRegionContain Contains( wxCoord x, wxCoord y ) const;
115 wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
8429bec1
RR
116 wxRegionContain Contains(const wxPoint& pt) const;
117 wxRegionContain Contains(const wxRect& rect) const;
5fc7ede9 118
819451b6 119 // Convert the region to a B&W bitmap with the white pixels being inside
1542ea39
RD
120 // the region.
121 wxBitmap ConvertToBitmap() const;
122
123 // Use the non-transparent pixels of a wxBitmap for the region to combine
85f6b408
VS
124 // with this region. First version takes transparency from bitmap's mask,
125 // second lets the user specify the colour to be treated as transparent
1542ea39 126 // along with an optional tolerance value.
85f6b408
VS
127 // NOTE: implemented in common/rgncmn.cpp
128 bool Union(const wxBitmap& bmp);
1542ea39 129 bool Union(const wxBitmap& bmp,
85f6b408 130 const wxColour& transColour, int tolerance = 0);
1542ea39
RD
131
132
e1208c31 133public:
331a0b6b
RR
134 // Init with GdkRegion, set ref count to 2 so that
135 // the C++ class will not destroy the region!
136 wxRegion( GdkRegion *region );
1542ea39 137
07818da8 138 GdkRegion *GetRegion() const;
1e6feb95
VZ
139
140protected:
e0f0b197
RR
141 // ref counting code
142 virtual wxObjectRefData *CreateRefData() const;
143 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
1542ea39 144
9fe4c99c
VZ
145 // common part of ctors for a rectangle region
146 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
147
e1208c31 148private:
777105f2 149 DECLARE_DYNAMIC_CLASS(wxRegion)
c801d85f
KB
150};
151
1e6feb95
VZ
152// ----------------------------------------------------------------------------
153// wxRegionIterator: decomposes a region into rectangles
154// ----------------------------------------------------------------------------
155
20123d49 156class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
8429bec1 157{
738f9e5a 158public:
07818da8 159 wxRegionIterator();
8429bec1
RR
160 wxRegionIterator(const wxRegion& region);
161
6f2a55e3 162 void Reset() { m_current = 0u; }
8429bec1
RR
163 void Reset(const wxRegion& region);
164
07818da8 165 bool HaveRects() const;
2b5f62a0 166 operator bool () const { return HaveRects(); }
8429bec1 167
2b5f62a0
VZ
168 wxRegionIterator& operator ++ ();
169 wxRegionIterator operator ++ (int);
8429bec1 170
b02da6b1
VZ
171 wxCoord GetX() const;
172 wxCoord GetY() const;
173 wxCoord GetW() const;
174 wxCoord GetWidth() const { return GetW(); }
175 wxCoord GetH() const;
176 wxCoord GetHeight() const { return GetH(); }
1e6feb95 177 wxRect GetRect() const;
8429bec1 178
738f9e5a 179private:
6f2a55e3
VZ
180 size_t m_current;
181 wxRegion m_region;
738f9e5a
RR
182
183private:
777105f2 184 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
8429bec1
RR
185};
186
187
c801d85f 188#endif
5fc7ede9 189 // _WX_GTK_REGION_H_