]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/region.h
Added DetachOldLog to avoid destruction of old log target
[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 wxRegion( const wxBitmap& bmp)
41 {
42 Union(bmp);
43 }
44 wxRegion( const wxBitmap& bmp,
45 const wxColour& transColour, int tolerance = 0)
46 {
47 Union(bmp, transColour, tolerance);
48 }
49
50 virtual ~wxRegion();
51
52 // wxRegionBase methods
53 virtual void Clear();
54 virtual bool IsEmpty() const;
55
56 public:
57 // Init with GdkRegion, set ref count to 2 so that
58 // the C++ class will not destroy the region!
59 wxRegion( GdkRegion *region );
60
61 GdkRegion *GetRegion() const;
62
63 protected:
64 // ref counting code
65 virtual wxObjectRefData *CreateRefData() const;
66 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
67
68 // wxRegionBase pure virtuals
69 virtual bool DoIsEqual(const wxRegion& region) const;
70 virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
71 virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
72 virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
73
74 virtual bool DoOffset(wxCoord x, wxCoord y);
75 virtual bool DoUnionWithRect(const wxRect& rect);
76 virtual bool DoUnionWithRegion(const wxRegion& region);
77 virtual bool DoIntersect(const wxRegion& region);
78 virtual bool DoSubtract(const wxRegion& region);
79 virtual bool DoXor(const wxRegion& region);
80
81 // common part of ctors for a rectangle region
82 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
83
84 private:
85 DECLARE_DYNAMIC_CLASS(wxRegion)
86 };
87
88 // ----------------------------------------------------------------------------
89 // wxRegionIterator: decomposes a region into rectangles
90 // ----------------------------------------------------------------------------
91
92 class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
93 {
94 public:
95 wxRegionIterator();
96 wxRegionIterator(const wxRegion& region);
97 wxRegionIterator(const wxRegionIterator& ri) : wxObject(ri) { Init(); *this = ri; }
98 ~wxRegionIterator();
99
100 wxRegionIterator& operator=(const wxRegionIterator& ri);
101
102 void Reset() { m_current = 0u; }
103 void Reset(const wxRegion& region);
104
105 bool HaveRects() const;
106 operator bool () const { return HaveRects(); }
107
108 wxRegionIterator& operator ++ ();
109 wxRegionIterator operator ++ (int);
110
111 wxCoord GetX() const;
112 wxCoord GetY() const;
113 wxCoord GetW() const;
114 wxCoord GetWidth() const { return GetW(); }
115 wxCoord GetH() const;
116 wxCoord GetHeight() const { return GetH(); }
117 wxRect GetRect() const;
118
119 private:
120 void Init();
121 void CreateRects( const wxRegion& r );
122
123 size_t m_current;
124 wxRegion m_region;
125
126 wxRect *m_rects;
127 size_t m_numRects;
128
129 private:
130 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
131 };
132
133
134 #endif
135 // _WX_GTK_REGION_H_