]> Pileus Git - ~andy/gtk/blob - gdk/gdkvisual.c
Seal gdk
[~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 #include "gdkvisual.h"
26 #include "gdkscreen.h"
27 #include "gdkalias.h"
28
29 /**
30  * gdk_list_visuals:
31  * 
32  * Lists the available visuals for the default screen.
33  * (See gdk_screen_list_visuals())
34  * A visual describes a hardware image data format.
35  * For example, a visual might support 24-bit color, or 8-bit color,
36  * and might expect pixels to be in a certain format.
37  *
38  * Call g_list_free() on the return value when you're finished with it.
39  * 
40  * Return value: a list of visuals; the list must be freed, but not its contents
41  **/
42 GList*
43 gdk_list_visuals (void)
44 {
45   return gdk_screen_list_visuals (gdk_screen_get_default ());
46 }
47
48 /**
49  * gdk_visual_get_system:
50  * 
51  * Get the system's default visual for the default GDK screen.
52  * This is the visual for the root window of the display.
53  * The return value should not be freed.
54  * 
55  * Return value: (transfer none): system visual
56  **/
57 GdkVisual*
58 gdk_visual_get_system (void)
59 {
60   return gdk_screen_get_system_visual (gdk_screen_get_default());
61 }
62
63 /**
64  * gdk_visual_get_visual_type:
65  * @visual: A #GdkVisual.
66  *
67  * Returns the type of visual this is (PseudoColor, TrueColor, etc).
68  *
69  * Return value: A #GdkVisualType stating the type of @visual.
70  *
71  * Since: 2.22
72  */
73 GdkVisualType
74 gdk_visual_get_visual_type (GdkVisual *visual)
75 {
76   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
77
78   return visual->type;
79 }
80
81 /**
82  * gdk_visual_get_depth:
83  * @visual: A #GdkVisual.
84  *
85  * Returns the bit depth of this visual.
86  *
87  * Return value: The bit depth of this visual.
88  *
89  * Since: 2.22
90  */
91 gint
92 gdk_visual_get_depth (GdkVisual *visual)
93 {
94   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
95
96   return visual->depth;
97 }
98
99 /**
100  * gdk_visual_get_byte_order:
101  * @visual: A #GdkVisual.
102  *
103  * Returns the byte order of this visual.
104  *
105  * Return value: A #GdkByteOrder stating the byte order of @visual.
106  *
107  * Since: 2.22
108  */
109 GdkByteOrder
110 gdk_visual_get_byte_order (GdkVisual *visual)
111 {
112   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
113
114   return visual->byte_order;
115 }
116
117 /**
118  * gdk_visual_get_colormap_size:
119  * @visual: A #GdkVisual.
120  *
121  * Returns the size of a colormap for this visual.
122  *
123  * Return value: The size of a colormap that is suitable for @visual.
124  *
125  * Since: 2.22
126  */
127 gint
128 gdk_visual_get_colormap_size (GdkVisual *visual)
129 {
130   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
131
132   return visual->colormap_size;
133 }
134
135 /**
136  * gdk_visual_get_bits_per_rgb:
137  * @visual: a #GdkVisual
138  *
139  * Returns the number of significant bits per red, green and blue value.
140  *
141  * Return value: The number of significant bits per color value for @visual.
142  *
143  * Since: 2.22
144  */
145 gint
146 gdk_visual_get_bits_per_rgb (GdkVisual *visual)
147 {
148   g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
149
150   return visual->bits_per_rgb;
151 }
152
153 /**
154  * gdk_visual_get_red_pixel_details:
155  * @visual: A #GdkVisual.
156  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
157  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
158  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
159  *
160  * Obtains values that are needed to calculate red pixel values in TrueColor
161  * and DirectColor.  The "mask" is the significant bits within the pixel.
162  * The "shift" is the number of bits left we must shift a primary for it
163  * to be in position (according to the "mask").  Finally, "precision" refers
164  * to how much precision the pixel value contains for a particular primary.
165  *
166  * Since: 2.22
167  */
168 void
169 gdk_visual_get_red_pixel_details (GdkVisual *visual,
170                                   guint32   *mask,
171                                   gint      *shift,
172                                   gint      *precision)
173 {
174   g_return_if_fail (GDK_IS_VISUAL (visual));
175
176   if (mask)
177     *mask = visual->red_mask;
178
179   if (shift)
180     *shift = visual->red_shift;
181
182   if (precision)
183     *precision = visual->red_prec;
184 }
185
186 /**
187  * gdk_visual_get_green_pixel_details:
188  * @visual: a #GdkVisual
189  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
190  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
191  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
192  *
193  * Obtains values that are needed to calculate green pixel values in TrueColor
194  * and DirectColor.  The "mask" is the significant bits within the pixel.
195  * The "shift" is the number of bits left we must shift a primary for it
196  * to be in position (according to the "mask").  Finally, "precision" refers
197  * to how much precision the pixel value contains for a particular primary.
198  *
199  * Since: 2.22
200  */
201 void
202 gdk_visual_get_green_pixel_details (GdkVisual *visual,
203                                     guint32   *mask,
204                                     gint      *shift,
205                                     gint      *precision)
206 {
207   g_return_if_fail (GDK_IS_VISUAL (visual));
208
209   if (mask)
210     *mask = visual->green_mask;
211
212   if (shift)
213     *shift = visual->green_shift;
214
215   if (precision)
216     *precision = visual->green_prec;
217 }
218
219 /**
220  * gdk_visual_get_blue_pixel_details:
221  * @visual: a #GdkVisual
222  * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
223  * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
224  * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
225  *
226  * Obtains values that are needed to calculate blue pixel values in TrueColor
227  * and DirectColor.  The "mask" is the significant bits within the pixel.
228  * The "shift" is the number of bits left we must shift a primary for it
229  * to be in position (according to the "mask").  Finally, "precision" refers
230  * to how much precision the pixel value contains for a particular primary.
231  *
232  * Since: 2.22
233  */
234 void
235 gdk_visual_get_blue_pixel_details (GdkVisual *visual,
236                                    guint32   *mask,
237                                    gint      *shift,
238                                    gint      *precision)
239 {
240   g_return_if_fail (GDK_IS_VISUAL (visual));
241
242   if (mask)
243     *mask = visual->blue_mask;
244
245   if (shift)
246     *shift = visual->blue_shift;
247
248   if (precision)
249     *precision = visual->blue_prec;
250 }
251
252 #define __GDK_VISUAL_C__
253 #include "gdkaliasdef.c"