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