The OpenD Programming Language

1 /**
2  * License:
3  * $(TABLE
4  *   $(TR $(TD cairoD wrapper/bindings)
5  *     $(TD $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)))
6  *   $(TR $(TD $(LINK2 http://cgit.freedesktop.org/cairo/tree/COPYING, _cairo))
7  *     $(TD $(LINK2 http://cgit.freedesktop.org/cairo/tree/COPYING-LGPL-2.1, LGPL 2.1) /
8  *     $(LINK2 http://cgit.freedesktop.org/cairo/plain/COPYING-MPL-1.1, MPL 1.1)))
9  * )
10  * Authors:
11  * $(TABLE
12  *   $(TR $(TD Johannes Pfau) $(TD cairoD))
13  *   $(TR $(TD $(LINK2 http://cairographics.org, _cairo team)) $(TD _cairo))
14  * )
15  */
16 /*
17  * Distributed under the Boost Software License, Version 1.0.
18  *    (See accompanying file LICENSE_1_0.txt or copy at
19  *          http://www.boost.org/LICENSE_1_0.txt)
20  */
21 module cairo.xcb;
22 
23 import std.string;
24 import std.conv;
25 
26 import cairo.cairo;
27 import cairo.c.cairo;
28 
29 static if(CAIRO_HAS_XCB_SURFACE)
30 {
31     import cairo.c.xcb;
32 
33     ///
34     public class XCBSurface : Surface
35     {
36         public:
37             /**
38              * Create a $(D XCBSurface) from a existing $(D cairo_surface_t*).
39              * XCBSurface is a garbage collected class. It will call $(D cairo_surface_destroy)
40              * when it gets collected by the GC or when $(D dispose()) is called.
41              *
42              * Warning:
43              * $(D ptr)'s reference count is not increased by this function!
44              * Adjust reference count before calling it if necessary
45              *
46              * $(RED Only use this if you know what your doing!
47              * This function should not be needed for standard cairoD usage.)
48              */
49             this(cairo_surface_t* ptr)
50             {
51                 super(ptr);
52             }
53 
54             ///
55             this(xcb_connection_t* connection, xcb_drawable_t drawable,
56                 xcb_visualtype_t* visual, int width, int height)
57             {
58                   super(cairo_xcb_surface_create(connection, drawable,
59                       visual, width, height));
60             }
61 
62             ///
63             this(xcb_connection_t* connection, xcb_screen_t* screen,
64                 xcb_pixmap_t bitmap, int width, int height)
65             {
66                   super(cairo_xcb_surface_create_for_bitmap(connection, screen,
67                       bitmap, width, height));
68             }
69 
70             ///
71             this(xcb_connection_t* connection, xcb_screen_t* screen,
72                 xcb_drawable_t drawable, xcb_render_pictforminfo_t* format,
73                 int width, int height)
74             {
75                   super(cairo_xcb_surface_create_with_xrender_format(connection,
76                       screen, drawable, format, width, height));
77             }
78 
79             ///
80             void setSize(int width, int height)
81             {
82                 cairo_xcb_surface_set_size(this.nativePointer, width, height);
83                 checkError();
84             }
85 
86             /* debug interface */
87             /* not exported, use c api*/
88     }
89 }