]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/region.h
removed SetAutoLayout(true) calls when a corresponding SetSizer() was also called...
[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
65571936 9// Licence: wxWindows licence
9b6dbb09
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_REGION_H_
13#define _WX_REGION_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
9b6dbb09
JS
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 22
25f47127
JS
23// ----------------------------------------------------------------------------
24// A list of rectangles type used by wxRegion and wxWindow
25// ----------------------------------------------------------------------------
26
27WX_DECLARE_LIST(wxRect, wxRectList);
28
9b6dbb09
JS
29
30enum wxRegionContain {
83df96d6 31 wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
9b6dbb09
JS
32};
33
34// So far, for internal use only
35enum wxRegionOp {
83df96d6
JS
36 wxRGN_AND, // Creates the intersection of the two combined regions.
37 wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
38 wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
39 wxRGN_OR, // Creates the union of two combined regions.
40 wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
9b6dbb09
JS
41};
42
43class WXDLLEXPORT wxRegion : public wxGDIObject {
f052d487 44 DECLARE_DYNAMIC_CLASS(wxRegion)
83df96d6 45 friend class WXDLLEXPORT wxRegionIterator;
9b6dbb09 46public:
3ccf6cd7 47 wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
9b6dbb09
JS
48 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
49 wxRegion(const wxRect& rect);
83df96d6 50 wxRegion();
85f6b408
VS
51 wxRegion( const wxBitmap& bmp)
52 {
53 Union(bmp);
54 }
1542ea39 55 wxRegion( const wxBitmap& bmp,
85f6b408 56 const wxColour& transColour, int tolerance = 0)
1542ea39
RD
57 {
58 Union(bmp, transColour, tolerance);
59 }
83df96d6 60 ~wxRegion();
1542ea39 61
83df96d6
JS
62 //# Copying
63 inline wxRegion(const wxRegion& r)
64 { Ref(r); }
65 inline wxRegion& operator = (const wxRegion& r)
66 { Ref(r); return (*this); }
1542ea39 67
83df96d6
JS
68 //# Modify region
69 // Clear current region
70 void Clear();
1542ea39 71
83df96d6
JS
72 // Union rectangle or region with this.
73 inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
74 inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
75 inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
1542ea39 76
83df96d6
JS
77 // Intersect rectangle or region with this.
78 inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
79 inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
80 inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
1542ea39 81
83df96d6 82 // Subtract rectangle or region from this:
9b6dbb09 83 // Combines the parts of 'this' that are not part of the second region.
83df96d6
JS
84 inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
85 inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
86 inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
1542ea39 87
83df96d6
JS
88 // XOR: the union of two combined regions except for any overlapping areas.
89 inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
90 inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
91 inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
1542ea39 92
83df96d6
JS
93 //# Information on region
94 // Outer bounds of region
95 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
96 wxRect GetBox() const ;
1542ea39 97
83df96d6
JS
98 // Is region empty?
99 bool Empty() const;
100 inline bool IsEmpty() const { return Empty(); }
101 bool Ok() const { return (m_refData != NULL) ; }
1542ea39 102
83df96d6
JS
103 //# Tests
104 // Does the region contain the point (x,y)?
105 wxRegionContain Contains(wxCoord x, wxCoord y) const;
106 // Does the region contain the point pt?
107 wxRegionContain Contains(const wxPoint& pt) const;
108 // Does the region contain the rectangle (x, y, w, h)?
109 wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
110 // Does the region contain the rectangle rect?
111 wxRegionContain Contains(const wxRect& rect) const;
1542ea39 112
819451b6 113 // Convert the region to a B&W bitmap with the white pixels being inside
1542ea39
RD
114 // the region.
115 wxBitmap ConvertToBitmap() const;
116
117 // Use the non-transparent pixels of a wxBitmap for the region to combine
85f6b408
VS
118 // with this region. First version takes transparency from bitmap's mask,
119 // second lets the user specify the colour to be treated as transparent
1542ea39 120 // along with an optional tolerance value.
85f6b408
VS
121 // NOTE: implemented in common/rgncmn.cpp
122 bool Union(const wxBitmap& bmp);
1542ea39 123 bool Union(const wxBitmap& bmp,
85f6b408 124 const wxColour& transColour, int tolerance = 0);
1542ea39 125
83df96d6
JS
126 // Internal
127 bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
128 bool Combine(const wxRegion& region, wxRegionOp op);
129 bool Combine(const wxRect& rect, wxRegionOp op);
1542ea39 130
55acd85e 131 // Get the internal Region handle
45d49251 132 WXRegion GetXRegion() const;
1542ea39 133
77ffb593 134 // 'Naughty' functions that allow wxWidgets to use a list of rects
83df96d6
JS
135 // instead of the region, in certain circumstances (e.g. when
136 // making a region out of the update rectangles).
137 // These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset.
25f47127
JS
138 bool UsingRects() const;
139 wxRect* GetRects();
140 int GetRectCount() const;
141 void SetRects(const wxRectList& rectList);
142 void SetRects(int count, const wxRect* rects);
9b6dbb09
JS
143};
144
145class WXDLLEXPORT wxRegionIterator : public wxObject {
f052d487 146 DECLARE_DYNAMIC_CLASS(wxRegionIterator)
9b6dbb09 147public:
83df96d6
JS
148 wxRegionIterator();
149 wxRegionIterator(const wxRegion& region);
150 ~wxRegionIterator();
1542ea39 151
83df96d6
JS
152 void Reset() { m_current = 0; }
153 void Reset(const wxRegion& region);
1542ea39 154
83df96d6
JS
155 operator bool () const { return m_current < m_numRects; }
156 bool HaveRects() const { return m_current < m_numRects; }
1542ea39 157
83df96d6
JS
158 void operator ++ ();
159 void operator ++ (int);
1542ea39 160
83df96d6
JS
161 wxCoord GetX() const;
162 wxCoord GetY() const;
163 wxCoord GetW() const;
164 wxCoord GetWidth() const { return GetW(); }
165 wxCoord GetH() const;
166 wxCoord GetHeight() const { return GetH(); }
167 wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
1542ea39 168
9b6dbb09 169private:
83df96d6
JS
170 size_t m_current;
171 size_t m_numRects;
172 wxRegion m_region;
173 wxRect* m_rects;
9b6dbb09
JS
174};
175
176#endif
83df96d6 177// _WX_REGION_H_