I've no idea here...
[gtkD.git] / src / gdk / Colormap.d
blobca6992bdcc1e4f717e8a55cf790f58a0de69d643
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-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 * local aliases:
57 module gdk.Colormap;
59 private import gdk.gdktypes;
61 private import lib.gdk;
63 private import gdk.Visual;
64 private import gdk.Colormap;
65 private import gdk.Color;
66 private import gdk.Screen;
68 /**
69 * Description
70 * These functions are used to modify colormaps.
71 * A colormap is an object that contains the mapping
72 * between the color values stored in memory and
73 * the RGB values that are used to display color
74 * values. In general, colormaps only contain
75 * significant information for pseudo-color visuals,
76 * but even for other visual types, a colormap object
77 * is required in some circumstances.
78 * There are a couple of special colormaps that can
79 * be retrieved. The system colormap (retrieved
80 * with gdk_colormap_get_system()) is the default
81 * colormap of the system. If you are using GdkRGB,
82 * there is another colormap that is important - the
83 * colormap in which GdkRGB works, retrieved with
84 * gdk_rgb_get_cmap(). However, when using GdkRGB,
85 * it is not generally necessary to allocate colors
86 * directly.
87 * In previous revisions of this interface, a number
88 * of functions that take a GdkColormap parameter
89 * were replaced with functions whose names began
90 * with "gdk_colormap_". This process will probably
91 * be extended somewhat in the future -
92 * gdk_color_white(), gdk_color_black(), and
93 * gdk_color_change() will probably become aliases.
95 public class Colormap
98 /** the main Gtk struct */
99 protected GdkColormap* gdkColormap;
102 public GdkColormap* getColormapStruct()
104 return gdkColormap;
108 /** the main Gtk struct as a void* */
109 protected void* getStruct()
111 return cast(void*)gdkColormap;
115 * Sets our main struct and passes it to the parent class
117 public this (GdkColormap* gdkColormap)
119 this.gdkColormap = gdkColormap;
128 * Creates a new colormap for the given visual.
129 * visual:
130 * a GdkVisual.
131 * allocate:
132 * if TRUE, the newly created colormap will be
133 * a private colormap, and all colors in it will be
134 * allocated for the applications use.
135 * Returns:
136 * the new GdkColormap.
138 public this (Visual visual, int allocate)
140 // GdkColormap* gdk_colormap_new (GdkVisual *visual, gboolean allocate);
141 this(cast(GdkColormap*)gdk_colormap_new((visual is null) ? null : visual.getVisualStruct(), allocate) );
145 * Warning
146 * gdk_colormap_ref is deprecated and should not be used in newly-written code.
147 * Deprecated function; use g_object_ref() instead.
148 * cmap:
149 * a GdkColormap
150 * Returns:
151 * the colormap
153 public Colormap ref()
155 // GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
156 return new Colormap( gdk_colormap_ref(gdkColormap) );
160 * Warning
161 * gdk_colormap_unref is deprecated and should not be used in newly-written code.
162 * Deprecated function; use g_object_ref() instead.
163 * cmap:
164 * a GdkColormap
166 public void unref()
168 // void gdk_colormap_unref (GdkColormap *cmap);
169 gdk_colormap_unref(gdkColormap);
173 * Gets the system's default colormap for the default screen. (See
174 * gdk_colormap_get_system_for_screen())
175 * Returns:
176 * the default colormap.
178 public static Colormap getSystem()
180 // GdkColormap* gdk_colormap_get_system (void);
181 return new Colormap( gdk_colormap_get_system() );
185 * Warning
186 * gdk_colormap_get_system_size is deprecated and should not be used in newly-written code.
187 * Returns the size of the system's default colormap.
188 * (See the description of struct GdkColormap for an
189 * explanation of the size of a colormap.)
190 * Returns:
191 * the size of the system's default colormap.
193 public static int getSystemSize()
195 // gint gdk_colormap_get_system_size (void);
196 return gdk_colormap_get_system_size();
200 * Warning
201 * gdk_colormap_change is deprecated and should not be used in newly-written code.
202 * Changes the value of the first ncolors in a private colormap
203 * to match the values in the colors
204 * array in the colormap. This function is obsolete and
205 * should not be used. See gdk_color_change().
206 * colormap:
207 * a GdkColormap.
208 * ncolors:
209 * the number of colors to change.
211 public void change(int ncolors)
213 // void gdk_colormap_change (GdkColormap *colormap, gint ncolors);
214 gdk_colormap_change(gdkColormap, ncolors);
218 * Allocates colors from a colormap.
219 * colormap:
220 * a GdkColormap.
221 * colors:
222 * The color values to allocate. On return, the pixel
223 * values for allocated colors will be filled in.
224 * ncolors:
225 * The number of colors in colors.
226 * writeable:
227 * If TRUE, the colors are allocated writeable
228 * (their values can later be changed using gdk_color_change()).
229 * Writeable colors cannot be shared between applications.
230 * best_match:
231 * If TRUE, GDK will attempt to do matching against
232 * existing colors if the colors cannot be allocated as requested.
233 * success:
234 * An array of length ncolors. On return, this
235 * indicates whether the corresponding color in colors was
236 * successfully allocated or not.
237 * Returns:
238 * The number of colors that were not successfully
239 * allocated.
241 public int allocColors(Color colors, int ncolors, int writeable, int bestMatch, int* success)
243 // gint gdk_colormap_alloc_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors, gboolean writeable, gboolean best_match, gboolean *success);
244 return gdk_colormap_alloc_colors(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors, writeable, bestMatch, success);
248 * Allocates a single color from a colormap.
249 * colormap:
250 * a GdkColormap.
251 * color:
252 * the color to allocate. On return the
253 * pixel field will be
254 * filled in if allocation succeeds.
255 * writeable:
256 * If TRUE, the color is allocated writeable
257 * (their values can later be changed using gdk_color_change()).
258 * Writeable colors cannot be shared between applications.
259 * best_match:
260 * If TRUE, GDK will attempt to do matching against
261 * existing colors if the color cannot be allocated as requested.
262 * Returns:
263 * TRUE if the allocation succeeded.
265 public int allocColor(Color color, int writeable, int bestMatch)
267 // gboolean gdk_colormap_alloc_color (GdkColormap *colormap, GdkColor *color, gboolean writeable, gboolean best_match);
268 return gdk_colormap_alloc_color(gdkColormap, (color is null) ? null : color.getColorStruct(), writeable, bestMatch);
272 * Frees previously allocated colors.
273 * colormap:
274 * a GdkColormap.
275 * colors:
276 * the colors to free.
277 * ncolors:
278 * the number of colors in colors.
280 public void freeColors(Color colors, int ncolors)
282 // void gdk_colormap_free_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors);
283 gdk_colormap_free_colors(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors);
287 * Locates the RGB color in colormap corresponding to the given
288 * hardware pixel pixel. pixel must be a valid pixel in the
289 * colormap; it's a programmer error to call this function with a
290 * pixel which is not in the colormap. Hardware pixels are normally
291 * obtained from gdk_colormap_alloc_colors(), or from a GdkImage. (A
292 * GdkImage contains image data in hardware format, a GdkPixbuf
293 * contains image data in a canonical 24-bit RGB format.)
294 * This function is rarely useful; it's used for example to
295 * implement the eyedropper feature in GtkColorSelection.
296 * colormap:
297 * a GdkColormap
298 * pixel:
299 * pixel value in hardware display format
300 * result:
301 * GdkColor with red, green, blue fields initialized
303 public void queryColor(uint pixel, Color result)
305 // void gdk_colormap_query_color (GdkColormap *colormap, gulong pixel, GdkColor *result);
306 gdk_colormap_query_color(gdkColormap, pixel, (result is null) ? null : result.getColorStruct());
310 * Returns the visual for which a given colormap was created.
311 * colormap:
312 * a GdkColormap.
313 * Returns:
314 * the visual of the colormap.
316 public Visual getVisual()
318 // GdkVisual* gdk_colormap_get_visual (GdkColormap *colormap);
319 return new Visual( gdk_colormap_get_visual(gdkColormap) );
323 * Gets the screen for which this colormap was created.
324 * cmap:
325 * a GdkColormap
326 * Returns:
327 * the screen for which this colormap was created.
328 * Since 2.2
330 public Screen getScreen()
332 // GdkScreen* gdk_colormap_get_screen (GdkColormap *cmap);
333 return new Screen( gdk_colormap_get_screen(gdkColormap) );
337 * Warning
338 * gdk_colors_store is deprecated and should not be used in newly-written code.
339 * Changes the value of the first ncolors colors in
340 * a private colormap. This function is obsolete and
341 * should not be used. See gdk_color_change().
342 * colormap:
343 * a GdkColormap.
344 * colors:
345 * the new color values.
346 * ncolors:
347 * the number of colors to change.
349 public void gdkColorsStore(Color colors, int ncolors)
351 // void gdk_colors_store (GdkColormap *colormap, GdkColor *colors, gint ncolors);
352 gdk_colors_store(gdkColormap, (colors is null) ? null : colors.getColorStruct(), ncolors);
358 * Warning
359 * gdk_colors_alloc is deprecated and should not be used in newly-written code.
360 * Allocates colors from a colormap. This function
361 * is obsolete. See gdk_colormap_alloc_colors().
362 * For full documentation of the fields, see
363 * the Xlib documentation for XAllocColorCells().
364 * colormap:
365 * a GdkColormap.
366 * contiguous:
367 * if TRUE, the colors should be allocated
368 * in contiguous color cells.
369 * planes:
370 * an array in which to store the plane masks.
371 * nplanes:
372 * the number of planes to allocate. (Or zero,
373 * to indicate that the color allocation should not be planar.)
374 * pixels:
375 * an array into which to store allocated pixel values.
376 * npixels:
377 * the number of pixels in each plane to allocate.
378 * Returns:
379 * TRUE if the allocation was successful
381 public int gdkColorsAlloc(int contiguous, uint* planes, int nplanes, uint* pixels, int npixels)
383 // gint gdk_colors_alloc (GdkColormap *colormap, gboolean contiguous, gulong *planes, gint nplanes, gulong *pixels, gint npixels);
384 return gdk_colors_alloc(gdkColormap, contiguous, planes, nplanes, pixels, npixels);
388 * Warning
389 * gdk_colors_free is deprecated and should not be used in newly-written code.
390 * Frees colors allocated with gdk_colors_alloc(). This
391 * function is obsolete. See gdk_colormap_free_colors().
392 * colormap:
393 * a GdkColormap.
394 * pixels:
395 * the pixel values of the colors to free.
396 * npixels:
397 * the number of values in pixels.
398 * planes:
399 * the plane masks for all planes to free, OR'd together.
401 public void gdkColorsFree(uint* pixels, int npixels, uint planes)
403 // void gdk_colors_free (GdkColormap *colormap, gulong *pixels, gint npixels, gulong planes);
404 gdk_colors_free(gdkColormap, pixels, npixels, planes);