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 	 * Return: 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 	 * Return: best available depth
101 	 */
102 	public static int getBestDepth()
103 	{
104 		return gdk_visual_get_best_depth();
105 	}
106 
107 	/**
108 	 * Return the best available visual type for the default GDK screen.
109 	 *
110 	 * Return: best visual type
111 	 */
112 	public static GdkVisualType getBestType()
113 	{
114 		return gdk_visual_get_best_type();
115 	}
116 
117 	/**
118 	 * Combines gdk_visual_get_best_with_depth() and
119 	 * gdk_visual_get_best_with_type().
120 	 *
121 	 * Params:
122 	 *     depth = a bit depth
123 	 *     visualType = a visual type
124 	 *
125 	 * Return: best visual with both @depth
126 	 *     and @visual_type, or %NULL if none
127 	 */
128 	public static Visual getBestWithBoth(int depth, GdkVisualType visualType)
129 	{
130 		auto p = gdk_visual_get_best_with_both(depth, visualType);
131 		
132 		if(p is null)
133 		{
134 			return null;
135 		}
136 		
137 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
138 	}
139 
140 	/**
141 	 * Get the best visual with depth @depth for the default GDK screen.
142 	 * Color visuals and visuals with mutable colormaps are preferred
143 	 * over grayscale or fixed-colormap visuals. The return value should
144 	 * not be freed. %NULL may be returned if no visual supports @depth.
145 	 *
146 	 * Params:
147 	 *     depth = a bit depth
148 	 *
149 	 * Return: best visual for the given depth
150 	 */
151 	public static Visual getBestWithDepth(int depth)
152 	{
153 		auto p = gdk_visual_get_best_with_depth(depth);
154 		
155 		if(p is null)
156 		{
157 			return null;
158 		}
159 		
160 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
161 	}
162 
163 	/**
164 	 * Get the best visual of the given @visual_type for the default GDK screen.
165 	 * Visuals with higher color depths are considered better. The return value
166 	 * should not be freed. %NULL may be returned if no visual has type
167 	 * @visual_type.
168 	 *
169 	 * Params:
170 	 *     visualType = a visual type
171 	 *
172 	 * Return: best visual of the given type
173 	 */
174 	public static Visual getBestWithType(GdkVisualType visualType)
175 	{
176 		auto p = gdk_visual_get_best_with_type(visualType);
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
184 	}
185 
186 	/**
187 	 * Get the system’s default visual for the default GDK screen.
188 	 * This is the visual for the root window of the display.
189 	 * The return value should not be freed.
190 	 *
191 	 * Return: system visual
192 	 */
193 	public static Visual getSystem()
194 	{
195 		auto p = gdk_visual_get_system();
196 		
197 		if(p is null)
198 		{
199 			return null;
200 		}
201 		
202 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
203 	}
204 
205 	/**
206 	 * Returns the number of significant bits per red, green and blue value.
207 	 *
208 	 * Return: The number of significant bits per color value for @visual.
209 	 *
210 	 * Since: 2.22
211 	 */
212 	public int getBitsPerRgb()
213 	{
214 		return gdk_visual_get_bits_per_rgb(gdkVisual);
215 	}
216 
217 	/**
218 	 * Obtains values that are needed to calculate blue pixel values in TrueColor
219 	 * and DirectColor. The “mask” is the significant bits within the pixel.
220 	 * The “shift” is the number of bits left we must shift a primary for it
221 	 * to be in position (according to the "mask"). Finally, "precision" refers
222 	 * to how much precision the pixel value contains for a particular primary.
223 	 *
224 	 * Params:
225 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
226 	 *     shift = A pointer to a #gint to be filled in, or %NULL
227 	 *     precision = A pointer to a #gint to be filled in, or %NULL
228 	 *
229 	 * Since: 2.22
230 	 */
231 	public void getBluePixelDetails(out uint mask, out int shift, out int precision)
232 	{
233 		gdk_visual_get_blue_pixel_details(gdkVisual, &mask, &shift, &precision);
234 	}
235 
236 	/**
237 	 * Returns the byte order of this visual.
238 	 *
239 	 * Return: A #GdkByteOrder stating the byte order of @visual.
240 	 *
241 	 * Since: 2.22
242 	 */
243 	public GdkByteOrder getByteOrder()
244 	{
245 		return gdk_visual_get_byte_order(gdkVisual);
246 	}
247 
248 	/**
249 	 * Returns the size of a colormap for this visual.
250 	 *
251 	 * Return: The size of a colormap that is suitable for @visual.
252 	 *
253 	 * Since: 2.22
254 	 */
255 	public int getColormapSize()
256 	{
257 		return gdk_visual_get_colormap_size(gdkVisual);
258 	}
259 
260 	/**
261 	 * Returns the bit depth of this visual.
262 	 *
263 	 * Return: The bit depth of this visual.
264 	 *
265 	 * Since: 2.22
266 	 */
267 	public int getDepth()
268 	{
269 		return gdk_visual_get_depth(gdkVisual);
270 	}
271 
272 	/**
273 	 * Obtains values that are needed to calculate green pixel values in TrueColor
274 	 * and DirectColor. The “mask” is the significant bits within the pixel.
275 	 * The “shift” is the number of bits left we must shift a primary for it
276 	 * to be in position (according to the "mask"). Finally, "precision" refers
277 	 * to how much precision the pixel value contains for a particular primary.
278 	 *
279 	 * Params:
280 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
281 	 *     shift = A pointer to a #gint to be filled in, or %NULL
282 	 *     precision = A pointer to a #gint to be filled in, or %NULL
283 	 *
284 	 * Since: 2.22
285 	 */
286 	public void getGreenPixelDetails(out uint mask, out int shift, out int precision)
287 	{
288 		gdk_visual_get_green_pixel_details(gdkVisual, &mask, &shift, &precision);
289 	}
290 
291 	/**
292 	 * Obtains values that are needed to calculate red pixel values in TrueColor
293 	 * and DirectColor. The “mask” is the significant bits within the pixel.
294 	 * The “shift” is the number of bits left we must shift a primary for it
295 	 * to be in position (according to the "mask"). Finally, "precision" refers
296 	 * to how much precision the pixel value contains for a particular primary.
297 	 *
298 	 * Params:
299 	 *     mask = A pointer to a #guint32 to be filled in, or %NULL
300 	 *     shift = A pointer to a #gint to be filled in, or %NULL
301 	 *     precision = A pointer to a #gint to be filled in, or %NULL
302 	 *
303 	 * Since: 2.22
304 	 */
305 	public void getRedPixelDetails(out uint mask, out int shift, out int precision)
306 	{
307 		gdk_visual_get_red_pixel_details(gdkVisual, &mask, &shift, &precision);
308 	}
309 
310 	/**
311 	 * Gets the screen to which this visual belongs
312 	 *
313 	 * Return: the screen to which this visual belongs.
314 	 *
315 	 * Since: 2.2
316 	 */
317 	public Screen getScreen()
318 	{
319 		auto p = gdk_visual_get_screen(gdkVisual);
320 		
321 		if(p is null)
322 		{
323 			return null;
324 		}
325 		
326 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
327 	}
328 
329 	/**
330 	 * Returns the type of visual this is (PseudoColor, TrueColor, etc).
331 	 *
332 	 * Return: A #GdkVisualType stating the type of @visual.
333 	 *
334 	 * Since: 2.22
335 	 */
336 	public GdkVisualType getVisualType()
337 	{
338 		return gdk_visual_get_visual_type(gdkVisual);
339 	}
340 
341 	/**
342 	 * Lists the available visuals for the default screen.
343 	 * (See gdk_screen_list_visuals())
344 	 * A visual describes a hardware image data format.
345 	 * For example, a visual might support 24-bit color, or 8-bit color,
346 	 * and might expect pixels to be in a certain format.
347 	 *
348 	 * Call g_list_free() on the return value when you’re finished with it.
349 	 *
350 	 * Return: a list of visuals; the list must be freed, but not its contents
351 	 */
352 	public static ListG listVisuals()
353 	{
354 		auto p = gdk_list_visuals();
355 		
356 		if(p is null)
357 		{
358 			return null;
359 		}
360 		
361 		return new ListG(cast(GList*) p);
362 	}
363 
364 	/**
365 	 * This function returns the available bit depths for the default
366 	 * screen. It’s equivalent to listing the visuals
367 	 * (gdk_list_visuals()) and then looking at the depth field in each
368 	 * visual, removing duplicates.
369 	 *
370 	 * The array returned by this function should not be freed.
371 	 *
372 	 * Params:
373 	 *     depths = return
374 	 *         location for available depths
375 	 *     count = return location for number of available depths
376 	 */
377 	public static void queryDepths(out int[] depths)
378 	{
379 		int* outdepths = null;
380 		int count;
381 		
382 		gdk_query_depths(&outdepths, &count);
383 		
384 		depths = outdepths[0 .. count];
385 	}
386 
387 	/**
388 	 * This function returns the available visual types for the default
389 	 * screen. It’s equivalent to listing the visuals
390 	 * (gdk_list_visuals()) and then looking at the type field in each
391 	 * visual, removing duplicates.
392 	 *
393 	 * The array returned by this function should not be freed.
394 	 *
395 	 * Params:
396 	 *     visualTypes = return
397 	 *         location for the available visual types
398 	 *     count = return location for the number of available visual types
399 	 */
400 	public static void queryVisualTypes(out GdkVisualType[] visualTypes)
401 	{
402 		GdkVisualType* outvisualTypes = null;
403 		int count;
404 		
405 		gdk_query_visual_types(&outvisualTypes, &count);
406 		
407 		visualTypes = outvisualTypes[0 .. count];
408 	}
409 }