region.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/carbon/region.h
  3. // Purpose: wxRegion class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MAC_CARBON_REGION_H_
  11. #define _WX_MAC_CARBON_REGION_H_
  12. #include "wx/list.h"
  13. class WXDLLIMPEXP_CORE wxRegion : public wxRegionWithCombine
  14. {
  15. public:
  16. wxRegion() { }
  17. wxRegion(long x, long y, long w, long h);
  18. wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
  19. wxRegion(const wxRect& rect);
  20. wxRegion( WXHRGN hRegion );
  21. wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
  22. #if wxUSE_IMAGE
  23. wxRegion(const wxBitmap& bmp)
  24. {
  25. Union(bmp);
  26. }
  27. wxRegion(const wxBitmap& bmp,
  28. const wxColour& transColour, int tolerance = 0)
  29. {
  30. Union(bmp, transColour, tolerance);
  31. }
  32. #endif
  33. virtual ~wxRegion();
  34. // wxRegionBase methods
  35. virtual void Clear();
  36. virtual bool IsEmpty() const;
  37. // Internal
  38. WXHRGN GetWXHRGN() const ;
  39. protected:
  40. virtual wxGDIRefData *CreateGDIRefData() const;
  41. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  42. virtual bool DoIsEqual(const wxRegion& region) const;
  43. virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
  44. virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
  45. virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
  46. virtual bool DoOffset(wxCoord x, wxCoord y);
  47. virtual bool DoCombine(const wxRegion& region, wxRegionOp op);
  48. virtual bool DoUnionWithRect(const wxRect& rect);
  49. private:
  50. DECLARE_DYNAMIC_CLASS(wxRegion)
  51. friend class WXDLLIMPEXP_FWD_CORE wxRegionIterator;
  52. };
  53. class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject
  54. {
  55. public:
  56. wxRegionIterator();
  57. wxRegionIterator(const wxRegion& region);
  58. wxRegionIterator(const wxRegionIterator& iterator);
  59. virtual ~wxRegionIterator();
  60. wxRegionIterator& operator=(const wxRegionIterator& iterator);
  61. void Reset() { m_current = 0; }
  62. void Reset(const wxRegion& region);
  63. operator bool () const { return m_current < m_numRects; }
  64. bool HaveRects() const { return m_current < m_numRects; }
  65. wxRegionIterator& operator++();
  66. wxRegionIterator operator++(int);
  67. long GetX() const;
  68. long GetY() const;
  69. long GetW() const;
  70. long GetWidth() const { return GetW(); }
  71. long GetH() const;
  72. long GetHeight() const { return GetH(); }
  73. wxRect GetRect() const { return wxRect((int)GetX(), (int)GetY(), (int)GetWidth(), (int)GetHeight()); }
  74. private:
  75. void SetRects(long numRects, wxRect *rects);
  76. long m_current;
  77. long m_numRects;
  78. wxRegion m_region;
  79. wxRect* m_rects;
  80. DECLARE_DYNAMIC_CLASS(wxRegionIterator)
  81. };
  82. #endif // _WX_MAC_CARBON_REGION_H_