gdk/auto/
drawing_context.rs1#[cfg(any(feature = "v3_22", feature = "dox"))]
6use cairo;
7use gdk_sys;
8use glib::translate::*;
9use std::fmt;
10#[cfg(any(feature = "v3_22", feature = "dox"))]
11use Window;
12
13glib_wrapper! {
14 pub struct DrawingContext(Object<gdk_sys::GdkDrawingContext, gdk_sys::GdkDrawingContextClass, DrawingContextClass>);
15
16 match fn {
17 get_type => || gdk_sys::gdk_drawing_context_get_type(),
18 }
19}
20
21impl DrawingContext {
22 #[cfg(any(feature = "v3_22", feature = "dox"))]
23 pub fn get_cairo_context(&self) -> Option<cairo::Context> {
24 unsafe {
25 from_glib_none(gdk_sys::gdk_drawing_context_get_cairo_context(
26 self.to_glib_none().0,
27 ))
28 }
29 }
30
31 #[cfg(any(feature = "v3_22", feature = "dox"))]
32 pub fn get_clip(&self) -> Option<cairo::Region> {
33 unsafe { from_glib_full(gdk_sys::gdk_drawing_context_get_clip(self.to_glib_none().0)) }
34 }
35
36 #[cfg(any(feature = "v3_22", feature = "dox"))]
37 pub fn get_window(&self) -> Option<Window> {
38 unsafe {
39 from_glib_none(gdk_sys::gdk_drawing_context_get_window(
40 self.to_glib_none().0,
41 ))
42 }
43 }
44
45 #[cfg(any(feature = "v3_22", feature = "dox"))]
46 pub fn is_valid(&self) -> bool {
47 unsafe { from_glib(gdk_sys::gdk_drawing_context_is_valid(self.to_glib_none().0)) }
48 }
49}
50
51impl fmt::Display for DrawingContext {
52 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
53 write!(f, "DrawingContext")
54 }
55}