]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/region.h
Many bug fixes for display code:
[wxWidgets.git] / include / wx / os2 / region.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: region.h
3// Purpose: wxRegion class
409c9842 4// Author: David Webster
0e320a79 5// Modified by:
409c9842 6// Created: 10/15/99
0e320a79 7// RCS-ID: $Id$
409c9842
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
14
0e320a79
DW
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 {
409c9842 23 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
0e320a79
DW
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 {
36DECLARE_DYNAMIC_CLASS(wxRegion);
409c9842 37 friend class WXDLLEXPORT wxRegionIterator;
0e320a79
DW
38public:
39 wxRegion(long x, long y, long w, long h);
40 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
41 wxRegion(const wxRect& rect);
409c9842
DW
42 wxRegion(WXHRGN hRegion); // Hangs on to this region
43
44 wxRegion();
45 ~wxRegion();
46
47 //# Copying
48 inline wxRegion(const wxRegion& r)
49 { Ref(r); }
50 inline wxRegion& operator = (const wxRegion& r)
51 { Ref(r); return (*this); }
52
53 //# Modify region
54 // Clear current region
55 void Clear();
56
57 // Union rectangle or region with this.
58 inline bool Union(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_OR); }
59 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
60 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
61
62 // Intersect rectangle or region with this.
63 inline bool Intersect(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_AND); }
64 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
65 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
66
67 // Subtract rectangle or region from this:
0e320a79 68 // Combines the parts of 'this' that are not part of the second region.
409c9842
DW
69 inline bool Subtract(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_DIFF); }
70 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
71 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
72
73 // XOR: the union of two combined regions except for any overlapping areas.
74 inline bool Xor(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_XOR); }
75 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
76 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
77
78 //# Information on region
79 // Outer bounds of region
80 void GetBox(long& x, long& y, long&w, long &h) const;
81 wxRect GetBox() const ;
82
83 // Is region empty?
84 bool Empty() const;
0e320a79
DW
85 inline bool IsEmpty() const { return Empty(); }
86
409c9842
DW
87 //# Tests
88 // Does the region contain the point (x,y)?
89 wxRegionContain Contains(long x, long y) const;
90 // Does the region contain the point pt?
91 wxRegionContain Contains(const wxPoint& pt) const;
92 // Does the region contain the rectangle (x, y, w, h)?
93 wxRegionContain Contains(long x, long y, long w, long h) const;
94 // Does the region contain the rectangle rect?
95 wxRegionContain Contains(const wxRect& rect) const;
0e320a79
DW
96
97// Internal
409c9842
DW
98 bool Combine(long x, long y, long width, long height, wxRegionOp op);
99 bool Combine(const wxRegion& region, wxRegionOp op);
100 bool Combine(const wxRect& rect, wxRegionOp op);
101
102 // Get internal region handle
103 WXHRGN GetHRGN() const;
0e320a79
DW
104};
105
106class WXDLLEXPORT wxRegionIterator : public wxObject {
107DECLARE_DYNAMIC_CLASS(wxRegionIterator);
108public:
409c9842
DW
109 wxRegionIterator();
110 wxRegionIterator(const wxRegion& region);
111 ~wxRegionIterator();
0e320a79 112
409c9842
DW
113 void Reset() { m_current = 0; }
114 void Reset(const wxRegion& region);
0e320a79 115
409c9842
DW
116 operator bool () const { return m_current < m_numRects; }
117 bool HaveRects() const { return m_current < m_numRects; }
0e320a79 118
409c9842
DW
119 void operator ++ ();
120 void operator ++ (int);
0e320a79 121
409c9842
DW
122 long GetX() const;
123 long GetY() const;
124 long GetW() const;
125 long GetWidth() const { return GetW(); }
126 long GetH() const;
127 long GetHeight() const { return GetH(); }
0e320a79
DW
128 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
129
130private:
409c9842
DW
131 long m_current;
132 long m_numRects;
133 wxRegion m_region;
0e320a79
DW
134 wxRect* m_rects;
135};
136
137#endif
409c9842 138 // _WX_REGION_H_