// This file was generated by gir (https://github.com/gtk-rs/gir)
// from ../gir-files
// from ../pps-girs
// DO NOT EDIT

#[cfg(feature = "v48")]
#[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
use crate::Page;
use crate::{ffi, Annotation, AnnotationMarkup};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "PpsAnnotationFreeText")]
    pub struct AnnotationFreeText(Object<ffi::PpsAnnotationFreeText, ffi::PpsAnnotationFreeTextClass>) @extends AnnotationMarkup, Annotation;

    match fn {
        type_ => || ffi::pps_annotation_free_text_get_type(),
    }
}

impl AnnotationFreeText {
    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_new")]
    pub fn new(page: &impl IsA<Page>) -> AnnotationFreeText {
        skip_assert_initialized!();
        unsafe {
            Annotation::from_glib_full(ffi::pps_annotation_free_text_new(
                page.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_auto_resize")]
    pub fn auto_resize(&self, ctx: &pango::Context) {
        unsafe {
            ffi::pps_annotation_free_text_auto_resize(self.to_glib_none().0, ctx.to_glib_none().0);
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_get_font_description")]
    #[doc(alias = "get_font_description")]
    pub fn font_description(&self) -> Option<pango::FontDescription> {
        unsafe {
            from_glib_full(ffi::pps_annotation_free_text_get_font_description(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_get_font_rgba")]
    #[doc(alias = "get_font_rgba")]
    #[doc(alias = "font-rgba")]
    pub fn font_rgba(&self) -> Option<gdk::RGBA> {
        unsafe {
            from_glib_full(ffi::pps_annotation_free_text_get_font_rgba(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_set_font_description")]
    pub fn set_font_description(&self, font_desc: &pango::FontDescription) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_free_text_set_font_description(
                self.to_glib_none().0,
                font_desc.to_glib_none().0,
            ))
        }
    }

    #[cfg(feature = "v48")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v48")))]
    #[doc(alias = "pps_annotation_free_text_set_font_rgba")]
    #[doc(alias = "font-rgba")]
    pub fn set_font_rgba(&self, rgba: &gdk::RGBA) -> bool {
        unsafe {
            from_glib(ffi::pps_annotation_free_text_set_font_rgba(
                self.to_glib_none().0,
                rgba.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "font-desc")]
    pub fn font_desc(&self) -> Option<pango::FontDescription> {
        ObjectExt::property(self, "font-desc")
    }

    #[doc(alias = "font-desc")]
    pub fn set_font_desc(&self, font_desc: Option<&pango::FontDescription>) {
        ObjectExt::set_property(self, "font-desc", font_desc)
    }

    #[cfg(not(feature = "v48"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v48"))))]
    #[doc(alias = "font-rgba")]
    pub fn font_rgba(&self) -> Option<gdk::RGBA> {
        ObjectExt::property(self, "font-rgba")
    }

    #[cfg(not(feature = "v48"))]
    #[cfg_attr(docsrs, doc(cfg(not(feature = "v48"))))]
    #[doc(alias = "font-rgba")]
    pub fn set_font_rgba(&self, font_rgba: Option<&gdk::RGBA>) {
        ObjectExt::set_property(self, "font-rgba", font_rgba)
    }

    #[doc(alias = "font-desc")]
    pub fn connect_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_font_desc_trampoline<F: Fn(&AnnotationFreeText) + 'static>(
            this: *mut ffi::PpsAnnotationFreeText,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::font-desc\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_font_desc_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "font-rgba")]
    pub fn connect_font_rgba_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_font_rgba_trampoline<F: Fn(&AnnotationFreeText) + 'static>(
            this: *mut ffi::PpsAnnotationFreeText,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::font-rgba\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_font_rgba_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}
