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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::PageSetup;
use glib::translate::*;
use std::fmt;
use std::mem;

glib::wrapper! {
    #[doc(alias = "GtkPrintContext")]
    pub struct PrintContext(Object<ffi::GtkPrintContext>);

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

impl PrintContext {
    #[doc(alias = "gtk_print_context_create_pango_context")]
    pub fn create_pango_context(&self) -> pango::Context {
        unsafe {
            from_glib_full(ffi::gtk_print_context_create_pango_context(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_print_context_create_pango_layout")]
    pub fn create_pango_layout(&self) -> pango::Layout {
        unsafe {
            from_glib_full(ffi::gtk_print_context_create_pango_layout(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_print_context_get_cairo_context")]
    #[doc(alias = "get_cairo_context")]
    pub fn cairo_context(&self) -> cairo::Context {
        unsafe {
            from_glib_none(ffi::gtk_print_context_get_cairo_context(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_print_context_get_dpi_x")]
    #[doc(alias = "get_dpi_x")]
    pub fn dpi_x(&self) -> f64 {
        unsafe { ffi::gtk_print_context_get_dpi_x(self.to_glib_none().0) }
    }

    #[doc(alias = "gtk_print_context_get_dpi_y")]
    #[doc(alias = "get_dpi_y")]
    pub fn dpi_y(&self) -> f64 {
        unsafe { ffi::gtk_print_context_get_dpi_y(self.to_glib_none().0) }
    }

    #[doc(alias = "gtk_print_context_get_hard_margins")]
    #[doc(alias = "get_hard_margins")]
    pub fn hard_margins(&self) -> Option<(f64, f64, f64, f64)> {
        unsafe {
            let mut top = mem::MaybeUninit::uninit();
            let mut bottom = mem::MaybeUninit::uninit();
            let mut left = mem::MaybeUninit::uninit();
            let mut right = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::gtk_print_context_get_hard_margins(
                self.to_glib_none().0,
                top.as_mut_ptr(),
                bottom.as_mut_ptr(),
                left.as_mut_ptr(),
                right.as_mut_ptr(),
            ));
            let top = top.assume_init();
            let bottom = bottom.assume_init();
            let left = left.assume_init();
            let right = right.assume_init();
            if ret {
                Some((top, bottom, left, right))
            } else {
                None
            }
        }
    }

    #[doc(alias = "gtk_print_context_get_height")]
    #[doc(alias = "get_height")]
    pub fn height(&self) -> f64 {
        unsafe { ffi::gtk_print_context_get_height(self.to_glib_none().0) }
    }

    #[doc(alias = "gtk_print_context_get_page_setup")]
    #[doc(alias = "get_page_setup")]
    pub fn page_setup(&self) -> PageSetup {
        unsafe { from_glib_none(ffi::gtk_print_context_get_page_setup(self.to_glib_none().0)) }
    }

    #[doc(alias = "gtk_print_context_get_pango_fontmap")]
    #[doc(alias = "get_pango_fontmap")]
    pub fn pango_fontmap(&self) -> pango::FontMap {
        unsafe {
            from_glib_none(ffi::gtk_print_context_get_pango_fontmap(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_print_context_get_width")]
    #[doc(alias = "get_width")]
    pub fn width(&self) -> f64 {
        unsafe { ffi::gtk_print_context_get_width(self.to_glib_none().0) }
    }

    #[doc(alias = "gtk_print_context_set_cairo_context")]
    pub fn set_cairo_context(&self, cr: &cairo::Context, dpi_x: f64, dpi_y: f64) {
        unsafe {
            ffi::gtk_print_context_set_cairo_context(
                self.to_glib_none().0,
                mut_override(cr.to_glib_none().0),
                dpi_x,
                dpi_y,
            );
        }
    }
}

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