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