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