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  * Conversion parameters:
26  * inFile  = gdk-Visuals.html
27  * outPack = gdk
28  * outFile = Visual
29  * strct   = GdkVisual
30  * realStrct=
31  * ctorStrct=
32  * clss    = Visual
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_visual_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gdk_query_depths
45  * omit signals:
46  * imports:
47  * 	- glib.ListG
48  * 	- gdk.Screen
49  * structWrap:
50  * 	- GList* -> ListG
51  * 	- GdkScreen* -> Screen
52  * 	- GdkVisual* -> Visual
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gdk.Visual;
59 
60 public  import gtkc.gdktypes;
61 
62 private import gtkc.gdk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 
67 private import glib.ListG;
68 private import gdk.Screen;
69 
70 
71 
72 
73 /**
74  * Description
75  * A GdkVisual describes a particular video hardware display format. It includes
76  * information about the number of bits used for each color, the way the bits are
77  * translated into an RGB value for display, and the way the bits are stored in
78  * memory. For example, a piece of display hardware might support 24-bit color,
79  * 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given
80  * pixel size, pixels can be in different formats; for example the "red" element
81  * of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower
82  * 4 bits.
83  * Usually you can avoid thinking about visuals in GTK+. Visuals are useful to
84  * interpret the contents of a GdkImage, but you should avoid GdkImage precisely
85  * because its contents depend on the display hardware; use GdkPixbuf instead, for
86  * all but the most low-level purposes. Also, anytime you provide a GdkColormap,
87  * the visual is implied as part of the colormap (gdk_colormap_get_visual()), so
88  * you won't have to provide a visual in addition.
89  * There are several standard visuals. The visual returned
90  * by gdk_visual_get_system() is the system's default
91  * visual. gdk_rgb_get_visual() return the visual most
92  * suited to displaying full-color image data. If you
93  * use the calls in GdkRGB, you should create your windows
94  * using this visual (and the colormap returned by
95  * gdk_rgb_get_colormap()).
96  * A number of functions are provided for determining
97  * the "best" available visual. For the purposes of
98  * making this determination, higher bit depths are
99  * considered better, and for visuals of the same
100  * bit depth, GDK_VISUAL_PSEUDO_COLOR is preferred at
101  * 8bpp, otherwise, the visual types are ranked in the
102  * order of (highest to lowest) GDK_VISUAL_DIRECT_COLOR,
103  * GDK_VISUAL_TRUE_COLOR, GDK_VISUAL_PSEUDO_COLOR,
104  * GDK_VISUAL_STATIC_COLOR, GDK_VISUAL_GRAYSCALE,
105  * then GDK_VISUAL_STATIC_GRAY.
106  */
107 public class Visual
108 {
109 	
110 	/** the main Gtk struct */
111 	protected GdkVisual* gdkVisual;
112 	
113 	
114 	public GdkVisual* getVisualStruct()
115 	{
116 		return gdkVisual;
117 	}
118 	
119 	
120 	/** the main Gtk struct as a void* */
121 	protected void* getStruct()
122 	{
123 		return cast(void*)gdkVisual;
124 	}
125 	
126 	/**
127 	 * Sets our main struct and passes it to the parent class
128 	 */
129 	public this (GdkVisual* gdkVisual)
130 	{
131 		this.gdkVisual = gdkVisual;
132 	}
133 	
134 	/**
135 	 * This function returns the available bit depths for the default
136 	 * screen. It's equivalent to listing the visuals
137 	 * (gdk_list_visuals()) and then looking at the depth field in each
138 	 * visual, removing duplicates.
139 	 * The array returned by this function should not be freed.
140 	 * Params:
141 	 * depths =  return location for available depths
142 	 */
143 	public static void gdkQueryDepths(out int[] depths)
144 	{
145 		int* dep = null;
146 		int count;
147 		
148 		// void gdk_query_depths (gint **depths,  gint *count);
149 		gdk_query_depths(&dep, &count);
150 		
151 		depths = dep[0 .. count];
152 	}
153 	
154 	/**
155 	 */
156 	
157 	/**
158 	 * This function returns the available visual types for the default
159 	 * screen. It's equivalent to listing the visuals
160 	 * (gdk_list_visuals()) and then looking at the type field in each
161 	 * visual, removing duplicates.
162 	 * The array returned by this function should not be freed.
163 	 * Params:
164 	 * visualTypes = return location for the available visual types
165 	 */
166 	public static void gdkQueryVisualTypes(out GdkVisualType[] visualTypes)
167 	{
168 		// void gdk_query_visual_types (GdkVisualType **visual_types,  gint *count);
169 		GdkVisualType* outvisualTypes = null;
170 		int count;
171 		
172 		gdk_query_visual_types(&outvisualTypes, &count);
173 		
174 		visualTypes = outvisualTypes[0 .. count];
175 	}
176 	
177 	/**
178 	 * Lists the available visuals for the default screen.
179 	 * (See gdk_screen_list_visuals())
180 	 * A visual describes a hardware image data format.
181 	 * For example, a visual might support 24-bit color, or 8-bit color,
182 	 * and might expect pixels to be in a certain format.
183 	 * Call g_list_free() on the return value when you're finished with it.
184 	 * Returns: a list of visuals; the list must be freed, but not its contents. [transfer container][element-type GdkVisual]
185 	 */
186 	public static ListG gdkListVisuals()
187 	{
188 		// GList * gdk_list_visuals (void);
189 		auto p = gdk_list_visuals();
190 		
191 		if(p is null)
192 		{
193 			return null;
194 		}
195 		
196 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
197 	}
198 	
199 	/**
200 	 * Get the best available depth for the default GDK screen. "Best"
201 	 * means "largest," i.e. 32 preferred over 24 preferred over 8 bits
202 	 * per pixel.
203 	 * Returns: best available depth
204 	 */
205 	public static int getBestDepth()
206 	{
207 		// gint gdk_visual_get_best_depth (void);
208 		return gdk_visual_get_best_depth();
209 	}
210 	
211 	/**
212 	 * Return the best available visual type for the default GDK screen.
213 	 * Returns: best visual type
214 	 */
215 	public static GdkVisualType getBestType()
216 	{
217 		// GdkVisualType gdk_visual_get_best_type (void);
218 		return gdk_visual_get_best_type();
219 	}
220 	
221 	/**
222 	 * Get the system's default visual for the default GDK screen.
223 	 * This is the visual for the root window of the display.
224 	 * The return value should not be freed.
225 	 * Returns: system visual. [transfer none]
226 	 */
227 	public static Visual getSystem()
228 	{
229 		// GdkVisual * gdk_visual_get_system (void);
230 		auto p = gdk_visual_get_system();
231 		
232 		if(p is null)
233 		{
234 			return null;
235 		}
236 		
237 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
238 	}
239 	
240 	/**
241 	 * Get the visual with the most available colors for the default
242 	 * GDK screen. The return value should not be freed.
243 	 * Returns: best visual. [transfer none]
244 	 */
245 	public static Visual getBest()
246 	{
247 		// GdkVisual * gdk_visual_get_best (void);
248 		auto p = gdk_visual_get_best();
249 		
250 		if(p is null)
251 		{
252 			return null;
253 		}
254 		
255 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
256 	}
257 	
258 	/**
259 	 * Get the best visual with depth depth for the default GDK screen.
260 	 * Color visuals and visuals with mutable colormaps are preferred
261 	 * over grayscale or fixed-colormap visuals. The return value should not
262 	 * be freed. NULL may be returned if no visual supports depth.
263 	 * Params:
264 	 * depth = a bit depth
265 	 * Returns: best visual for the given depth. [transfer none]
266 	 */
267 	public static Visual getBestWithDepth(int depth)
268 	{
269 		// GdkVisual * gdk_visual_get_best_with_depth (gint depth);
270 		auto p = gdk_visual_get_best_with_depth(depth);
271 		
272 		if(p is null)
273 		{
274 			return null;
275 		}
276 		
277 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
278 	}
279 	
280 	/**
281 	 * Get the best visual of the given visual_type for the default GDK screen.
282 	 * Visuals with higher color depths are considered better. The return value
283 	 * should not be freed. NULL may be returned if no visual has type
284 	 * visual_type.
285 	 * Params:
286 	 * visualType = a visual type
287 	 * Returns: best visual of the given type. [transfer none]
288 	 */
289 	public static Visual getBestWithType(GdkVisualType visualType)
290 	{
291 		// GdkVisual * gdk_visual_get_best_with_type (GdkVisualType visual_type);
292 		auto p = gdk_visual_get_best_with_type(visualType);
293 		
294 		if(p is null)
295 		{
296 			return null;
297 		}
298 		
299 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
300 	}
301 	
302 	/**
303 	 * Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type().
304 	 * Params:
305 	 * depth = a bit depth
306 	 * visualType = a visual type
307 	 * Returns: best visual with both depth and visual_type, or NULL if none. [transfer none]
308 	 */
309 	public static Visual getBestWithBoth(int depth, GdkVisualType visualType)
310 	{
311 		// GdkVisual * gdk_visual_get_best_with_both (gint depth,  GdkVisualType visual_type);
312 		auto p = gdk_visual_get_best_with_both(depth, visualType);
313 		
314 		if(p is null)
315 		{
316 			return null;
317 		}
318 		
319 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
320 	}
321 	
322 	/**
323 	 * Gets the screen to which this visual belongs
324 	 * Since 2.2
325 	 * Returns: the screen to which this visual belongs. [transfer none]
326 	 */
327 	public Screen getScreen()
328 	{
329 		// GdkScreen * gdk_visual_get_screen (GdkVisual *visual);
330 		auto p = gdk_visual_get_screen(gdkVisual);
331 		
332 		if(p is null)
333 		{
334 			return null;
335 		}
336 		
337 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
338 	}
339 	
340 	/**
341 	 * Returns the number of significant bits per red, green and blue value.
342 	 * Since 2.22
343 	 * Returns: The number of significant bits per color value for visual.
344 	 */
345 	public int getBitsPerRgb()
346 	{
347 		// gint gdk_visual_get_bits_per_rgb (GdkVisual *visual);
348 		return gdk_visual_get_bits_per_rgb(gdkVisual);
349 	}
350 	
351 	/**
352 	 * Obtains values that are needed to calculate blue pixel values in TrueColor
353 	 * and DirectColor. The "mask" is the significant bits within the pixel.
354 	 * The "shift" is the number of bits left we must shift a primary for it
355 	 * to be in position (according to the "mask"). Finally, "precision" refers
356 	 * to how much precision the pixel value contains for a particular primary.
357 	 * Since 2.22
358 	 * Params:
359 	 * mask = A pointer to a guint32 to be filled in, or NULL. [out][allow-none]
360 	 * shift = A pointer to a gint to be filled in, or NULL. [out][allow-none]
361 	 * precision = A pointer to a gint to be filled in, or NULL. [out][allow-none]
362 	 */
363 	public void getBluePixelDetails(out uint mask, out int shift, out int precision)
364 	{
365 		// void gdk_visual_get_blue_pixel_details (GdkVisual *visual,  guint32 *mask,  gint *shift,  gint *precision);
366 		gdk_visual_get_blue_pixel_details(gdkVisual, &mask, &shift, &precision);
367 	}
368 	
369 	/**
370 	 * Returns the byte order of this visual.
371 	 * Since 2.22
372 	 * Returns: A GdkByteOrder stating the byte order of visual.
373 	 */
374 	public GdkByteOrder getByteOrder()
375 	{
376 		// GdkByteOrder gdk_visual_get_byte_order (GdkVisual *visual);
377 		return gdk_visual_get_byte_order(gdkVisual);
378 	}
379 	
380 	/**
381 	 * Returns the size of a colormap for this visual.
382 	 * Since 2.22
383 	 * Returns: The size of a colormap that is suitable for visual.
384 	 */
385 	public int getColormapSize()
386 	{
387 		// gint gdk_visual_get_colormap_size (GdkVisual *visual);
388 		return gdk_visual_get_colormap_size(gdkVisual);
389 	}
390 	
391 	/**
392 	 * Returns the bit depth of this visual.
393 	 * Since 2.22
394 	 * Returns: The bit depth of this visual.
395 	 */
396 	public int getDepth()
397 	{
398 		// gint gdk_visual_get_depth (GdkVisual *visual);
399 		return gdk_visual_get_depth(gdkVisual);
400 	}
401 	
402 	/**
403 	 * Obtains values that are needed to calculate green pixel values in TrueColor
404 	 * and DirectColor. The "mask" is the significant bits within the pixel.
405 	 * The "shift" is the number of bits left we must shift a primary for it
406 	 * to be in position (according to the "mask"). Finally, "precision" refers
407 	 * to how much precision the pixel value contains for a particular primary.
408 	 * Since 2.22
409 	 * Params:
410 	 * mask = A pointer to a guint32 to be filled in, or NULL. [out][allow-none]
411 	 * shift = A pointer to a gint to be filled in, or NULL. [out][allow-none]
412 	 * precision = A pointer to a gint to be filled in, or NULL. [out][allow-none]
413 	 */
414 	public void getGreenPixelDetails(out uint mask, out int shift, out int precision)
415 	{
416 		// void gdk_visual_get_green_pixel_details (GdkVisual *visual,  guint32 *mask,  gint *shift,  gint *precision);
417 		gdk_visual_get_green_pixel_details(gdkVisual, &mask, &shift, &precision);
418 	}
419 	
420 	/**
421 	 * Obtains values that are needed to calculate red pixel values in TrueColor
422 	 * and DirectColor. The "mask" is the significant bits within the pixel.
423 	 * The "shift" is the number of bits left we must shift a primary for it
424 	 * to be in position (according to the "mask"). Finally, "precision" refers
425 	 * to how much precision the pixel value contains for a particular primary.
426 	 * Since 2.22
427 	 * Params:
428 	 * mask = A pointer to a guint32 to be filled in, or NULL. [out][allow-none]
429 	 * shift = A pointer to a gint to be filled in, or NULL. [out][allow-none]
430 	 * precision = A pointer to a gint to be filled in, or NULL. [out][allow-none]
431 	 */
432 	public void getRedPixelDetails(out uint mask, out int shift, out int precision)
433 	{
434 		// void gdk_visual_get_red_pixel_details (GdkVisual *visual,  guint32 *mask,  gint *shift,  gint *precision);
435 		gdk_visual_get_red_pixel_details(gdkVisual, &mask, &shift, &precision);
436 	}
437 	
438 	/**
439 	 * Returns the type of visual this is (PseudoColor, TrueColor, etc).
440 	 * Since 2.22
441 	 * Returns: A GdkVisualType stating the type of visual.
442 	 */
443 	public GdkVisualType getVisualType()
444 	{
445 		// GdkVisualType gdk_visual_get_visual_type (GdkVisual *visual);
446 		return gdk_visual_get_visual_type(gdkVisual);
447 	}
448 }