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.ToplevelT;
26 
27 public  import gdk.Device;
28 public  import gdk.Event;
29 public  import gdk.Surface;
30 public  import gdk.Texture;
31 public  import gdk.ToplevelLayout;
32 public  import gdk.ToplevelSize;
33 public  import gdk.c.functions;
34 public  import gdk.c.types;
35 public  import glib.ListG;
36 public  import glib.Str;
37 public  import gobject.Signals;
38 public  import std.algorithm;
39 
40 
41 /**
42  * A `GdkToplevel` is a freestanding toplevel surface.
43  * 
44  * The `GdkToplevel` interface provides useful APIs for interacting with
45  * the windowing system, such as controlling maximization and size of the
46  * surface, setting icons and transient parents for dialogs.
47  */
48 public template ToplevelT(TStruct)
49 {
50 	/** Get the main Gtk struct */
51 	public GdkToplevel* getToplevelStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return cast(GdkToplevel*)getStruct();
56 	}
57 
58 
59 	/**
60 	 * Begins an interactive move operation.
61 	 *
62 	 * You might use this function to implement draggable titlebars.
63 	 *
64 	 * Params:
65 	 *     device = the device used for the operation
66 	 *     button = the button being used to drag, or 0 for a keyboard-initiated drag
67 	 *     x = surface X coordinate of mouse click that began the drag
68 	 *     y = surface Y coordinate of mouse click that began the drag
69 	 *     timestamp = timestamp of mouse click that began the drag (use
70 	 *         [method@Gdk.Event.get_time])
71 	 */
72 	public void beginMove(Device device, int button, double x, double y, uint timestamp)
73 	{
74 		gdk_toplevel_begin_move(getToplevelStruct(), (device is null) ? null : device.getDeviceStruct(), button, x, y, timestamp);
75 	}
76 
77 	/**
78 	 * Begins an interactive resize operation.
79 	 *
80 	 * You might use this function to implement a “window resize grip.”
81 	 *
82 	 * Params:
83 	 *     edge = the edge or corner from which the drag is started
84 	 *     device = the device used for the operation
85 	 *     button = the button being used to drag, or 0 for a keyboard-initiated drag
86 	 *     x = surface X coordinate of mouse click that began the drag
87 	 *     y = surface Y coordinate of mouse click that began the drag
88 	 *     timestamp = timestamp of mouse click that began the drag (use
89 	 *         [method@Gdk.Event.get_time])
90 	 */
91 	public void beginResize(GdkSurfaceEdge edge, Device device, int button, double x, double y, uint timestamp)
92 	{
93 		gdk_toplevel_begin_resize(getToplevelStruct(), edge, (device is null) ? null : device.getDeviceStruct(), button, x, y, timestamp);
94 	}
95 
96 	/**
97 	 * Sets keyboard focus to @surface.
98 	 *
99 	 * In most cases, [method@Gtk.Window.present_with_time] should be
100 	 * used on a [class@Gtk.Window], rather than calling this function.
101 	 *
102 	 * Params:
103 	 *     timestamp = timestamp of the event triggering the surface focus
104 	 */
105 	public void focus(uint timestamp)
106 	{
107 		gdk_toplevel_focus(getToplevelStruct(), timestamp);
108 	}
109 
110 	/**
111 	 * Gets the bitwise or of the currently active surface state flags,
112 	 * from the `GdkToplevelState` enumeration.
113 	 *
114 	 * Returns: surface state bitfield
115 	 */
116 	public GdkToplevelState getState()
117 	{
118 		return gdk_toplevel_get_state(getToplevelStruct());
119 	}
120 
121 	/**
122 	 * Requests that the @toplevel inhibit the system shortcuts.
123 	 *
124 	 * This is asking the desktop environment/windowing system to let all
125 	 * keyboard events reach the surface, as long as it is focused, instead
126 	 * of triggering system actions.
127 	 *
128 	 * If granted, the rerouting remains active until the default shortcuts
129 	 * processing is restored with [method@Gdk.Toplevel.restore_system_shortcuts],
130 	 * or the request is revoked by the desktop environment, windowing system
131 	 * or the user.
132 	 *
133 	 * A typical use case for this API is remote desktop or virtual machine
134 	 * viewers which need to inhibit the default system keyboard shortcuts
135 	 * so that the remote session or virtual host gets those instead of the
136 	 * local environment.
137 	 *
138 	 * The windowing system or desktop environment may ask the user to grant
139 	 * or deny the request or even choose to ignore the request entirely.
140 	 *
141 	 * The caller can be notified whenever the request is granted or revoked
142 	 * by listening to the [property@Gdk.Toplevel:shortcuts-inhibited] property.
143 	 *
144 	 * Params:
145 	 *     event = the `GdkEvent` that is triggering the inhibit
146 	 *         request, or %NULL if none is available
147 	 */
148 	public void inhibitSystemShortcuts(Event event)
149 	{
150 		gdk_toplevel_inhibit_system_shortcuts(getToplevelStruct(), (event is null) ? null : event.getEventStruct());
151 	}
152 
153 	/**
154 	 * Asks to lower the @toplevel below other windows.
155 	 *
156 	 * The windowing system may choose to ignore the request.
157 	 *
158 	 * Returns: %TRUE if the surface was lowered
159 	 */
160 	public bool lower()
161 	{
162 		return gdk_toplevel_lower(getToplevelStruct()) != 0;
163 	}
164 
165 	/**
166 	 * Asks to minimize the @toplevel.
167 	 *
168 	 * The windowing system may choose to ignore the request.
169 	 *
170 	 * Returns: %TRUE if the surface was minimized
171 	 */
172 	public bool minimize()
173 	{
174 		return gdk_toplevel_minimize(getToplevelStruct()) != 0;
175 	}
176 
177 	/**
178 	 * Present @toplevel after having processed the `GdkToplevelLayout` rules.
179 	 *
180 	 * If the toplevel was previously not showing, it will be showed,
181 	 * otherwise it will change layout according to @layout.
182 	 *
183 	 * GDK may emit the [signal@Gdk.Toplevel::compute-size] signal to let
184 	 * the user of this toplevel compute the preferred size of the toplevel
185 	 * surface.
186 	 *
187 	 * Presenting is asynchronous and the specified layout parameters are not
188 	 * guaranteed to be respected.
189 	 *
190 	 * Params:
191 	 *     layout = the `GdkToplevelLayout` object used to layout
192 	 */
193 	public void present(ToplevelLayout layout)
194 	{
195 		gdk_toplevel_present(getToplevelStruct(), (layout is null) ? null : layout.getToplevelLayoutStruct());
196 	}
197 
198 	/**
199 	 * Restore default system keyboard shortcuts which were previously
200 	 * inhibited.
201 	 *
202 	 * This undoes the effect of [method@Gdk.Toplevel.inhibit_system_shortcuts].
203 	 */
204 	public void restoreSystemShortcuts()
205 	{
206 		gdk_toplevel_restore_system_shortcuts(getToplevelStruct());
207 	}
208 
209 	/**
210 	 * Sets the toplevel to be decorated.
211 	 *
212 	 * Setting @decorated to %FALSE hints the desktop environment
213 	 * that the surface has its own, client-side decorations and
214 	 * does not need to have window decorations added.
215 	 *
216 	 * Params:
217 	 *     decorated = %TRUE to request decorations
218 	 */
219 	public void setDecorated(bool decorated)
220 	{
221 		gdk_toplevel_set_decorated(getToplevelStruct(), decorated);
222 	}
223 
224 	/**
225 	 * Sets the toplevel to be deletable.
226 	 *
227 	 * Setting @deletable to %TRUE hints the desktop environment
228 	 * that it should offer the user a way to close the surface.
229 	 *
230 	 * Params:
231 	 *     deletable = %TRUE to request a delete button
232 	 */
233 	public void setDeletable(bool deletable)
234 	{
235 		gdk_toplevel_set_deletable(getToplevelStruct(), deletable);
236 	}
237 
238 	/**
239 	 * Sets a list of icons for the surface.
240 	 *
241 	 * One of these will be used to represent the surface in iconic form.
242 	 * The icon may be shown in window lists or task bars. Which icon
243 	 * size is shown depends on the window manager. The window manager
244 	 * can scale the icon but setting several size icons can give better
245 	 * image quality.
246 	 *
247 	 * Note that some platforms don't support surface icons.
248 	 *
249 	 * Params:
250 	 *     surfaces = A list of textures to use as icon, of different sizes
251 	 */
252 	public void setIconList(ListG surfaces)
253 	{
254 		gdk_toplevel_set_icon_list(getToplevelStruct(), (surfaces is null) ? null : surfaces.getListGStruct());
255 	}
256 
257 	/**
258 	 * Sets the toplevel to be modal.
259 	 *
260 	 * The application can use this hint to tell the
261 	 * window manager that a certain surface has modal
262 	 * behaviour. The window manager can use this information
263 	 * to handle modal surfaces in a special way.
264 	 *
265 	 * You should only use this on surfaces for which you have
266 	 * previously called [method@Gdk.Toplevel.set_transient_for].
267 	 *
268 	 * Params:
269 	 *     modal = %TRUE if the surface is modal, %FALSE otherwise.
270 	 */
271 	public void setModal(bool modal)
272 	{
273 		gdk_toplevel_set_modal(getToplevelStruct(), modal);
274 	}
275 
276 	/**
277 	 * Sets the startup notification ID.
278 	 *
279 	 * When using GTK, typically you should use
280 	 * [method@Gtk.Window.set_startup_id] instead of this
281 	 * low-level function.
282 	 *
283 	 * Params:
284 	 *     startupId = a string with startup-notification identifier
285 	 */
286 	public void setStartupId(string startupId)
287 	{
288 		gdk_toplevel_set_startup_id(getToplevelStruct(), Str.toStringz(startupId));
289 	}
290 
291 	/**
292 	 * Sets the title of a toplevel surface.
293 	 *
294 	 * The title maybe be displayed in the titlebar,
295 	 * in lists of windows, etc.
296 	 *
297 	 * Params:
298 	 *     title = title of @surface
299 	 */
300 	public void setTitle(string title)
301 	{
302 		gdk_toplevel_set_title(getToplevelStruct(), Str.toStringz(title));
303 	}
304 
305 	/**
306 	 * Sets a transient-for parent.
307 	 *
308 	 * Indicates to the window manager that @surface is a transient
309 	 * dialog associated with the application surface @parent. This
310 	 * allows the window manager to do things like center @surface
311 	 * on @parent and keep @surface above @parent.
312 	 *
313 	 * See [method@Gtk.Window.set_transient_for] if you’re using
314 	 * [class@Gtk.Window] or [class@Gtk.Dialog].
315 	 *
316 	 * Params:
317 	 *     parent = another toplevel `GdkSurface`
318 	 */
319 	public void setTransientFor(Surface parent)
320 	{
321 		gdk_toplevel_set_transient_for(getToplevelStruct(), (parent is null) ? null : parent.getSurfaceStruct());
322 	}
323 
324 	/**
325 	 * Asks the windowing system to show the window menu.
326 	 *
327 	 * The window menu is the menu shown when right-clicking the titlebar
328 	 * on traditional windows managed by the window manager. This is useful
329 	 * for windows using client-side decorations, activating it with a
330 	 * right-click on the window decorations.
331 	 *
332 	 * Params:
333 	 *     event = a `GdkEvent` to show the menu for
334 	 *
335 	 * Returns: %TRUE if the window menu was shown and %FALSE otherwise.
336 	 */
337 	public bool showWindowMenu(Event event)
338 	{
339 		return gdk_toplevel_show_window_menu(getToplevelStruct(), (event is null) ? null : event.getEventStruct()) != 0;
340 	}
341 
342 	/**
343 	 * Returns whether the desktop environment supports
344 	 * tiled window states.
345 	 *
346 	 * Returns: %TRUE if the desktop environment supports
347 	 *     tiled window states
348 	 */
349 	public bool supportsEdgeConstraints()
350 	{
351 		return gdk_toplevel_supports_edge_constraints(getToplevelStruct()) != 0;
352 	}
353 
354 	/**
355 	 * Emitted when the size for the surface needs to be computed, when
356 	 * it is present.
357 	 *
358 	 * It will normally be emitted during or after [method@Gdk.Toplevel.present],
359 	 * depending on the configuration received by the windowing system.
360 	 * It may also be emitted at any other point in time, in response
361 	 * to the windowing system spontaneously changing the configuration.
362 	 *
363 	 * It is the responsibility of the toplevel user to handle this signal
364 	 * and compute the desired size of the toplevel, given the information
365 	 * passed via the [struct@Gdk.ToplevelSize] object. Failing to do so
366 	 * will result in an arbitrary size being used as a result.
367 	 *
368 	 * Params:
369 	 *     size = a `GdkToplevelSize`
370 	 */
371 	gulong addOnComputeSize(void delegate(ToplevelSize, ToplevelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
372 	{
373 		return Signals.connect(this, "compute-size", dlg, connectFlags ^ ConnectFlags.SWAPPED);
374 	}
375 }