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