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()
54 	{
55 		return gdkDrawingContext;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gdkDrawingContext;
62 	}
63 
64 	protected override void setStruct(GObject* obj)
65 	{
66 		gdkDrawingContext = cast(GdkDrawingContext*)obj;
67 		super.setStruct(obj);
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GdkDrawingContext* gdkDrawingContext, bool ownedRef = false)
74 	{
75 		this.gdkDrawingContext = gdkDrawingContext;
76 		super(cast(GObject*)gdkDrawingContext, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gdk_drawing_context_get_type();
84 	}
85 
86 	/**
87 	 * Retrieves a Cairo context to be used to draw on the #GdkWindow
88 	 * that created the #GdkDrawingContext.
89 	 *
90 	 * The returned context is guaranteed to be valid as long as the
91 	 * #GdkDrawingContext is valid, that is between a call to
92 	 * gdk_window_begin_draw_frame() and gdk_window_end_draw_frame().
93 	 *
94 	 * Return: a Cairo context to be used to draw
95 	 *     the contents of the #GdkWindow. The context is owned by the
96 	 *     #GdkDrawingContext and should not be destroyed
97 	 *
98 	 * Since: 3.22
99 	 */
100 	public Context getCairoContext()
101 	{
102 		auto p = gdk_drawing_context_get_cairo_context(gdkDrawingContext);
103 		
104 		if(p is null)
105 		{
106 			return null;
107 		}
108 		
109 		return new Context(cast(cairo_t*) p);
110 	}
111 
112 	/**
113 	 * Retrieves a copy of the clip region used when creating the @context.
114 	 *
115 	 * Return: a Cairo region
116 	 *
117 	 * Since: 3.22
118 	 */
119 	public Region getClip()
120 	{
121 		auto p = gdk_drawing_context_get_clip(gdkDrawingContext);
122 		
123 		if(p is null)
124 		{
125 			return null;
126 		}
127 		
128 		return new Region(cast(cairo_region_t*) p);
129 	}
130 
131 	/**
132 	 * Retrieves the window that created the drawing @context.
133 	 *
134 	 * Return: a #GdkWindow
135 	 *
136 	 * Since: 3.22
137 	 */
138 	public Window getWindow()
139 	{
140 		auto p = gdk_drawing_context_get_window(gdkDrawingContext);
141 		
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 		
147 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
148 	}
149 
150 	/**
151 	 * Checks whether the given #GdkDrawingContext is valid.
152 	 *
153 	 * Return: %TRUE if the context is valid
154 	 *
155 	 * Since: 3.22
156 	 */
157 	public bool isValid()
158 	{
159 		return gdk_drawing_context_is_valid(gdkDrawingContext) != 0;
160 	}
161 }