1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdk.Visual;
26 
27 private import gdk.Screen;
28 private import gdk.c.functions;
29 public  import gdk.c.types;
30 private import glib.ListG;
31 private import gobject.ObjectG;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * A #GdkVisual contains information about
37  * a particular visual.
38  */
39 public class Visual : ObjectG
40 {
41 	/** the main Gtk struct */
42 	protected GdkVisual* gdkVisual;
43 
44 	/** Get the main Gtk struct */
45 	public GdkVisual* getVisualStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gdkVisual;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected override void* getStruct()
54 	{
55 		return cast(void*)gdkVisual;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GdkVisual* gdkVisual, bool ownedRef = false)
62 	{
63 		this.gdkVisual = gdkVisual;
64 		super(cast(GObject*)gdkVisual, ownedRef);
65 	}
66 
67 
68 	/** */
69 	public static GType getType()
70 	{
71 		return gdk_visual_get_type();
72 	}
73 
74 	/**
75 	 * Get the visual with the most available colors for the default
76 	 * GDK screen. The return value should not be freed.
77 	 *
78 	 * Deprecated: Visual selection should be done using
79 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
80 	 *
81 	 * Returns: best visual
82 	 */
83 	public static Visual getBest()
84 	{
85 		auto p = gdk_visual_get_best();
86 
87 		if(p is null)
88 		{
89 			return null;
90 		}
91 
92 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
93 	}
94 
95 	/**
96 	 * Get the best available depth for the default GDK screen.  “Best”
97 	 * means “largest,” i.e. 32 preferred over 24 preferred over 8 bits
98 	 * per pixel.
99 	 *
100 	 * Deprecated: Visual selection should be done using
101 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
102 	 *
103 	 * Returns: best available depth
104 	 */
105 	public static int getBestDepth()
106 	{
107 		return gdk_visual_get_best_depth();
108 	}
109 
110 	/**
111 	 * Return the best available visual type for the default GDK screen.
112 	 *
113 	 * Deprecated: Visual selection should be done using
114 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
115 	 *
116 	 * Returns: best visual type
117 	 */
118 	public static GdkVisualType getBestType()
119 	{
120 		return gdk_visual_get_best_type();
121 	}
122 
123 	/**
124 	 * Combines gdk_visual_get_best_with_depth() and
125 	 * gdk_visual_get_best_with_type().
126 	 *
127 	 * Deprecated: Visual selection should be done using
128 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
129 	 *
130 	 * Params:
131 	 *     depth = a bit depth
132 	 *     visualType = a visual type
133 	 *
134 	 * Returns: best visual with both @depth
135 	 *     and @visual_type, or %NULL if none
136 	 */
137 	public static Visual getBestWithBoth(int depth, GdkVisualType visualType)
138 	{
139 		auto p = gdk_visual_get_best_with_both(depth, visualType);
140 
141 		if(p is null)
142 		{
143 			return null;
144 		}
145 
146 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
147 	}
148 
149 	/**
150 	 * Get the best visual with depth @depth for the default GDK screen.
151 	 * Color visuals and visuals with mutable colormaps are preferred
152 	 * over grayscale or fixed-colormap visuals. The return value should
153 	 * not be freed. %NULL may be returned if no visual supports @depth.
154 	 *
155 	 * Deprecated: Visual selection should be done using
156 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
157 	 *
158 	 * Params:
159 	 *     depth = a bit depth
160 	 *
161 	 * Returns: best visual for the given depth
162 	 */
163 	public static Visual getBestWithDepth(int depth)
164 	{
165 		auto p = gdk_visual_get_best_with_depth(depth);
166 
167 		if(p is null)
168 		{
169 			return null;
170 		}
171 
172 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
173 	}
174 
175 	/**
176 	 * Get the best visual of the given @visual_type for the default GDK screen.
177 	 * Visuals with higher color depths are considered better. The return value
178 	 * should not be freed. %NULL may be returned if no visual has type
179 	 * @visual_type.
180 	 *
181 	 * Deprecated: Visual selection should be done using
182 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
183 	 *
184 	 * Params:
185 	 *     visualType = a visual type
186 	 *
187 	 * Returns: best visual of the given type
188 	 */
189 	public static Visual getBestWithType(GdkVisualType visualType)
190 	{
191 		auto p = gdk_visual_get_best_with_type(visualType);
192 
193 		if(p is null)
194 		{
195 			return null;
196 		}
197 
198 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
199 	}
200 
201 	/**
202 	 * Get the system’s default visual for the default GDK screen.
203 	 * This is the visual for the root window of the display.
204 	 * The return value should not be freed.
205 	 *
206 	 * Deprecated: Use gdk_screen_get_system_visual (gdk_screen_get_default ()).
207 	 *
208 	 * Returns: system visual
209 	 */
210 	public static Visual getSystem()
211 	{
212 		auto p = gdk_visual_get_system();
213 
214 		if(p is null)
215 		{
216 			return null;
217 		}
218 
219 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
220 	}
221 
222 	/**
223 	 * Returns the number of significant bits per red, green and blue value.
224 	 *
225 	 * Not all GDK backend provide a meaningful value for this function.
226 	 *
227 	 * Deprecated: Use gdk_visual_get_red_pixel_details() and its variants to
228 	 * learn about the pixel layout of TrueColor and DirectColor visuals
229 	 *
230 	 * Returns: The number of significant bits per color value for @visual.
231 	 *
232 	 * Since: 2.22
233 	 */
234 	public int getBitsPerRgb()
235 	{
236 		return gdk_visual_get_bits_per_rgb(gdkVisual);
237 	}
238 
239 	/**
240 	 * Obtains values that are needed to calculate blue pixel values in TrueColor
241 	 * and DirectColor. The “mask” is the significant bits within the pixel.
242 	 * The “shift” is the number of bits left we must shift a primary for it
243 	 * to be in position (according to the "mask"). Finally, "precision" refers
244 	 * to how much precision the pixel value contains for a particular primary.
245 	 *
246 	 * Params:
247 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
248 	 *     shift = A pointer to a #gint to be filled in, or %NULL
249 	 *     precision = A pointer to a #gint to be filled in, or %NULL
250 	 *
251 	 * Since: 2.22
252 	 */
253 	public void getBluePixelDetails(out uint mask, out int shift, out int precision)
254 	{
255 		gdk_visual_get_blue_pixel_details(gdkVisual, &mask, &shift, &precision);
256 	}
257 
258 	/**
259 	 * Returns the byte order of this visual.
260 	 *
261 	 * The information returned by this function is only relevant
262 	 * when working with XImages, and not all backends return
263 	 * meaningful information for this.
264 	 *
265 	 * Deprecated: This information is not useful
266 	 *
267 	 * Returns: A #GdkByteOrder stating the byte order of @visual.
268 	 *
269 	 * Since: 2.22
270 	 */
271 	public GdkByteOrder getByteOrder()
272 	{
273 		return gdk_visual_get_byte_order(gdkVisual);
274 	}
275 
276 	/**
277 	 * Returns the size of a colormap for this visual.
278 	 *
279 	 * You have to use platform-specific APIs to manipulate colormaps.
280 	 *
281 	 * Deprecated: This information is not useful, since GDK does not
282 	 * provide APIs to operate on colormaps.
283 	 *
284 	 * Returns: The size of a colormap that is suitable for @visual.
285 	 *
286 	 * Since: 2.22
287 	 */
288 	public int getColormapSize()
289 	{
290 		return gdk_visual_get_colormap_size(gdkVisual);
291 	}
292 
293 	/**
294 	 * Returns the bit depth of this visual.
295 	 *
296 	 * Returns: The bit depth of this visual.
297 	 *
298 	 * Since: 2.22
299 	 */
300 	public int getDepth()
301 	{
302 		return gdk_visual_get_depth(gdkVisual);
303 	}
304 
305 	/**
306 	 * Obtains values that are needed to calculate green pixel values in TrueColor
307 	 * and DirectColor. The “mask” is the significant bits within the pixel.
308 	 * The “shift” is the number of bits left we must shift a primary for it
309 	 * to be in position (according to the "mask"). Finally, "precision" refers
310 	 * to how much precision the pixel value contains for a particular primary.
311 	 *
312 	 * Params:
313 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
314 	 *     shift = A pointer to a #gint to be filled in, or %NULL
315 	 *     precision = A pointer to a #gint to be filled in, or %NULL
316 	 *
317 	 * Since: 2.22
318 	 */
319 	public void getGreenPixelDetails(out uint mask, out int shift, out int precision)
320 	{
321 		gdk_visual_get_green_pixel_details(gdkVisual, &mask, &shift, &precision);
322 	}
323 
324 	/**
325 	 * Obtains values that are needed to calculate red pixel values in TrueColor
326 	 * and DirectColor. The “mask” is the significant bits within the pixel.
327 	 * The “shift” is the number of bits left we must shift a primary for it
328 	 * to be in position (according to the "mask"). Finally, "precision" refers
329 	 * to how much precision the pixel value contains for a particular primary.
330 	 *
331 	 * Params:
332 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
333 	 *     shift = A pointer to a #gint to be filled in, or %NULL
334 	 *     precision = A pointer to a #gint to be filled in, or %NULL
335 	 *
336 	 * Since: 2.22
337 	 */
338 	public void getRedPixelDetails(out uint mask, out int shift, out int precision)
339 	{
340 		gdk_visual_get_red_pixel_details(gdkVisual, &mask, &shift, &precision);
341 	}
342 
343 	/**
344 	 * Gets the screen to which this visual belongs
345 	 *
346 	 * Returns: the screen to which this visual belongs.
347 	 *
348 	 * Since: 2.2
349 	 */
350 	public Screen getScreen()
351 	{
352 		auto p = gdk_visual_get_screen(gdkVisual);
353 
354 		if(p is null)
355 		{
356 			return null;
357 		}
358 
359 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
360 	}
361 
362 	/**
363 	 * Returns the type of visual this is (PseudoColor, TrueColor, etc).
364 	 *
365 	 * Returns: A #GdkVisualType stating the type of @visual.
366 	 *
367 	 * Since: 2.22
368 	 */
369 	public GdkVisualType getVisualType()
370 	{
371 		return gdk_visual_get_visual_type(gdkVisual);
372 	}
373 
374 	/**
375 	 * Lists the available visuals for the default screen.
376 	 * (See gdk_screen_list_visuals())
377 	 * A visual describes a hardware image data format.
378 	 * For example, a visual might support 24-bit color, or 8-bit color,
379 	 * and might expect pixels to be in a certain format.
380 	 *
381 	 * Call g_list_free() on the return value when you’re finished with it.
382 	 *
383 	 * Deprecated: Use gdk_screen_list_visuals (gdk_screen_get_default ()).
384 	 *
385 	 * Returns: a list of visuals; the list must be freed, but not its contents
386 	 */
387 	public static ListG listVisuals()
388 	{
389 		auto p = gdk_list_visuals();
390 
391 		if(p is null)
392 		{
393 			return null;
394 		}
395 
396 		return new ListG(cast(GList*) p);
397 	}
398 
399 	/**
400 	 * This function returns the available bit depths for the default
401 	 * screen. It’s equivalent to listing the visuals
402 	 * (gdk_list_visuals()) and then looking at the depth field in each
403 	 * visual, removing duplicates.
404 	 *
405 	 * The array returned by this function should not be freed.
406 	 *
407 	 * Deprecated: Visual selection should be done using
408 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
409 	 *
410 	 * Params:
411 	 *     depths = return
412 	 *         location for available depths
413 	 */
414 	public static void queryDepths(out int[] depths)
415 	{
416 		int* outdepths = null;
417 		int count;
418 
419 		gdk_query_depths(&outdepths, &count);
420 
421 		depths = outdepths[0 .. count];
422 	}
423 
424 	/**
425 	 * This function returns the available visual types for the default
426 	 * screen. It’s equivalent to listing the visuals
427 	 * (gdk_list_visuals()) and then looking at the type field in each
428 	 * visual, removing duplicates.
429 	 *
430 	 * The array returned by this function should not be freed.
431 	 *
432 	 * Deprecated: Visual selection should be done using
433 	 * gdk_screen_get_system_visual() and gdk_screen_get_rgba_visual()
434 	 *
435 	 * Params:
436 	 *     visualTypes = return
437 	 *         location for the available visual types
438 	 */
439 	public static void queryVisualTypes(out GdkVisualType[] visualTypes)
440 	{
441 		GdkVisualType* outvisualTypes = null;
442 		int count;
443 
444 		gdk_query_visual_types(&outvisualTypes, &count);
445 
446 		visualTypes = outvisualTypes[0 .. count];
447 	}
448 }