]> Pileus Git - ~andy/gtk/blob - gdk/gdkvisual.c
Inclusion cleanups in sources
[~andy/gtk] / gdk / gdkvisual.c
1 /* GDK - The GIMP Drawing Kit
2  * gdkvisual.c
3  * 
4  * Copyright 2001 Sun Microsystems Inc. 
5  *
6  * Erwann Chenede <erwann.chenede@sun.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "config.h"
25
26 #include "gdkvisual.h"
27
28 #include "gdkscreen.h"
29
30
31 /**
32  * gdk_list_visuals:
33  * 
34  * Lists the available visuals for the default screen.
35  * (See gdk_screen_list_visuals())
36  * A visual describes a hardware image data format.
37  * For example, a visual might support 24-bit color, or 8-bit color,
38  * and might expect pixels to be in a certain format.
39  *
40  * Call g_list_free() on the return value when you're finished with it.
41  * 
42  * Return value: (transfer container) (element-type GdkVisual):
43  *     a list of visuals; the list must be freed, but not its contents
44  **/
45 GList*
46 gdk_list_visuals (void)
47 {
48   return gdk_screen_list_visuals (gdk_screen_get_default ());
49 }
50
51 /**
52  * gdk_visual_get_system:
53  * 
54  * Get the system's default visual for the default GDK screen.
55  * This is the visual for the root window of the display.
56  * The return value should not be freed.
57  * 
58  * Return value: (transfer none): system visual
59  **/
60 GdkVisual*
61 gdk_visual_get_system (void)
62 {
63   return gdk_screen_get_system_visual (gdk_screen_get_default());
64 }
65
66 /**
67  * gdk_visual_get_visual_type:
68  * @visual: A #GdkVisual.
69  *
70  * Returns the type of visual this is (PseudoColor, TrueColor, etc).
71  *
72  * Return value: A #GdkVisualType stating the type of @visual.
73  *
74  * Since: 2.22
75  */
76 GdkVisualType
77 gdk_visual_get_visual_type (GdkVisual *visual)
78 {
79   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
80
81   return visual->type;
82 }
83
84 /**
85  * gdk_visual_get_depth:
86  * @visual: A #GdkVisual.
87  *
88  * Returns the bit depth of this visual.
89  *
90  * Return value: The bit depth of this visual.
91  *
92  * Since: 2.22
93  */
94 gint
95 gdk_visual_get_depth (GdkVisual *visual)
96 {
97   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
98
99   return visual->depth;
100 }
101
102 /**
103  * gdk_visual_get_byte_order:
104  * @visual: A #GdkVisual.
105  *
106  * Returns the byte order of this visual.
107  *
108  * Return value: A #GdkByteOrder stating the byte order of @visual.
109  *
110  * Since: 2.22
111  */
112 GdkByteOrder
113 gdk_visual_get_byte_order (GdkVisual *visual)
114 {
115   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
116
117   return visual->byte_order;
118 }
119
120 /**
121  * gdk_visual_get_colormap_size:
122  * @visual: A #GdkVisual.
123  *
124  * Returns the size of a colormap for this visual.
125  *
126  * Return value: The size of a colormap that is suitable for @visual.
127  *
128  * Since: 2.22
129  */
130 gint
131 gdk_visual_get_colormap_size (GdkVisual *visual)
132 {
133   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
134
135   return visual->colormap_size;
136 }
137
138 /**
139  * gdk_visual_get_bits_per_rgb:
140  * @visual: a #GdkVisual
141  *
142  * Returns the number of significant bits per red, green and blue value.
143  *
144  * Return value: The number of significant bits per color value for @visual.
145  *
146  * Since: 2.22
147  */
148 gint
149 gdk_visual_get_bits_per_rgb (GdkVisual *visual)
150 {
151   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
152
153   return visual->bits_per_rgb;
154 }
155
156 /**
157  * gdk_visual_get_red_pixel_details:
158  * @visual: A #GdkVisual.
159  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
160  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
161  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
162  *
163  * Obtains values that are needed to calculate red pixel values in TrueColor
164  * and DirectColor.  The "mask" is the significant bits within the pixel.
165  * The "shift" is the number of bits left we must shift a primary for it
166  * to be in position (according to the "mask").  Finally, "precision" refers
167  * to how much precision the pixel value contains for a particular primary.
168  *
169  * Since: 2.22
170  */
171 void
172 gdk_visual_get_red_pixel_details (GdkVisual *visual,
173                                   guint32   *mask,
174                                   gint      *shift,
175                                   gint      *precision)
176 {
177   g_return_if_fail (GDK_IS_VISUAL (visual));
178
179   if (mask)
180     *mask = visual->red_mask;
181
182   if (shift)
183     *shift = visual->red_shift;
184
185   if (precision)
186     *precision = visual->red_prec;
187 }
188
189 /**
190  * gdk_visual_get_green_pixel_details:
191  * @visual: a #GdkVisual
192  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
193  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
194  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
195  *
196  * Obtains values that are needed to calculate green pixel values in TrueColor
197  * and DirectColor.  The "mask" is the significant bits within the pixel.
198  * The "shift" is the number of bits left we must shift a primary for it
199  * to be in position (according to the "mask").  Finally, "precision" refers
200  * to how much precision the pixel value contains for a particular primary.
201  *
202  * Since: 2.22
203  */
204 void
205 gdk_visual_get_green_pixel_details (GdkVisual *visual,
206                                     guint32   *mask,
207                                     gint      *shift,
208                                     gint      *precision)
209 {
210   g_return_if_fail (GDK_IS_VISUAL (visual));
211
212   if (mask)
213     *mask = visual->green_mask;
214
215   if (shift)
216     *shift = visual->green_shift;
217
218   if (precision)
219     *precision = visual->green_prec;
220 }
221
222 /**
223  * gdk_visual_get_blue_pixel_details:
224  * @visual: a #GdkVisual
225  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
226  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
227  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
228  *
229  * Obtains values that are needed to calculate blue pixel values in TrueColor
230  * and DirectColor.  The "mask" is the significant bits within the pixel.
231  * The "shift" is the number of bits left we must shift a primary for it
232  * to be in position (according to the "mask").  Finally, "precision" refers
233  * to how much precision the pixel value contains for a particular primary.
234  *
235  * Since: 2.22
236  */
237 void
238 gdk_visual_get_blue_pixel_details (GdkVisual *visual,
239                                    guint32   *mask,
240                                    gint      *shift,
241                                    gint      *precision)
242 {
243   g_return_if_fail (GDK_IS_VISUAL (visual));
244
245   if (mask)
246     *mask = visual->blue_mask;
247
248   if (shift)
249     *shift = visual->blue_shift;
250
251   if (precision)
252     *precision = visual->blue_prec;
253 }