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