]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/region.h
Handle WebKitWebView create-web-view.
[wxWidgets.git] / include / wx / gtk / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/region.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_GTK_REGION_H_
10 #define _WX_GTK_REGION_H_
11
12 #ifdef __WXGTK3__
13 typedef struct _cairo_region cairo_region_t;
14 #endif
15
16 // ----------------------------------------------------------------------------
17 // wxRegion
18 // ----------------------------------------------------------------------------
19
20 class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
21 {
22 public:
23 wxRegion() { }
24
25 wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
26 {
27 InitRect(x, y, w, h);
28 }
29
30 wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight )
31 {
32 InitRect(topLeft.x, topLeft.y,
33 bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
34 }
35
36 wxRegion( const wxRect& rect )
37 {
38 InitRect(rect.x, rect.y, rect.width, rect.height);
39 }
40
41 wxRegion( size_t n, const wxPoint *points,
42 wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
43
44 #if wxUSE_IMAGE
45 wxRegion( const wxBitmap& bmp)
46 {
47 Union(bmp);
48 }
49 wxRegion( const wxBitmap& bmp,
50 const wxColour& transColour, int tolerance = 0)
51 {
52 Union(bmp, transColour, tolerance);
53 }
54 #endif // wxUSE_IMAGE
55
56 virtual ~wxRegion();
57
58 // wxRegionBase methods
59 virtual void Clear();
60 virtual bool IsEmpty() const;
61
62 #ifdef __WXGTK3__
63 cairo_region_t* GetRegion() const;
64 #else
65 wxRegion(const GdkRegion* region);
66 GdkRegion *GetRegion() const;
67 #endif
68
69 protected:
70 virtual wxGDIRefData *CreateGDIRefData() const;
71 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
72
73 // wxRegionBase pure virtuals
74 virtual bool DoIsEqual(const wxRegion& region) const;
75 virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
76 virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
77 virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
78
79 virtual bool DoOffset(wxCoord x, wxCoord y);
80 virtual bool DoUnionWithRect(const wxRect& rect);
81 virtual bool DoUnionWithRegion(const wxRegion& region);
82 virtual bool DoIntersect(const wxRegion& region);
83 virtual bool DoSubtract(const wxRegion& region);
84 virtual bool DoXor(const wxRegion& region);
85
86 // common part of ctors for a rectangle region
87 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
88
89 private:
90 DECLARE_DYNAMIC_CLASS(wxRegion)
91 };
92
93 // ----------------------------------------------------------------------------
94 // wxRegionIterator: decomposes a region into rectangles
95 // ----------------------------------------------------------------------------
96
97 class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
98 {
99 public:
100 wxRegionIterator();
101 wxRegionIterator(const wxRegion& region);
102 wxRegionIterator(const wxRegionIterator& ri) : wxObject(ri) { Init(); *this = ri; }
103 ~wxRegionIterator();
104
105 wxRegionIterator& operator=(const wxRegionIterator& ri);
106
107 void Reset() { m_current = 0u; }
108 void Reset(const wxRegion& region);
109
110 bool HaveRects() const;
111 operator bool () const { return HaveRects(); }
112
113 wxRegionIterator& operator ++ ();
114 wxRegionIterator operator ++ (int);
115
116 wxCoord GetX() const;
117 wxCoord GetY() const;
118 wxCoord GetW() const;
119 wxCoord GetWidth() const { return GetW(); }
120 wxCoord GetH() const;
121 wxCoord GetHeight() const { return GetH(); }
122 wxRect GetRect() const;
123
124 private:
125 void Init();
126 void CreateRects( const wxRegion& r );
127
128 wxRegion m_region;
129 wxRect *m_rects;
130 int m_numRects;
131 int m_current;
132
133 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
134 };
135
136
137 #endif
138 // _WX_GTK_REGION_H_