]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mgl/region.h
Don't use images for wxNotebook because of crash
[wxWidgets.git] / include / wx / mgl / region.h
CommitLineData
32b8ec41
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: region.h
3// Purpose: wxRegion class
4// Author: Vaclav Slavik
5// Created: 2001/03/12
6// RCS-ID: $Id$
52750c2e 7// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
32b8ec41
VZ
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_REGION_H_
12#define _WX_REGION_H_
13
14#ifdef __GNUG__
15#pragma interface "region.h"
16#endif
17
18#include "wx/list.h"
19#include "wx/gdiobj.h"
20#include "wx/gdicmn.h"
21#include "wx/list.h"
22
23class WXDLLEXPORT wxRect;
24class WXDLLEXPORT wxPoint;
25class MGLRegion;
26
27enum wxRegionContain
28{
29 wxOutRegion = 0,
30 wxPartRegion = 1,
31 wxInRegion = 2
32};
33
34class WXDLLEXPORT wxRegion : public wxGDIObject
35{
36 DECLARE_DYNAMIC_CLASS(wxRegion);
37 friend class WXDLLEXPORT wxRegionIterator;
38
39public:
40 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
41 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
42 wxRegion(const wxRect& rect);
43 wxRegion(const MGLRegion& region);
44
45 wxRegion();
46 ~wxRegion();
47
48 //# Copying
49 inline wxRegion(const wxRegion& r)
50 { Ref(r); }
51 inline wxRegion& operator = (const wxRegion& r)
52 { Ref(r); return (*this); }
53
54 //# Modify region
55 // Clear current region
56 void Clear(void);
57
6d7ee9e8
VS
58 bool Offset(wxCoord x, wxCoord y);
59
32b8ec41
VZ
60 // Union rectangle or region with this.
61 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
62 bool Union(const wxRect& rect) { return Union(rect.x, rect.y, rect.width, rect.height); }
63 bool Union(const wxRegion& region);
64
65 // Intersect rectangle or region with this.
66 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
67 bool Intersect(const wxRect& rect) { return Intersect(rect.x, rect.y, rect.width, rect.height); }
68 bool Intersect(const wxRegion& region);
69
70 // Subtract rectangle or region from this:
71 // Combines the parts of 'this' that are not part of the second region.
72 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
73 bool Subtract(const wxRect& rect) { return Subtract(rect.x, rect.y, rect.width, rect.height); }
74 bool Subtract(const wxRegion& region);
75
76 // XOR: the union of two combined regions except for any overlapping areas.
77 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
78 bool Xor(const wxRect& rect) { return Xor(rect.x, rect.y, rect.width, rect.height); }
79 bool Xor(const wxRegion& 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(void) const ;
85
86 // Is region empty?
87 bool Empty(void) const;
88 inline bool IsEmpty(void) const { return Empty(); }
89
90 //# Tests
91 // Does the region contain the point (x,y)?
92 wxRegionContain Contains(wxCoord x, wxCoord 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(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
97 // Does the region contain the rectangle rect?
98 wxRegionContain Contains(const wxRect& rect) const;
99
100 // implementation from now on:
101 const MGLRegion& GetMGLRegion() const;
6d7ee9e8
VS
102
103protected:
104 // ref counting code
105 virtual wxObjectRefData *CreateRefData() const;
106 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
32b8ec41
VZ
107};
108
109
110WX_DECLARE_EXPORTED_LIST(wxRect, wxRegionRectList);
111
112class WXDLLEXPORT wxRegionIterator : public wxObject
113{
114 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
115public:
116 wxRegionIterator(void);
117 wxRegionIterator(const wxRegion& region);
118 ~wxRegionIterator(void);
119
120 void Reset(void) { m_currentNode = NULL; }
121 void Reset(const wxRegion& region);
122
123#ifndef __SALFORDC__
124 operator bool (void) const { return (m_currentNode != NULL); }
125#endif
126
127 bool HaveRects(void) const { return (m_currentNode != NULL); }
128
129 void operator ++ (void);
130 void operator ++ (int);
131
132 wxCoord GetX(void) const;
133 wxCoord GetY(void) const;
134 wxCoord GetW(void) const;
135 wxCoord GetWidth(void) const { return GetW(); }
136 wxCoord GetH(void) const;
137 wxCoord GetHeight(void) const { return GetH(); }
138 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
139
140private:
141 wxRegionRectList m_rects;
142 wxRegionRectList::Node *m_currentNode;
143};
144
145#endif
146 // _WX_REGION_H_