]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/region.h
optimize FindItem(data) performance (closes #9870)
[wxWidgets.git] / include / wx / generic / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/region.h
3 // Purpose: generic wxRegion class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/04/12
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_REGION_H__
13 #define _WX_GENERIC_REGION_H__
14
15 class WXDLLIMPEXP_CORE wxRegionGeneric : public wxRegionBase
16 {
17 public:
18 wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
19 wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
20 wxRegionGeneric(const wxRect& rect);
21 wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
22 wxRegionGeneric(const wxBitmap& bmp);
23 wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0);
24 wxRegionGeneric();
25 virtual ~wxRegionGeneric();
26
27 // wxRegionBase pure virtuals
28 virtual void Clear();
29 virtual bool IsEmpty() const;
30
31 protected:
32 virtual wxGDIRefData *CreateGDIRefData() const;
33 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
34
35 // wxRegionBase pure virtuals
36 virtual bool DoIsEqual(const wxRegion& region) const;
37 virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
38 virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
39 virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
40
41 virtual bool DoOffset(wxCoord x, wxCoord y);
42 virtual bool DoUnionWithRect(const wxRect& rect);
43 virtual bool DoUnionWithRegion(const wxRegion& region);
44 virtual bool DoIntersect(const wxRegion& region);
45 virtual bool DoSubtract(const wxRegion& region);
46 virtual bool DoXor(const wxRegion& region);
47
48 friend class WXDLLIMPEXP_FWD_CORE wxRegionIteratorGeneric;
49 };
50
51 class WXDLLIMPEXP_CORE wxRegionIteratorGeneric : public wxObject
52 {
53 public:
54 wxRegionIteratorGeneric();
55 wxRegionIteratorGeneric(const wxRegionGeneric& region);
56 wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator);
57 virtual ~wxRegionIteratorGeneric();
58
59 wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator);
60
61 void Reset() { m_current = 0; }
62 void Reset(const wxRegionGeneric& region);
63
64 operator bool () const { return HaveRects(); }
65 bool HaveRects() const;
66
67 wxRegionIteratorGeneric& operator++();
68 wxRegionIteratorGeneric operator++(int);
69
70 long GetX() const;
71 long GetY() const;
72 long GetW() const;
73 long GetWidth() const { return GetW(); }
74 long GetH() const;
75 long GetHeight() const { return GetH(); }
76 wxRect GetRect() const;
77 private:
78 long m_current;
79 wxRegionGeneric m_region;
80 };
81
82 #endif // _WX_GENERIC_REGION_H__