Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gdk / src / rectangle.ccg
1 // -*- c++ -*-
2 /* $Id: rectangle.ccg,v 1.1 2003/01/21 13:38:38 murrayc Exp $ */
3
4 /*
5  *
6  * Copyright 1998-2002 The gtkmm Development Team
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 namespace Gdk
24 {
25
26 Rectangle::Rectangle(int x, int y, int width, int height)
27 {
28   gobject_.x = x;
29   gobject_.y = y;
30   gobject_.width  = width;
31   gobject_.height = height;
32 }
33
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.
37
38 Rectangle& Rectangle::join(const Rectangle& src2)
39 {
40   gdk_rectangle_union(
41       &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
42   return *this;
43 }
44
45 Rectangle& Rectangle::intersect(const Rectangle& src2)
46 {
47   gdk_rectangle_intersect(
48       &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
49   return *this;
50 }
51
52 Rectangle& Rectangle::intersect(const Rectangle& src2, bool& rectangles_intersect)
53 {
54   rectangles_intersect = gdk_rectangle_intersect(
55       &gobject_, const_cast<GdkRectangle*>(&src2.gobject_), &gobject_);
56   return *this;
57 }
58
59 bool Rectangle::has_zero_area() const
60 {
61   return (gobject_.width == 0 || gobject_.height == 0);
62 }
63
64 } // namespace Gdk
65