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