alternative to assert
[gtkD.git] / src / gdk / Visual.d
blob125a2794eb90933a00832b5c9862c6bf66d4ae97
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 * local aliases:
54 module gdk.Visual;
56 private import gdk.gdktypes;
58 private import lib.gdk;
60 private import glib.ListG;
61 private import gdk.Visual;
62 private import gdk.Screen;
64 /**
65 * Description
66 * A GdkVisual describes a particular video hardware display format. It includes
67 * information about the number of bits used for each color, the way the bits are
68 * translated into an RGB value for display, and the way the bits are stored in
69 * memory. For example, a piece of display hardware might support 24-bit color,
70 * 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given
71 * pixel size, pixels can be in different formats; for example the "red" element
72 * of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower
73 * 4 bits.
74 * Usually you can avoid thinking about visuals in GTK+. Visuals are useful to
75 * interpret the contents of a GdkImage, but you should avoid GdkImage precisely
76 * because its contents depend on the display hardware; use GdkPixbuf instead, for
77 * all but the most low-level purposes. Also, anytime you provide a GdkColormap,
78 * the visual is implied as part of the colormap (gdk_colormap_get_visual()), so
79 * you won't have to provide a visual in addition.
80 * There are several standard visuals. The visual returned
81 * by gdk_visual_get_system() is the system's default
82 * visual. gdk_rgb_get_visual() return the visual most
83 * suited to displaying full-color image data. If you
84 * use the calls in GdkRGB, you should create your windows
85 * using this visual (and the colormap returned by
86 * gdk_rgb_get_colormap()).
87 * A number of functions are provided for determining
88 * the "best" available visual. For the purposes of
89 * making this determination, higher bit depths are
90 * considered better, and for visuals of the same
91 * bit depth, GDK_VISUAL_PSEUDO_COLOR is preferred at
92 * 8bpp, otherwise, the visual types are ranked in the
93 * order of (highest to lowest) GDK_VISUAL_DIRECT_COLOR,
94 * GDK_VISUAL_TRUE_COLOR, GDK_VISUAL_PSEUDO_COLOR,
95 * GDK_VISUAL_STATIC_COLOR, GDK_VISUAL_GRAYSCALE,
96 * then GDK_VISUAL_STATIC_GRAY.
98 public class Visual
101 /** the main Gtk struct */
102 protected GdkVisual* gdkVisual;
105 public GdkVisual* getVisualStruct()
107 return gdkVisual;
111 /** the main Gtk struct as a void* */
112 protected void* getStruct()
114 return cast(void*)gdkVisual;
118 * Sets our main struct and passes it to the parent class
120 public this (GdkVisual* gdkVisual)
122 this.gdkVisual = gdkVisual;
132 * This function returns the available bit depths for the default
133 * screen. It's equivalent to listing the visuals
134 * (gdk_list_visuals()) and then looking at the depth field in each
135 * visual, removing duplicates.
136 * The array returned by this function should not be freed.
137 * depths:
138 * return location for available depths
139 * count:
140 * return location for number of available depths
142 public static void gdkQueryDepths(int** depths, int* count)
144 // void gdk_query_depths (gint **depths, gint *count);
145 gdk_query_depths(depths, count);
149 * This function returns the available visual types for the default
150 * screen. It's equivalent to listing the visuals
151 * (gdk_list_visuals()) and then looking at the type field in each
152 * visual, removing duplicates.
153 * The array returned by this function should not be freed.
154 * visual_types:
155 * return location for the available visual types
156 * count:
157 * return location for the number of available visual types
159 public static void gdkQueryVisualTypes(GdkVisualType** visualTypes, int* count)
161 // void gdk_query_visual_types (GdkVisualType **visual_types, gint *count);
162 gdk_query_visual_types(visualTypes, count);
166 * Lists the available visuals for the default screen.
167 * (See gdk_screen_list_visuals())
168 * A visual describes a hardware image data format.
169 * For example, a visual might support 24-bit color, or 8-bit color,
170 * and might expect pixels to be in a certain format.
171 * Call g_list_free() on the return value when you're finished with it.
172 * Returns:
173 * a list of visuals; the list must be freed, but not its contents
175 public static ListG gdkListVisuals()
177 // GList* gdk_list_visuals (void);
178 return new ListG( gdk_list_visuals() );
182 * Get the best available depth for the default GDK screen. "Best"
183 * means "largest," i.e. 32 preferred over 24 preferred over 8 bits
184 * per pixel.
185 * Returns:
186 * best available depth
188 public static int getBestDepth()
190 // gint gdk_visual_get_best_depth (void);
191 return gdk_visual_get_best_depth();
195 * Return the best available visual type for the default GDK screen.
196 * Returns:
197 * best visual type
199 public static GdkVisualType getBestType()
201 // GdkVisualType gdk_visual_get_best_type (void);
202 return gdk_visual_get_best_type();
206 * Get the system'sdefault visual for the default GDK screen.
207 * This is the visual for the root window of the display.
208 * The return value should not be freed.
209 * Returns:
210 * system visual
212 public static Visual getSystem()
214 // GdkVisual* gdk_visual_get_system (void);
215 return new Visual( gdk_visual_get_system() );
219 * Get the visual with the most available colors for the default
220 * GDK screen. The return value should not be freed.
221 * Returns:
222 * best visual
224 public static Visual getBest()
226 // GdkVisual* gdk_visual_get_best (void);
227 return new Visual( gdk_visual_get_best() );
231 * Get the best visual with depth depth for the default GDK screen.
232 * Color visuals and visuals with mutable colormaps are preferred
233 * over grayscale or fixed-colormap visuals. The return value should not
234 * be freed. NULL may be returned if no visual supports depth.
235 * depth:
236 * a bit depth
237 * Returns:
238 * best visual for the given depth
240 public static Visual getBestWithDepth(int depth)
242 // GdkVisual* gdk_visual_get_best_with_depth (gint depth);
243 return new Visual( gdk_visual_get_best_with_depth(depth) );
247 * Get the best visual of the given visual_type for the default GDK screen.
248 * Visuals with higher color depths are considered better. The return value
249 * should not be freed. NULL may be returned if no visual has type
250 * visual_type.
251 * visual_type:
252 * a visual type
253 * Returns:
254 * best visual of the given type
256 public static Visual getBestWithType(GdkVisualType visualType)
258 // GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type);
259 return new Visual( gdk_visual_get_best_with_type(visualType) );
263 * Combines gdk_visual_get_best_with_depth() and gdk_visual_get_best_with_type().
264 * depth:
265 * a bit depth
266 * visual_type:
267 * a visual type
268 * Returns:
269 * best visual with both depth and visual_type, or NULL if none
271 public static Visual getBestWithBoth(int depth, GdkVisualType visualType)
273 // GdkVisual* gdk_visual_get_best_with_both (gint depth, GdkVisualType visual_type);
274 return new Visual( gdk_visual_get_best_with_both(depth, visualType) );
280 * Gets the screen to which this visual belongs
281 * visual:
282 * a GdkVisual
283 * Returns:
284 * the screen to which this visual belongs.
285 * Since 2.2
286 * See Also
287 * GdkImage, GdkColormap, GdkRGB
289 public Screen getScreen()
291 // GdkScreen* gdk_visual_get_screen (GdkVisual *visual);
292 return new Screen( gdk_visual_get_screen(gdkVisual) );