1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
// 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;
use crate::VisualType;
use glib::translate::*;
use std::fmt;
use std::mem;
glib::wrapper! {
/// A [`Visual`][crate::Visual] contains information about
/// a particular visual.
#[doc(alias = "GdkVisual")]
pub struct Visual(Object<ffi::GdkVisual>);
match fn {
type_ => || ffi::gdk_visual_get_type(),
}
}
impl Visual {
/// Obtains values that are needed to calculate blue pixel values in TrueColor
/// and DirectColor. The “mask” is the significant bits within the pixel.
/// The “shift” is the number of bits left we must shift a primary for it
/// to be in position (according to the "mask"). Finally, "precision" refers
/// to how much precision the pixel value contains for a particular primary.
///
/// # Returns
///
///
/// ## `mask`
/// A pointer to a `guint32` to be filled in, or [`None`]
///
/// ## `shift`
/// A pointer to a `gint` to be filled in, or [`None`]
///
/// ## `precision`
/// A pointer to a `gint` to be filled in, or [`None`]
#[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(),
)
}
}
/// Returns the bit depth of this visual.
///
/// # Returns
///
/// The bit depth of this visual.
#[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) }
}
/// Obtains values that are needed to calculate green pixel values in TrueColor
/// and DirectColor. The “mask” is the significant bits within the pixel.
/// The “shift” is the number of bits left we must shift a primary for it
/// to be in position (according to the "mask"). Finally, "precision" refers
/// to how much precision the pixel value contains for a particular primary.
///
/// # Returns
///
///
/// ## `mask`
/// A pointer to a `guint32` to be filled in, or [`None`]
///
/// ## `shift`
/// A pointer to a `gint` to be filled in, or [`None`]
///
/// ## `precision`
/// A pointer to a `gint` to be filled in, or [`None`]
#[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(),
)
}
}
/// Obtains values that are needed to calculate red pixel values in TrueColor
/// and DirectColor. The “mask” is the significant bits within the pixel.
/// The “shift” is the number of bits left we must shift a primary for it
/// to be in position (according to the "mask"). Finally, "precision" refers
/// to how much precision the pixel value contains for a particular primary.
///
/// # Returns
///
///
/// ## `mask`
/// A pointer to a `guint32` to be filled in, or [`None`]
///
/// ## `shift`
/// A pointer to a `gint` to be filled in, or [`None`]
///
/// ## `precision`
/// A pointer to a `gint` to be filled in, or [`None`]
#[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(),
)
}
}
/// Gets the screen to which this visual belongs
///
/// # Returns
///
/// the screen to which this visual belongs.
#[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)) }
}
/// Returns the type of visual this is (PseudoColor, TrueColor, etc).
///
/// # Returns
///
/// A [`VisualType`][crate::VisualType] stating the type of `self`.
#[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")
}
}