]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
5fc7ede9 | 2 | // Name: wx/gtk/region.h |
c801d85f KB |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
58614078 RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
5fc7ede9 VZ |
10 | #ifndef _WX_GTK_REGION_H_ |
11 | #define _WX_GTK_REGION_H_ | |
c801d85f | 12 | |
1e6feb95 | 13 | // ---------------------------------------------------------------------------- |
c801d85f | 14 | // wxRegion |
1e6feb95 | 15 | // ---------------------------------------------------------------------------- |
c801d85f | 16 | |
8a16d737 | 17 | class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase |
c801d85f | 18 | { |
e1208c31 | 19 | public: |
9fe4c99c | 20 | wxRegion() { } |
1542ea39 | 21 | |
9fe4c99c VZ |
22 | wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) |
23 | { | |
24 | InitRect(x, y, w, h); | |
25 | } | |
26 | ||
27 | wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight ) | |
28 | { | |
29 | InitRect(topLeft.x, topLeft.y, | |
30 | bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); | |
31 | } | |
32 | ||
33 | wxRegion( const wxRect& rect ) | |
34 | { | |
35 | InitRect(rect.x, rect.y, rect.width, rect.height); | |
36 | } | |
37 | ||
03647350 | 38 | wxRegion( size_t n, const wxPoint *points, |
89efaf2b | 39 | wxPolygonFillMode fillStyle = wxODDEVEN_RULE ); |
1542ea39 | 40 | |
c0521644 | 41 | #if wxUSE_IMAGE |
85f6b408 VS |
42 | wxRegion( const wxBitmap& bmp) |
43 | { | |
44 | Union(bmp); | |
45 | } | |
1542ea39 | 46 | wxRegion( const wxBitmap& bmp, |
85f6b408 | 47 | const wxColour& transColour, int tolerance = 0) |
1542ea39 RD |
48 | { |
49 | Union(bmp, transColour, tolerance); | |
50 | } | |
c0521644 | 51 | #endif // wxUSE_IMAGE |
1542ea39 | 52 | |
d3c7fc99 | 53 | virtual ~wxRegion(); |
c801d85f | 54 | |
8a16d737 VZ |
55 | // wxRegionBase methods |
56 | virtual void Clear(); | |
57 | virtual bool IsEmpty() const; | |
1542ea39 | 58 | |
e1208c31 | 59 | public: |
331a0b6b RR |
60 | // Init with GdkRegion, set ref count to 2 so that |
61 | // the C++ class will not destroy the region! | |
62 | wxRegion( GdkRegion *region ); | |
1542ea39 | 63 | |
07818da8 | 64 | GdkRegion *GetRegion() const; |
1e6feb95 VZ |
65 | |
66 | protected: | |
8f884a0d VZ |
67 | virtual wxGDIRefData *CreateGDIRefData() const; |
68 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
1542ea39 | 69 | |
8a16d737 VZ |
70 | // wxRegionBase pure virtuals |
71 | virtual bool DoIsEqual(const wxRegion& region) const; | |
72 | virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const; | |
73 | virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const; | |
74 | virtual wxRegionContain DoContainsRect(const wxRect& rect) const; | |
75 | ||
76 | virtual bool DoOffset(wxCoord x, wxCoord y); | |
77 | virtual bool DoUnionWithRect(const wxRect& rect); | |
78 | virtual bool DoUnionWithRegion(const wxRegion& region); | |
79 | virtual bool DoIntersect(const wxRegion& region); | |
80 | virtual bool DoSubtract(const wxRegion& region); | |
81 | virtual bool DoXor(const wxRegion& region); | |
82 | ||
9fe4c99c VZ |
83 | // common part of ctors for a rectangle region |
84 | void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); | |
85 | ||
e1208c31 | 86 | private: |
777105f2 | 87 | DECLARE_DYNAMIC_CLASS(wxRegion) |
c801d85f KB |
88 | }; |
89 | ||
1e6feb95 VZ |
90 | // ---------------------------------------------------------------------------- |
91 | // wxRegionIterator: decomposes a region into rectangles | |
92 | // ---------------------------------------------------------------------------- | |
93 | ||
20123d49 | 94 | class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject |
8429bec1 | 95 | { |
738f9e5a | 96 | public: |
07818da8 | 97 | wxRegionIterator(); |
8429bec1 | 98 | wxRegionIterator(const wxRegion& region); |
ac7d3dd1 | 99 | wxRegionIterator(const wxRegionIterator& ri) : wxObject(ri) { Init(); *this = ri; } |
55ccdb93 | 100 | ~wxRegionIterator(); |
8429bec1 | 101 | |
ac7d3dd1 RR |
102 | wxRegionIterator& operator=(const wxRegionIterator& ri); |
103 | ||
6f2a55e3 | 104 | void Reset() { m_current = 0u; } |
8429bec1 RR |
105 | void Reset(const wxRegion& region); |
106 | ||
07818da8 | 107 | bool HaveRects() const; |
2b5f62a0 | 108 | operator bool () const { return HaveRects(); } |
8429bec1 | 109 | |
2b5f62a0 VZ |
110 | wxRegionIterator& operator ++ (); |
111 | wxRegionIterator operator ++ (int); | |
8429bec1 | 112 | |
b02da6b1 VZ |
113 | wxCoord GetX() const; |
114 | wxCoord GetY() const; | |
115 | wxCoord GetW() const; | |
116 | wxCoord GetWidth() const { return GetW(); } | |
117 | wxCoord GetH() const; | |
118 | wxCoord GetHeight() const { return GetH(); } | |
1e6feb95 | 119 | wxRect GetRect() const; |
8429bec1 | 120 | |
738f9e5a | 121 | private: |
55ccdb93 VZ |
122 | void Init(); |
123 | void CreateRects( const wxRegion& r ); | |
124 | ||
6f2a55e3 | 125 | wxRegion m_region; |
55ccdb93 | 126 | wxRect *m_rects; |
46a1983a PC |
127 | int m_numRects; |
128 | int m_current; | |
55ccdb93 | 129 | |
777105f2 | 130 | DECLARE_DYNAMIC_CLASS(wxRegionIterator) |
8429bec1 RR |
131 | }; |
132 | ||
133 | ||
c801d85f | 134 | #endif |
5fc7ede9 | 135 | // _WX_GTK_REGION_H_ |