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-Bitmaps-and-Pixmaps.html
27  * outPack = gdk
28  * outFile = Pixmap
29  * strct   = GdkPixmap
30  * realStrct=
31  * ctorStrct=
32  * clss    = Pixmap
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_pixmap_
41  * omit structs:
42  * omit prefixes:
43  * 	- gdk_bitmap_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gdk.Drawable
49  * 	- gdk.Color
50  * 	- gdk.Bitmap
51  * 	- gdk.Colormap
52  * structWrap:
53  * 	- GdkBitmap* -> Bitmap
54  * 	- GdkColor* -> Color
55  * 	- GdkColormap* -> Colormap
56  * 	- GdkDrawable* -> Drawable
57  * 	- GdkPixmap* -> Pixmap
58  * module aliases:
59  * local aliases:
60  * overrides:
61  * 	- getSize
62  */
63 
64 module gdk.Pixmap;
65 
66 public  import gtkc.gdktypes;
67 
68 private import gtkc.gdk;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 
73 private import glib.Str;
74 private import gdk.Drawable;
75 private import gdk.Color;
76 private import gdk.Bitmap;
77 private import gdk.Colormap;
78 
79 
80 
81 private import gdk.Drawable;
82 
83 /**
84  * Description
85  * Pixmaps are offscreen drawables. They can be drawn upon with the
86  * standard drawing primitives, then copied to another drawable (such as
87  * a GdkWindow) with gdk_pixmap_draw(). The depth of a pixmap
88  * is the number of bits per pixels. Bitmaps are simply pixmaps
89  * with a depth of 1. (That is, they are monochrome bitmaps - each
90  * pixel can be either on or off).
91  * GTK 3 will remove GdkPixmap and GdkBitmap. You should use cairo
92  * surfaces instead. However, because a lot of functions still use these
93  * types, they are not deprecated.
94  */
95 public class Pixmap : Drawable
96 {
97 	
98 	/** the main Gtk struct */
99 	protected GdkPixmap* gdkPixmap;
100 	
101 	
102 	public GdkPixmap* getPixmapStruct()
103 	{
104 		return gdkPixmap;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected override void* getStruct()
110 	{
111 		return cast(void*)gdkPixmap;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GdkPixmap* gdkPixmap)
118 	{
119 		super(cast(GdkDrawable*)gdkPixmap);
120 		this.gdkPixmap = gdkPixmap;
121 	}
122 	
123 	protected override void setStruct(GObject* obj)
124 	{
125 		super.setStruct(obj);
126 		gdkPixmap = cast(GdkPixmap*)obj;
127 	}
128 	
129 	/**
130 	 */
131 	
132 	/**
133 	 * Create a new pixmap with a given size and depth.
134 	 * Please use gdk_window_create_similar_surface() instead of this
135 	 * function if you're not forced to use a GdkPixmap. It is intended
136 	 * as the replacement function for this function in GTK 3.
137 	 * Params:
138 	 * drawable = A GdkDrawable, used to determine default values
139 	 * for the new pixmap. Can be NULL if depth is specified,
140 	 * width = The width of the new pixmap in pixels.
141 	 * height = The height of the new pixmap in pixels.
142 	 * depth = The depth (number of bits per pixel) of the new pixmap.
143 	 * If -1, and drawable is not NULL, the depth of the new
144 	 * pixmap will be equal to that of drawable.
145 	 * Throws: ConstructionException GTK+ fails to create the object.
146 	 */
147 	public this (Drawable drawable, int width, int height, int depth)
148 	{
149 		// GdkPixmap * gdk_pixmap_new (GdkDrawable *drawable,  gint width,  gint height,  gint depth);
150 		auto p = gdk_pixmap_new((drawable is null) ? null : drawable.getDrawableStruct(), width, height, depth);
151 		if(p is null)
152 		{
153 			throw new ConstructionException("null returned by gdk_pixmap_new((drawable is null) ? null : drawable.getDrawableStruct(), width, height, depth)");
154 		}
155 		this(cast(GdkPixmap*) p);
156 	}
157 	
158 	/**
159 	 * Warning
160 	 * gdk_pixmap_create_from_data has been deprecated since version 2.22 and should not be used in newly-written code. If you must replicate the functionality of this
161 	 * function, create a pixmap using gdk_pixmap_new(), cairo_paint() it
162 	 * with the background color and then create a Cairo image surface as
163 	 * pointed out in the docs to gdk_bitmap_create_from_data() and use
164 	 * this surface with cairo_mask_surface() to paint the foreground color.
165 	 * Create a two-color pixmap from data in XBM data.
166 	 * Params:
167 	 * drawable = a GdkDrawable, used to determine default values
168 	 * for the new pixmap. Can be NULL, if the depth is given.
169 	 * data = a pointer to the data.
170 	 * width = the width of the new pixmap in pixels.
171 	 * height = the height of the new pixmap in pixels.
172 	 * depth = the depth (number of bits per pixel) of the new pixmap.
173 	 * fg = the foreground color.
174 	 * bg = the background color.
175 	 * Returns: the GdkPixmap
176 	 */
177 	public static Pixmap createFromData(Drawable drawable, string data, int width, int height, int depth, Color fg, Color bg)
178 	{
179 		// GdkPixmap * gdk_pixmap_create_from_data (GdkDrawable *drawable,  const gchar *data,  gint width,  gint height,  gint depth,  const GdkColor *fg,  const GdkColor *bg);
180 		auto p = gdk_pixmap_create_from_data((drawable is null) ? null : drawable.getDrawableStruct(), Str.toStringz(data), width, height, depth, (fg is null) ? null : fg.getColorStruct(), (bg is null) ? null : bg.getColorStruct());
181 		
182 		if(p is null)
183 		{
184 			return null;
185 		}
186 		
187 		return ObjectG.getDObject!(Pixmap)(cast(GdkPixmap*) p);
188 	}
189 	
190 	/**
191 	 * Warning
192 	 * gdk_pixmap_create_from_xpm has been deprecated since version 2.22 and should not be used in newly-written code. Use a GdkPixbuf instead. You can use
193 	 * gdk_pixbuf_new_from_file() to create it.
194 	 * If you must use a pixmap, use gdk_pixmap_new() to
195 	 * create it and Cairo to draw the pixbuf onto it.
196 	 * Create a pixmap from a XPM file.
197 	 * Params:
198 	 * drawable = a GdkDrawable, used to determine default values
199 	 * for the new pixmap.
200 	 * mask = (out) a pointer to a place to store a bitmap representing
201 	 * the transparency mask of the XPM file. Can be NULL,
202 	 * in which case transparency will be ignored.
203 	 * transparentColor = the color to be used for the pixels
204 	 * that are transparent in the input file. Can be NULL,
205 	 * in which case a default color will be used.
206 	 * filename = the filename of a file containing XPM data.
207 	 * Returns: the GdkPixmap. [transfer none]
208 	 */
209 	public static Pixmap createFromXpm(Drawable drawable, out Bitmap mask, Color transparentColor, string filename)
210 	{
211 		// GdkPixmap * gdk_pixmap_create_from_xpm (GdkDrawable *drawable,  GdkBitmap **mask,  const GdkColor *transparent_color,  const gchar *filename);
212 		GdkBitmap* outmask = null;
213 		
214 		auto p = gdk_pixmap_create_from_xpm((drawable is null) ? null : drawable.getDrawableStruct(), &outmask, (transparentColor is null) ? null : transparentColor.getColorStruct(), Str.toStringz(filename));
215 		
216 		mask = ObjectG.getDObject!(Bitmap)(outmask);
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return ObjectG.getDObject!(Pixmap)(cast(GdkPixmap*) p);
224 	}
225 	
226 	/**
227 	 * Warning
228 	 * gdk_pixmap_colormap_create_from_xpm has been deprecated since version 2.22 and should not be used in newly-written code. Use a GdkPixbuf instead. You can use
229 	 * gdk_pixbuf_new_from_file() to create it.
230 	 * If you must use a pixmap, use gdk_pixmap_new() to
231 	 * create it and Cairo to draw the pixbuf onto it.
232 	 * Create a pixmap from a XPM file using a particular colormap.
233 	 * Params:
234 	 * drawable = a GdkDrawable, used to determine default values
235 	 * for the new pixmap. Can be NULL if colormap is given.
236 	 * colormap = the GdkColormap that the new pixmap will be use.
237 	 * If omitted, the colormap for window will be used.
238 	 * mask = a pointer to a place to store a bitmap representing
239 	 * the transparency mask of the XPM file. Can be NULL,
240 	 * in which case transparency will be ignored.
241 	 * transparentColor = the color to be used for the pixels
242 	 * that are transparent in the input file. Can be NULL,
243 	 * in which case a default color will be used.
244 	 * filename = the filename of a file containing XPM data.
245 	 * Returns: the GdkPixmap. [transfer none]
246 	 */
247 	public static Pixmap colormapCreateFromXpm(Drawable drawable, Colormap colormap, out Bitmap mask, Color transparentColor, string filename)
248 	{
249 		// GdkPixmap * gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,  GdkColormap *colormap,  GdkBitmap **mask,  const GdkColor *transparent_color,  const gchar *filename);
250 		GdkBitmap* outmask = null;
251 		
252 		auto p = gdk_pixmap_colormap_create_from_xpm((drawable is null) ? null : drawable.getDrawableStruct(), (colormap is null) ? null : colormap.getColormapStruct(), &outmask, (transparentColor is null) ? null : transparentColor.getColorStruct(), Str.toStringz(filename));
253 		
254 		mask = ObjectG.getDObject!(Bitmap)(outmask);
255 		
256 		if(p is null)
257 		{
258 			return null;
259 		}
260 		
261 		return ObjectG.getDObject!(Pixmap)(cast(GdkPixmap*) p);
262 	}
263 	
264 	/**
265 	 * Warning
266 	 * gdk_pixmap_create_from_xpm_d has been deprecated since version 2.22 and should not be used in newly-written code. Use a GdkPixbuf instead. You can use
267 	 * gdk_pixbuf_new_from_xpm_data() to create it.
268 	 * If you must use a pixmap, use gdk_pixmap_new() to
269 	 * create it and Cairo to draw the pixbuf onto it.
270 	 * Create a pixmap from data in XPM format.
271 	 * Params:
272 	 * drawable = a GdkDrawable, used to determine default values
273 	 * for the new pixmap.
274 	 * mask = Pointer to a place to store a bitmap representing
275 	 * the transparency mask of the XPM file. Can be NULL,
276 	 * in which case transparency will be ignored. [out]
277 	 * transparentColor = This color will be used for the pixels
278 	 * that are transparent in the input file. Can be NULL
279 	 * in which case a default color will be used.
280 	 * data = Pointer to a string containing the XPM data.
281 	 * Returns: the GdkPixmap. [transfer none]
282 	 */
283 	public static Pixmap createFromXpmD(Drawable drawable, out Bitmap mask, Color transparentColor, string[] data)
284 	{
285 		// GdkPixmap * gdk_pixmap_create_from_xpm_d (GdkDrawable *drawable,  GdkBitmap **mask,  const GdkColor *transparent_color,  gchar **data);
286 		GdkBitmap* outmask = null;
287 		
288 		auto p = gdk_pixmap_create_from_xpm_d((drawable is null) ? null : drawable.getDrawableStruct(), &outmask, (transparentColor is null) ? null : transparentColor.getColorStruct(), Str.toStringzArray(data));
289 		
290 		mask = ObjectG.getDObject!(Bitmap)(outmask);
291 		
292 		if(p is null)
293 		{
294 			return null;
295 		}
296 		
297 		return ObjectG.getDObject!(Pixmap)(cast(GdkPixmap*) p);
298 	}
299 	
300 	/**
301 	 * Warning
302 	 * gdk_pixmap_colormap_create_from_xpm_d has been deprecated since version 2.22 and should not be used in newly-written code. Use a GdkPixbuf instead. You can use
303 	 * gdk_pixbuf_new_from_xpm_data() to create it.
304 	 * If you must use a pixmap, use gdk_pixmap_new() to
305 	 * create it and Cairo to draw the pixbuf onto it.
306 	 * Create a pixmap from data in XPM format using a particular
307 	 * colormap.
308 	 * Params:
309 	 * drawable = a GdkDrawable, used to determine default values
310 	 * for the new pixmap. Can be NULL if colormap is given.
311 	 * colormap = the GdkColormap that the new pixmap will be use.
312 	 * If omitted, the colormap for window will be used.
313 	 * mask = a pointer to a place to store a bitmap representing
314 	 * the transparency mask of the XPM file. Can be NULL,
315 	 * in which case transparency will be ignored.
316 	 * transparentColor = the color to be used for the pixels
317 	 * that are transparent in the input file. Can be NULL,
318 	 * in which case a default color will be used.
319 	 * data = Pointer to a string containing the XPM data.
320 	 * Returns: the GdkPixmap. [transfer none]
321 	 */
322 	public static Pixmap colormapCreateFromXpmD(Drawable drawable, Colormap colormap, out Bitmap mask, Color transparentColor, string[] data)
323 	{
324 		// GdkPixmap * gdk_pixmap_colormap_create_from_xpm_d  (GdkDrawable *drawable,  GdkColormap *colormap,  GdkBitmap **mask,  const GdkColor *transparent_color,  gchar **data);
325 		GdkBitmap* outmask = null;
326 		
327 		auto p = gdk_pixmap_colormap_create_from_xpm_d((drawable is null) ? null : drawable.getDrawableStruct(), (colormap is null) ? null : colormap.getColormapStruct(), &outmask, (transparentColor is null) ? null : transparentColor.getColorStruct(), Str.toStringzArray(data));
328 		
329 		mask = ObjectG.getDObject!(Bitmap)(outmask);
330 		
331 		if(p is null)
332 		{
333 			return null;
334 		}
335 		
336 		return ObjectG.getDObject!(Pixmap)(cast(GdkPixmap*) p);
337 	}
338 	
339 	/**
340 	 * This function is purely to make it possible to query the size of pixmaps
341 	 * even when compiling without deprecated symbols and you must use pixmaps.
342 	 * It is identical to gdk_drawable_get_size(), but for pixmaps.
343 	 * Since 2.24
344 	 * Params:
345 	 * width = location to store pixmap's width, or NULL. [out][allow-none]
346 	 * height = location to store pixmap's height, or NULL. [out][allow-none]
347 	 */
348 	public override void getSize(out int width, out int height)
349 	{
350 		// void gdk_pixmap_get_size (GdkPixmap *pixmap,  gint *width,  gint *height);
351 		gdk_pixmap_get_size(gdkPixmap, &width, &height);
352 	}
353 }