1 /* Copyright (C) 2005 The cairomm Development Team
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.
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.
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
19 #include <cairomm/xlib_surface.h>
20 #include <cairomm/private.h>
26 #ifdef CAIRO_HAS_XLIB_SURFACE
28 XlibSurface::XlibSurface(cairo_surface_t* cobject, bool has_reference) :
29 Surface(cobject, has_reference)
32 XlibSurface::~XlibSurface()
34 // surface is destroyed in base class
37 RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Drawable drawable, Visual* visual, int width, int height)
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 */));
44 RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Pixmap bitmap, Screen* screen, int width, int height)
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 */));
51 void XlibSurface::set_size(int width, int height)
53 cairo_xlib_surface_set_size(m_cobject, width, height);
54 check_object_status_and_throw_exception(*this);
57 void XlibSurface::set_drawable(Drawable drawable, int width, int height)
59 cairo_xlib_surface_set_drawable(m_cobject, drawable, width, height);
60 check_object_status_and_throw_exception(*this);
63 Drawable XlibSurface::get_drawable() const
65 Drawable drawable = cairo_xlib_surface_get_drawable(m_cobject);
66 check_object_status_and_throw_exception(*this);
70 const Display* XlibSurface::get_display() const
72 const Display* dpy = cairo_xlib_surface_get_display(m_cobject);
73 check_object_status_and_throw_exception(*this);
77 Display* XlibSurface::get_display()
79 Display* dpy = cairo_xlib_surface_get_display(m_cobject);
80 check_object_status_and_throw_exception(*this);
84 Screen* XlibSurface::get_screen()
86 Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
87 check_object_status_and_throw_exception(*this);
91 const Screen* XlibSurface::get_screen() const
93 const Screen* screen = cairo_xlib_surface_get_screen(m_cobject);
94 check_object_status_and_throw_exception(*this);
98 Visual* XlibSurface::get_visual()
100 Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
101 check_object_status_and_throw_exception(*this);
105 const Visual* XlibSurface::get_visual() const
107 const Visual* visual = cairo_xlib_surface_get_visual(m_cobject);
108 check_object_status_and_throw_exception(*this);
112 int XlibSurface::get_depth() const
114 int depth = cairo_xlib_surface_get_depth(m_cobject);
115 check_object_status_and_throw_exception(*this);
119 int XlibSurface::get_height() const
121 int h = cairo_xlib_surface_get_height(m_cobject);
122 check_object_status_and_throw_exception(*this);
126 int XlibSurface::get_width() const
128 int w = cairo_xlib_surface_get_width(m_cobject);
129 check_object_status_and_throw_exception(*this);
133 #endif // CAIRO_HAS_XLIB_SURFACE