1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(any(feature = "v3_22", feature = "dox"))]
use cairo;
use gdk_sys;
use glib::translate::*;
use std::fmt;
#[cfg(any(feature = "v3_22", feature = "dox"))]
use Window;

glib_wrapper! {
    pub struct DrawingContext(Object<gdk_sys::GdkDrawingContext, gdk_sys::GdkDrawingContextClass, DrawingContextClass>);

    match fn {
        get_type => || gdk_sys::gdk_drawing_context_get_type(),
    }
}

impl DrawingContext {
    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn get_cairo_context(&self) -> Option<cairo::Context> {
        unsafe {
            from_glib_none(gdk_sys::gdk_drawing_context_get_cairo_context(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn get_clip(&self) -> Option<cairo::Region> {
        unsafe { from_glib_full(gdk_sys::gdk_drawing_context_get_clip(self.to_glib_none().0)) }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn get_window(&self) -> Option<Window> {
        unsafe {
            from_glib_none(gdk_sys::gdk_drawing_context_get_window(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v3_22", feature = "dox"))]
    pub fn is_valid(&self) -> bool {
        unsafe { from_glib(gdk_sys::gdk_drawing_context_is_valid(self.to_glib_none().0)) }
    }
}

impl fmt::Display for DrawingContext {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "DrawingContext")
    }
}