1
/////////////////////////////////////////////////////////////////////////////
2
// Name: wx/generic/region.h
3
// Purpose: generic wxRegion class
4
// Author: David Elliott
7
// RCS-ID: $Id: region.h,v 1.4 2004/06/17 16:22:27 ABX Exp $
8
// Copyright: (c) 2004 David Elliott
9
// Licence: wxWindows licence
10
/////////////////////////////////////////////////////////////////////////////
12
#ifndef _WX_GENERIC_REGION_H__
13
#define _WX_GENERIC_REGION_H__
15
#include "wx/gdiobj.h"
16
#include "wx/gdicmn.h"
18
class WXDLLEXPORT wxRect;
19
class WXDLLEXPORT wxPoint;
27
class WXDLLEXPORT wxRegionGeneric : public wxGDIObject
29
// DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
30
friend class WXDLLEXPORT wxRegionIteratorGeneric;
32
wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
33
wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
34
wxRegionGeneric(const wxRect& rect);
39
wxRegionGeneric(const wxRegionGeneric& r)
42
wxRegionGeneric& operator= (const wxRegionGeneric& r)
43
{ Ref(r); return (*this); }
45
bool Ok() const { return m_refData != NULL; }
47
bool operator == ( const wxRegionGeneric& region );
48
bool operator != ( const wxRegionGeneric& region ) { return !(*this == region); }
51
// Clear current region
55
bool Offset(wxCoord x, wxCoord y);
57
// Union rectangle or region with this.
58
bool Union(long x, long y, long width, long height)
59
{ return Union(wxRect(x,y,width,height)); }
60
bool Union(const wxRect& rect);
61
bool Union(const wxRegionGeneric& region);
63
// Intersect rectangle or region with this.
64
bool Intersect(long x, long y, long width, long height)
65
{ return Intersect(wxRect(x,y,width,height)); }
66
bool Intersect(const wxRect& rect);
67
bool Intersect(const wxRegionGeneric& region);
69
// Subtract rectangle or region from this:
70
// Combines the parts of 'this' that are not part of the second region.
71
bool Subtract(long x, long y, long width, long height)
72
{ return Subtract(wxRect(x,y,width,height)); }
73
bool Subtract(const wxRect& rect);
74
bool Subtract(const wxRegionGeneric& region);
76
// XOR: the union of two combined regions except for any overlapping areas.
77
bool Xor(long x, long y, long width, long height);
78
bool Xor(const wxRect& rect);
79
bool Xor(const wxRegionGeneric& region);
81
//# Information on region
82
// Outer bounds of region
83
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
84
wxRect GetBox() const;
88
inline bool IsEmpty() const { return Empty(); }
91
// Does the region contain the point (x,y)?
92
wxRegionContain Contains(long x, long y) const;
93
// Does the region contain the point pt?
94
wxRegionContain Contains(const wxPoint& pt) const;
95
// Does the region contain the rectangle (x, y, w, h)?
96
wxRegionContain Contains(long x, long y, long w, long h) const;
97
// Does the region contain the rectangle rect?
98
wxRegionContain Contains(const wxRect& rect) const;
101
virtual wxObjectRefData *CreateRefData() const;
102
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
105
class WXDLLEXPORT wxRegionIteratorGeneric : public wxObject
107
// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
109
wxRegionIteratorGeneric();
110
wxRegionIteratorGeneric(const wxRegionGeneric& region);
111
wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator);
112
~wxRegionIteratorGeneric();
114
wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator);
116
void Reset() { m_current = 0; }
117
void Reset(const wxRegionGeneric& region);
119
operator bool () const { return HaveRects(); }
120
bool HaveRects() const;
122
wxRegionIteratorGeneric& operator++();
123
wxRegionIteratorGeneric operator++(int);
128
long GetWidth() const { return GetW(); }
130
long GetHeight() const { return GetH(); }
131
wxRect GetRect() const;
134
wxRegionGeneric m_region;
137
#endif //ndef _WX_GENERIC_REGION_H__