2 /* $Id: region.ccg,v 1.1 2003/01/21 13:38:38 murrayc Exp $ */
6 * Copyright 1998-2002 The gtkmm Development Team
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <gdk/gdkregion.h>
28 Region::Region(const Glib::ArrayHandle<Gdk::Point>& points, FillRule fill_rule)
30 // The dangerous-looking cast to GdkPoint* works, because Gdk::Point
31 // has only one member variable of type GdkPoint, and no vtable. Please
32 // don't copy this code, casts like that won't work with most other types.
34 gobject_ (gdk_region_polygon(
35 reinterpret_cast<GdkPoint*>(const_cast<Gdk::Point*>(points.data())),
36 points.size(), (GdkFillRule)(fill_rule)))
39 Region::Region(const Rectangle& rectangle)
41 gobject_ (gdk_region_rectangle(const_cast<GdkRectangle*>(rectangle.gobj())))
44 Glib::ArrayHandle<Rectangle> Region::get_rectangles() const
46 GdkRectangle* rectangles = 0;
49 gdk_region_get_rectangles(gobject_, &rectangles, &n_rectangles);
51 // The dangerous-looking cast to Rectangle* works, because Gdk::Rectangle
52 // has only one member variable of type GdkRectangle, and no vtable. Please
53 // don't copy this code, casts like that won't work with most other types.
55 return Glib::ArrayHandle<Rectangle>(
56 reinterpret_cast<Rectangle*>(rectangles), n_rectangles, Glib::OWNERSHIP_SHALLOW);