]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/region.h
allow customization of individual grid lines appearance (patch 1496015)
[wxWidgets.git] / include / wx / generic / region.h
CommitLineData
4c3c3844
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/region.h
3// Purpose: generic wxRegion class
4// Author: David Elliott
5// Modified by:
6// Created: 2004/04/12
7// RCS-ID: $Id$
8// Copyright: (c) 2004 David Elliott
ca65c044 9// Licence: wxWindows licence
4c3c3844
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GENERIC_REGION_H__
13#define _WX_GENERIC_REGION_H__
14
15#include "wx/gdiobj.h"
16#include "wx/gdicmn.h"
17
18class WXDLLEXPORT wxRect;
19class WXDLLEXPORT wxPoint;
20
21enum wxRegionContain
22{ wxOutRegion = 0
23, wxPartRegion = 1
24, wxInRegion = 2
25};
26
27class WXDLLEXPORT wxRegionGeneric : public wxGDIObject
28{
29// DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
30 friend class WXDLLEXPORT wxRegionIteratorGeneric;
31public:
32 wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
33 wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
34 wxRegionGeneric(const wxRect& rect);
35 wxRegionGeneric();
36 ~wxRegionGeneric();
37
4c3c3844
DE
38 bool Ok() const { return m_refData != NULL; }
39
fbfb8bcc
VZ
40 bool operator == ( const wxRegionGeneric& region ) const;
41 bool operator != ( const wxRegionGeneric& region ) const { return !(*this == region); }
4c3c3844
DE
42
43 //# Modify region
44 // Clear current region
45 void Clear();
46
47 // Move the region
48 bool Offset(wxCoord x, wxCoord y);
49
50 // Union rectangle or region with this.
51 bool Union(long x, long y, long width, long height)
52 { return Union(wxRect(x,y,width,height)); }
53 bool Union(const wxRect& rect);
54 bool Union(const wxRegionGeneric& region);
55
56 // Intersect rectangle or region with this.
57 bool Intersect(long x, long y, long width, long height)
58 { return Intersect(wxRect(x,y,width,height)); }
59 bool Intersect(const wxRect& rect);
60 bool Intersect(const wxRegionGeneric& region);
61
62 // Subtract rectangle or region from this:
63 // Combines the parts of 'this' that are not part of the second region.
64 bool Subtract(long x, long y, long width, long height)
65 { return Subtract(wxRect(x,y,width,height)); }
66 bool Subtract(const wxRect& rect);
67 bool Subtract(const wxRegionGeneric& region);
68
69 // XOR: the union of two combined regions except for any overlapping areas.
70 bool Xor(long x, long y, long width, long height);
71 bool Xor(const wxRect& rect);
72 bool Xor(const wxRegionGeneric& region);
73
74 //# Information on region
75 // Outer bounds of region
76 void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
77 wxRect GetBox() const;
78
79 // Is region empty?
80 bool Empty() const;
81 inline bool IsEmpty() const { return Empty(); }
82
83 //# Tests
84 // Does the region contain the point (x,y)?
85 wxRegionContain Contains(long x, long y) const;
86 // Does the region contain the point pt?
87 wxRegionContain Contains(const wxPoint& pt) const;
88 // Does the region contain the rectangle (x, y, w, h)?
89 wxRegionContain Contains(long x, long y, long w, long h) const;
90 // Does the region contain the rectangle rect?
91 wxRegionContain Contains(const wxRect& rect) const;
92
9a6384ca
WS
93 // Use the non-transparent pixels of a wxBitmap for the region to combine
94 // with this region. First version takes transparency from bitmap's mask,
95 // second lets the user specify the colour to be treated as transparent
96 // along with an optional tolerance value.
97 // NOTE: implemented in common/rgncmn.cpp
98 bool Union(const wxBitmap& bmp);
99 bool Union(const wxBitmap& bmp,
100 const wxColour& transColour, int tolerance = 0);
101
102 // Convert the region to a B&W bitmap with the white pixels being inside
103 // the region.
104 wxBitmap ConvertToBitmap() const;
105
4c3c3844
DE
106protected:
107 virtual wxObjectRefData *CreateRefData() const;
108 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
109};
110
111class WXDLLEXPORT wxRegionIteratorGeneric : public wxObject
112{
113// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
114public:
115 wxRegionIteratorGeneric();
116 wxRegionIteratorGeneric(const wxRegionGeneric& region);
117 wxRegionIteratorGeneric(const wxRegionIteratorGeneric& iterator);
118 ~wxRegionIteratorGeneric();
119
120 wxRegionIteratorGeneric& operator=(const wxRegionIteratorGeneric& iterator);
121
122 void Reset() { m_current = 0; }
123 void Reset(const wxRegionGeneric& region);
124
125 operator bool () const { return HaveRects(); }
126 bool HaveRects() const;
127
128 wxRegionIteratorGeneric& operator++();
129 wxRegionIteratorGeneric operator++(int);
130
131 long GetX() const;
132 long GetY() const;
133 long GetW() const;
134 long GetWidth() const { return GetW(); }
135 long GetH() const;
136 long GetHeight() const { return GetH(); }
137 wxRect GetRect() const;
138private:
139 long m_current;
140 wxRegionGeneric m_region;
141};
142
143#endif //ndef _WX_GENERIC_REGION_H__