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  * Conversion parameters:
26  * inFile  = gdk-GdkRGB.html
27  * outPack = gdk
28  * outFile = RGB
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = RGB
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_
41  * omit structs:
42  * omit prefixes:
43  * 	- gdk_rgb_cmap_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gdk.Drawable
48  * 	- gdk.GC
49  * 	- gdk.RgbCmap
50  * 	- gdk.Colormap
51  * 	- gdk.Color
52  * 	- gdk.Visual
53  * structWrap:
54  * 	- GdkColor* -> Color
55  * 	- GdkColormap* -> Colormap
56  * 	- GdkDrawable* -> Drawable
57  * 	- GdkGC* -> GC
58  * 	- GdkRgbCmap* -> RgbCmap
59  * 	- GdkVisual* -> Visual
60  * module aliases:
61  * local aliases:
62  * overrides:
63  */
64 
65 module gdk.RGB;
66 
67 public  import gtkc.gdktypes;
68 
69 private import gtkc.gdk;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 
74 private import gdk.Drawable;
75 private import gdk.GC;
76 private import gdk.RgbCmap;
77 private import gdk.Colormap;
78 private import gdk.Color;
79 private import gdk.Visual;
80 
81 
82 
83 
84 /**
85  * Description
86  * GdkRGB is a low-level module which renders RGB, grayscale, and indexed
87  * colormap images to a GdkDrawable. It does this as efficiently as
88  * possible, handling issues such as colormaps, visuals, dithering,
89  * temporary buffers, and so on. Most code should use the higher-level
90  * GdkPixbuf features in place of this module; for example,
91  * gdk_draw_pixbuf() uses GdkRGB in its implementation.
92  * GdkRGB allocates a color cube to use when rendering images. You can
93  * set the threshold for installing colormaps with
94  * gdk_rgb_set_min_colors(). The default is 5x5x5 (125). If a colorcube
95  * of this size or larger can be allocated in the default colormap, then
96  * that's done. Otherwise, GdkRGB creates its own private colormap.
97  * Setting it to 0 means that it always tries to use the default
98  * colormap, and setting it to 216 means that it always creates a private
99  * one if it cannot allocate the 6x6x6 colormap in the default. If you
100  * always want a private colormap (to avoid consuming too many colormap
101  * entries for other apps, say), you can use
102  * gdk_rgb_set_install(TRUE).
103  * Setting the value greater than 216 exercises a bug in older versions
104  * of GdkRGB. Note, however, that setting it to 0 doesn't let you get
105  * away with ignoring the colormap and visual - a colormap is always
106  * created in grayscale and direct color modes, and the visual is changed
107  * in cases where a "better" visual than the default is available.
108  * If GDK is built with the Sun mediaLib library, the GdkRGB functions are
109  * accelerated using mediaLib, which provides hardware acceleration on Intel,
110  * AMD, and Sparc chipsets. If desired, mediaLib support can be turned off
111  * by setting the GDK_DISABLE_MEDIALIB environment variable.
112  * $(DDOC_COMMENT example)
113  */
114 public class RGB
115 {
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Warning
122 	 * gdk_rgb_init is deprecated and should not be used in newly-written code.
123 	 * This function no longer does anything at all. It's completely useless
124 	 * (and harmless).
125 	 */
126 	public static void rgbInit()
127 	{
128 		// void gdk_rgb_init (void);
129 		gdk_rgb_init();
130 	}
131 	
132 	/**
133 	 * Warning
134 	 * gdk_draw_rgb_image is deprecated and should not be used in newly-written code.
135 	 * Draws an RGB image in the drawable. This is the core GdkRGB
136 	 * function, and likely the only one you will need to use.
137 	 * The rowstride parameter allows for lines to be aligned more flexibly.
138 	 * For example, lines may be allocated to begin on 32-bit boundaries,
139 	 * even if the width of the rectangle is odd. Rowstride is also useful
140 	 * when drawing a subrectangle of a larger image in memory. Finally, to
141 	 * replicate the same line a number of times, the trick of setting
142 	 * rowstride to 0 is allowed.
143 	 * In general, for 0 <= i < width and 0 <= j < height,
144 	 * the pixel (x + i, y + j) is colored with red value rgb_buf[j *
145 	 * rowstride + i * 3], green value rgb_buf[j * rowstride + i * 3 +
146 	 * 1], and blue value rgb_buf[j * rowstride + i * 3 + 2].
147 	 * Params:
148 	 * drawable = The GdkDrawable to draw in (usually a GdkWindow).
149 	 * gc = The graphics context (all GDK drawing operations require one; its
150 	 * contents are ignored).
151 	 * x = The x coordinate of the top-left corner in the drawable.
152 	 * y = The y coordinate of the top-left corner in the drawable.
153 	 * width = The width of the rectangle to be drawn.
154 	 * height = The height of the rectangle to be drawn.
155 	 * dith = A GdkRgbDither value, selecting the desired dither mode.
156 	 * rgbBuf = The pixel data, represented as packed 24-bit data.
157 	 * rowstride = The number of bytes from the start of one row in rgb_buf to the
158 	 * start of the next.
159 	 */
160 	public static void drawRgbImage(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* rgbBuf, int rowstride)
161 	{
162 		// void gdk_draw_rgb_image (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *rgb_buf,  gint rowstride);
163 		gdk_draw_rgb_image((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, rgbBuf, rowstride);
164 	}
165 	
166 	/**
167 	 * Warning
168 	 * gdk_draw_rgb_image_dithalign is deprecated and should not be used in newly-written code.
169 	 * Draws an RGB image in the drawable, with an adjustment for dither alignment.
170 	 * This function is useful when drawing dithered images into a window
171 	 * that may be scrolled. Pixel (x, y) will be drawn dithered as if its
172 	 * actual location is (x + xdith, y + ydith). Thus, if you draw an
173 	 * image into a window using zero dither alignment, then scroll up one
174 	 * pixel, subsequent draws to the window should have ydith = 1.
175 	 * Setting the dither alignment correctly allows updating of small parts
176 	 * of the screen while avoiding visible "seams" between the different
177 	 * dither textures.
178 	 * Params:
179 	 * drawable = The GdkDrawable to draw in (usually a GdkWindow).
180 	 * gc = The graphics context.
181 	 * x = The x coordinate of the top-left corner in the drawable.
182 	 * y = The y coordinate of the top-left corner in the drawable.
183 	 * width = The width of the rectangle to be drawn.
184 	 * height = The height of the rectangle to be drawn.
185 	 * dith = A GdkRgbDither value, selecting the desired dither mode.
186 	 * rgbBuf = The pixel data, represented as packed 24-bit data.
187 	 * rowstride = The number of bytes from the start of one row in rgb_buf to the
188 	 * start of the next.
189 	 * xdith = An x offset for dither alignment.
190 	 * ydith = A y offset for dither alignment.
191 	 */
192 	public static void drawRgbImageDithalign(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* rgbBuf, int rowstride, int xdith, int ydith)
193 	{
194 		// void gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *rgb_buf,  gint rowstride,  gint xdith,  gint ydith);
195 		gdk_draw_rgb_image_dithalign((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, rgbBuf, rowstride, xdith, ydith);
196 	}
197 	
198 	/**
199 	 * Warning
200 	 * gdk_draw_indexed_image is deprecated and should not be used in newly-written code.
201 	 * Draws an indexed image in the drawable, using a GdkRgbCmap to assign
202 	 * actual colors to the color indices.
203 	 * Params:
204 	 * drawable = The GdkDrawable to draw in (usually a GdkWindow).
205 	 * gc = The graphics context.
206 	 * x = The x coordinate of the top-left corner in the drawable.
207 	 * y = The y coordinate of the top-left corner in the drawable.
208 	 * width = The width of the rectangle to be drawn.
209 	 * height = The height of the rectangle to be drawn.
210 	 * dith = A GdkRgbDither value, selecting the desired dither mode.
211 	 * buf = The pixel data, represented as 8-bit color indices.
212 	 * rowstride = The number of bytes from the start of one row in buf to the
213 	 * start of the next.
214 	 * cmap = The GdkRgbCmap used to assign colors to the color indices.
215 	 */
216 	public static void drawIndexedImage(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* buf, int rowstride, RgbCmap cmap)
217 	{
218 		// void gdk_draw_indexed_image (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *buf,  gint rowstride,  GdkRgbCmap *cmap);
219 		gdk_draw_indexed_image((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, buf, rowstride, (cmap is null) ? null : cmap.getRgbCmapStruct());
220 	}
221 	
222 	/**
223 	 * Warning
224 	 * gdk_draw_gray_image is deprecated and should not be used in newly-written code.
225 	 * Draws a grayscale image in the drawable.
226 	 * Params:
227 	 * drawable = The GdkDrawable to draw in (usually a GdkWindow).
228 	 * gc = The graphics context.
229 	 * x = The x coordinate of the top-left corner in the drawable.
230 	 * y = The y coordinate of the top-left corner in the drawable.
231 	 * width = The width of the rectangle to be drawn.
232 	 * height = The height of the rectangle to be drawn.
233 	 * dith = A GdkRgbDither value, selecting the desired dither mode.
234 	 * buf = The pixel data, represented as 8-bit gray values.
235 	 * rowstride = The number of bytes from the start of one row in buf to the
236 	 * start of the next.
237 	 */
238 	public static void drawGrayImage(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* buf, int rowstride)
239 	{
240 		// void gdk_draw_gray_image (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *buf,  gint rowstride);
241 		gdk_draw_gray_image((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, buf, rowstride);
242 	}
243 	
244 	/**
245 	 * Warning
246 	 * gdk_draw_rgb_32_image is deprecated and should not be used in newly-written code.
247 	 * Draws a padded RGB image in the drawable. The image is stored as one
248 	 * pixel per 32-bit word. It is laid out as a red byte, a green byte, a
249 	 * blue byte, and a padding byte.
250 	 * It's unlikely that this function will give significant performance
251 	 * gains in practice. In my experience, the performance gain from having
252 	 * pixels aligned to 32-bit boundaries is cancelled out by the increased
253 	 * memory bandwidth.
254 	 * Params:
255 	 * drawable = The GdkDrawable to draw in (usually a GdkWindow).
256 	 * gc = The graphics context.
257 	 * x = The x coordinate of the top-left corner in the drawable.
258 	 * y = The y coordinate of the top-left corner in the drawable.
259 	 * width = The width of the rectangle to be drawn.
260 	 * height = The height of the rectangle to be drawn.
261 	 * dith = A GdkRgbDither value, selecting the desired dither mode.
262 	 * buf = The pixel data, represented as padded 32-bit data.
263 	 * rowstride = The number of bytes from the start of one row in buf to the
264 	 * start of the next.
265 	 */
266 	public static void drawRgb32_Image(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* buf, int rowstride)
267 	{
268 		// void gdk_draw_rgb_32_image (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *buf,  gint rowstride);
269 		gdk_draw_rgb_32_image((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, buf, rowstride);
270 	}
271 	
272 	/**
273 	 * Warning
274 	 * gdk_draw_rgb_32_image_dithalign has been deprecated since version 2.22 and should not be used in newly-written code. Cairo handles colors automatically.
275 	 * Like gdk_draw_rgb_32_image(), but allows you to specify the dither
276 	 * offsets. See gdk_draw_rgb_image_dithalign() for more details.
277 	 * Params:
278 	 * drawable = a GdkDrawable
279 	 * gc = a GdkGC
280 	 * x = X coordinate on drawable where image should go
281 	 * y = Y coordinate on drawable where image should go
282 	 * width = width of area of image to draw
283 	 * height = height of area of image to draw
284 	 * dith = dithering mode
285 	 * buf = RGB image data
286 	 * rowstride = rowstride of RGB image data
287 	 * xdith = X dither offset
288 	 * ydith = Y dither offset
289 	 */
290 	public static void drawRgb32_ImageDithalign(Drawable drawable, GC gc, int x, int y, int width, int height, GdkRgbDither dith, char* buf, int rowstride, int xdith, int ydith)
291 	{
292 		// void gdk_draw_rgb_32_image_dithalign (GdkDrawable *drawable,  GdkGC *gc,  gint x,  gint y,  gint width,  gint height,  GdkRgbDither dith,  const guchar *buf,  gint rowstride,  gint xdith,  gint ydith);
293 		gdk_draw_rgb_32_image_dithalign((drawable is null) ? null : drawable.getDrawableStruct(), (gc is null) ? null : gc.getGCStruct(), x, y, width, height, dith, buf, rowstride, xdith, ydith);
294 	}
295 	
296 	/**
297 	 * Warning
298 	 * gdk_rgb_gc_set_foreground is deprecated and should not be used in newly-written code.
299 	 * Sets the foreground color in gc to the specified color (or the
300 	 * closest approximation, in the case of limited visuals).
301 	 * Params:
302 	 * gc = The GdkGC to modify.
303 	 * rgb = The color, represented as a 0xRRGGBB integer value.
304 	 */
305 	public static void rgbGcSetForeground(GC gc, uint rgb)
306 	{
307 		// void gdk_rgb_gc_set_foreground (GdkGC *gc,  guint32 rgb);
308 		gdk_rgb_gc_set_foreground((gc is null) ? null : gc.getGCStruct(), rgb);
309 	}
310 	
311 	/**
312 	 * Warning
313 	 * gdk_rgb_gc_set_background is deprecated and should not be used in newly-written code.
314 	 * Sets the background color in gc to the specified color (or the
315 	 * closest approximation, in the case of limited visuals).
316 	 * Params:
317 	 * gc = The GdkGC to modify.
318 	 * rgb = The color, represented as a 0xRRGGBB integer value.
319 	 */
320 	public static void rgbGcSetBackground(GC gc, uint rgb)
321 	{
322 		// void gdk_rgb_gc_set_background (GdkGC *gc,  guint32 rgb);
323 		gdk_rgb_gc_set_background((gc is null) ? null : gc.getGCStruct(), rgb);
324 	}
325 	
326 	/**
327 	 * Warning
328 	 * gdk_rgb_xpixel_from_rgb is deprecated and should not be used in newly-written code.
329 	 * Finds the X pixel closest in color to the rgb color specified. This
330 	 * value may be used to set the pixel field of
331 	 * a GdkColor struct.
332 	 * Params:
333 	 * rgb = The color, represented as a 0xRRGGBB integer value.
334 	 * Returns: The X pixel value.
335 	 */
336 	public static gulong rgbXpixelFromRgb(uint rgb)
337 	{
338 		// gulong gdk_rgb_xpixel_from_rgb (guint32 rgb);
339 		return gdk_rgb_xpixel_from_rgb(rgb);
340 	}
341 	
342 	/**
343 	 * Warning
344 	 * gdk_rgb_find_color has been deprecated since version 2.22 and should not be used in newly-written code. Cairo handles colors automatically.
345 	 * colormap should be the colormap for the graphics context and
346 	 * drawable you're using to draw. If you're drawing to a GtkWidget,
347 	 * call gtk_widget_get_colormap().
348 	 * color should have its red, green, and blue fields initialized;
349 	 * gdk_rgb_find_color() will fill in the pixel field with the best
350 	 * matching pixel from a color cube. The color is then ready to be
351 	 * used for drawing, e.g. you can call gdk_gc_set_foreground() which
352 	 * expects pixel to be initialized.
353 	 * In many cases, you can avoid this whole issue by calling
354 	 * gdk_gc_set_rgb_fg_color() or gdk_gc_set_rgb_bg_color(), which
355 	 * do not expect pixel to be initialized in advance. If you use those
356 	 * functions, there's no need for gdk_rgb_find_color().
357 	 * Params:
358 	 * colormap = a GdkColormap
359 	 * color = a GdkColor
360 	 */
361 	public static void rgbFindColor(Colormap colormap, Color color)
362 	{
363 		// void gdk_rgb_find_color (GdkColormap *colormap,  GdkColor *color);
364 		gdk_rgb_find_color((colormap is null) ? null : colormap.getColormapStruct(), (color is null) ? null : color.getColorStruct());
365 	}
366 	
367 	/**
368 	 * Warning
369 	 * gdk_rgb_set_install is deprecated and should not be used in newly-written code.
370 	 * If install is TRUE, directs GdkRGB to always install a new "private"
371 	 * colormap rather than trying to find a best fit with the colors already
372 	 * allocated. Ordinarily, GdkRGB will install a colormap only if a
373 	 * sufficient cube cannot be allocated.
374 	 * A private colormap has more colors, leading to better quality display,
375 	 * but also leads to the dreaded "colormap flashing" effect.
376 	 * Params:
377 	 * install = TRUE to set install mode.
378 	 */
379 	public static void rgbSetInstall(int install)
380 	{
381 		// void gdk_rgb_set_install (gboolean install);
382 		gdk_rgb_set_install(install);
383 	}
384 	
385 	/**
386 	 * Warning
387 	 * gdk_rgb_set_min_colors is deprecated and should not be used in newly-written code.
388 	 * Sets the minimum number of colors for the color cube. Generally,
389 	 * GdkRGB tries to allocate the largest color cube it can. If it can't
390 	 * allocate a color cube at least as large as min_colors, it installs a
391 	 * private colormap.
392 	 * Params:
393 	 * minColors = The minimum number of colors accepted.
394 	 */
395 	public static void rgbSetMinColors(int minColors)
396 	{
397 		// void gdk_rgb_set_min_colors (gint min_colors);
398 		gdk_rgb_set_min_colors(minColors);
399 	}
400 	
401 	/**
402 	 * Warning
403 	 * gdk_rgb_get_visual has been deprecated since version 2.22 and should not be used in newly-written code. Use gdk_visual_get_system_visual (gdk_screen_get_default()) instead.
404 	 * Gets a "preferred visual" chosen by GdkRGB for rendering image data
405 	 * on the default screen. In previous versions of GDK, this was the
406 	 * only visual GdkRGB could use for rendering. In current versions,
407 	 * it's simply the visual GdkRGB would have chosen as the optimal one
408 	 * in those previous versions. GdkRGB can now render to drawables with
409 	 * any visual.
410 	 * Returns: The GdkVisual chosen by GdkRGB. [transfer none]
411 	 */
412 	public static Visual rgbGetVisual()
413 	{
414 		// GdkVisual * gdk_rgb_get_visual (void);
415 		auto p = gdk_rgb_get_visual();
416 		
417 		if(p is null)
418 		{
419 			return null;
420 		}
421 		
422 		return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p);
423 	}
424 	
425 	/**
426 	 * Warning
427 	 * gdk_rgb_get_colormap has been deprecated since version 2.22 and should not be used in newly-written code. Use gdk_screen_get_system_colormap (gdk_screen_get_default()) instead.
428 	 * Get the preferred colormap for rendering image data. Not a
429 	 * very useful function; historically, GDK could only render RGB image
430 	 * data to one colormap and visual, but in the current version it can
431 	 * render to any colormap and visual. So there's no need to call this
432 	 * function.
433 	 * Returns: the preferred colormap. [transfer none]
434 	 */
435 	public static Colormap rgbGetColormap()
436 	{
437 		// GdkColormap * gdk_rgb_get_colormap (void);
438 		auto p = gdk_rgb_get_colormap();
439 		
440 		if(p is null)
441 		{
442 			return null;
443 		}
444 		
445 		return ObjectG.getDObject!(Colormap)(cast(GdkColormap*) p);
446 	}
447 	
448 	/**
449 	 * Warning
450 	 * gdk_rgb_ditherable is deprecated and should not be used in newly-written code.
451 	 * Determines whether the preferred visual is ditherable. This function may be
452 	 * useful for presenting a user interface choice to the user about which
453 	 * dither mode is desired; if the display is not ditherable, it may make
454 	 * sense to gray out or hide the corresponding UI widget.
455 	 * Returns: TRUE if the preferred visual is ditherable.
456 	 */
457 	public static int rgbDitherable()
458 	{
459 		// gboolean gdk_rgb_ditherable (void);
460 		return gdk_rgb_ditherable();
461 	}
462 	
463 	/**
464 	 * Warning
465 	 * gdk_rgb_colormap_ditherable is deprecated and should not be used in newly-written code.
466 	 * Determines whether the visual associated with cmap is ditherable. This
467 	 * function may be useful for presenting a user interface choice to the user
468 	 * about which dither mode is desired; if the display is not ditherable, it may
469 	 * make sense to gray out or hide the corresponding UI widget.
470 	 * Params:
471 	 * cmap = a GdkColormap
472 	 * Returns: TRUE if the visual associated with cmap is ditherable.
473 	 */
474 	public static int rgbColormapDitherable(Colormap cmap)
475 	{
476 		// gboolean gdk_rgb_colormap_ditherable (GdkColormap *cmap);
477 		return gdk_rgb_colormap_ditherable((cmap is null) ? null : cmap.getColormapStruct());
478 	}
479 	
480 	/**
481 	 * Warning
482 	 * gdk_rgb_set_verbose is deprecated and should not be used in newly-written code.
483 	 * Sets the "verbose" flag. This is generally only useful for debugging.
484 	 * Params:
485 	 * verbose = TRUE if verbose messages are desired.
486 	 */
487 	public static void rgbSetVerbose(int verbose)
488 	{
489 		// void gdk_rgb_set_verbose (gboolean verbose);
490 		gdk_rgb_set_verbose(verbose);
491 	}
492 }