You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Region.h 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. // Cross-platform Region class based on the X11 region implementation
  19. #ifndef __RFB_REGION_INCLUDED__
  20. #define __RFB_REGION_INCLUDED__
  21. #include <rfb/Rect.h>
  22. #include <vector>
  23. struct _XRegion;
  24. namespace rfb {
  25. struct ShortRect {
  26. short x1, y1, x2, y2;
  27. };
  28. class Region {
  29. public:
  30. // Create an empty region
  31. Region();
  32. // Create a rectangular region
  33. Region(const Rect& r);
  34. Region(const Region& r);
  35. Region &operator=(const Region& src);
  36. ~Region();
  37. // the following methods alter the region in place:
  38. void clear();
  39. void reset(const Rect& r);
  40. void translate(const rfb::Point& delta);
  41. void setOrderedRects(const std::vector<Rect>& rects);
  42. void setExtentsAndOrderedRects(const ShortRect* extents, int nRects,
  43. const ShortRect* rects);
  44. void assign_intersect(const Region& r);
  45. void assign_union(const Region& r);
  46. void assign_subtract(const Region& r);
  47. // the following three operations return a new region:
  48. Region intersect(const Region& r) const;
  49. Region union_(const Region& r) const;
  50. Region subtract(const Region& r) const;
  51. bool equals(const Region& b) const;
  52. int numRects() const;
  53. bool is_empty() const { return numRects() == 0; }
  54. bool get_rects(std::vector<Rect>* rects, bool left2right=true,
  55. bool topdown=true, int maxArea=0) const;
  56. Rect get_bounding_rect() const;
  57. void debug_print(const char *prefix) const;
  58. protected:
  59. struct _XRegion* xrgn;
  60. };
  61. };
  62. #endif // __RFB_REGION_INCLUDED__