1use glib::translate::*;
4
5use crate::{ffi, AttrType, Color};
6
7define_attribute_struct!(
8 AttrColor,
9 ffi::PangoAttrColor,
10 &[
11 AttrType::Foreground,
12 AttrType::Background,
13 AttrType::UnderlineColor,
14 AttrType::StrikethroughColor,
15 AttrType::OverlineColor
16 ]
17);
18
19impl AttrColor {
20 #[doc(alias = "pango_attr_background_new")]
21 pub fn new_background(red: u16, green: u16, blue: u16) -> Self {
22 unsafe { from_glib_full(ffi::pango_attr_background_new(red, green, blue)) }
23 }
24
25 #[doc(alias = "pango_attr_foreground_new")]
26 pub fn new_foreground(red: u16, green: u16, blue: u16) -> Self {
27 unsafe { from_glib_full(ffi::pango_attr_foreground_new(red, green, blue)) }
28 }
29
30 #[cfg(feature = "v1_46")]
31 #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
32 #[doc(alias = "pango_attr_overline_color_new")]
33 pub fn new_overline_color(red: u16, green: u16, blue: u16) -> Self {
34 unsafe { from_glib_full(ffi::pango_attr_overline_color_new(red, green, blue)) }
35 }
36
37 #[doc(alias = "pango_attr_strikethrough_color_new")]
38 pub fn new_strikethrough_color(red: u16, green: u16, blue: u16) -> Self {
39 unsafe { from_glib_full(ffi::pango_attr_strikethrough_color_new(red, green, blue)) }
40 }
41
42 #[doc(alias = "pango_attr_underline_color_new")]
43 pub fn new_underline_color(red: u16, green: u16, blue: u16) -> Self {
44 unsafe { from_glib_full(ffi::pango_attr_underline_color_new(red, green, blue)) }
45 }
46
47 pub fn color(&self) -> Color {
48 unsafe { from_glib_none((&self.inner.color) as *const ffi::PangoColor) }
49 }
50}