]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mgl/region.h
no changes, just corrected the comment for wxConvLocal
[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)
65571936 8// Licence: wxWindows licence
32b8ec41
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_REGION_H_
12#define _WX_REGION_H_
13
32b8ec41
VZ
14#include "wx/list.h"
15#include "wx/gdiobj.h"
16#include "wx/gdicmn.h"
32b8ec41
VZ
17
18class WXDLLEXPORT wxRect;
19class WXDLLEXPORT wxPoint;
20class MGLRegion;
21
1542ea39 22enum wxRegionContain
32b8ec41 23{
1542ea39
RD
24 wxOutRegion = 0,
25 wxPartRegion = 1,
32b8ec41
VZ
26 wxInRegion = 2
27};
28
1542ea39 29class WXDLLEXPORT wxRegion : public wxGDIObject
32b8ec41
VZ
30{
31 DECLARE_DYNAMIC_CLASS(wxRegion);
32 friend class WXDLLEXPORT wxRegionIterator;
33
34public:
35 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
36 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
37 wxRegion(const wxRect& rect);
38 wxRegion(const MGLRegion& region);
85f6b408
VS
39 wxRegion( const wxBitmap& bmp)
40 {
41 Union(bmp);
42 }
1542ea39 43 wxRegion( const wxBitmap& bmp,
85f6b408 44 const wxColour& transColour, int tolerance = 0)
1542ea39
RD
45 {
46 Union(bmp, transColour, tolerance);
47 }
32b8ec41
VZ
48
49 wxRegion();
50 ~wxRegion();
51
32b8ec41
VZ
52 //# Modify region
53 // Clear current region
54 void Clear(void);
55
6d7ee9e8
VS
56 bool Offset(wxCoord x, wxCoord y);
57
32b8ec41
VZ
58 // Union rectangle or region with this.
59 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
60 bool Union(const wxRect& rect) { return Union(rect.x, rect.y, rect.width, rect.height); }
61 bool Union(const wxRegion& region);
62
63 // Intersect rectangle or region with this.
64 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
65 bool Intersect(const wxRect& rect) { return Intersect(rect.x, rect.y, rect.width, rect.height); }
66 bool Intersect(const wxRegion& region);
67
68 // Subtract rectangle or region from this:
69 // Combines the parts of 'this' that are not part of the second region.
70 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
71 bool Subtract(const wxRect& rect) { return Subtract(rect.x, rect.y, rect.width, rect.height); }
72 bool Subtract(const wxRegion& region);
73
74 // XOR: the union of two combined regions except for any overlapping areas.
75 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
76 bool Xor(const wxRect& rect) { return Xor(rect.x, rect.y, rect.width, rect.height); }
77 bool Xor(const wxRegion& region);
78
79 //# Information on region
80 // Outer bounds of region
81 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
82 wxRect GetBox(void) const ;
83
84 // Is region empty?
85 bool Empty(void) const;
86 inline bool IsEmpty(void) const { return Empty(); }
87
88 //# Tests
89 // Does the region contain the point (x,y)?
90 wxRegionContain Contains(wxCoord x, wxCoord y) const;
91 // Does the region contain the point pt?
92 wxRegionContain Contains(const wxPoint& pt) const;
93 // Does the region contain the rectangle (x, y, w, h)?
94 wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
95 // Does the region contain the rectangle rect?
96 wxRegionContain Contains(const wxRect& rect) const;
1542ea39 97
819451b6 98 // Convert the region to a B&W bitmap with the white pixels being inside
1542ea39
RD
99 // the region.
100 wxBitmap ConvertToBitmap() const;
101
102 // Use the non-transparent pixels of a wxBitmap for the region to combine
85f6b408
VS
103 // with this region. First version takes transparency from bitmap's mask,
104 // second lets the user specify the colour to be treated as transparent
1542ea39 105 // along with an optional tolerance value.
85f6b408
VS
106 // NOTE: implemented in common/rgncmn.cpp
107 bool Union(const wxBitmap& bmp);
1542ea39 108 bool Union(const wxBitmap& bmp,
85f6b408 109 const wxColour& transColour, int tolerance = 0);
1542ea39
RD
110
111
32b8ec41
VZ
112 // implementation from now on:
113 const MGLRegion& GetMGLRegion() const;
6d7ee9e8
VS
114
115protected:
116 // ref counting code
117 virtual wxObjectRefData *CreateRefData() const;
118 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
32b8ec41
VZ
119};
120
121
122WX_DECLARE_EXPORTED_LIST(wxRect, wxRegionRectList);
123
1542ea39 124class WXDLLEXPORT wxRegionIterator : public wxObject
32b8ec41
VZ
125{
126 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
127public:
128 wxRegionIterator(void);
129 wxRegionIterator(const wxRegion& region);
130 ~wxRegionIterator(void);
131
132 void Reset(void) { m_currentNode = NULL; }
133 void Reset(const wxRegion& region);
134
135#ifndef __SALFORDC__
136 operator bool (void) const { return (m_currentNode != NULL); }
137#endif
138
139 bool HaveRects(void) const { return (m_currentNode != NULL); }
140
141 void operator ++ (void);
142 void operator ++ (int);
143
144 wxCoord GetX(void) const;
145 wxCoord GetY(void) const;
146 wxCoord GetW(void) const;
147 wxCoord GetWidth(void) const { return GetW(); }
148 wxCoord GetH(void) const;
149 wxCoord GetHeight(void) const { return GetH(); }
150 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
151
152private:
153 wxRegionRectList m_rects;
154 wxRegionRectList::Node *m_currentNode;
155};
156
157#endif
158 // _WX_REGION_H_