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::Rectangle; 6 use glib::translate::*; 7 use std::mem; 8 use std::ptr; 9 10 glib::wrapper! { 11 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 12 pub struct LayoutLine(Shared<ffi::PangoLayoutLine>); 13 14 match fn { 15 ref => |ptr| ffi::pango_layout_line_ref(ptr), 16 unref => |ptr| ffi::pango_layout_line_unref(ptr), 17 type_ => || ffi::pango_layout_line_get_type(), 18 } 19 } 20 21 impl LayoutLine { 22 #[doc(alias = "pango_layout_line_get_extents")] 23 #[doc(alias = "get_extents")] extents(&self) -> (Rectangle, Rectangle)24 pub fn extents(&self) -> (Rectangle, Rectangle) { 25 unsafe { 26 let mut ink_rect = Rectangle::uninitialized(); 27 let mut logical_rect = Rectangle::uninitialized(); 28 ffi::pango_layout_line_get_extents( 29 self.to_glib_none().0, 30 ink_rect.to_glib_none_mut().0, 31 logical_rect.to_glib_none_mut().0, 32 ); 33 (ink_rect, logical_rect) 34 } 35 } 36 37 #[cfg(any(feature = "v1_44", feature = "dox"))] 38 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_44")))] 39 #[doc(alias = "pango_layout_line_get_height")] 40 #[doc(alias = "get_height")] height(&self) -> i3241 pub fn height(&self) -> i32 { 42 unsafe { 43 let mut height = mem::MaybeUninit::uninit(); 44 ffi::pango_layout_line_get_height(self.to_glib_none().0, height.as_mut_ptr()); 45 let height = height.assume_init(); 46 height 47 } 48 } 49 50 #[doc(alias = "pango_layout_line_get_pixel_extents")] 51 #[doc(alias = "get_pixel_extents")] pixel_extents(&self) -> (Rectangle, Rectangle)52 pub fn pixel_extents(&self) -> (Rectangle, Rectangle) { 53 unsafe { 54 let mut ink_rect = Rectangle::uninitialized(); 55 let mut logical_rect = Rectangle::uninitialized(); 56 ffi::pango_layout_line_get_pixel_extents( 57 self.to_glib_none().0, 58 ink_rect.to_glib_none_mut().0, 59 logical_rect.to_glib_none_mut().0, 60 ); 61 (ink_rect, logical_rect) 62 } 63 } 64 65 #[doc(alias = "pango_layout_line_get_x_ranges")] 66 #[doc(alias = "get_x_ranges")] x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32>67 pub fn x_ranges(&self, start_index: i32, end_index: i32) -> Vec<i32> { 68 unsafe { 69 let mut ranges = ptr::null_mut(); 70 let mut n_ranges = mem::MaybeUninit::uninit(); 71 ffi::pango_layout_line_get_x_ranges( 72 self.to_glib_none().0, 73 start_index, 74 end_index, 75 &mut ranges, 76 n_ranges.as_mut_ptr(), 77 ); 78 FromGlibContainer::from_glib_full_num(ranges, n_ranges.assume_init() as usize) 79 } 80 } 81 82 #[doc(alias = "pango_layout_line_index_to_x")] index_to_x(&self, index_: i32, trailing: bool) -> i3283 pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32 { 84 unsafe { 85 let mut x_pos = mem::MaybeUninit::uninit(); 86 ffi::pango_layout_line_index_to_x( 87 self.to_glib_none().0, 88 index_, 89 trailing.into_glib(), 90 x_pos.as_mut_ptr(), 91 ); 92 let x_pos = x_pos.assume_init(); 93 x_pos 94 } 95 } 96 } 97