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 glgdk.GLWindow;
26 
27 private import gdk.Window;
28 private import glgdk.GLConfig;
29 private import glgdk.GLDrawableIF;
30 private import glgdk.GLDrawableT;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 private import gtkglc.glgdk;
34 public  import gtkglc.glgdktypes;
35 
36 
37 public class GLWindow : ObjectG, GLDrawableIF
38 {
39 	/** the main Gtk struct */
40 	protected GdkGLWindow* gdkGLWindow;
41 
42 	/** Get the main Gtk struct */
43 	public GdkGLWindow* getGLWindowStruct()
44 	{
45 		return gdkGLWindow;
46 	}
47 
48 	/** the main Gtk struct as a void* */
49 	protected override void* getStruct()
50 	{
51 		return cast(void*)gdkGLWindow;
52 	}
53 
54 	protected override void setStruct(GObject* obj)
55 	{
56 		gdkGLWindow = cast(GdkGLWindow*)obj;
57 		super.setStruct(obj);
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GdkGLWindow* gdkGLWindow, bool ownedRef = false)
64 	{
65 		this.gdkGLWindow = gdkGLWindow;
66 		super(cast(GObject*)gdkGLWindow, ownedRef);
67 	}
68 
69 	// add the GLDrawable capabilities
70 	mixin GLDrawableT!(GdkGLWindow);
71 
72 	/**
73 	 */
74 
75 	public static GType getType()
76 	{
77 		return gdk_gl_window_get_type();
78 	}
79 
80 	/**
81 	 * Creates an on-screen rendering area.
82 	 * attrib_list is currently unused. This must be set to NULL or empty
83 	 * (first attribute of None). See GLX 1.3 spec.
84 	 *
85 	 * Params:
86 	 *     glconfig = a #GdkGLConfig.
87 	 *     window = the #GdkWindow to be used as the rendering area.
88 	 *     attribList = this must be set to NULL or empty (first attribute of None).
89 	 *
90 	 * Return: the new #GdkGLWindow.
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this(GLConfig glconfig, Window window, int* attribList)
95 	{
96 		auto p = gdk_gl_window_new((glconfig is null) ? null : glconfig.getGLConfigStruct(), (window is null) ? null : window.getWindowStruct(), attribList);
97 		
98 		if(p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 		
103 		this(cast(GdkGLWindow*) p, true);
104 	}
105 
106 	/**
107 	 * Returns the #GdkGLWindow held by the @window.
108 	 *
109 	 * Params:
110 	 *     window = a #GdkWindow.
111 	 *
112 	 * Return: the #GdkGLWindow.
113 	 */
114 	public static GLWindow getGlWindow(Window window)
115 	{
116 		auto p = gdk_window_get_gl_window((window is null) ? null : window.getWindowStruct());
117 		
118 		if(p is null)
119 		{
120 			return null;
121 		}
122 		
123 		return ObjectG.getDObject!(GLWindow)(cast(GdkGLWindow*) p);
124 	}
125 
126 	/**
127 	 * Returns whether the @window is OpenGL-capable.
128 	 *
129 	 * Params:
130 	 *     window = a #GdkWindow.
131 	 *
132 	 * Return: TRUE if the @window is OpenGL-capable, FALSE otherwise.
133 	 */
134 	public static bool isGlCapable(Window window)
135 	{
136 		return gdk_window_is_gl_capable((window is null) ? null : window.getWindowStruct()) != 0;
137 	}
138 
139 	/**
140 	 * Set the OpenGL-capability to the @window.
141 	 * This function creates a new #GdkGLWindow held by the @window.
142 	 * attrib_list is currently unused. This must be set to NULL or empty
143 	 * (first attribute of None).
144 	 *
145 	 * Params:
146 	 *     window = the #GdkWindow to be used as the rendering area.
147 	 *     glconfig = a #GdkGLConfig.
148 	 *     attribList = this must be set to NULL or empty (first attribute of None).
149 	 *
150 	 * Return: the #GdkGLWindow used by the @window if it is successful, NULL otherwise.
151 	 */
152 	public static GLWindow setGlCapability(Window window, GLConfig glconfig, int* attribList)
153 	{
154 		auto p = gdk_window_set_gl_capability((window is null) ? null : window.getWindowStruct(), (glconfig is null) ? null : glconfig.getGLConfigStruct(), attribList);
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return ObjectG.getDObject!(GLWindow)(cast(GdkGLWindow*) p);
162 	}
163 
164 	/**
165 	 * Unset the OpenGL-capability of the @window.
166 	 * This function destroys the #GdkGLWindow held by the @window.
167 	 *
168 	 * Params:
169 	 *     window = a #GdkWindow.
170 	 */
171 	public static void unsetGlCapability(Window window)
172 	{
173 		gdk_window_unset_gl_capability((window is null) ? null : window.getWindowStruct());
174 	}
175 
176 	/**
177 	 * Returns the #GdkWindow associated with @glwindow.
178 	 *
179 	 * Return: the #GdkWindow associated with @glwindow.
180 	 */
181 	public Window getWindow()
182 	{
183 		auto p = gdk_gl_window_get_window(gdkGLWindow);
184 		
185 		if(p is null)
186 		{
187 			return null;
188 		}
189 		
190 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
191 	}
192 }