Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gdk / src / types.ccg
1 // -*- c++ -*-
2 /* $Id: types.ccg,v 1.3 2004/02/10 17:29:54 mxpxpod Exp $ */
3
4 /* Copyright 1998-2002 The gtkmm Development Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 namespace Gdk
22 {
23
24 Point::Point()
25 {
26   gobject_.x = 0;
27   gobject_.y = 0;
28 }
29
30 Point::Point(int x, int y)
31 {
32   gobject_.x = x;
33   gobject_.y = y;
34 }
35
36 bool Point::equal(const Gdk::Point& rhs) const
37 {
38   return (gobject_.x == rhs.gobject_.x) && (gobject_.y == rhs.gobject_.y);
39 }
40
41 // static
42 GdkAtom AtomStringTraits::to_c_type(const std::string& atom_name)
43 {
44   return gdk_atom_intern(atom_name.c_str(), 0);
45 }
46
47 // static
48 std::string AtomStringTraits::to_cpp_type(GdkAtom atom)
49 {
50   if(char *const atom_name = gdk_atom_name(atom))
51     return std::string(Glib::ScopedPtr<char>(atom_name).get());
52   else
53     return std::string();
54 }
55
56 } // namespace Gdk
57
58
59 namespace Glib
60 {
61
62 Gdk::Point& wrap(GdkPoint* object)
63 {
64   return *reinterpret_cast<Gdk::Point*>(object);
65 }
66
67 const Gdk::Point& wrap(const GdkPoint* object)
68 {
69   return *reinterpret_cast<const Gdk::Point*>(object);
70 }
71
72 } // namespace Glib
73