]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/region.h
Added userData to wxSizerItems and other things to make sizers more
[wxWidgets.git] / include / wx / motif / region.h
CommitLineData
9b6dbb09
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: region.h
3// Purpose: wxRegion class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
14
15#ifdef __GNUG__
16#pragma interface "region.h"
17#endif
18
19#include "wx/list.h"
20#include "wx/gdiobj.h"
3dd4e4e0 21#include "wx/gdicmn.h"
9b6dbb09
JS
22
23class WXDLLEXPORT wxRect;
24class WXDLLEXPORT wxPoint;
25
26enum wxRegionContain {
27 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
28};
29
30// So far, for internal use only
31enum wxRegionOp {
32wxRGN_AND, // Creates the intersection of the two combined regions.
33wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
34wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
35wxRGN_OR, // Creates the union of two combined regions.
36wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
37};
38
39class WXDLLEXPORT wxRegion : public wxGDIObject {
40DECLARE_DYNAMIC_CLASS(wxRegion);
41 friend class WXDLLEXPORT wxRegionIterator;
42public:
43 wxRegion(long x, long y, long w, long h);
44 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
45 wxRegion(const wxRect& rect);
46 wxRegion();
47 ~wxRegion();
48
49 //# Copying
50 inline wxRegion(const wxRegion& r)
51 { Ref(r); }
52 inline wxRegion& operator = (const wxRegion& r)
53 { Ref(r); return (*this); }
54
55 //# Modify region
56 // Clear current region
57 void Clear();
58
59 // Union rectangle or region with this.
60 inline bool Union(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_OR); }
61 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
62 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
63
64 // Intersect rectangle or region with this.
65 inline bool Intersect(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_AND); }
66 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
67 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
68
69 // Subtract rectangle or region from this:
70 // Combines the parts of 'this' that are not part of the second region.
71 inline bool Subtract(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_DIFF); }
72 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
73 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
74
75 // XOR: the union of two combined regions except for any overlapping areas.
76 inline bool Xor(long x, long y, long width, long height) { return Combine(x, y, width, height, wxRGN_XOR); }
77 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
78 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
79
80 //# Information on region
81 // Outer bounds of region
82 void GetBox(long& x, long& y, long&w, long &h) const;
83 wxRect GetBox() const ;
84
85 // Is region empty?
86 bool Empty() const;
55acd85e
JS
87 inline bool IsEmpty() const { return Empty(); }
88 bool Ok() const { return (m_refData != NULL) ; }
9b6dbb09
JS
89
90 //# Tests
91 // Does the region contain the point (x,y)?
92 wxRegionContain Contains(long x, long y) const;
93 // Does the region contain the point pt?
94 wxRegionContain Contains(const wxPoint& pt) const;
95 // Does the region contain the rectangle (x, y, w, h)?
96 wxRegionContain Contains(long x, long y, long w, long h) const;
97 // Does the region contain the rectangle rect?
98 wxRegionContain Contains(const wxRect& rect) const;
99
100// Internal
101 bool Combine(long x, long y, long width, long height, wxRegionOp op);
102 bool Combine(const wxRegion& region, wxRegionOp op);
103 bool Combine(const wxRect& rect, wxRegionOp op);
55acd85e
JS
104
105 // Get the internal Region handle
45d49251 106 WXRegion GetXRegion() const;
9b6dbb09
JS
107};
108
109class WXDLLEXPORT wxRegionIterator : public wxObject {
110DECLARE_DYNAMIC_CLASS(wxRegionIterator);
111public:
112 wxRegionIterator();
113 wxRegionIterator(const wxRegion& region);
114 ~wxRegionIterator();
115
116 void Reset() { m_current = 0; }
117 void Reset(const wxRegion& region);
118
119 operator bool () const { return m_current < m_numRects; }
120 bool HaveRects() const { return m_current < m_numRects; }
121
122 void operator ++ ();
123 void operator ++ (int);
124
125 long GetX() const;
126 long GetY() const;
127 long GetW() const;
128 long GetWidth() const { return GetW(); }
129 long GetH() const;
130 long GetHeight() const { return GetH(); }
3572173c 131 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
9b6dbb09
JS
132
133private:
134 long m_current;
135 long m_numRects;
136 wxRegion m_region;
137 wxRect* m_rects;
138};
139
140#endif
141 // _WX_REGION_H_