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

use crate::{Screen, VisualType};
use glib::translate::*;
use std::{fmt, mem};

glib::wrapper! {
    #[doc(alias = "GdkVisual")]
    pub struct Visual(Object<ffi::GdkVisual>);

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

impl Visual {
    #[doc(alias = "gdk_visual_get_blue_pixel_details")]
    #[doc(alias = "get_blue_pixel_details")]
    pub fn blue_pixel_details(&self) -> (u32, i32, i32) {
        unsafe {
            let mut mask = mem::MaybeUninit::uninit();
            let mut shift = mem::MaybeUninit::uninit();
            let mut precision = mem::MaybeUninit::uninit();
            ffi::gdk_visual_get_blue_pixel_details(
                self.to_glib_none().0,
                mask.as_mut_ptr(),
                shift.as_mut_ptr(),
                precision.as_mut_ptr(),
            );
            (
                mask.assume_init(),
                shift.assume_init(),
                precision.assume_init(),
            )
        }
    }

    #[doc(alias = "gdk_visual_get_depth")]
    #[doc(alias = "get_depth")]
    pub fn depth(&self) -> i32 {
        unsafe { ffi::gdk_visual_get_depth(self.to_glib_none().0) }
    }

    #[doc(alias = "gdk_visual_get_green_pixel_details")]
    #[doc(alias = "get_green_pixel_details")]
    pub fn green_pixel_details(&self) -> (u32, i32, i32) {
        unsafe {
            let mut mask = mem::MaybeUninit::uninit();
            let mut shift = mem::MaybeUninit::uninit();
            let mut precision = mem::MaybeUninit::uninit();
            ffi::gdk_visual_get_green_pixel_details(
                self.to_glib_none().0,
                mask.as_mut_ptr(),
                shift.as_mut_ptr(),
                precision.as_mut_ptr(),
            );
            (
                mask.assume_init(),
                shift.assume_init(),
                precision.assume_init(),
            )
        }
    }

    #[doc(alias = "gdk_visual_get_red_pixel_details")]
    #[doc(alias = "get_red_pixel_details")]
    pub fn red_pixel_details(&self) -> (u32, i32, i32) {
        unsafe {
            let mut mask = mem::MaybeUninit::uninit();
            let mut shift = mem::MaybeUninit::uninit();
            let mut precision = mem::MaybeUninit::uninit();
            ffi::gdk_visual_get_red_pixel_details(
                self.to_glib_none().0,
                mask.as_mut_ptr(),
                shift.as_mut_ptr(),
                precision.as_mut_ptr(),
            );
            (
                mask.assume_init(),
                shift.assume_init(),
                precision.assume_init(),
            )
        }
    }

    #[doc(alias = "gdk_visual_get_screen")]
    #[doc(alias = "get_screen")]
    pub fn screen(&self) -> Screen {
        unsafe { from_glib_none(ffi::gdk_visual_get_screen(self.to_glib_none().0)) }
    }

    #[doc(alias = "gdk_visual_get_visual_type")]
    #[doc(alias = "get_visual_type")]
    pub fn visual_type(&self) -> VisualType {
        unsafe { from_glib(ffi::gdk_visual_get_visual_type(self.to_glib_none().0)) }
    }
}

impl fmt::Display for Visual {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Visual")
    }
}
