1 // Generated by gmmproc 2.45.3 -- DO NOT MODIFY!
2 
3 #undef GDK_DISABLE_DEPRECATED
4 
5 
6 #include <glibmm.h>
7 
8 #include <gdkmm/region.h>
9 #include <gdkmm/private/region_p.h>
10 
11 #include <gdk/gdk.h>
12 
13 // -*- c++ -*-
14 /* $Id: region.ccg,v 1.1 2003/01/21 13:38:38 murrayc Exp $ */
15 
16 /*
17  *
18  * Copyright 1998-2002 The gtkmm Development Team
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free
32  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33  */
34 
35 #include <gdk/gdk.h>
36 
37 namespace Gdk
38 {
39 
Region(const Glib::ArrayHandle<Gdk::Point> & points,FillRule fill_rule)40 Region::Region(const Glib::ArrayHandle<Gdk::Point>& points, FillRule fill_rule)
41 :
42   // The dangerous-looking cast to GdkPoint* works, because Gdk::Point
43   // has only one member variable of type GdkPoint, and no vtable.  Please
44   // don't copy this code, casts like that won't work with most other types.
45 
46   gobject_ (gdk_region_polygon(
47       reinterpret_cast<GdkPoint*>(const_cast<Gdk::Point*>(points.data())),
48       points.size(), (GdkFillRule)(fill_rule)))
49 {}
50 
Region(const Rectangle & rectangle)51 Region::Region(const Rectangle& rectangle)
52 :
53   gobject_ (gdk_region_rectangle(const_cast<GdkRectangle*>(rectangle.gobj())))
54 {}
55 
get_rectangles() const56 Glib::ArrayHandle<Rectangle> Region::get_rectangles() const
57 {
58   GdkRectangle* rectangles = 0;
59   int n_rectangles = 0;
60 
61   gdk_region_get_rectangles(gobject_, &rectangles, &n_rectangles);
62 
63   // The dangerous-looking cast to Rectangle* works, because Gdk::Rectangle
64   // has only one member variable of type GdkRectangle, and no vtable.  Please
65   // don't copy this code, casts like that won't work with most other types.
66 
67   return Glib::ArrayHandle<Rectangle>(
68       reinterpret_cast<Rectangle*>(rectangles), n_rectangles, Glib::OWNERSHIP_SHALLOW);
69 }
70 
71 } // namespace Gdk
72 
73 
74 namespace
75 {
76 } // anonymous namespace
77 
78 // static
value_type()79 GType Glib::Value<Gdk::FillRule>::value_type()
80 {
81   return gdk_fill_rule_get_type();
82 }
83 
84 // static
value_type()85 GType Glib::Value<Gdk::OverlapType>::value_type()
86 {
87   return gdk_overlap_type_get_type();
88 }
89 
90 
91 namespace Glib
92 {
93 
wrap(GdkRegion * object,bool take_copy)94 Gdk::Region wrap(GdkRegion* object, bool take_copy /* = false */)
95 {
96   return Gdk::Region(object, take_copy);
97 }
98 
99 } // namespace Glib
100 
101 
102 namespace Gdk
103 {
104 
105 
Region()106 Region::Region()
107 :
108   gobject_ (gdk_region_new())
109 {}
110 
Region(const Region & src)111 Region::Region(const Region& src)
112 :
113   gobject_ ((src.gobject_) ? gdk_region_copy(src.gobject_) : 0)
114 {}
115 
Region(GdkRegion * castitem,bool make_a_copy)116 Region::Region(GdkRegion* castitem, bool make_a_copy /* = false */)
117 {
118   if(!make_a_copy)
119   {
120     // It was given to us by a function which has already made a copy for us to keep.
121     gobject_ = castitem;
122   }
123   else
124   {
125     // We are probably getting it via direct access to a struct,
126     // so we can not just take it - we have to take a copy of it.
127     if(castitem)
128       gobject_ = gdk_region_copy(castitem);
129     else
130       gobject_ = 0;
131   }
132 }
133 
134 
operator =(const Region & src)135 Region& Region::operator=(const Region& src)
136 {
137   GdkRegion *const new_gobject = (src.gobject_) ? gdk_region_copy(src.gobject_) : 0;
138 
139   if(gobject_)
140     gdk_region_destroy(gobject_);
141 
142   gobject_ = new_gobject;
143 
144   return *this;
145 }
146 
~Region()147 Region::~Region()
148 {
149   if(gobject_)
150     gdk_region_destroy(gobject_);
151 }
152 
gobj_copy() const153 GdkRegion* Region::gobj_copy() const
154 {
155   return gdk_region_copy(gobject_);
156 }
157 
158 
get_clipbox(const Rectangle & rectangle)159 void Region::get_clipbox(const Rectangle& rectangle)
160 {
161   gdk_region_get_clipbox(gobj(), const_cast<GdkRectangle*>(rectangle.gobj()));
162 }
163 
empty()164 bool Region::empty()
165 {
166   return gdk_region_empty(gobj());
167 }
168 
point_in(int x,int y)169 bool Region::point_in(int x, int y)
170 {
171   return gdk_region_point_in(gobj(), x, y);
172 }
173 
rect_in(const Rectangle & rect)174 OverlapType Region::rect_in(const Rectangle& rect)
175 {
176   return ((OverlapType)(gdk_region_rect_in(gobj(), (rect).gobj())));
177 }
178 
offset(int dx,int dy)179 void Region::offset(int dx, int dy)
180 {
181   gdk_region_offset(gobj(), dx, dy);
182 }
183 
shrink(int dx,int dy)184 void Region::shrink(int dx, int dy)
185 {
186   gdk_region_shrink(gobj(), dx, dy);
187 }
188 
union_with_rect(const Rectangle & rect)189 void Region::union_with_rect(const Rectangle& rect)
190 {
191   gdk_region_union_with_rect(gobj(), (rect).gobj());
192 }
193 
intersect(const Region & source2)194 void Region::intersect(const Region& source2)
195 {
196   gdk_region_intersect(gobj(), (source2).gobj());
197 }
198 
union_(const Region & source2)199 void Region::union_(const Region& source2)
200 {
201   gdk_region_union(gobj(), (source2).gobj());
202 }
203 
subtract(const Region & source2)204 void Region::subtract(const Region& source2)
205 {
206   gdk_region_subtract(gobj(), (source2).gobj());
207 }
208 
xor_(const Region & source2)209 void Region::xor_(const Region& source2)
210 {
211   gdk_region_xor(gobj(), (source2).gobj());
212 }
213 
spans_intersect_foreach(GdkSpan * spans,int n_spans,bool sorted,GdkSpanFunc function,gpointer data)214 void Region::spans_intersect_foreach(GdkSpan* spans, int n_spans, bool sorted, GdkSpanFunc function, gpointer data)
215 {
216   gdk_region_spans_intersect_foreach(gobj(), (spans), n_spans, static_cast<int>(sorted), function, data);
217 }
218 
219 
operator ==(const Region & lhs,const Region & rhs)220 bool operator==(const Region& lhs, const Region& rhs)
221 {
222   return (gdk_region_equal(const_cast<GdkRegion*>(lhs.gobj()), const_cast<GdkRegion*>(rhs.gobj())) != 0);
223 }
224 
operator !=(const Region & lhs,const Region & rhs)225 bool operator!=(const Region& lhs, const Region& rhs)
226 {
227   return (gdk_region_equal(const_cast<GdkRegion*>(lhs.gobj()), const_cast<GdkRegion*>(rhs.gobj())) == 0);
228 }
229 
230 
231 } // namespace Gdk
232 
233 
234