pango/
attr_int.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5#[cfg(feature = "v1_50")]
6use crate::BaselineShift;
7#[cfg(feature = "v1_50")]
8use crate::FontScale;
9#[cfg(feature = "v1_46")]
10use crate::Overline;
11#[cfg(feature = "v1_44")]
12use crate::ShowFlags;
13#[cfg(feature = "v1_50")]
14use crate::TextTransform;
15use crate::{ffi, AttrType, Gravity, GravityHint, Stretch, Style, Underline, Variant, Weight};
16
17define_attribute_struct!(
18    AttrInt,
19    ffi::PangoAttrInt,
20    &[
21        #[cfg(feature = "v1_50")]
22        AttrType::AbsoluteLineHeight,
23        #[cfg(feature = "v1_50")]
24        AttrType::BaselineShift,
25        #[cfg(feature = "v1_50")]
26        AttrType::FontScale,
27        #[cfg(feature = "v1_50")]
28        AttrType::Sentence,
29        #[cfg(feature = "v1_50")]
30        AttrType::TextTransform,
31        #[cfg(feature = "v1_50")]
32        AttrType::Word,
33        AttrType::AllowBreaks,
34        AttrType::BackgroundAlpha,
35        AttrType::Fallback,
36        AttrType::ForegroundAlpha,
37        AttrType::Gravity,
38        AttrType::GravityHint,
39        AttrType::InsertHyphens,
40        AttrType::LetterSpacing,
41        AttrType::Overline,
42        AttrType::Rise,
43        AttrType::Show,
44        AttrType::Stretch,
45        AttrType::Strikethrough,
46        AttrType::Style,
47        AttrType::Underline,
48        AttrType::Variant,
49        AttrType::Weight
50    ]
51);
52
53impl AttrInt {
54    #[cfg(feature = "v1_50")]
55    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
56    #[doc(alias = "pango_attr_line_height_new_absolute")]
57    pub fn new_line_height_absolute(height: i32) -> Self {
58        unsafe { from_glib_full(ffi::pango_attr_line_height_new_absolute(height)) }
59    }
60
61    #[cfg(feature = "v1_50")]
62    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
63    #[doc(alias = "pango_attr_baseline_shift_new")]
64    pub fn new_baseline_shift(shift: BaselineShift) -> Self {
65        unsafe { from_glib_full(ffi::pango_attr_baseline_shift_new(shift.into_glib())) }
66    }
67
68    #[cfg(feature = "v1_50")]
69    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
70    #[doc(alias = "pango_attr_font_scale_new")]
71    pub fn new_font_scale(scale: FontScale) -> Self {
72        unsafe { from_glib_full(ffi::pango_attr_font_scale_new(scale.into_glib())) }
73    }
74
75    #[cfg(feature = "v1_50")]
76    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
77    #[doc(alias = "pango_attr_sentence_new")]
78    pub fn new_sentence() -> Self {
79        unsafe { from_glib_full(ffi::pango_attr_sentence_new()) }
80    }
81
82    #[cfg(feature = "v1_50")]
83    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
84    #[doc(alias = "pango_attr_text_transform_new")]
85    pub fn new_text_transform(transform: TextTransform) -> Self {
86        unsafe { from_glib_full(ffi::pango_attr_text_transform_new(transform.into_glib())) }
87    }
88
89    #[cfg(feature = "v1_50")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
91    #[doc(alias = "pango_attr_word_new")]
92    pub fn new_word() -> Self {
93        unsafe { from_glib_full(ffi::pango_attr_word_new()) }
94    }
95
96    #[cfg(feature = "v1_44")]
97    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
98    #[doc(alias = "pango_attr_allow_breaks_new")]
99    pub fn new_allow_breaks(allow_breaks: bool) -> Self {
100        unsafe { from_glib_full(ffi::pango_attr_allow_breaks_new(allow_breaks.into_glib())) }
101    }
102
103    #[doc(alias = "pango_attr_background_alpha_new")]
104    pub fn new_background_alpha(alpha: u16) -> Self {
105        unsafe { from_glib_full(ffi::pango_attr_background_alpha_new(alpha)) }
106    }
107
108    #[doc(alias = "pango_attr_fallback_new")]
109    pub fn new_fallback(enable_fallback: bool) -> Self {
110        unsafe { from_glib_full(ffi::pango_attr_fallback_new(enable_fallback.into_glib())) }
111    }
112
113    #[doc(alias = "pango_attr_foreground_alpha_new")]
114    pub fn new_foreground_alpha(alpha: u16) -> Self {
115        unsafe { from_glib_full(ffi::pango_attr_foreground_alpha_new(alpha)) }
116    }
117
118    #[doc(alias = "pango_attr_gravity_hint_new")]
119    pub fn new_gravity_hint(hint: GravityHint) -> Self {
120        unsafe { from_glib_full(ffi::pango_attr_gravity_hint_new(hint.into_glib())) }
121    }
122
123    #[doc(alias = "pango_attr_weight_new")]
124    pub fn new_weight(weight: Weight) -> Self {
125        unsafe { from_glib_full(ffi::pango_attr_weight_new(weight.into_glib())) }
126    }
127
128    #[doc(alias = "pango_attr_gravity_new")]
129    pub fn new_gravity(gravity: Gravity) -> Self {
130        unsafe { from_glib_full(ffi::pango_attr_gravity_new(gravity.into_glib())) }
131    }
132
133    #[cfg(feature = "v1_44")]
134    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
135    #[doc(alias = "pango_attr_insert_hyphens_new")]
136    pub fn new_insert_hyphens(insert_hyphens: bool) -> Self {
137        unsafe {
138            from_glib_full(ffi::pango_attr_insert_hyphens_new(
139                insert_hyphens.into_glib(),
140            ))
141        }
142    }
143
144    #[doc(alias = "pango_attr_letter_spacing_new")]
145    pub fn new_letter_spacing(letter_spacing: i32) -> Self {
146        unsafe { from_glib_full(ffi::pango_attr_letter_spacing_new(letter_spacing)) }
147    }
148
149    #[cfg(feature = "v1_46")]
150    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
151    #[doc(alias = "pango_attr_overline_new")]
152    pub fn new_overline(overline: Overline) -> Self {
153        unsafe { from_glib_full(ffi::pango_attr_overline_new(overline.into_glib())) }
154    }
155
156    #[doc(alias = "pango_attr_rise_new")]
157    pub fn new_rise(rise: i32) -> Self {
158        unsafe { from_glib_full(ffi::pango_attr_rise_new(rise)) }
159    }
160
161    #[cfg(feature = "v1_44")]
162    #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
163    #[doc(alias = "pango_attr_show_new")]
164    pub fn new_show(flags: ShowFlags) -> Self {
165        unsafe { from_glib_full(ffi::pango_attr_show_new(flags.into_glib())) }
166    }
167
168    #[doc(alias = "pango_attr_stretch_new")]
169    pub fn new_stretch(stretch: Stretch) -> Self {
170        unsafe { from_glib_full(ffi::pango_attr_stretch_new(stretch.into_glib())) }
171    }
172
173    #[doc(alias = "pango_attr_strikethrough_new")]
174    pub fn new_strikethrough(strikethrough: bool) -> Self {
175        unsafe { from_glib_full(ffi::pango_attr_strikethrough_new(strikethrough.into_glib())) }
176    }
177
178    #[doc(alias = "pango_attr_style_new")]
179    pub fn new_style(style: Style) -> Self {
180        unsafe { from_glib_full(ffi::pango_attr_style_new(style.into_glib())) }
181    }
182
183    #[doc(alias = "pango_attr_underline_new")]
184    pub fn new_underline(underline: Underline) -> Self {
185        unsafe { from_glib_full(ffi::pango_attr_underline_new(underline.into_glib())) }
186    }
187
188    #[doc(alias = "pango_attr_variant_new")]
189    pub fn new_variant(variant: Variant) -> Self {
190        unsafe { from_glib_full(ffi::pango_attr_variant_new(variant.into_glib())) }
191    }
192
193    pub fn value(&self) -> i32 {
194        self.inner.value
195    }
196}