alternative to assert
[gtkD.git] / gtkD / src / gdk / Visual.d
blobdacade70f98de11961175469615bc4135bf697d8
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Visuals.html
26 * outPack = gdk
27 * outFile = Visual
28 * strct = GdkVisual
29 * realStrct=
30 * ctorStrct=
31 * clss = Visual
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_visual_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ListG
45 * - gdk.Visual
46 * - gdk.Screen
47 * structWrap:
48 * - GList* -> ListG
49 * - GdkScreen* -> Screen
50 * - GdkVisual* -> Visual
51 * module aliases:
52 * local aliases:
55 module gdk.Visual;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gdktypes;
67 private import gtkc.gdk;
70 private import glib.ListG;
71 private import gdk.Visual;
72 private import gdk.Screen;
77 /**
78 * Description
79 * A GdkVisual describes a particular video hardware display format. It includes
80 * information about the number of bits used for each color, the way the bits are
81 * translated into an RGB value for display, and the way the bits are stored in
82 * memory. For example, a piece of display hardware might support 24-bit color,
83 * 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given
84 * pixel size, pixels can be in different formats; for example the "red" element
85 * of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower
86 * 4 bits.
87 * Usually you can avoid thinking about visuals in GTK+. Visuals are useful to
88 * interpret the contents of a GdkImage, but you should avoid GdkImage precisely
89 * because its contents depend on the display hardware; use GdkPixbuf instead, for
90 * all but the most low-level purposes. Also, anytime you provide a GdkColormap,
91 * the visual is implied as part of the colormap (gdk_colormap_get_visual()), so
92 * you won't have to provide a visual in addition.
93 * There are several standard visuals. The visual returned
94 * by gdk_visual_get_system() is the system's default
95 * visual. gdk_rgb_get_visual() return the visual most
96 * suited to displaying full-color image data. If you
97 * use the calls in GdkRGB, you should create your windows
98 * using this visual (and the colormap returned by
99 * gdk_rgb_get_colormap()).
100 * A number of functions are provided for determining
101 * the "best" available visual. For the purposes of
102 * making this determination, higher bit depths are
103 * considered better, and for visuals of the same
104 * bit depth, GDK_VISUAL_PSEUDO_COLOR is preferred at
105 * 8bpp, otherwise, the visual types are ranked in the
106 * order of (highest to lowest) GDK_VISUAL_DIRECT_COLOR,
107 * GDK_VISUAL_TRUE_COLOR, GDK_VISUAL_PSEUDO_COLOR,
108 * GDK_VISUAL_STATIC_COLOR, GDK_VISUAL_GRAYSCALE,
109 * then GDK_VISUAL_STATIC_GRAY.
111 public class Visual
114 /** the main Gtk struct */
115 protected GdkVisual* gdkVisual;
118 public GdkVisual* getVisualStruct()
120 return gdkVisual;
124 /** the main Gtk struct as a void* */
125 protected void* getStruct()
127 return cast(void*)gdkVisual;
131 * Sets our main struct and passes it to the parent class
133 public this (GdkVisual* gdkVisual)
135 version(noAssert)
137 if ( gdkVisual is null )
139 int zero = 0;
140 version(Tango)
142 Stdout("struct gdkVisual is null on constructor").newline;
144 else
146 printf("struct gdkVisual is null on constructor");
148 zero = zero / zero;
151 else
153 assert(gdkVisual !is null, "struct gdkVisual is null on constructor");
155 this.gdkVisual = gdkVisual;
165 * This function returns the available bit depths for the default
166 * screen. It's equivalent to listing the visuals
167 * (gdk_list_visuals()) and then looking at the depth field in each
168 * visual, removing duplicates.
169 * The array returned by this function should not be freed.
170 * depths:
171 * return location for available depths
172 * count:
173 * return location for number of available depths
175 public static void gdkQueryDepths(int** depths, int* count)
177 // void gdk_query_depths (gint **depths, gint *count);
178 gdk_query_depths(depths, count);
182 * This function returns the available visual types for the default
183 * screen. It's equivalent to listing the visuals
184 * (gdk_list_visuals()) and then looking at the type field in each
185 * visual, removing duplicates.
186 * The array returned by this function should not be freed.
187 * visual_types:
188 * return location for the available visual types
189 * count:
190 * return location for the number of available visual types
192 public static void gdkQueryVisualTypes(GdkVisualType** visualTypes, int* count)
194 // void gdk_query_visual_types (GdkVisualType **visual_types, gint *count);
195 gdk_query_visual_types(visualTypes, count);
199 * Lists the available visuals for the default screen.
200 * (See gdk_screen_list_visuals())
201 * A visual describes a hardware image data format.
202 * For example, a visual might support 24-bit color, or 8-bit color,
203 * and might expect pixels to be in a certain format.
204 * Call g_list_free() on the return value when you're finished with it.
205 * Returns:
206 * a list of visuals; the list must be freed, but not its contents
208 public static ListG gdkListVisuals()
210 // GList* gdk_list_visuals (void);
211 return new ListG( gdk_list_visuals() );
215 * Get the best available depth for the default GDK screen. "Best"
216 * means "largest," i.e. 32 preferred over 24 preferred over 8 bits
217 * per pixel.
218 * Returns:
219 * best available depth
221 public static int getBestDepth()
223 // gint gdk_visual_get_best_depth (void);
224 return gdk_visual_get_best_depth();
228 * Return the best available visual type for the default GDK screen.
229 * Returns:
230 * best visual type
232 public static GdkVisualType getBestType()
234 // GdkVisualType gdk_visual_get_best_type (void);
235 return gdk_visual_get_best_type();
239 * Get the system'sdefault visual for the default GDK screen.
240 * This is the visual for the root window of the display.
241 * The return value should not be freed.
242 * Returns:
243 * system visual
245 public static Visual getSystem()
247 // GdkVisual* gdk_visual_get_system (void);
248 return new Visual( gdk_visual_get_system() );
252 * Get the visual with the most available colors for the default
253 * GDK screen. The return value should not be freed.
254 * Returns:
255 * best visual
257 public static Visual getBest()
259 // GdkVisual* gdk_visual_get_best (void);
260 return new Visual( gdk_visual_get_best() );
264 * Get the best visual with depth depth for the default GDK screen.
265 * Color visuals and visuals with mutable colormaps are preferred
266 * over grayscale or fixed-colormap visuals. The return value should not
267 * be freed. NULL may be returned if no visual supports depth.
268 * depth:
269 * a bit depth
270 * Returns:
271 * best visual for the given depth
273 public static Visual getBestWithDepth(int depth)
275 // GdkVisual* gdk_visual_get_best_with_depth (gint depth);
276 return new Visual( gdk_visual_get_best_with_depth(depth) );
280 * Get the best visual of the given visual_type for the default GDK screen.
281 * Visuals with higher color depths are considered better. The return value
282 * should not be freed. NULL may be returned if no visual has type
283 * visual_type.
284 * visual_type:
285 * a visual type
286 * Returns:
287 * best visual of the given type
289 public static Visual getBestWithType(GdkVisualType visualType)
291 // GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type);
292 return new Visual( gdk_visual_get_best_with_type(visualType) );
296 * Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type().
297 * depth:
298 * a bit depth
299 * visual_type:
300 * a visual type
301 * Returns:
302 * best visual with both depth and visual_type, or NULL if none
304 public static Visual getBestWithBoth(int depth, GdkVisualType visualType)
306 // GdkVisual* gdk_visual_get_best_with_both (gint depth, GdkVisualType visual_type);
307 return new Visual( gdk_visual_get_best_with_both(depth, visualType) );
313 * Gets the screen to which this visual belongs
314 * visual:
315 * a GdkVisual
316 * Returns:
317 * the screen to which this visual belongs.
318 * Since 2.2
319 * See Also
320 * GdkImage, GdkColormap, GdkRGB
322 public Screen getScreen()
324 // GdkScreen* gdk_visual_get_screen (GdkVisual *visual);
325 return new Screen( gdk_visual_get_screen(gdkVisual) );