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.DrawingContext;
26 
27 private import cairo.Context;
28 private import cairo.Region;
29 private import gdk.Window;
30 private import gobject.ObjectG;
31 private import gtkc.gdk;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * #GdkDrawingContext is an object that represents the current drawing
37  * state of a #GdkWindow.
38  * 
39  * It's possible to use a #GdkDrawingContext to draw on a #GdkWindow
40  * via rendering API like Cairo or OpenGL.
41  * 
42  * A #GdkDrawingContext can only be created by calling gdk_window_begin_draw_frame()
43  * and will be valid until a call to gdk_window_end_draw_frame().
44  * 
45  * #GdkDrawingContext is available since GDK 3.22
46  */
47 public class DrawingContext : ObjectG
48 {
49 	/** the main Gtk struct */
50 	protected GdkDrawingContext* gdkDrawingContext;
51 
52 	/** Get the main Gtk struct */
53 	public GdkDrawingContext* getDrawingContextStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gdkDrawingContext;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gdkDrawingContext;
64 	}
65 
66 	protected override void setStruct(GObject* obj)
67 	{
68 		gdkDrawingContext = cast(GdkDrawingContext*)obj;
69 		super.setStruct(obj);
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GdkDrawingContext* gdkDrawingContext, bool ownedRef = false)
76 	{
77 		this.gdkDrawingContext = gdkDrawingContext;
78 		super(cast(GObject*)gdkDrawingContext, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gdk_drawing_context_get_type();
86 	}
87 
88 	/**
89 	 * Retrieves a Cairo context to be used to draw on the #GdkWindow
90 	 * that created the #GdkDrawingContext.
91 	 *
92 	 * The returned context is guaranteed to be valid as long as the
93 	 * #GdkDrawingContext is valid, that is between a call to
94 	 * gdk_window_begin_draw_frame() and gdk_window_end_draw_frame().
95 	 *
96 	 * Returns: a Cairo context to be used to draw
97 	 *     the contents of the #GdkWindow. The context is owned by the
98 	 *     #GdkDrawingContext and should not be destroyed
99 	 *
100 	 * Since: 3.22
101 	 */
102 	public Context getCairoContext()
103 	{
104 		auto p = gdk_drawing_context_get_cairo_context(gdkDrawingContext);
105 		
106 		if(p is null)
107 		{
108 			return null;
109 		}
110 		
111 		return new Context(cast(cairo_t*) p);
112 	}
113 
114 	/**
115 	 * Retrieves a copy of the clip region used when creating the @context.
116 	 *
117 	 * Returns: a Cairo region
118 	 *
119 	 * Since: 3.22
120 	 */
121 	public Region getClip()
122 	{
123 		auto p = gdk_drawing_context_get_clip(gdkDrawingContext);
124 		
125 		if(p is null)
126 		{
127 			return null;
128 		}
129 		
130 		return new Region(cast(cairo_region_t*) p);
131 	}
132 
133 	/**
134 	 * Retrieves the window that created the drawing @context.
135 	 *
136 	 * Returns: a #GdkWindow
137 	 *
138 	 * Since: 3.22
139 	 */
140 	public Window getWindow()
141 	{
142 		auto p = gdk_drawing_context_get_window(gdkDrawingContext);
143 		
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 		
149 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
150 	}
151 
152 	/**
153 	 * Checks whether the given #GdkDrawingContext is valid.
154 	 *
155 	 * Returns: %TRUE if the context is valid
156 	 *
157 	 * Since: 3.22
158 	 */
159 	public bool isValid()
160 	{
161 		return gdk_drawing_context_is_valid(gdkDrawingContext) != 0;
162 	}
163 }