add new sigc++2 directory
[ardour.git] / libs / cairomm / cairomm / xlib_surface.cc
1 /* Copyright (C) 2005 The cairomm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301, USA.
17  */
18
19 #include <cairomm/xlib_surface.h>
20 #include <cairomm/private.h>
21
22
23 namespace Cairo
24 {
25
26 #ifdef CAIRO_HAS_XLIB_SURFACE
27
28 XlibSurface::XlibSurface(cairo_surface_t* cobject, bool has_reference) :
29     Surface(cobject, has_reference)
30 {}
31
32 XlibSurface::~XlibSurface()
33 {
34   // surface is destroyed in base class
35 }
36
37 RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Drawable drawable, Visual* visual, int width, int height)
38 {
39   cairo_surface_t* cobject = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
40   check_status_and_throw_exception(cairo_surface_status(cobject));
41   return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
42 }
43
44 RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Pixmap bitmap, Screen* screen, int width, int height)
45 {
46   cairo_surface_t* cobject = cairo_xlib_surface_create_for_bitmap(dpy, bitmap, screen, width, height);
47   check_status_and_throw_exception(cairo_surface_status(cobject));
48   return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
49 }
50
51 void XlibSurface::set_size(int width, int height)
52 {
53   cairo_xlib_surface_set_size(m_cobject, width, height);
54   check_object_status_and_throw_exception(*this);
55 }
56
57 void XlibSurface::set_drawable(Drawable drawable, int width, int height)
58 {
59   cairo_xlib_surface_set_drawable(m_cobject, drawable, width, height);
60   check_object_status_and_throw_exception(*this);
61 }
62
63 Drawable XlibSurface::get_drawable() const
64 {
65   Drawable drawable = cairo_xlib_surface_get_drawable(m_cobject);
66   check_object_status_and_throw_exception(*this);
67   return drawable;
68 }
69
70 const Display* XlibSurface::get_display() const
71 {
72   const Display* dpy = cairo_xlib_surface_get_display(m_cobject);
73   check_object_status_and_throw_exception(*this);
74   return dpy;
75 }
76
77 Display* XlibSurface::get_display()
78 {
79   Display* dpy = cairo_xlib_surface_get_display(m_cobject);
80   check_object_status_and_throw_exception(*this);
81   return dpy;
82 }
83
84 Screen* XlibSurface::get_screen()
85 {
86   Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
87   check_object_status_and_throw_exception(*this);
88   return screen;
89 }
90
91 const Screen* XlibSurface::get_screen() const
92 {
93   const Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
94   check_object_status_and_throw_exception(*this);
95   return screen;
96 }
97
98 Visual* XlibSurface::get_visual()
99 {
100   Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
101   check_object_status_and_throw_exception(*this);
102   return visual;
103 }
104
105 const Visual* XlibSurface::get_visual() const
106 {
107   const Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
108   check_object_status_and_throw_exception(*this);
109   return visual;
110 }
111
112 int XlibSurface::get_depth() const
113 {
114   int depth = cairo_xlib_surface_get_depth(m_cobject);
115   check_object_status_and_throw_exception(*this);
116   return depth;
117 }
118
119 int XlibSurface::get_height() const
120 {
121   int h = cairo_xlib_surface_get_height(m_cobject);
122   check_object_status_and_throw_exception(*this);
123   return h;
124 }
125
126 int XlibSurface::get_width() const
127 {
128   int w = cairo_xlib_surface_get_width(m_cobject);
129   check_object_status_and_throw_exception(*this);
130   return w;
131 }
132
133 #endif // CAIRO_HAS_XLIB_SURFACE
134
135 } //namespace Cairo
136
137 // vim: ts=2 sw=2 et