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
// 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

use crate::DrawContext;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// [`CairoContext`][crate::CairoContext] is an object representing the platform-specific
    /// draw context.
    ///
    /// [`CairoContext`][crate::CairoContext]s are created for a surface using
    /// [`SurfaceExt::create_cairo_context()`][crate::prelude::SurfaceExt::create_cairo_context()], and the context
    /// can then be used to draw on that surface.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`DrawContextExt`][trait@crate::prelude::DrawContextExt], [`DrawContextExtManual`][trait@crate::prelude::DrawContextExtManual]
    #[doc(alias = "GdkCairoContext")]
    pub struct CairoContext(Object<ffi::GdkCairoContext>) @extends DrawContext;

    match fn {
        type_ => || ffi::gdk_cairo_context_get_type(),
    }
}

impl CairoContext {
    /// Retrieves a Cairo context to be used to draw on the [`Surface`][crate::Surface]
    /// of @context.
    ///
    /// A call to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()] with this
    /// @context must have been done or this function will return [`None`].
    ///
    /// The returned context is guaranteed to be valid until
    /// [`DrawContextExt::end_frame()`][crate::prelude::DrawContextExt::end_frame()] is called.
    ///
    /// # Returns
    ///
    /// a Cairo context
    ///   to draw on `GdkSurface
    #[doc(alias = "gdk_cairo_context_cairo_create")]
    pub fn cairo_create(&self) -> Option<cairo::Context> {
        unsafe { from_glib_full(ffi::gdk_cairo_context_cairo_create(self.to_glib_none().0)) }
    }
}

impl fmt::Display for CairoContext {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("CairoContext")
    }
}