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