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