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