]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/region.h
use SS_CENTERIMAGE to prevent wxStaticBitmap from stretching its bitmap; also a face...
[wxWidgets.git] / include / wx / msw / region.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
5549e9f7 2// Name: wx/msw/region.h
2bda0e17
KB
3// Purpose: wxRegion class
4// Author: Markus Holzem, Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
2b5f62a0 8// Copyright: (c) 1997-2002 wxWindows team
5549e9f7 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
2bda0e17
KB
14
15#ifdef __GNUG__
2b5f62a0 16 #pragma interface "region.h"
2bda0e17
KB
17#endif
18
2bda0e17 19#include "wx/gdiobj.h"
2432b92d 20#include "wx/gdicmn.h"
2bda0e17
KB
21
22class WXDLLEXPORT wxRect;
23class WXDLLEXPORT wxPoint;
24
5549e9f7
VZ
25enum wxRegionContain
26{
27 wxOutRegion = 0,
28 wxPartRegion = 1,
29 wxInRegion = 2
2bda0e17
KB
30};
31
32// So far, for internal use only
5549e9f7
VZ
33enum wxRegionOp
34{
35 wxRGN_AND, // Creates the intersection of the two combined regions.
36 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
37 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
38 wxRGN_OR, // Creates the union of two combined regions.
39 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
2bda0e17
KB
40};
41
5549e9f7
VZ
42class WXDLLEXPORT wxRegion : public wxGDIObject
43{
2bda0e17 44public:
5549e9f7 45 wxRegion();
9b1801c1 46 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
2bda0e17
KB
47 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
48 wxRegion(const wxRect& rect);
81d66cf3 49 wxRegion(WXHRGN hRegion); // Hangs on to this region
5549e9f7 50 wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
2bda0e17 51
5549e9f7 52 virtual ~wxRegion();
2bda0e17 53
5549e9f7
VZ
54 // Copying
55 wxRegion(const wxRegion& r)
56 { Ref(r); }
57 wxRegion& operator = (const wxRegion& r)
58 { Ref(r); return (*this); }
2bda0e17 59
5549e9f7 60 // Modify region
0fb067bb
VZ
61 // -------------
62
5549e9f7 63 // Clear current region
0fb067bb
VZ
64 void Clear();
65
66 // Move the region
67 bool Offset(wxCoord x, wxCoord y);
2bda0e17 68
5549e9f7 69 // Union rectangle or region with this.
0fb067bb
VZ
70 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
71 bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
72 bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
2bda0e17 73
5549e9f7 74 // Intersect rectangle or region with this.
0fb067bb
VZ
75 bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
76 bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
77 bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
2bda0e17 78
5549e9f7 79 // Subtract rectangle or region from this:
2bda0e17 80 // Combines the parts of 'this' that are not part of the second region.
0fb067bb
VZ
81 bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
82 bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
83 bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
5549e9f7
VZ
84
85 // XOR: the union of two combined regions except for any overlapping areas.
0fb067bb
VZ
86 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
87 bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
88 bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
5549e9f7
VZ
89
90 // Information on region
0fb067bb
VZ
91 // ---------------------
92
5549e9f7
VZ
93 // Outer bounds of region
94 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
2b5f62a0 95 wxRect GetBox() const ;
5549e9f7
VZ
96
97 // Is region empty?
2b5f62a0
VZ
98 bool Empty() const;
99 inline bool IsEmpty() const { return Empty(); }
2bda0e17 100
5549e9f7
VZ
101 // Tests
102 // Does the region contain the point (x,y)?
103 wxRegionContain Contains(wxCoord x, wxCoord y) const;
104 // Does the region contain the point pt?
105 wxRegionContain Contains(const wxPoint& pt) const;
106 // Does the region contain the rectangle (x, y, w, h)?
107 wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
108 // Does the region contain the rectangle rect?
109 wxRegionContain Contains(const wxRect& rect) const;
2bda0e17
KB
110
111// Internal
5549e9f7
VZ
112 bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
113 bool Combine(const wxRegion& region, wxRegionOp op);
114 bool Combine(const wxRect& rect, wxRegionOp op);
a724d789
JS
115
116 // Get internal region handle
117 WXHRGN GetHRGN() const;
5549e9f7 118
0fb067bb 119protected:
02576308 120 virtual wxObjectRefData *CreateRefData() const;
b8027888 121 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
0fb067bb 122
5549e9f7 123 friend class WXDLLEXPORT wxRegionIterator;
0fb067bb
VZ
124
125 DECLARE_DYNAMIC_CLASS(wxRegion)
2bda0e17
KB
126};
127
5549e9f7
VZ
128class WXDLLEXPORT wxRegionIterator : public wxObject
129{
2bda0e17 130public:
2b5f62a0 131 wxRegionIterator() { Init(); }
5549e9f7 132 wxRegionIterator(const wxRegion& region);
2b5f62a0 133 wxRegionIterator(const wxRegionIterator& ri) { Init(); *this = ri; }
2bda0e17 134
2b5f62a0
VZ
135 wxRegionIterator& operator=(const wxRegionIterator& ri);
136
137 virtual ~wxRegionIterator();
138
139 void Reset() { m_current = 0; }
5549e9f7 140 void Reset(const wxRegion& region);
2bda0e17 141
2b5f62a0
VZ
142 bool HaveRects() const { return (m_current < m_numRects); }
143
a3ef5bf5 144#ifndef __SALFORDC__
2b5f62a0 145 operator bool () const { return HaveRects(); }
a3ef5bf5
JS
146#endif
147
2b5f62a0
VZ
148 wxRegionIterator& operator++();
149 wxRegionIterator operator++(int);
2bda0e17 150
2b5f62a0
VZ
151 wxCoord GetX() const;
152 wxCoord GetY() const;
153 wxCoord GetW() const;
154 wxCoord GetWidth() const { return GetW(); }
155 wxCoord GetH() const;
156 wxCoord GetHeight() const { return GetH(); }
2bda0e17 157
2b5f62a0 158 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetW(), GetH()); }
2bda0e17
KB
159
160private:
2b5f62a0
VZ
161 // common part of all ctors
162 void Init();
163
5549e9f7
VZ
164 long m_current;
165 long m_numRects;
166 wxRegion m_region;
2bda0e17 167 wxRect* m_rects;
5549e9f7
VZ
168
169 DECLARE_DYNAMIC_CLASS(wxRegionIterator);
2bda0e17
KB
170};
171
172#endif
5549e9f7 173 // _WX_REGION_H_