region.h 2.9 KB

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