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