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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
// 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::ByteOrder;
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 {
/// Returns the number of significant bits per red, green and blue value.
///
/// Not all GDK backend provide a meaningful value for this function.
///
/// # Deprecated since 3.22
///
/// Use [`red_pixel_details()`][Self::red_pixel_details()] and its variants to
/// learn about the pixel layout of TrueColor and DirectColor visuals
///
/// # Returns
///
/// The number of significant bits per color value for `self`.
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_bits_per_rgb")]
#[doc(alias = "get_bits_per_rgb")]
pub fn bits_per_rgb(&self) -> i32 {
unsafe { ffi::gdk_visual_get_bits_per_rgb(self.to_glib_none().0) }
}
/// 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(),
);
let mask = mask.assume_init();
let shift = shift.assume_init();
let precision = precision.assume_init();
(mask, shift, precision)
}
}
/// Returns the byte order of this visual.
///
/// The information returned by this function is only relevant
/// when working with XImages, and not all backends return
/// meaningful information for this.
///
/// # Deprecated since 3.22
///
/// This information is not useful
///
/// # Returns
///
/// A [`ByteOrder`][crate::ByteOrder] stating the byte order of `self`.
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_byte_order")]
#[doc(alias = "get_byte_order")]
pub fn byte_order(&self) -> ByteOrder {
unsafe { from_glib(ffi::gdk_visual_get_byte_order(self.to_glib_none().0)) }
}
/// Returns the size of a colormap for this visual.
///
/// You have to use platform-specific APIs to manipulate colormaps.
///
/// # Deprecated since 3.22
///
/// This information is not useful, since GDK does not
/// provide APIs to operate on colormaps.
///
/// # Returns
///
/// The size of a colormap that is suitable for `self`.
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_colormap_size")]
#[doc(alias = "get_colormap_size")]
pub fn colormap_size(&self) -> i32 {
unsafe { ffi::gdk_visual_get_colormap_size(self.to_glib_none().0) }
}
/// 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(),
);
let mask = mask.assume_init();
let shift = shift.assume_init();
let precision = precision.assume_init();
(mask, shift, precision)
}
}
/// 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(),
);
let mask = mask.assume_init();
let shift = shift.assume_init();
let precision = precision.assume_init();
(mask, shift, precision)
}
}
/// 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)) }
}
/// Get the visual with the most available colors for the default
/// GDK screen. The return value should not be freed.
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
///
/// # Returns
///
/// best visual
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best")]
#[doc(alias = "get_best")]
pub fn best() -> Visual {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_visual_get_best()) }
}
/// Get the best available depth for the default GDK screen. “Best”
/// means “largest,” i.e. 32 preferred over 24 preferred over 8 bits
/// per pixel.
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
///
/// # Returns
///
/// best available depth
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best_depth")]
#[doc(alias = "get_best_depth")]
pub fn best_depth() -> i32 {
assert_initialized_main_thread!();
unsafe { ffi::gdk_visual_get_best_depth() }
}
/// Return the best available visual type for the default GDK screen.
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
///
/// # Returns
///
/// best visual type
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best_type")]
#[doc(alias = "get_best_type")]
pub fn best_type() -> VisualType {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::gdk_visual_get_best_type()) }
}
/// Combines [`best_with_depth()`][Self::best_with_depth()] and
/// [`best_with_type()`][Self::best_with_type()].
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
/// ## `depth`
/// a bit depth
/// ## `visual_type`
/// a visual type
///
/// # Returns
///
/// best visual with both `depth`
/// and `visual_type`, or [`None`] if none
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best_with_both")]
#[doc(alias = "get_best_with_both")]
pub fn best_with_both(depth: i32, visual_type: VisualType) -> Option<Visual> {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gdk_visual_get_best_with_both(
depth,
visual_type.into_glib(),
))
}
}
/// Get the best visual with depth `depth` for the default GDK screen.
/// Color visuals and visuals with mutable colormaps are preferred
/// over grayscale or fixed-colormap visuals. The return value should
/// not be freed. [`None`] may be returned if no visual supports `depth`.
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
/// ## `depth`
/// a bit depth
///
/// # Returns
///
/// best visual for the given depth
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best_with_depth")]
#[doc(alias = "get_best_with_depth")]
pub fn best_with_depth(depth: i32) -> Option<Visual> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_visual_get_best_with_depth(depth)) }
}
/// Get the best visual of the given `visual_type` for the default GDK screen.
/// Visuals with higher color depths are considered better. The return value
/// should not be freed. [`None`] may be returned if no visual has type
/// `visual_type`.
///
/// # Deprecated since 3.22
///
/// Visual selection should be done using
/// [`Screen::system_visual()`][crate::Screen::system_visual()] and [`Screen::rgba_visual()`][crate::Screen::rgba_visual()]
/// ## `visual_type`
/// a visual type
///
/// # Returns
///
/// best visual of the given type
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_best_with_type")]
#[doc(alias = "get_best_with_type")]
pub fn best_with_type(visual_type: VisualType) -> Option<Visual> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_visual_get_best_with_type(visual_type.into_glib())) }
}
/// Get the system’s default visual for the default GDK screen.
/// This is the visual for the root window of the display.
/// The return value should not be freed.
///
/// # Deprecated since 3.22
///
/// Use gdk_screen_get_system_visual (gdk_screen_get_default ()).
///
/// # Returns
///
/// system visual
#[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")]
#[doc(alias = "gdk_visual_get_system")]
#[doc(alias = "get_system")]
pub fn system() -> Visual {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::gdk_visual_get_system()) }
}
}
impl fmt::Display for Visual {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Visual")
}
}