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