cairo/
lib.rs

1// Copyright 2013-2016, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5extern crate cairo_sys as ffi;
6extern crate libc;
7
8#[macro_use]
9extern crate bitflags;
10
11#[cfg(feature = "use_glib")]
12#[macro_use]
13extern crate glib;
14
15#[cfg(feature = "use_glib")]
16extern crate glib_sys as glib_ffi;
17
18#[cfg(feature = "use_glib")]
19extern crate gobject_sys as gobject_ffi;
20
21#[cfg(test)]
22extern crate tempfile;
23
24// Helper macro for our GValue related trait impls
25#[cfg(feature = "use_glib")]
26macro_rules! gvalue_impl {
27    ($name:ty, $ffi_name:ty, $get_type:expr) => {
28        use glib;
29        #[allow(unused_imports)]
30        use glib::translate::*;
31        use glib_ffi;
32        use gobject_ffi;
33
34        impl glib::types::StaticType for $name {
35            fn static_type() -> glib::types::Type {
36                unsafe { from_glib($get_type()) }
37            }
38        }
39
40        impl<'a> glib::value::FromValueOptional<'a> for $name {
41            unsafe fn from_value_optional(v: &'a glib::value::Value) -> Option<Self> {
42                let ptr = gobject_ffi::g_value_get_boxed(v.to_glib_none().0);
43                assert!(!ptr.is_null());
44                from_glib_none(ptr as *mut $ffi_name)
45            }
46        }
47
48        impl glib::value::SetValue for $name {
49            unsafe fn set_value(v: &mut glib::value::Value, s: &Self) {
50                gobject_ffi::g_value_set_boxed(
51                    v.to_glib_none_mut().0,
52                    s.to_glib_none().0 as glib_ffi::gpointer,
53                );
54            }
55        }
56
57        impl glib::value::SetValueOptional for $name {
58            unsafe fn set_value_optional(v: &mut glib::value::Value, s: Option<&Self>) {
59                if let Some(s) = s {
60                    gobject_ffi::g_value_set_boxed(
61                        v.to_glib_none_mut().0,
62                        s.to_glib_none().0 as glib_ffi::gpointer,
63                    );
64                } else {
65                    gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, ::std::ptr::null_mut());
66                }
67            }
68        }
69    };
70}
71
72pub use user_data::UserDataKey;
73
74pub use context::{Context, RectangleList};
75
76pub use paths::{Path, PathSegment, PathSegments};
77
78pub use device::Device;
79
80pub use enums::*;
81
82pub use error::{BorrowError, IoError};
83
84pub use patterns::{
85    Gradient, LinearGradient, Mesh, Pattern, RadialGradient, SolidPattern, SurfacePattern
86};
87
88pub use font::{
89    FontExtents, FontFace, FontOptions, FontSlant, FontType, FontWeight, Glyph, ScaledFont,
90    TextCluster, TextExtents,
91};
92
93pub use matrices::Matrix;
94
95pub use recording_surface::RecordingSurface;
96pub use rectangle::Rectangle;
97pub use rectangle_int::RectangleInt;
98
99pub use region::Region;
100
101pub use surface::{MappedImageSurface, Surface};
102
103pub use image_surface::{ImageSurface, ImageSurfaceData};
104
105#[cfg(any(feature = "pdf", feature = "svg", feature = "ps", feature = "dox"))]
106pub use stream::StreamWithError;
107
108#[cfg(any(feature = "pdf", feature = "dox"))]
109pub use pdf::PdfSurface;
110
111#[cfg(any(feature = "ps", feature = "dox"))]
112pub use ps::PsSurface;
113
114#[cfg(any(feature = "svg", feature = "dox"))]
115pub use svg::SvgSurface;
116
117#[cfg(any(feature = "xcb", feature = "dox"))]
118pub use xcb::{
119    XCBConnection, XCBDrawable, XCBPixmap, XCBRenderPictFormInfo, XCBScreen, XCBSurface,
120    XCBVisualType,
121};
122
123#[macro_use]
124mod user_data;
125mod constants;
126pub use constants::*;
127mod utils;
128pub use utils::*;
129
130mod context;
131mod device;
132mod enums;
133mod error;
134mod font;
135mod image_surface;
136#[cfg(any(feature = "png", feature = "dox"))]
137mod image_surface_png;
138mod matrices;
139mod paths;
140mod patterns;
141mod recording_surface;
142mod rectangle;
143mod rectangle_int;
144mod region;
145mod surface;
146#[cfg(any(feature = "xcb", feature = "dox"))]
147mod xcb;
148
149#[cfg(any(feature = "pdf", feature = "svg", feature = "ps", feature = "dox"))]
150#[macro_use]
151mod stream;
152#[cfg(any(feature = "pdf", feature = "dox"))]
153mod pdf;
154#[cfg(any(feature = "ps", feature = "dox"))]
155mod ps;
156#[cfg(any(feature = "svg", feature = "dox"))]
157mod svg;
158
159#[cfg(any(target_os = "macos", target_os = "ios", feature = "dox"))]
160mod quartz_surface;
161#[cfg(any(target_os = "macos", target_os = "ios", feature = "dox"))]
162pub use quartz_surface::QuartzSurface;
163
164#[cfg(any(windows, feature = "dox"))]
165mod win32_surface;
166
167#[cfg(any(windows, feature = "dox"))]
168pub use win32_surface::Win32Surface;