region.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dfb/region.h
  3. // Purpose: wxRegion class
  4. // Author: Vaclav Slavik
  5. // Created: 2006-08-08
  6. // Copyright: (c) 2006 REA Elektronik GmbH
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_DFB_REGION_H_
  10. #define _WX_DFB_REGION_H_
  11. class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
  12. {
  13. public:
  14. wxRegion();
  15. wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
  16. wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
  17. wxRegion(const wxRect& rect);
  18. wxRegion(const wxBitmap& bmp)
  19. {
  20. Union(bmp);
  21. }
  22. wxRegion(const wxBitmap& bmp,
  23. const wxColour& transColour, int tolerance = 0)
  24. {
  25. Union(bmp, transColour, tolerance);
  26. }
  27. virtual ~wxRegion();
  28. // wxRegionBase methods
  29. virtual void Clear();
  30. virtual bool IsEmpty() const;
  31. // NB: implementation detail of DirectFB, should be removed if full
  32. // (i.e. not rect-only version is implemented) so that all code that
  33. // assumes region==rect breaks
  34. wxRect AsRect() const { return GetBox(); }
  35. protected:
  36. virtual wxGDIRefData *CreateGDIRefData() const;
  37. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  38. // wxRegionBase pure virtuals
  39. virtual bool DoIsEqual(const wxRegion& region) const;
  40. virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
  41. virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
  42. virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
  43. virtual bool DoOffset(wxCoord x, wxCoord y);
  44. virtual bool DoUnionWithRect(const wxRect& rect);
  45. virtual bool DoUnionWithRegion(const wxRegion& region);
  46. virtual bool DoIntersect(const wxRegion& region);
  47. virtual bool DoSubtract(const wxRegion& region);
  48. virtual bool DoXor(const wxRegion& region);
  49. friend class WXDLLIMPEXP_FWD_CORE wxRegionIterator;
  50. DECLARE_DYNAMIC_CLASS(wxRegion);
  51. };
  52. class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject
  53. {
  54. public:
  55. wxRegionIterator() {}
  56. wxRegionIterator(const wxRegion& region) { Reset(region); }
  57. void Reset() { m_rect = wxRect(); }
  58. void Reset(const wxRegion& region);
  59. bool HaveRects() const { return !m_rect.IsEmpty(); }
  60. operator bool() const { return HaveRects(); }
  61. wxRegionIterator& operator++();
  62. wxRegionIterator operator++(int);
  63. wxCoord GetX() const { return m_rect.GetX(); }
  64. wxCoord GetY() const { return m_rect.GetY(); }
  65. wxCoord GetW() const { return m_rect.GetWidth(); }
  66. wxCoord GetWidth() const { return GetW(); }
  67. wxCoord GetH() const { return m_rect.GetHeight(); }
  68. wxCoord GetHeight() const { return GetH(); }
  69. wxRect GetRect() const { return m_rect; }
  70. private:
  71. wxRect m_rect;
  72. DECLARE_DYNAMIC_CLASS(wxRegionIterator);
  73. };
  74. #endif // _WX_DFB_REGION_H_