Skip to main content

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