pango/
analysis.rs

1// Copyright 2018, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib::translate::*;
6use pango_sys;
7use EngineLang;
8use EngineShape;
9use Font;
10use Gravity;
11use Language;
12use Script;
13
14#[repr(C)]
15pub struct Analysis(pango_sys::PangoAnalysis);
16
17impl Analysis {
18    pub fn shape_engine(&self) -> EngineShape {
19        unsafe { from_glib_none(self.0.shape_engine) }
20    }
21
22    pub fn lang_engine(&self) -> EngineLang {
23        unsafe { from_glib_none(self.0.lang_engine) }
24    }
25
26    pub fn font(&self) -> Font {
27        unsafe { from_glib_none(self.0.font) }
28    }
29
30    pub fn level(&self) -> u8 {
31        self.0.level
32    }
33
34    pub fn gravity(&self) -> Gravity {
35        from_glib(self.0.gravity as i32)
36    }
37
38    pub fn flags(&self) -> u8 {
39        self.0.flags
40    }
41
42    pub fn script(&self) -> Script {
43        from_glib(self.0.script as i32)
44    }
45
46    pub fn language(&self) -> Language {
47        unsafe { from_glib_none(self.0.language) }
48    }
49
50    /*pub fn extra_attrs(&self) -> Vec<LogAttr> {
51        unsafe { from_glib_none_num_as_vec(self.0.extra_attrs) }
52    }*/
53}
54
55#[doc(hidden)]
56impl<'a> ToGlibPtr<'a, *const pango_sys::PangoAnalysis> for Analysis {
57    type Storage = &'a Self;
58
59    #[inline]
60    fn to_glib_none(&'a self) -> Stash<'a, *const pango_sys::PangoAnalysis, Self> {
61        let ptr: *const pango_sys::PangoAnalysis = &self.0;
62        Stash(ptr, self)
63    }
64}
65
66#[doc(hidden)]
67impl<'a> ToGlibPtrMut<'a, *mut pango_sys::PangoAnalysis> for Analysis {
68    type Storage = &'a mut Self;
69
70    #[inline]
71    fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut pango_sys::PangoAnalysis, Self> {
72        let ptr: *mut pango_sys::PangoAnalysis = &mut self.0;
73        StashMut(ptr, self)
74    }
75}
76
77#[doc(hidden)]
78impl FromGlibPtrNone<*const pango_sys::PangoAnalysis> for Analysis {
79    unsafe fn from_glib_none(ptr: *const pango_sys::PangoAnalysis) -> Self {
80        Analysis(*ptr)
81    }
82}
83
84#[doc(hidden)]
85impl FromGlibPtrNone<*mut pango_sys::PangoAnalysis> for Analysis {
86    unsafe fn from_glib_none(ptr: *mut pango_sys::PangoAnalysis) -> Self {
87        Analysis(*ptr)
88    }
89}