blob: 9337556939e4702cb400ceabf3cd38cc3e47fde8 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* 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
19// Cross-platform Region class based on the X11 region implementation
20
21#ifndef __RFB_REGION_INCLUDED__
22#define __RFB_REGION_INCLUDED__
23
24#include <rfb/Rect.h>
25#include <vector>
26
27struct _XRegion;
28
29namespace rfb {
30
31 struct ShortRect {
32 short x1, y1, x2, y2;
33 };
34
35 class Region {
36 public:
37 // Create an empty region
38 Region();
39 // Create a rectangular region
40 Region(const Rect& r);
41
42 Region(const Region& r);
43 Region &operator=(const Region& src);
44
45 ~Region();
46
47 // the following methods alter the region in place:
48
49 void clear();
50 void reset(const Rect& r);
51 void translate(const rfb::Point& delta);
52 void setOrderedRects(const std::vector<Rect>& rects);
53 void setExtentsAndOrderedRects(const ShortRect* extents, int nRects,
54 const ShortRect* rects);
55 void copyFrom(const Region& r);
56
57 void assign_intersect(const Region& r);
58 void assign_union(const Region& r);
59 void assign_subtract(const Region& r);
60
61 // the following three operations return a new region:
62
63 Region intersect(const Region& r) const;
64 Region union_(const Region& r) const;
65 Region subtract(const Region& r) const;
66
67 bool equals(const Region& b) const;
68 int numRects() const;
69 bool is_empty() const { return numRects() == 0; }
70
71 bool get_rects(std::vector<Rect>* rects, bool left2right=true,
72 bool topdown=true, int maxArea=0) const;
73 Rect get_bounding_rect() const;
74
75 void debug_print(const char *prefix) const;
76
77 protected:
78
79 struct _XRegion* xrgn;
80 };
81
82};
83
84#endif // __RFB_REGION_INCLUDED__