gdk4/auto/cairo_context.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, DrawContext};
6use glib::translate::*;
7
8glib::wrapper! {
9 /// [`CairoContext`][crate::CairoContext] is an object representing the platform-specific
10 /// draw context.
11 ///
12 /// [`CairoContext`][crate::CairoContext]s are created for a surface using
13 /// [`SurfaceExt::create_cairo_context()`][crate::prelude::SurfaceExt::create_cairo_context()], and the context
14 /// can then be used to draw on that surface.
15 ///
16 /// This is an Abstract Base Class, you cannot instantiate it.
17 ///
18 /// # Implements
19 ///
20 /// [`DrawContextExt`][trait@crate::prelude::DrawContextExt], [`DrawContextExtManual`][trait@crate::prelude::DrawContextExtManual]
21 #[doc(alias = "GdkCairoContext")]
22 pub struct CairoContext(Object<ffi::GdkCairoContext>) @extends DrawContext;
23
24 match fn {
25 type_ => || ffi::gdk_cairo_context_get_type(),
26 }
27}
28
29impl CairoContext {
30 /// Retrieves a Cairo context to be used to draw on the [`Surface`][crate::Surface]
31 /// of @context.
32 ///
33 /// A call to [`DrawContextExt::begin_frame()`][crate::prelude::DrawContextExt::begin_frame()] with this
34 /// @context must have been done or this function will return [`None`].
35 ///
36 /// The returned context is guaranteed to be valid until
37 /// [`DrawContextExt::end_frame()`][crate::prelude::DrawContextExt::end_frame()] is called.
38 ///
39 /// # Returns
40 ///
41 /// a Cairo context
42 /// to draw on `GdkSurface
43 #[doc(alias = "gdk_cairo_context_cairo_create")]
44 pub fn cairo_create(&self) -> Option<cairo::Context> {
45 unsafe { from_glib_full(ffi::gdk_cairo_context_cairo_create(self.to_glib_none().0)) }
46 }
47}