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: region.h 41429 2006-09-25 11:47:23Z VZ $
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
21class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
22{
23public:
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, int 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
60public:
61    WXRegion *GetX11Region() const;
62
63protected:
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
84private:
85    DECLARE_DYNAMIC_CLASS(wxRegion)
86};
87
88// ----------------------------------------------------------------------------
89// wxRegionIterator: decomposes a region into rectangles
90// ----------------------------------------------------------------------------
91
92class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
93{
94public:
95    wxRegionIterator();
96    wxRegionIterator(const wxRegion& region);
97
98    void Reset() { m_current = 0u; }
99    void Reset(const wxRegion& region);
100
101    operator bool () const;
102    bool HaveRects() const;
103
104    void operator ++ ();
105    void operator ++ (int);
106
107    wxCoord GetX() const;
108    wxCoord GetY() const;
109    wxCoord GetW() const;
110    wxCoord GetWidth() const { return GetW(); }
111    wxCoord GetH() const;
112    wxCoord GetHeight() const { return GetH(); }
113    wxRect GetRect() const;
114
115private:
116    size_t   m_current;
117    wxRegion m_region;
118
119private:
120    DECLARE_DYNAMIC_CLASS(wxRegionIterator)
121};
122
123#endif
124// _WX_REGION_H_
125