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