[go: up one dir, main page]

gtk4/auto/
print_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, PageSetup};
6use glib::translate::*;
7
8glib::wrapper! {
9    #[doc(alias = "GtkPrintContext")]
10    pub struct PrintContext(Object<ffi::GtkPrintContext>);
11
12    match fn {
13        type_ => || ffi::gtk_print_context_get_type(),
14    }
15}
16
17impl PrintContext {
18    #[doc(alias = "gtk_print_context_create_pango_context")]
19    pub fn create_pango_context(&self) -> pango::Context {
20        unsafe {
21            from_glib_full(ffi::gtk_print_context_create_pango_context(
22                self.to_glib_none().0,
23            ))
24        }
25    }
26
27    #[doc(alias = "gtk_print_context_create_pango_layout")]
28    pub fn create_pango_layout(&self) -> pango::Layout {
29        unsafe {
30            from_glib_full(ffi::gtk_print_context_create_pango_layout(
31                self.to_glib_none().0,
32            ))
33        }
34    }
35
36    #[doc(alias = "gtk_print_context_get_cairo_context")]
37    #[doc(alias = "get_cairo_context")]
38    pub fn cairo_context(&self) -> cairo::Context {
39        unsafe {
40            from_glib_none(ffi::gtk_print_context_get_cairo_context(
41                self.to_glib_none().0,
42            ))
43        }
44    }
45
46    #[doc(alias = "gtk_print_context_get_dpi_x")]
47    #[doc(alias = "get_dpi_x")]
48    pub fn dpi_x(&self) -> f64 {
49        unsafe { ffi::gtk_print_context_get_dpi_x(self.to_glib_none().0) }
50    }
51
52    #[doc(alias = "gtk_print_context_get_dpi_y")]
53    #[doc(alias = "get_dpi_y")]
54    pub fn dpi_y(&self) -> f64 {
55        unsafe { ffi::gtk_print_context_get_dpi_y(self.to_glib_none().0) }
56    }
57
58    #[doc(alias = "gtk_print_context_get_hard_margins")]
59    #[doc(alias = "get_hard_margins")]
60    pub fn hard_margins(&self) -> Option<(f64, f64, f64, f64)> {
61        unsafe {
62            let mut top = std::mem::MaybeUninit::uninit();
63            let mut bottom = std::mem::MaybeUninit::uninit();
64            let mut left = std::mem::MaybeUninit::uninit();
65            let mut right = std::mem::MaybeUninit::uninit();
66            let ret = from_glib(ffi::gtk_print_context_get_hard_margins(
67                self.to_glib_none().0,
68                top.as_mut_ptr(),
69                bottom.as_mut_ptr(),
70                left.as_mut_ptr(),
71                right.as_mut_ptr(),
72            ));
73            if ret {
74                Some((
75                    top.assume_init(),
76                    bottom.assume_init(),
77                    left.assume_init(),
78                    right.assume_init(),
79                ))
80            } else {
81                None
82            }
83        }
84    }
85
86    #[doc(alias = "gtk_print_context_get_height")]
87    #[doc(alias = "get_height")]
88    pub fn height(&self) -> f64 {
89        unsafe { ffi::gtk_print_context_get_height(self.to_glib_none().0) }
90    }
91
92    #[doc(alias = "gtk_print_context_get_page_setup")]
93    #[doc(alias = "get_page_setup")]
94    pub fn page_setup(&self) -> PageSetup {
95        unsafe { from_glib_none(ffi::gtk_print_context_get_page_setup(self.to_glib_none().0)) }
96    }
97
98    #[doc(alias = "gtk_print_context_get_pango_fontmap")]
99    #[doc(alias = "get_pango_fontmap")]
100    pub fn pango_fontmap(&self) -> pango::FontMap {
101        unsafe {
102            from_glib_none(ffi::gtk_print_context_get_pango_fontmap(
103                self.to_glib_none().0,
104            ))
105        }
106    }
107
108    #[doc(alias = "gtk_print_context_get_width")]
109    #[doc(alias = "get_width")]
110    pub fn width(&self) -> f64 {
111        unsafe { ffi::gtk_print_context_get_width(self.to_glib_none().0) }
112    }
113
114    #[doc(alias = "gtk_print_context_set_cairo_context")]
115    pub fn set_cairo_context(&self, cr: &cairo::Context, dpi_x: f64, dpi_y: f64) {
116        unsafe {
117            ffi::gtk_print_context_set_cairo_context(
118                self.to_glib_none().0,
119                mut_override(cr.to_glib_none().0),
120                dpi_x,
121                dpi_y,
122            );
123        }
124    }
125}