]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/region.h
Use DeafultAttributes instead of hard coded defaults
[wxWidgets.git] / include / wx / generic / region.h
CommitLineData
4c3c3844
DE
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
ca65c044 9// Licence: wxWindows licence
4c3c3844
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GENERIC_REGION_H__
13#define _WX_GENERIC_REGION_H__
14
15#include "wx/gdiobj.h"
16#include "wx/gdicmn.h"
17
18class WXDLLEXPORT wxRect;
19class WXDLLEXPORT wxPoint;
20
21enum wxRegionContain
22{ wxOutRegion = 0
23, wxPartRegion = 1
24, wxInRegion = 2
25};
26
27class WXDLLEXPORT wxRegionGeneric : public wxGDIObject
28{
29// DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
30 friend class WXDLLEXPORT wxRegionIteratorGeneric;
31public:
32 wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
33 wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
34 wxRegionGeneric(const wxRect& rect);
35 wxRegionGeneric();
36 ~wxRegionGeneric();
37
38 //# Copying
39 wxRegionGeneric(const wxRegionGeneric& r)
40 : wxGDIObject()
41 { Ref(r); }
42 wxRegionGeneric& operator= (const wxRegionGeneric& r)
43 { Ref(r); return (*this); }
44
45 bool Ok() const { return m_refData != NULL; }
46
47 bool operator == ( const wxRegionGeneric& region );
48 bool operator != ( const wxRegionGeneric& region ) { return !(*this == region); }
49
50 //# Modify region
51 // Clear current region
52 void Clear();
53
54 // Move the region
55 bool Offset(wxCoord x, wxCoord y);
56
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);
62
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);
68
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);
75
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);
80
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;
85
86 // Is region empty?
87 bool Empty() const;
88 inline bool IsEmpty() const { return Empty(); }
89
90 //# Tests
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;
99
100protected:
101 virtual wxObjectRefData *CreateRefData() const;
102 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
103};
104
105class WXDLLEXPORT wxRegionIteratorGeneric : public wxObject
106{
107// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
108public:
109 wxRegionIteratorGeneric();
110 wxRegionIteratorGeneric(const wxRegionGeneric& region);
111 wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator);
112 ~wxRegionIteratorGeneric();
113
114 wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator);
115
116 void Reset() { m_current = 0; }
117 void Reset(const wxRegionGeneric& region);
118
119 operator bool () const { return HaveRects(); }
120 bool HaveRects() const;
121
122 wxRegionIteratorGeneric& operator++();
123 wxRegionIteratorGeneric operator++(int);
124
125 long GetX() const;
126 long GetY() const;
127 long GetW() const;
128 long GetWidth() const { return GetW(); }
129 long GetH() const;
130 long GetHeight() const { return GetH(); }
131 wxRect GetRect() const;
132private:
133 long m_current;
134 wxRegionGeneric m_region;
135};
136
137#endif //ndef _WX_GENERIC_REGION_H__