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