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