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 module gdk.Cairo;
26 
27 private import cairo.Context;
28 private import cairo.Region;
29 private import cairo.Surface;
30 private import gdk.Color;
31 private import gdk.RGBA;
32 private import gdk.Window;
33 private import gdkpixbuf.Pixbuf;
34 private import gtkc.gdk;
35 public  import gtkc.gdktypes;
36 
37 
38 /**
39  */
40 
41 /**
42  * Creates a Cairo context for drawing to @window.
43  *
44  * Note that calling cairo_reset_clip() on the resulting #cairo_t will
45  * rproduce undefined results, so avoid it at all costs.
46  *
47  * Params:
48  *     window = a #GdkWindow
49  *
50  * Return: A newly created Cairo context. Free with
51  *     cairo_destroy() when you are done drawing.
52  *
53  * Since: 2.8
54  */
55 public Context createContext(Window window)
56 {
57 	auto p = gdk_cairo_create((window is null) ? null : window.getWindowStruct());
58 	
59 	if(p is null)
60 	{
61 		return null;
62 	}
63 	
64 	return new Context(cast(cairo_t*) p);
65 }
66 
67 /**
68  * This is a convenience function around cairo_clip_extents().
69  * It rounds the clip extents to integer coordinates and returns
70  * a boolean indicating if a clip area exists.
71  *
72  * Params:
73  *     cr = a cairo context
74  *     rect = return location for the clip, or %NULL
75  *
76  * Return: %TRUE if a clip rectangle exists, %FALSE if all of @cr is
77  *     clipped and all drawing can be skipped
78  */
79 public bool getClipRectangle(Context cr, out GdkRectangle rect)
80 {
81 	return gdk_cairo_get_clip_rectangle((cr is null) ? null : cr.getContextStruct(), &rect) != 0;
82 }
83 
84 /**
85  * Adds the given rectangle to the current path of @cr.
86  *
87  * Params:
88  *     cr = a cairo context
89  *     rectangle = a #GdkRectangle
90  *
91  * Since: 2.8
92  */
93 public void rectangle(Context cr, GdkRectangle* rectangle)
94 {
95 	gdk_cairo_rectangle((cr is null) ? null : cr.getContextStruct(), rectangle);
96 }
97 
98 /**
99  * Adds the given region to the current path of @cr.
100  *
101  * Params:
102  *     cr = a cairo context
103  *     region = a #cairo_region_t
104  *
105  * Since: 2.8
106  */
107 public void region(Context cr, Region region)
108 {
109 	gdk_cairo_region((cr is null) ? null : cr.getContextStruct(), (region is null) ? null : region.getRegionStruct());
110 }
111 
112 /**
113  * Creates region that describes covers the area where the given
114  * @surface is more than 50% opaque.
115  *
116  * This function takes into account device offsets that might be
117  * set with cairo_surface_set_device_offset().
118  *
119  * Params:
120  *     surface = a cairo surface
121  *
122  * Return: A #cairo_region_t; must be freed with cairo_region_destroy()
123  */
124 public Region regionCreateFromSurface(Surface surface)
125 {
126 	auto p = gdk_cairo_region_create_from_surface((surface is null) ? null : surface.getSurfaceStruct());
127 	
128 	if(p is null)
129 	{
130 		return null;
131 	}
132 	
133 	return new Region(cast(cairo_region_t*) p);
134 }
135 
136 /**
137  * Sets the specified #GdkColor as the source color of @cr.
138  *
139  * Deprecated: Use gdk_cairo_set_source_rgba() instead
140  *
141  * Params:
142  *     cr = a cairo context
143  *     color = a #GdkColor
144  *
145  * Since: 2.8
146  */
147 public void setSourceColor(Context cr, Color color)
148 {
149 	gdk_cairo_set_source_color((cr is null) ? null : cr.getContextStruct(), (color is null) ? null : color.getColorStruct());
150 }
151 
152 /**
153  * Sets the given pixbuf as the source pattern for @cr.
154  *
155  * The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
156  * so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y.
157  *
158  * Params:
159  *     cr = a cairo context
160  *     pixbuf = a #GdkPixbuf
161  *     pixbufX = X coordinate of location to place upper left corner of @pixbuf
162  *     pixbufY = Y coordinate of location to place upper left corner of @pixbuf
163  *
164  * Since: 2.8
165  */
166 public void setSourcePixbuf(Context cr, Pixbuf pixbuf, double pixbufX, double pixbufY)
167 {
168 	gdk_cairo_set_source_pixbuf((cr is null) ? null : cr.getContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), pixbufX, pixbufY);
169 }
170 
171 /**
172  * Sets the specified #GdkRGBA as the source color of @cr.
173  *
174  * Params:
175  *     cr = a cairo context
176  *     rgba = a #GdkRGBA
177  *
178  * Since: 3.0
179  */
180 public void setSourceRgba(Context cr, RGBA rgba)
181 {
182 	gdk_cairo_set_source_rgba((cr is null) ? null : cr.getContextStruct(), (rgba is null) ? null : rgba.getRGBAStruct());
183 }
184 
185 /**
186  * Sets the given window as the source pattern for @cr.
187  *
188  * The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
189  * so that the origin of @window is @x, @y. The window contains all its
190  * subwindows when rendering.
191  *
192  * Note that the contents of @window are undefined outside of the
193  * visible part of @window, so use this function with care.
194  *
195  * Params:
196  *     cr = a cairo context
197  *     window = a #GdkWindow
198  *     x = X coordinate of location to place upper left corner of @window
199  *     y = Y coordinate of location to place upper left corner of @window
200  *
201  * Since: 2.24
202  */
203 public void setSourceWindow(Context cr, Window window, double x, double y)
204 {
205 	gdk_cairo_set_source_window((cr is null) ? null : cr.getContextStruct(), (window is null) ? null : window.getWindowStruct(), x, y);
206 }
207 
208 /**
209  * Creates an image surface with the same contents as
210  * the pixbuf.
211  *
212  * Params:
213  *     pixbuf = a #GdkPixbuf
214  *     scale = the scale of the new surface, or 0 to use same as @window
215  *     forWindow = The window this will be drawn to, or %NULL
216  *
217  * Return: a new cairo surface, must be freed with cairo_surface_destroy()
218  *
219  * Since: 3.10
220  */
221 public Surface surfaceCreateFromPixbuf(Pixbuf pixbuf, int scale, Window forWindow)
222 {
223 	auto p = gdk_cairo_surface_create_from_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct(), scale, (forWindow is null) ? null : forWindow.getWindowStruct());
224 	
225 	if(p is null)
226 	{
227 		return null;
228 	}
229 	
230 	return new Surface(cast(cairo_surface_t*) p);
231 }