gtk/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 cairo;
6use glib::translate::*;
7use gtk_sys;
8use pango;
9use std::fmt;
10use std::mem;
11use PageSetup;
12
13glib_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
21impl PrintContext {
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
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
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
46    pub fn get_dpi_x(&self) -> f64 {
47        unsafe { gtk_sys::gtk_print_context_get_dpi_x(self.to_glib_none().0) }
48    }
49
50    pub fn get_dpi_y(&self) -> f64 {
51        unsafe { gtk_sys::gtk_print_context_get_dpi_y(self.to_glib_none().0) }
52    }
53
54    pub fn get_hard_margins(&self) -> Option<(f64, f64, f64, f64)> {
55        unsafe {
56            let mut top = mem::uninitialized();
57            let mut bottom = mem::uninitialized();
58            let mut left = mem::uninitialized();
59            let mut right = mem::uninitialized();
60            let ret = from_glib(gtk_sys::gtk_print_context_get_hard_margins(
61                self.to_glib_none().0,
62                &mut top,
63                &mut bottom,
64                &mut left,
65                &mut right,
66            ));
67            if ret {
68                Some((top, bottom, left, right))
69            } else {
70                None
71            }
72        }
73    }
74
75    pub fn get_height(&self) -> f64 {
76        unsafe { gtk_sys::gtk_print_context_get_height(self.to_glib_none().0) }
77    }
78
79    pub fn get_page_setup(&self) -> Option<PageSetup> {
80        unsafe {
81            from_glib_none(gtk_sys::gtk_print_context_get_page_setup(
82                self.to_glib_none().0,
83            ))
84        }
85    }
86
87    pub fn get_pango_fontmap(&self) -> Option<pango::FontMap> {
88        unsafe {
89            from_glib_none(gtk_sys::gtk_print_context_get_pango_fontmap(
90                self.to_glib_none().0,
91            ))
92        }
93    }
94
95    pub fn get_width(&self) -> f64 {
96        unsafe { gtk_sys::gtk_print_context_get_width(self.to_glib_none().0) }
97    }
98
99    pub fn set_cairo_context(&self, cr: &cairo::Context, dpi_x: f64, dpi_y: f64) {
100        unsafe {
101            gtk_sys::gtk_print_context_set_cairo_context(
102                self.to_glib_none().0,
103                mut_override(cr.to_glib_none().0),
104                dpi_x,
105                dpi_y,
106            );
107        }
108    }
109}
110
111impl fmt::Display for PrintContext {
112    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
113        write!(f, "PrintContext")
114    }
115}