]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/region.h
synchronize GTK2 minimum version in docs
[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
9dc44eff
PC
13#ifdef __WXGTK3__
14typedef struct _cairo_region cairo_region_t;
15#endif
16
1e6feb95 17// ----------------------------------------------------------------------------
c801d85f 18// wxRegion
1e6feb95 19// ----------------------------------------------------------------------------
c801d85f 20
8a16d737 21class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
c801d85f 22{
e1208c31 23public:
9fe4c99c 24 wxRegion() { }
1542ea39 25
9fe4c99c
VZ
26 wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
27 {
28 InitRect(x, y, w, h);
29 }
30
31 wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight )
32 {
33 InitRect(topLeft.x, topLeft.y,
34 bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
35 }
36
37 wxRegion( const wxRect& rect )
38 {
39 InitRect(rect.x, rect.y, rect.width, rect.height);
40 }
41
03647350 42 wxRegion( size_t n, const wxPoint *points,
89efaf2b 43 wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
1542ea39 44
c0521644 45#if wxUSE_IMAGE
85f6b408
VS
46 wxRegion( const wxBitmap& bmp)
47 {
48 Union(bmp);
49 }
1542ea39 50 wxRegion( const wxBitmap& bmp,
85f6b408 51 const wxColour& transColour, int tolerance = 0)
1542ea39
RD
52 {
53 Union(bmp, transColour, tolerance);
54 }
c0521644 55#endif // wxUSE_IMAGE
1542ea39 56
d3c7fc99 57 virtual ~wxRegion();
c801d85f 58
8a16d737
VZ
59 // wxRegionBase methods
60 virtual void Clear();
61 virtual bool IsEmpty() const;
1542ea39 62
9dc44eff
PC
63#ifdef __WXGTK3__
64 cairo_region_t* GetRegion() const;
65#else
66 wxRegion(const GdkRegion* region);
07818da8 67 GdkRegion *GetRegion() const;
9dc44eff 68#endif
1e6feb95
VZ
69
70protected:
8f884a0d
VZ
71 virtual wxGDIRefData *CreateGDIRefData() const;
72 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
1542ea39 73
8a16d737
VZ
74 // wxRegionBase pure virtuals
75 virtual bool DoIsEqual(const wxRegion& region) const;
76 virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
77 virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
78 virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
79
80 virtual bool DoOffset(wxCoord x, wxCoord y);
81 virtual bool DoUnionWithRect(const wxRect& rect);
82 virtual bool DoUnionWithRegion(const wxRegion& region);
83 virtual bool DoIntersect(const wxRegion& region);
84 virtual bool DoSubtract(const wxRegion& region);
85 virtual bool DoXor(const wxRegion& region);
86
9fe4c99c
VZ
87 // common part of ctors for a rectangle region
88 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
89
e1208c31 90private:
777105f2 91 DECLARE_DYNAMIC_CLASS(wxRegion)
c801d85f
KB
92};
93
1e6feb95
VZ
94// ----------------------------------------------------------------------------
95// wxRegionIterator: decomposes a region into rectangles
96// ----------------------------------------------------------------------------
97
20123d49 98class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
8429bec1 99{
738f9e5a 100public:
07818da8 101 wxRegionIterator();
8429bec1 102 wxRegionIterator(const wxRegion& region);
ac7d3dd1 103 wxRegionIterator(const wxRegionIterator& ri) : wxObject(ri) { Init(); *this = ri; }
55ccdb93 104 ~wxRegionIterator();
8429bec1 105
ac7d3dd1
RR
106 wxRegionIterator& operator=(const wxRegionIterator& ri);
107
6f2a55e3 108 void Reset() { m_current = 0u; }
8429bec1
RR
109 void Reset(const wxRegion& region);
110
07818da8 111 bool HaveRects() const;
2b5f62a0 112 operator bool () const { return HaveRects(); }
8429bec1 113
2b5f62a0
VZ
114 wxRegionIterator& operator ++ ();
115 wxRegionIterator operator ++ (int);
8429bec1 116
b02da6b1
VZ
117 wxCoord GetX() const;
118 wxCoord GetY() const;
119 wxCoord GetW() const;
120 wxCoord GetWidth() const { return GetW(); }
121 wxCoord GetH() const;
122 wxCoord GetHeight() const { return GetH(); }
1e6feb95 123 wxRect GetRect() const;
8429bec1 124
738f9e5a 125private:
55ccdb93
VZ
126 void Init();
127 void CreateRects( const wxRegion& r );
128
6f2a55e3 129 wxRegion m_region;
55ccdb93 130 wxRect *m_rects;
46a1983a
PC
131 int m_numRects;
132 int m_current;
55ccdb93 133
777105f2 134 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
8429bec1
RR
135};
136
137
c801d85f 138#endif
5fc7ede9 139 // _WX_GTK_REGION_H_