]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/region.h
Added wxRegion construction from an NSRect or an array of NSRects
[wxWidgets.git] / include / wx / cocoa / region.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/region.h
3 // Purpose: wxRegion class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/04/12
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COCOA_REGION_H__
13 #define _WX_COCOA_REGION_H__
14
15 #include "wx/generic/region.h"
16
17 typedef struct _NSRect NSRect;
18
19 class WXDLLEXPORT wxRegion : public wxRegionGeneric
20 {
21 DECLARE_DYNAMIC_CLASS(wxRegion);
22 public:
23 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
24 : wxRegionGeneric(x,y,w,h)
25 {}
26 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
27 : wxRegionGeneric(topLeft, bottomRight)
28 {}
29 wxRegion(const wxRect& rect)
30 : wxRegionGeneric(rect)
31 {}
32 wxRegion() {}
33 wxRegion(const wxBitmap& bmp,
34 const wxColour& transColour = wxNullColour,
35 int tolerance = 0)
36 : wxRegionGeneric()
37 {
38 Union(bmp, transColour, tolerance);
39 }
40 ~wxRegion() {}
41 wxRegion(const wxRegion& r)
42 : wxRegionGeneric(r)
43 {}
44 wxRegion& operator= (const wxRegion& r)
45 { return *(wxRegion*)&(this->wxRegionGeneric::operator=(r)); }
46
47 // Cocoa-specific creation
48 wxRegion(const NSRect& rect);
49 wxRegion(const NSRect *rects, int count);
50
51 // Use the non-transparent pixels of a wxBitmap for the region to combine
52 // with this region. If the bitmap has a mask then it will be used,
53 // otherwise the colour to be treated as transparent may be specified,
54 // along with an optional tolerance value.
55 // NOTE: implemented in common/rgncmn.cpp
56 bool Union(const wxBitmap& bmp,
57 const wxColour& transColour = wxNullColour,
58 int tolerance = 0);
59 /* And because of function hiding: */
60 bool Union(long x, long y, long width, long height)
61 { return wxRegionGeneric::Union(x,y,width,height); }
62 bool Union(const wxRect& rect)
63 { return wxRegionGeneric::Union(rect); }
64 bool Union(const wxRegion& region)
65 { return wxRegionGeneric::Union(region); }
66
67 // Convert the region to a B&W bitmap with the black pixels being inside
68 // the region.
69 // NOTE: implemented in common/rgncmn.cpp
70 wxBitmap ConvertToBitmap() const;
71
72 };
73
74 class WXDLLEXPORT wxRegionIterator : public wxRegionIteratorGeneric
75 {
76 // DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
77 public:
78 wxRegionIterator() {}
79 wxRegionIterator(const wxRegion& region)
80 : wxRegionIteratorGeneric(region)
81 {}
82 wxRegionIterator(const wxRegionIterator& iterator)
83 : wxRegionIteratorGeneric(iterator)
84 {}
85 ~wxRegionIterator() {}
86
87 wxRegionIterator& operator=(const wxRegionIterator& iter)
88 { return *(wxRegionIterator*)&(this->wxRegionIteratorGeneric::operator=(iter)); }
89 };
90
91 #endif //ndef _WX_COCOA_REGION_H__