add new sigc++2 directory
[ardour.git] / libs / libgnomecanvasmm / libgnomecanvasmm / point.cc
1 /* point.cc
2  * 
3  * Copyright (C) 1999 The gnomemm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <libgnomecanvasmm/point.h>
21
22 namespace Gnome
23 {
24
25 namespace Art
26 {
27
28 Point::Point(const ArtPoint& artpoint)
29 {
30   m_ArtPoint = artpoint;
31 }
32   
33 Point::Point(gdouble x /* = 0.0 */, gdouble y /* = 0.0 */)
34 {
35   m_ArtPoint.x = x;
36   m_ArtPoint.y = y;
37 }
38
39 Point::Point(const Point& src)
40 {
41   operator=(src);
42 }
43
44 Point& Point::operator=(const Point& src)
45 {
46   m_ArtPoint = src.m_ArtPoint;
47   return *this;
48 }
49
50 Point::~Point()
51 {
52 }
53
54 gdouble Point::get_x() const
55 {
56   return m_ArtPoint.x; 
57 }
58
59 void Point::set_x(gdouble x)
60 {
61   m_ArtPoint.x = x; 
62 }
63
64 gdouble Point::get_y() const
65 {
66   return m_ArtPoint.y; 
67 }
68
69 void Point::set_y(gdouble y)
70 {
71   m_ArtPoint.y = y;
72 }
73   
74 Point Point::operator+(const Point& p2)
75 {
76   return Point(get_x() + p2.get_x(), get_y() + p2.get_y());
77 }
78
79 Point Point::operator-(const Point& p2)
80 {
81   return Point(get_x() - p2.get_x(), get_y() - p2.get_y());
82 }
83
84 Point const & Point::operator+=(const Point& other)
85 {
86   set_x(get_x() + other.get_x());
87   set_y(get_y() + other.get_y());
88   return *this;
89 }
90
91 Point const & Point::operator-=(const Point& other)
92 {
93   set_x(get_x() - other.get_x());
94   set_y(get_y() - other.get_y());
95   return *this;
96 }
97
98 ArtPoint* Point::gobj()
99 {
100   return &m_ArtPoint;
101 }
102
103 const ArtPoint* Point::gobj() const
104 {
105   return &m_ArtPoint;
106 }
107
108
109 } //namespace Art
110
111 } //namespace Gnome
112
113
114 std::ostream& operator<<(std::ostream& out, const Gnome::Art::Point& p)
115 {
116   return out << '(' << p.get_x() << ", " << p.get_y() << ')';
117 }