region.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/x11/region.h
  3. // Purpose: wxRegion class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 17/09/98
  7. // Copyright: (c) Julian Smart, Robert Roebling
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_REGION_H_
  11. #define _WX_REGION_H_
  12. #include "wx/list.h"
  13. // ----------------------------------------------------------------------------
  14. // wxRegion
  15. // ----------------------------------------------------------------------------
  16. class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
  17. {
  18. public:
  19. wxRegion() { }
  20. wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
  21. {
  22. InitRect(x, y, w, h);
  23. }
  24. wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight )
  25. {
  26. InitRect(topLeft.x, topLeft.y,
  27. bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
  28. }
  29. wxRegion( const wxRect& rect )
  30. {
  31. InitRect(rect.x, rect.y, rect.width, rect.height);
  32. }
  33. wxRegion( size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
  34. wxRegion( const wxBitmap& bmp)
  35. {
  36. Union(bmp);
  37. }
  38. wxRegion( const wxBitmap& bmp,
  39. const wxColour& transColour, int tolerance = 0)
  40. {
  41. Union(bmp, transColour, tolerance);
  42. }
  43. virtual ~wxRegion();
  44. // wxRegionBase methods
  45. virtual void Clear();
  46. virtual bool IsEmpty() const;
  47. public:
  48. WXRegion *GetX11Region() const;
  49. protected:
  50. virtual wxGDIRefData *CreateGDIRefData() const;
  51. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  52. // wxRegionBase pure virtuals
  53. virtual bool DoIsEqual(const wxRegion& region) const;
  54. virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
  55. virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
  56. virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
  57. virtual bool DoOffset(wxCoord x, wxCoord y);
  58. virtual bool DoUnionWithRect(const wxRect& rect);
  59. virtual bool DoUnionWithRegion(const wxRegion& region);
  60. virtual bool DoIntersect(const wxRegion& region);
  61. virtual bool DoSubtract(const wxRegion& region);
  62. virtual bool DoXor(const wxRegion& region);
  63. // common part of ctors for a rectangle region
  64. void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
  65. private:
  66. DECLARE_DYNAMIC_CLASS(wxRegion)
  67. };
  68. // ----------------------------------------------------------------------------
  69. // wxRegionIterator: decomposes a region into rectangles
  70. // ----------------------------------------------------------------------------
  71. class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
  72. {
  73. public:
  74. wxRegionIterator();
  75. wxRegionIterator(const wxRegion& region);
  76. void Reset() { m_current = 0u; }
  77. void Reset(const wxRegion& region);
  78. operator bool () const;
  79. bool HaveRects() const;
  80. void operator ++ ();
  81. void operator ++ (int);
  82. wxCoord GetX() const;
  83. wxCoord GetY() const;
  84. wxCoord GetW() const;
  85. wxCoord GetWidth() const { return GetW(); }
  86. wxCoord GetH() const;
  87. wxCoord GetHeight() const { return GetH(); }
  88. wxRect GetRect() const;
  89. private:
  90. size_t m_current;
  91. wxRegion m_region;
  92. private:
  93. DECLARE_DYNAMIC_CLASS(wxRegionIterator)
  94. };
  95. #endif
  96. // _WX_REGION_H_