]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/region.h
Don't return a dangling pointer from wxDateTime::ParseXXX(wxCStrData).
[wxWidgets.git] / include / wx / x11 / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/region.h
3 // Purpose: wxRegion class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_REGION_H_
13 #define _WX_REGION_H_
14
15 #include "wx/list.h"
16
17 // ----------------------------------------------------------------------------
18 // wxRegion
19 // ----------------------------------------------------------------------------
20
21 class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
22 {
23 public:
24 wxRegion() { }
25
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
42 wxRegion( size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
43
44 wxRegion( const wxBitmap& bmp)
45 {
46 Union(bmp);
47 }
48 wxRegion( const wxBitmap& bmp,
49 const wxColour& transColour, int tolerance = 0)
50 {
51 Union(bmp, transColour, tolerance);
52 }
53
54 virtual ~wxRegion();
55
56 // wxRegionBase methods
57 virtual void Clear();
58 virtual bool IsEmpty() const;
59
60 public:
61 WXRegion *GetX11Region() const;
62
63 protected:
64 virtual wxGDIRefData *CreateGDIRefData() const;
65 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
66
67 // wxRegionBase pure virtuals
68 virtual bool DoIsEqual(const wxRegion& region) const;
69 virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
70 virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
71 virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
72
73 virtual bool DoOffset(wxCoord x, wxCoord y);
74 virtual bool DoUnionWithRect(const wxRect& rect);
75 virtual bool DoUnionWithRegion(const wxRegion& region);
76 virtual bool DoIntersect(const wxRegion& region);
77 virtual bool DoSubtract(const wxRegion& region);
78 virtual bool DoXor(const wxRegion& region);
79
80 // common part of ctors for a rectangle region
81 void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
82
83 private:
84 DECLARE_DYNAMIC_CLASS(wxRegion)
85 };
86
87 // ----------------------------------------------------------------------------
88 // wxRegionIterator: decomposes a region into rectangles
89 // ----------------------------------------------------------------------------
90
91 class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
92 {
93 public:
94 wxRegionIterator();
95 wxRegionIterator(const wxRegion& region);
96
97 void Reset() { m_current = 0u; }
98 void Reset(const wxRegion& region);
99
100 operator bool () const;
101 bool HaveRects() const;
102
103 void operator ++ ();
104 void operator ++ (int);
105
106 wxCoord GetX() const;
107 wxCoord GetY() const;
108 wxCoord GetW() const;
109 wxCoord GetWidth() const { return GetW(); }
110 wxCoord GetH() const;
111 wxCoord GetHeight() const { return GetH(); }
112 wxRect GetRect() const;
113
114 private:
115 size_t m_current;
116 wxRegion m_region;
117
118 private:
119 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
120 };
121
122 #endif
123 // _WX_REGION_H_