alternative to assert
[gtkD.git] / gtkD / src / gdk / Colormap.d
blob0eef75831a0327caa639b09d3b03ea59cbd00974
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-Colormaps-and-Colors.html
26 * outPack = gdk
27 * outFile = Colormap
28 * strct = GdkColormap
29 * realStrct=
30 * ctorStrct=
31 * clss = Colormap
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_colormap_
40 * omit structs:
41 * omit prefixes:
42 * - gdk_color_
43 * omit code:
44 * imports:
45 * - gdk.Visual
46 * - gdk.Colormap
47 * - gdk.Color
48 * - gdk.Screen
49 * structWrap:
50 * - GdkColor* -> Color
51 * - GdkColormap* -> Colormap
52 * - GdkScreen* -> Screen
53 * - GdkVisual* -> Visual
54 * module aliases:
55 * local aliases:
58 module gdk.Colormap;
60 version(noAssert)
62 version(Tango)
64 import tango.io.Stdout; // use the tango loging?
68 private import gtkc.gdktypes;
70 private import gtkc.gdk;
73 private import gdk.Visual;
74 private import gdk.Colormap;
75 private import gdk.Color;
76 private import gdk.Screen;
81 /**
82 * Description
83 * These functions are used to modify colormaps.
84 * A colormap is an object that contains the mapping
85 * between the color values stored in memory and
86 * the RGB values that are used to display color
87 * values. In general, colormaps only contain
88 * significant information for pseudo-color visuals,
89 * but even for other visual types, a colormap object
90 * is required in some circumstances.
91 * There are a couple of special colormaps that can
92 * be retrieved. The system colormap (retrieved
93 * with gdk_colormap_get_system()) is the default
94 * colormap of the system. If you are using GdkRGB,
95 * there is another colormap that is important - the
96 * colormap in which GdkRGB works, retrieved with
97 * gdk_rgb_get_cmap(). However, when using GdkRGB,
98 * it is not generally necessary to allocate colors
99 * directly.
100 * In previous revisions of this interface, a number
101 * of functions that take a GdkColormap parameter
102 * were replaced with functions whose names began
103 * with "gdk_colormap_". This process will probably
104 * be extended somewhat in the future -
105 * gdk_color_white(), gdk_color_black(), and
106 * gdk_color_change() will probably become aliases.
108 public class Colormap
111 /** the main Gtk struct */
112 protected GdkColormap* gdkColormap;
115 public GdkColormap* getColormapStruct()
117 return gdkColormap;
121 /** the main Gtk struct as a void* */
122 protected void* getStruct()
124 return cast(void*)gdkColormap;
128 * Sets our main struct and passes it to the parent class
130 public this (GdkColormap* gdkColormap)
132 version(noAssert)
134 if ( gdkColormap is null )
136 int zero = 0;
137 version(Tango)
139 Stdout("struct gdkColormap is null on constructor").newline;
141 else
143 printf("struct gdkColormap is null on constructor");
145 zero = zero / zero;
148 else
150 assert(gdkColormap !is null, "struct gdkColormap is null on constructor");
152 this.gdkColormap = gdkColormap;
161 * Creates a new colormap for the given visual.
162 * visual:
163 * a GdkVisual.
164 * allocate:
165 * if TRUE, the newly created colormap will be
166 * a private colormap, and all colors in it will be
167 * allocated for the applications use.
168 * Returns:
169 * the new GdkColormap.
171 public this (Visual visual, int allocate)
173 // GdkColormap* gdk_colormap_new (GdkVisual *visual, gboolean allocate);
174 this(cast(GdkColormap*)gdk_colormap_new((visual is null) ? null : visual.getVisualStruct(), allocate) );
178 * Warning
179 * gdk_colormap_ref is deprecated and should not be used in newly-written code.
180 * Deprecated function; use g_object_ref() instead.
181 * cmap:
182 * a GdkColormap
183 * Returns:
184 * the colormap
186 public Colormap doref()
188 // GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
189 return new Colormap( gdk_colormap_ref(gdkColormap) );
193 * Warning
194 * gdk_colormap_unref is deprecated and should not be used in newly-written code.
195 * Deprecated function; use g_object_ref() instead.
196 * cmap:
197 * a GdkColormap
199 public void unref()
201 // void gdk_colormap_unref (GdkColormap *cmap);
202 gdk_colormap_unref(gdkColormap);
206 * Gets the system's default colormap for the default screen. (See
207 * gdk_colormap_get_system_for_screen())
208 * Returns:
209 * the default colormap.
211 public static Colormap getSystem()
213 // GdkColormap* gdk_colormap_get_system (void);
214 return new Colormap( gdk_colormap_get_system() );
218 * Warning
219 * gdk_colormap_get_system_size is deprecated and should not be used in newly-written code.
220 * Returns the size of the system's default colormap.
221 * (See the description of struct GdkColormap for an
222 * explanation of the size of a colormap.)
223 * Returns:
224 * the size of the system's default colormap.
226 public static int getSystemSize()
228 // gint gdk_colormap_get_system_size (void);
229 return gdk_colormap_get_system_size();
233 * Warning
234 * gdk_colormap_change is deprecated and should not be used in newly-written code.
235 * Changes the value of the first ncolors in a private colormap
236 * to match the values in the colors
237 * array in the colormap. This function is obsolete and
238 * should not be used. See gdk_color_change().
239 * colormap:
240 * a GdkColormap.
241 * ncolors:
242 * the number of colors to change.
244 public void change(int ncolors)
246 // void gdk_colormap_change (GdkColormap *colormap, gint ncolors);
247 gdk_colormap_change(gdkColormap, ncolors);
251 * Allocates colors from a colormap.
252 * colormap:
253 * a GdkColormap.
254 * colors:
255 * The color values to allocate. On return, the pixel
256 * values for allocated colors will be filled in.
257 * ncolors:
258 * The number of colors in colors.
259 * writeable:
260 * If TRUE, the colors are allocated writeable
261 * (their values can later be changed using gdk_color_change()).
262 * Writeable colors cannot be shared between applications.
263 * best_match:
264 * If TRUE, GDK will attempt to do matching against
265 * existing colors if the colors cannot be allocated as requested.
266 * success:
267 * An array of length ncolors. On return, this
268 * indicates whether the corresponding color in colors was
269 * successfully allocated or not.
270 * Returns:
271 * The number of colors that were not successfully
272 * allocated.
274 public int allocColors(Color colors, int ncolors, int writeable, int bestMatch, int* success)
276 // gint gdk_colormap_alloc_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors, gboolean writeable, gboolean best_match, gboolean *success);
277 return gdk_colormap_alloc_colors(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors, writeable, bestMatch, success);
281 * Allocates a single color from a colormap.
282 * colormap:
283 * a GdkColormap.
284 * color:
285 * the color to allocate. On return the
286 * pixel field will be
287 * filled in if allocation succeeds.
288 * writeable:
289 * If TRUE, the color is allocated writeable
290 * (their values can later be changed using gdk_color_change()).
291 * Writeable colors cannot be shared between applications.
292 * best_match:
293 * If TRUE, GDK will attempt to do matching against
294 * existing colors if the color cannot be allocated as requested.
295 * Returns:
296 * TRUE if the allocation succeeded.
298 public int allocColor(Color color, int writeable, int bestMatch)
300 // gboolean gdk_colormap_alloc_color (GdkColormap *colormap, GdkColor *color, gboolean writeable, gboolean best_match);
301 return gdk_colormap_alloc_color(gdkColormap, (color is null) ? null : color.getColorStruct(), writeable, bestMatch);
305 * Frees previously allocated colors.
306 * colormap:
307 * a GdkColormap.
308 * colors:
309 * the colors to free.
310 * ncolors:
311 * the number of colors in colors.
313 public void freeColors(Color colors, int ncolors)
315 // void gdk_colormap_free_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors);
316 gdk_colormap_free_colors(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors);
320 * Locates the RGB color in colormap corresponding to the given
321 * hardware pixel pixel. pixel must be a valid pixel in the
322 * colormap; it's a programmer error to call this function with a
323 * pixel which is not in the colormap. Hardware pixels are normally
324 * obtained from gdk_colormap_alloc_colors(), or from a GdkImage. (A
325 * GdkImage contains image data in hardware format, a GdkPixbuf
326 * contains image data in a canonical 24-bit RGB format.)
327 * This function is rarely useful; it's used for example to
328 * implement the eyedropper feature in GtkColorSelection.
329 * colormap:
330 * a GdkColormap
331 * pixel:
332 * pixel value in hardware display format
333 * result:
334 * GdkColor with red, green, blue fields initialized
336 public void queryColor(uint pixel, Color result)
338 // void gdk_colormap_query_color (GdkColormap *colormap, gulong pixel, GdkColor *result);
339 gdk_colormap_query_color(gdkColormap, pixel, (result is null) ? null : result.getColorStruct());
343 * Returns the visual for which a given colormap was created.
344 * colormap:
345 * a GdkColormap.
346 * Returns:
347 * the visual of the colormap.
349 public Visual getVisual()
351 // GdkVisual* gdk_colormap_get_visual (GdkColormap *colormap);
352 return new Visual( gdk_colormap_get_visual(gdkColormap) );
356 * Gets the screen for which this colormap was created.
357 * cmap:
358 * a GdkColormap
359 * Returns:
360 * the screen for which this colormap was created.
361 * Since 2.2
363 public Screen getScreen()
365 // GdkScreen* gdk_colormap_get_screen (GdkColormap *cmap);
366 return new Screen( gdk_colormap_get_screen(gdkColormap) );
370 * Warning
371 * gdk_colors_store is deprecated and should not be used in newly-written code.
372 * Changes the value of the first ncolors colors in
373 * a private colormap. This function is obsolete and
374 * should not be used. See gdk_color_change().
375 * colormap:
376 * a GdkColormap.
377 * colors:
378 * the new color values.
379 * ncolors:
380 * the number of colors to change.
382 public void gdkColorsStore(Color colors, int ncolors)
384 // void gdk_colors_store (GdkColormap *colormap, GdkColor *colors, gint ncolors);
385 gdk_colors_store(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors);
391 * Warning
392 * gdk_colors_alloc is deprecated and should not be used in newly-written code.
393 * Allocates colors from a colormap. This function
394 * is obsolete. See gdk_colormap_alloc_colors().
395 * For full documentation of the fields, see
396 * the Xlib documentation for XAllocColorCells().
397 * colormap:
398 * a GdkColormap.
399 * contiguous:
400 * if TRUE, the colors should be allocated
401 * in contiguous color cells.
402 * planes:
403 * an array in which to store the plane masks.
404 * nplanes:
405 * the number of planes to allocate. (Or zero,
406 * to indicate that the color allocation should not be planar.)
407 * pixels:
408 * an array into which to store allocated pixel values.
409 * npixels:
410 * the number of pixels in each plane to allocate.
411 * Returns:
412 * TRUE if the allocation was successful
414 public int gdkColorsAlloc(int contiguous, uint* planes, int nplanes, uint* pixels, int npixels)
416 // gint gdk_colors_alloc (GdkColormap *colormap, gboolean contiguous, gulong *planes, gint nplanes, gulong *pixels, gint npixels);
417 return gdk_colors_alloc(gdkColormap, contiguous, planes, nplanes, pixels, npixels);
421 * Warning
422 * gdk_colors_free is deprecated and should not be used in newly-written code.
423 * Frees colors allocated with gdk_colors_alloc(). This
424 * function is obsolete. See gdk_colormap_free_colors().
425 * colormap:
426 * a GdkColormap.
427 * pixels:
428 * the pixel values of the colors to free.
429 * npixels:
430 * the number of values in pixels.
431 * planes:
432 * the plane masks for all planes to free, OR'd together.
434 public void gdkColorsFree(uint* pixels, int npixels, uint planes)
436 // void gdk_colors_free (GdkColormap *colormap, gulong *pixels, gint npixels, gulong planes);
437 gdk_colors_free(gdkColormap, pixels, npixels, planes);