Added GetRect to region iterator; cured window.cpp problem for BC++
[wxWidgets.git] / include / wx / gtk / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: region.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __REGIONH__
11 #define __REGIONH__
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "wx/list.h"
18 #include "wx/gdiobj.h"
19 #include "wx/gdicmn.h"
20
21 //-----------------------------------------------------------------------------
22 // classes
23 //-----------------------------------------------------------------------------
24
25 class wxRegion;
26
27 //-----------------------------------------------------------------------------
28 // constants
29 //-----------------------------------------------------------------------------
30
31 enum wxRegionContain
32 {
33 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
34 };
35
36 // So far, for internal use only
37 enum wxRegionOp {
38 wxRGN_AND, // Creates the intersection of the two combined regions.
39 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
40 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
41 wxRGN_OR, // Creates the union of two combined regions.
42 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
43 };
44
45 //-----------------------------------------------------------------------------
46 // wxRegion
47 //-----------------------------------------------------------------------------
48
49 class wxRegion : public wxGDIObject
50 {
51 DECLARE_DYNAMIC_CLASS(wxRegion);
52
53 public:
54
55 wxRegion( long x, long y, long w, long h );
56 wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight );
57 wxRegion( const wxRect& rect );
58 wxRegion(void);
59 ~wxRegion(void);
60
61 inline wxRegion( const wxRegion& r )
62 { Ref(r); }
63 inline wxRegion& operator = ( const wxRegion& r )
64 { Ref(r); return (*this); }
65
66 void Clear(void);
67
68 bool Union( long x, long y, long width, long height );
69 bool Union( const wxRect& rect );
70 bool Union( const wxRegion& region );
71
72 bool Intersect( long x, long y, long width, long height );
73 bool Intersect( const wxRect& rect );
74 bool Intersect( const wxRegion& region );
75
76 bool Subtract( long x, long y, long width, long height );
77 bool Subtract( const wxRect& rect );
78 bool Subtract( const wxRegion& region );
79
80 bool Xor( long x, long y, long width, long height );
81 bool Xor( const wxRect& rect );
82 bool Xor( const wxRegion& region );
83
84 void GetBox( long& x, long& y, long&w, long &h ) const;
85 wxRect GetBox(void) const ;
86
87 bool Empty(void) const;
88
89 wxRegionContain Contains( long x, long y ) const;
90 wxRegionContain Contains( long x, long y, long w, long h ) const;
91 wxRegionContain Contains(const wxPoint& pt) const;
92 wxRegionContain Contains(const wxRect& rect) const;
93
94 public:
95
96 wxList *GetRectList() const;
97 GdkRegion *GetRegion(void) const;
98 };
99
100 class wxRegionIterator: public wxObject
101 {
102 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
103
104 public:
105
106 wxRegionIterator(void);
107 wxRegionIterator(const wxRegion& region);
108
109 void Reset(void) { m_current = 0; }
110 void Reset(const wxRegion& region);
111
112 operator bool (void) const;
113 bool HaveRects(void) const;
114
115 void operator ++ (void);
116 void operator ++ (int);
117
118 long GetX(void) const;
119 long GetY(void) const;
120 long GetW(void) const;
121 long GetWidth(void) const { return GetW(); }
122 long GetH(void) const;
123 long GetHeight(void) const { return GetH(); }
124 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
125
126 private:
127
128 long m_current;
129 wxRegion m_region;
130 };
131
132
133 #endif
134 // __REGIONH__