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  = gdk3-Cairo-Interaction.html
27  * outPack = gdk
28  * outFile = Cairo
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = 
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_cairo_
41  * 	- gdk_window_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- cairo.Context
48  * 	- cairo.Region
49  * 	- cairo.Surface
50  * 	- gdk.Color
51  * 	- gdk.Pixbuf
52  * 	- gdk.RGBA
53  * 	- gdk.Window
54  * structWrap:
55  * 	- GdkColor* -> Color
56  * 	- GdkPixbuf* -> Pixbuf
57  * 	- GdkRGBA* -> RGBA
58  * 	- GdkWindow* -> Window
59  * 	- cairo_region_t* -> Region
60  * 	- cairo_surface_t* -> Surface
61  * 	- cairo_t* -> Context
62  * module aliases:
63  * local aliases:
64  * 	- create -> createContext
65  * overrides:
66  */
67 
68 module gdk.Cairo;
69 
70 public  import gtkc.gdktypes;
71 
72 private import gtkc.gdk;
73 private import glib.ConstructionException;
74 private import gobject.ObjectG;
75 
76 
77 private import cairo.Context;
78 private import cairo.Region;
79 private import cairo.Surface;
80 private import gdk.Color;
81 private import gdk.Pixbuf;
82 private import gdk.RGBA;
83 private import gdk.Window;
84 
85 
86 
87 
88 /**
89  * Use these functions in combination with UFCS.
90  */
91 
92 /**
93  */
94 
95 /**
96  * Create a new surface that is as compatible as possible with the
97  * given window. For example the new surface will have the same
98  * fallback resolution and font options as window. Generally, the new
99  * surface will also use the same backend as window, unless that is
100  * not possible for some reason. The type of the returned surface may
101  * be examined with cairo_surface_get_type().
102  * Initially the surface contents are all 0 (transparent if contents
103  * have transparency, black otherwise.)
104  * Since 2.22
105  * Params:
106  * window = window to make new surface similar to
107  * content = the content for the new surface
108  * width = width of the new surface
109  * height = height of the new surface
110  * Returns: a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs.
111  */
112 public static Surface createSimilarSurface(Window window, cairo_content_t content, int width, int height)
113 {
114 	// cairo_surface_t * gdk_window_create_similar_surface (GdkWindow *window,  cairo_content_t content,  int width,  int height);
115 	auto p = gdk_window_create_similar_surface((window is null) ? null : window.getWindowStruct(), content, width, height);
116 	
117 	if(p is null)
118 	{
119 		return null;
120 	}
121 	
122 	return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p);
123 }
124 
125 /**
126  * Create a new image surface that is efficient to draw on the
127  * given window.
128  * Initially the surface contents are all 0 (transparent if contents
129  * have transparency, black otherwise.)
130  * Params:
131  * window = window to make new surface similar to, or NULL if none
132  * format = the format for the new surface. [type int]
133  * width = width of the new surface
134  * height = height of the new surface
135  * scale = the scale of the new surface, or 0 to use same as window
136  * Returns: a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it. This function always returns a valid pointer, but it will return a pointer to a "nil" surface if other is already in an error state or any other error occurs. Since 3.10
137  */
138 public static Surface createSimilarImageSurface(Window window, cairo_format_t format, int width, int height, int scale)
139 {
140 	// cairo_surface_t * gdk_window_create_similar_image_surface  (GdkWindow *window,  cairo_format_t format,  int width,  int height,  int scale);
141 	auto p = gdk_window_create_similar_image_surface((window is null) ? null : window.getWindowStruct(), format, width, height, scale);
142 	
143 	if(p is null)
144 	{
145 		return null;
146 	}
147 	
148 	return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p);
149 }
150 
151 /**
152  * Creates a Cairo context for drawing to window.
153  * Note
154  * Warning
155  * Note that calling cairo_reset_clip() on the resulting cairo_t will
156  * produce undefined results, so avoid it at all costs.
157  * Since 2.8
158  * Params:
159  * window = a GdkWindow
160  * Returns: A newly created Cairo context. Free with cairo_destroy() when you are done drawing.
161  */
162 public static Context createContext(Window window)
163 {
164 	// cairo_t * gdk_cairo_create (GdkWindow *window);
165 	auto p = gdk_cairo_create((window is null) ? null : window.getWindowStruct());
166 	
167 	if(p is null)
168 	{
169 		return null;
170 	}
171 	
172 	return ObjectG.getDObject!(Context)(cast(cairo_t*) p);
173 }
174 
175 /**
176  * This is a convenience function around cairo_clip_extents().
177  * It rounds the clip extents to integer coordinates and returns
178  * a boolean indicating if a clip area exists.
179  * Params:
180  * cr = a cairo context
181  * rect = return location for the clip, or NULL. [out][allow-none]
182  * Returns: TRUE if a clip rectangle exists, FALSE if all of cr is clipped and all drawing can be skipped
183  */
184 public static int getClipRectangle(Context cr, Rectangle* rect)
185 {
186 	// gboolean gdk_cairo_get_clip_rectangle (cairo_t *cr,  GdkRectangle *rect);
187 	return gdk_cairo_get_clip_rectangle((cr is null) ? null : cr.getContextStruct(), rect);
188 }
189 
190 /**
191  * Warning
192  * gdk_cairo_set_source_color has been deprecated since version 3.4 and should not be used in newly-written code. Use gdk_cairo_set_source_rgba() instead
193  * Sets the specified GdkColor as the source color of cr.
194  * Since 2.8
195  * Params:
196  * cr = a cairo context
197  * color = a GdkColor
198  */
199 public static void setSourceColor(Context cr, Color color)
200 {
201 	// void gdk_cairo_set_source_color (cairo_t *cr,  const GdkColor *color);
202 	gdk_cairo_set_source_color((cr is null) ? null : cr.getContextStruct(), (color is null) ? null : color.getColorStruct());
203 }
204 
205 /**
206  * Sets the specified GdkRGBA as the source color of cr.
207  * Params:
208  * cr = a cairo context
209  * rgba = a GdkRGBA
210  * Since 3.0
211  */
212 public static void setSourceRgba(Context cr, RGBA rgba)
213 {
214 	// void gdk_cairo_set_source_rgba (cairo_t *cr,  const GdkRGBA *rgba);
215 	gdk_cairo_set_source_rgba((cr is null) ? null : cr.getContextStruct(), (rgba is null) ? null : rgba.getRGBAStruct());
216 }
217 
218 /**
219  * Sets the given pixbuf as the source pattern for cr.
220  * The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned
221  * so that the origin of pixbuf is pixbuf_x, pixbuf_y.
222  * Since 2.8
223  * Params:
224  * cr = a cairo context
225  * pixbuf = a GdkPixbuf
226  * pixbufX = X coordinate of location to place upper left corner of pixbuf
227  * pixbufY = Y coordinate of location to place upper left corner of pixbuf
228  */
229 public static void setSourcePixbuf(Context cr, Pixbuf pixbuf, double pixbufX, double pixbufY)
230 {
231 	// void gdk_cairo_set_source_pixbuf (cairo_t *cr,  const GdkPixbuf *pixbuf,  gdouble pixbuf_x,  gdouble pixbuf_y);
232 	gdk_cairo_set_source_pixbuf((cr is null) ? null : cr.getContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), pixbufX, pixbufY);
233 }
234 
235 /**
236  * Sets the given window as the source pattern for cr.
237  * The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned
238  * so that the origin of window is x, y. The window contains all its
239  * subwindows when rendering.
240  * Note that the contents of window are undefined outside of the
241  * visible part of window, so use this function with care.
242  * Since 2.24
243  * Params:
244  * cr = a cairo context
245  * window = a GdkWindow
246  * x = X coordinate of location to place upper left corner of window
247  * y = Y coordinate of location to place upper left corner of window
248  */
249 public static void setSourceWindow(Context cr, Window window, double x, double y)
250 {
251 	// void gdk_cairo_set_source_window (cairo_t *cr,  GdkWindow *window,  gdouble x,  gdouble y);
252 	gdk_cairo_set_source_window((cr is null) ? null : cr.getContextStruct(), (window is null) ? null : window.getWindowStruct(), x, y);
253 }
254 
255 /**
256  * Adds the given rectangle to the current path of cr.
257  * Since 2.8
258  * Params:
259  * cr = a cairo context
260  * rectangle = a GdkRectangle
261  */
262 public static void rectangle(Context cr, Rectangle* rectangle)
263 {
264 	// void gdk_cairo_rectangle (cairo_t *cr,  const GdkRectangle *rectangle);
265 	gdk_cairo_rectangle((cr is null) ? null : cr.getContextStruct(), rectangle);
266 }
267 
268 /**
269  * Adds the given region to the current path of cr.
270  * Since 2.8
271  * Params:
272  * cr = a cairo context
273  * region = a cairo_region_t
274  */
275 public static void region(Context cr, Region region)
276 {
277 	// void gdk_cairo_region (cairo_t *cr,  const cairo_region_t *region);
278 	gdk_cairo_region((cr is null) ? null : cr.getContextStruct(), (region is null) ? null : region.getRegionStruct());
279 }
280 
281 /**
282  * Creates region that describes covers the area where the given
283  * surface is more than 50% opaque.
284  * This function takes into account device offsets that might be
285  * set with cairo_surface_set_device_offset().
286  * Params:
287  * surface = a cairo surface
288  * Returns: A cairo_region_t; must be freed with cairo_region_destroy()
289  */
290 public static Region regionCreateFromSurface(Surface surface)
291 {
292 	// cairo_region_t * gdk_cairo_region_create_from_surface  (cairo_surface_t *surface);
293 	auto p = gdk_cairo_region_create_from_surface((surface is null) ? null : surface.getSurfaceStruct());
294 	
295 	if(p is null)
296 	{
297 		return null;
298 	}
299 	
300 	return ObjectG.getDObject!(Region)(cast(cairo_region_t*) p);
301 }
302 
303 /**
304  * Creates an image surface with the same contents as
305  * the pixbuf.
306  * Params:
307  * pixbuf = a GdkPixbuf
308  * scale = the scale of the new surface, or 0 to use same as window
309  * forWindow = The window this will be drawn to, on NULL.
310  * Returns: a new cairo surface, must be freed with cairo_surface_destroy() Since 3.10
311  */
312 public static Surface surfaceCreateFromPixbuf(Pixbuf pixbuf, int scale, Window forWindow)
313 {
314 	// cairo_surface_t * gdk_cairo_surface_create_from_pixbuf  (const GdkPixbuf *pixbuf,  int scale,  GdkWindow *for_window);
315 	auto p = gdk_cairo_surface_create_from_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct(), scale, (forWindow is null) ? null : forWindow.getWindowStruct());
316 	
317 	if(p is null)
318 	{
319 		return null;
320 	}
321 	
322 	return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p);
323 }
324