2 /* $Id: rectangle.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.
26 Rectangle::Rectangle(int x, int y, int width, int height)
30 gobject_.width = width;
31 gobject_.height = height;
34 // gdk_rectangle_union() and gdk_rectangle_intersect() work fine even if
35 // the destination points to one of the input rectangles. The join() and
36 // intersect() implementations rely on this ability.
38 Rectangle& Rectangle::join(const Rectangle& src2)
41 &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
45 Rectangle& Rectangle::intersect(const Rectangle& src2)
47 gdk_rectangle_intersect(
48 &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
52 Rectangle& Rectangle::intersect(const Rectangle& src2, bool& rectangles_intersect)
54 rectangles_intersect = gdk_rectangle_intersect(
55 &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
59 bool Rectangle::has_zero_area() const
61 return (gobject_.width == 0 || gobject_.height == 0);