add new sigc++2 directory
[ardour.git] / libs / cairomm / cairomm / win32_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/win32_surface.h>
20 #include <cairomm/private.h>
21
22 namespace Cairo
23 {
24
25 #ifdef CAIRO_HAS_WIN32_SURFACE
26
27 Win32Surface::Win32Surface(cairo_surface_t* cobject, bool has_reference) :
28     Surface(cobject, has_reference)
29 {}
30
31 Win32Surface::~Win32Surface()
32 {
33   // surface is destroyed in base class
34 }
35
36 HDC Win32Surface::get_dc() const
37 {
38   return cairo_win32_surface_get_dc(m_cobject);
39 }
40
41 RefPtr<Win32Surface> Win32Surface::create(HDC hdc)
42 {
43   cairo_surface_t* cobject = cairo_win32_surface_create(hdc);
44   check_status_and_throw_exception(cairo_surface_status(cobject));
45   return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
46 }
47
48 RefPtr<Win32Surface> Win32Surface::create(Format format, int width, int height)
49 {
50   cairo_surface_t* cobject = cairo_win32_surface_create_with_dib((cairo_format_t)format, width, height);
51   check_status_and_throw_exception(cairo_surface_status(cobject));
52   return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
53 }
54
55 #endif // CAIRO_HAS_WIN32_SURFACE
56
57 } //namespace Cairo
58
59 // vim: ts=2 sw=2 et