]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/region.h
added a couple of base classes
[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
c801d85f 27// So far, for internal use only
1e6feb95 28enum wxRegionOp
e1208c31
RR
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.
c801d85f
KB
35};
36
1e6feb95 37// ----------------------------------------------------------------------------
c801d85f 38// wxRegion
1e6feb95 39// ----------------------------------------------------------------------------
c801d85f 40
20123d49 41class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
c801d85f 42{
e1208c31 43public:
9fe4c99c 44 wxRegion() { }
1542ea39 45
9fe4c99c
VZ
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 );
1542ea39 63
85f6b408
VS
64 wxRegion( const wxBitmap& bmp)
65 {
66 Union(bmp);
67 }
1542ea39 68 wxRegion( const wxBitmap& bmp,
85f6b408 69 const wxColour& transColour, int tolerance = 0)
1542ea39
RD
70 {
71 Union(bmp, transColour, tolerance);
72 }
73
c89f5c02 74 ~wxRegion();
c801d85f 75
c89f5c02 76 bool Ok() const { return m_refData != NULL; }
c801d85f 77
fbfb8bcc
VZ
78 bool operator == ( const wxRegion& region ) const;
79 bool operator != ( const wxRegion& region ) const { return !(*this == region); }
5fc7ede9 80
07818da8 81 void Clear();
9fe4c99c 82
35917d22 83 bool Offset( wxCoord x, wxCoord y );
c801d85f 84
5fc7ede9 85 bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
86 bool Union( const wxRect& rect );
87 bool Union( const wxRegion& region );
88
5fc7ede9 89 bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
90 bool Intersect( const wxRect& rect );
91 bool Intersect( const wxRegion& region );
92
5fc7ede9 93 bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
94 bool Subtract( const wxRect& rect );
95 bool Subtract( const wxRegion& region );
96
5fc7ede9 97 bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
c801d85f
KB
98 bool Xor( const wxRect& rect );
99 bool Xor( const wxRegion& region );
100
5fc7ede9 101 void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
07818da8 102 wxRect GetBox() const ;
c801d85f 103
07818da8
VZ
104 bool Empty() const;
105 bool IsEmpty() const { return Empty(); }
c801d85f 106
5fc7ede9
VZ
107 wxRegionContain Contains( wxCoord x, wxCoord y ) const;
108 wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
8429bec1
RR
109 wxRegionContain Contains(const wxPoint& pt) const;
110 wxRegionContain Contains(const wxRect& rect) const;
5fc7ede9 111
819451b6 112 // Convert the region to a B&W bitmap with the white pixels being inside
1542ea39
RD
113 // the region.
114 wxBitmap ConvertToBitmap() const;
115
116 // Use the non-transparent pixels of a wxBitmap for the region to combine
85f6b408
VS
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
1542ea39 119 // along with an optional tolerance value.
85f6b408
VS
120 // NOTE: implemented in common/rgncmn.cpp
121 bool Union(const wxBitmap& bmp);
1542ea39 122 bool Union(const wxBitmap& bmp,
85f6b408 123 const wxColour& transColour, int tolerance = 0);
1542ea39
RD
124
125
e1208c31 126public:
331a0b6b
RR
127 // Init with GdkRegion, set ref count to 2 so that
128 // the C++ class will not destroy the region!
129 wxRegion( GdkRegion *region );
1542ea39 130
07818da8 131 GdkRegion *GetRegion() const;
1e6feb95
VZ
132
133protected:
e0f0b197
RR
134 // ref counting code
135 virtual wxObjectRefData *CreateRefData() const;
136 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
1542ea39 137
9fe4c99c
VZ
138 // common part of ctors for a rectangle region
139 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
140
e1208c31 141private:
777105f2 142 DECLARE_DYNAMIC_CLASS(wxRegion)
c801d85f
KB
143};
144
1e6feb95
VZ
145// ----------------------------------------------------------------------------
146// wxRegionIterator: decomposes a region into rectangles
147// ----------------------------------------------------------------------------
148
20123d49 149class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
8429bec1 150{
738f9e5a 151public:
07818da8 152 wxRegionIterator();
8429bec1
RR
153 wxRegionIterator(const wxRegion& region);
154
6f2a55e3 155 void Reset() { m_current = 0u; }
8429bec1
RR
156 void Reset(const wxRegion& region);
157
07818da8 158 bool HaveRects() const;
2b5f62a0 159 operator bool () const { return HaveRects(); }
8429bec1 160
2b5f62a0
VZ
161 wxRegionIterator& operator ++ ();
162 wxRegionIterator operator ++ (int);
8429bec1 163
b02da6b1
VZ
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(); }
1e6feb95 170 wxRect GetRect() const;
8429bec1 171
738f9e5a 172private:
6f2a55e3
VZ
173 size_t m_current;
174 wxRegion m_region;
738f9e5a
RR
175
176private:
777105f2 177 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
8429bec1
RR
178};
179
180
c801d85f 181#endif
5fc7ede9 182 // _WX_GTK_REGION_H_