]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/region.h
removed duplicate entries for UTF-16/32 (which are aliases for either LE or BE varian...
[wxWidgets.git] / include / wx / mac / carbon / region.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: region.h
3// Purpose: wxRegion class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
14
8cf73271
SC
15#include "wx/list.h"
16#include "wx/gdiobj.h"
17#include "wx/gdicmn.h"
18
19class WXDLLEXPORT wxRect;
20class WXDLLEXPORT wxPoint;
21
22enum wxRegionContain {
23 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
24};
25
26// So far, for internal use only
27enum wxRegionOp {
28wxRGN_AND, // Creates the intersection of the two combined regions.
29wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
30wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
31wxRGN_OR, // Creates the union of two combined regions.
32wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
33};
34
35class WXDLLEXPORT wxRegion : public wxGDIObject {
48456801 36DECLARE_DYNAMIC_CLASS(wxRegion)
8cf73271
SC
37 friend class WXDLLEXPORT wxRegionIterator;
38public:
39 wxRegion(long x, long y, long w, long h);
40 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
41 wxRegion(const wxRect& rect);
42 wxRegion( WXHRGN hRegion );
564cb9de 43 wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
8cf73271 44 wxRegion();
85f6b408
VS
45 wxRegion(const wxBitmap& bmp)
46 {
47 Union(bmp);
48 }
49 wxRegion(const wxBitmap& bmp,
50 const wxColour& transColour, int tolerance = 0)
8cf73271
SC
51 {
52 Union(bmp, transColour, tolerance);
53 }
54
55 ~wxRegion();
56
57 //# Copying
58 wxRegion(const wxRegion& r)
59 : wxGDIObject()
60 { Ref(r); }
61 wxRegion& operator = (const wxRegion& r)
62 { Ref(r); return (*this); }
63
64 //# Modify region
65 // Clear current region
66 void Clear();
67
c871c71b
SC
68 // Move the region
69 bool Offset(wxCoord x, wxCoord y);
70
8cf73271
SC
71 // Union rectangle or region with this.
72 bool Union(long x, long y, long width, long height)
73 { return Combine(x, y, width, height, wxRGN_OR); }
74 bool Union(const wxRect& rect)
75 { return Combine(rect, wxRGN_OR); }
76 bool Union(const wxRegion& region)
77 { return Combine(region, wxRGN_OR); }
78
79 // Intersect rectangle or region with this.
80 bool Intersect(long x, long y, long width, long height)
81 { return Combine(x, y, width, height, wxRGN_AND); }
82 bool Intersect(const wxRect& rect)
83 { return Combine(rect, wxRGN_AND); }
84 bool Intersect(const wxRegion& region)
85 { return Combine(region, wxRGN_AND); }
86
87 // Subtract rectangle or region from this:
88 // Combines the parts of 'this' that are not part of the second region.
89 bool Subtract(long x, long y, long width, long height)
90 { return Combine(x, y, width, height, wxRGN_DIFF); }
91 bool Subtract(const wxRect& rect)
92 { return Combine(rect, wxRGN_DIFF); }
93 bool Subtract(const wxRegion& region)
94 { return Combine(region, wxRGN_DIFF); }
95
96 // XOR: the union of two combined regions except for any overlapping areas.
97 bool Xor(long x, long y, long width, long height)
98 { return Combine(x, y, width, height, wxRGN_XOR); }
99 bool Xor(const wxRect& rect)
100 { return Combine(rect, wxRGN_XOR); }
101 bool Xor(const wxRegion& region)
102 { return Combine(region, wxRGN_XOR); }
103
104 //# Information on region
105 // Outer bounds of region
106 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
107 wxRect GetBox() const ;
108
109 // Is region empty?
110 bool Empty() const;
111 inline bool IsEmpty() const { return Empty(); }
112
113 //# Tests
114 // Does the region contain the point (x,y)?
115 wxRegionContain Contains(long x, long y) const;
116 // Does the region contain the point pt?
117 wxRegionContain Contains(const wxPoint& pt) const;
118 // Does the region contain the rectangle (x, y, w, h)?
119 wxRegionContain Contains(long x, long y, long w, long h) const;
120 // Does the region contain the rectangle rect?
121 wxRegionContain Contains(const wxRect& rect) const;
122
123 // Convert the region to a B&W bitmap with the white pixels being inside
124 // the region.
125 wxBitmap ConvertToBitmap() const;
126
127 // Use the non-transparent pixels of a wxBitmap for the region to combine
85f6b408
VS
128 // with this region. First version takes transparency from bitmap's mask,
129 // second lets the user specify the colour to be treated as transparent
8cf73271 130 // along with an optional tolerance value.
85f6b408
VS
131 // NOTE: implemented in common/rgncmn.cpp
132 bool Union(const wxBitmap& bmp);
8cf73271 133 bool Union(const wxBitmap& bmp,
85f6b408 134 const wxColour& transColour, int tolerance = 0);
8cf73271
SC
135
136 // Internal
137 bool Combine(long x, long y, long width, long height, wxRegionOp op);
138 bool Combine(const wxRegion& region, wxRegionOp op);
139 bool Combine(const wxRect& rect, wxRegionOp op);
140 const WXHRGN GetWXHRGN() const ;
141};
142
143class WXDLLEXPORT wxRegionIterator : public wxObject
144{
145 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
146
147public:
148 wxRegionIterator();
149 wxRegionIterator(const wxRegion& region);
150 wxRegionIterator(const wxRegionIterator& iterator);
151 ~wxRegionIterator();
152
153 wxRegionIterator& operator=(const wxRegionIterator& iterator);
154
155 void Reset() { m_current = 0; }
156 void Reset(const wxRegion& region);
157
158 operator bool () const { return m_current < m_numRects; }
159 bool HaveRects() const { return m_current < m_numRects; }
160
161 wxRegionIterator& operator++();
162 wxRegionIterator operator++(int);
163
164 long GetX() const;
165 long GetY() const;
166 long GetW() const;
167 long GetWidth() const { return GetW(); }
168 long GetH() const;
169 long GetHeight() const { return GetH(); }
170 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
171private:
172 void SetRects(long numRects, wxRect *rects);
173
174 long m_current;
175 long m_numRects;
176 wxRegion m_region;
177 wxRect* m_rects;
178};
179
180#endif
181 // _WX_REGION_H_