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  * Conversion parameters:
26  * inFile  = gdk3-General.html
27  * outPack = gdk
28  * outFile = Gdk
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = Gdk
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- gdk.Cursor
48  * 	- gdk.Window
49  * structWrap:
50  * 	- GdkCursor* -> Cursor
51  * 	- GdkWindow* -> Window
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gdk.Gdk;
58 
59 public  import gtkc.gdktypes;
60 
61 private import gtkc.gdk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import glib.Str;
66 private import gdk.Cursor;
67 private import gdk.Window;
68 
69 
70 
71 /**
72  * This section describes the GDK initialization functions and miscellaneous
73  * utility functions, as well as deprecation facilities.
74  *
75  * The GDK and GTK+ headers annotate deprecated APIs in a way that produces
76  * compiler warnings if these deprecated APIs are used. The warnings
77  * can be turned off by defining the macro GDK_DISABLE_DEPRECATION_WARNINGS
78  * before including the glib.h header.
79  *
80  * GDK and GTK+ also provide support for building applications against
81  * defined subsets of deprecated or new APIs. Define the macro
82  * GDK_VERSION_MIN_REQUIRED to specify up to what version
83  * you want to receive warnings about deprecated APIs. Define the
84  * macro GDK_VERSION_MAX_ALLOWED to specify the newest version
85  * whose API you want to use.
86  */
87 public class Gdk
88 {
89 	
90 	/**
91 	 */
92 	
93 	/**
94 	 * Initializes the GDK library and connects to the windowing system.
95 	 * If initialization fails, a warning message is output and the application
96 	 * terminates with a call to exit(1).
97 	 * Any arguments used by GDK are removed from the array and argc and argv
98 	 * are updated accordingly.
99 	 * GTK+ initializes GDK in gtk_init() and so this function is not usually
100 	 * needed by GTK+ applications.
101 	 * Params:
102 	 * argv = the array of command line arguments. [array length=argc][inout]
103 	 */
104 	public static void init(ref string[] argv)
105 	{
106 		// void gdk_init (gint *argc,  gchar ***argv);
107 		char** outargv = Str.toStringzArray(argv);
108 		int argc = cast(int) argv.length;
109 		
110 		gdk_init(&argc, &outargv);
111 		
112 		argv = null;
113 		foreach ( cstr; outargv[0 .. argc] )
114 		{
115 			argv ~= Str.toString(cstr);
116 		}
117 	}
118 	
119 	/**
120 	 * Initializes the GDK library and connects to the windowing system,
121 	 * returning TRUE on success.
122 	 * Any arguments used by GDK are removed from the array and argc and argv
123 	 * are updated accordingly.
124 	 * GTK+ initializes GDK in gtk_init() and so this function is not usually
125 	 * needed by GTK+ applications.
126 	 * Params:
127 	 * argv = the array of command line arguments. [array length=argc][inout]
128 	 * Returns: TRUE if initialization succeeded.
129 	 */
130 	public static int initCheck(ref string[] argv)
131 	{
132 		// gboolean gdk_init_check (gint *argc,  gchar ***argv);
133 		char** outargv = Str.toStringzArray(argv);
134 		int argc = cast(int) argv.length;
135 		
136 		auto p = gdk_init_check(&argc, &outargv);
137 		
138 		argv = null;
139 		foreach ( cstr; outargv[0 .. argc] )
140 		{
141 			argv ~= Str.toString(cstr);
142 		}
143 		return p;
144 	}
145 	
146 	/**
147 	 * Parse command line arguments, and store for future
148 	 * use by calls to gdk_display_open().
149 	 * Any arguments used by GDK are removed from the array and argc and argv are
150 	 * updated accordingly.
151 	 * You shouldn't call this function explicitely if you are using
152 	 * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
153 	 * Since 2.2
154 	 * Params:
155 	 * argv = the array of command line arguments. [inout][array length=argc]
156 	 */
157 	public static void parseArgs(ref string[] argv)
158 	{
159 		// void gdk_parse_args (gint *argc,  gchar ***argv);
160 		char** outargv = Str.toStringzArray(argv);
161 		int argc = cast(int) argv.length;
162 		
163 		gdk_parse_args(&argc, &outargv);
164 		
165 		argv = null;
166 		foreach ( cstr; outargv[0 .. argc] )
167 		{
168 			argv ~= Str.toString(cstr);
169 		}
170 	}
171 	
172 	/**
173 	 * Gets the display name specified in the command line arguments passed
174 	 * to gdk_init() or gdk_parse_args(), if any.
175 	 * Since 2.2
176 	 * Returns: the display name, if specified explicitely, otherwise NULL this string is owned by GTK+ and must not be modified or freed.
177 	 */
178 	public static string getDisplayArgName()
179 	{
180 		// const gchar * gdk_get_display_arg_name (void);
181 		return Str.toString(gdk_get_display_arg_name());
182 	}
183 	
184 	/**
185 	 * Indicates to the GUI environment that the application has finished
186 	 * loading. If the applications opens windows, this function is
187 	 * normally called after opening the application's initial set of
188 	 * windows.
189 	 * GTK+ will call this function automatically after opening the first
190 	 * GtkWindow unless gtk_window_set_auto_startup_notification() is called
191 	 * to disable that feature.
192 	 * Since 2.2
193 	 */
194 	public static void notifyStartupComplete()
195 	{
196 		// void gdk_notify_startup_complete (void);
197 		gdk_notify_startup_complete();
198 	}
199 	
200 	/**
201 	 * Indicates to the GUI environment that the application has
202 	 * finished loading, using a given identifier.
203 	 * GTK+ will call this function automatically for GtkWindow
204 	 * with custom startup-notification identifier unless
205 	 * gtk_window_set_auto_startup_notification() is called to
206 	 * disable that feature.
207 	 * Since 2.12
208 	 * Params:
209 	 * startupId = a startup-notification identifier, for which
210 	 * notification process should be completed
211 	 */
212 	public static void notifyStartupCompleteWithId(string startupId)
213 	{
214 		// void gdk_notify_startup_complete_with_id (const gchar *startup_id);
215 		gdk_notify_startup_complete_with_id(Str.toStringz(startupId));
216 	}
217 	
218 	/**
219 	 * Sets a list of backends that GDK should try to use.
220 	 * This can be be useful if your application does not
221 	 * work with certain GDK backends.
222 	 * By default, GDK tries all included backends.
223 	 * For example,
224 	 * gdk_set_allowed_backends ("wayland,quartz,*");
225 	 * instructs GDK to try the Wayland backend first,
226 	 * followed by the Quartz backend, and then all
227 	 * others.
228 	 * If the GDK_BACKEND environment variable
229 	 * is set, it determines what backends are tried in what
230 	 * order, while still respecting the set of allowed backends
231 	 * that are specified by this function.
232 	 * The possible backend names are x11, win32, quartz,
233 	 * broadway, wayland. You can also include a * in the
234 	 * list to try all remaining backends.
235 	 * This call must happen prior to gdk_display_open(),
236 	 * gtk_init(), gtk_init_with_args() or gtk_init_check()
237 	 * in order to take effect.
238 	 * Params:
239 	 * backends = a comma-separated list of backends
240 	 * Since 3.10
241 	 */
242 	public static void setAllowedBackends(string backends)
243 	{
244 		// void gdk_set_allowed_backends (const gchar *backends);
245 		gdk_set_allowed_backends(Str.toStringz(backends));
246 	}
247 	
248 	/**
249 	 * Gets the program class. Unless the program class has explicitly
250 	 * been set with gdk_set_program_class() or with the --class
251 	 * commandline option, the default value is the program name (determined
252 	 * with g_get_prgname()) with the first character converted to uppercase.
253 	 * Returns: the program class.
254 	 */
255 	public static string getProgramClass()
256 	{
257 		// const gchar * gdk_get_program_class (void);
258 		return Str.toString(gdk_get_program_class());
259 	}
260 	
261 	/**
262 	 * Sets the program class. The X11 backend uses the program class to set
263 	 * the class name part of the WM_CLASS property on
264 	 * toplevel windows; see the ICCCM.
265 	 * Params:
266 	 * programClass = a string.
267 	 */
268 	public static void setProgramClass(string programClass)
269 	{
270 		// void gdk_set_program_class (const gchar *program_class);
271 		gdk_set_program_class(Str.toStringz(programClass));
272 	}
273 	
274 	/**
275 	 * Warning
276 	 * gdk_get_display has been deprecated since version 3.8 and should not be used in newly-written code. Call gdk_display_get_name (gdk_display_get_default()))
277 	 *  instead.
278 	 * Gets the name of the display, which usually comes from the
279 	 * DISPLAY environment variable or the
280 	 * --display command line option.
281 	 * Returns: the name of the display.
282 	 */
283 	public static string getDisplay()
284 	{
285 		// gchar * gdk_get_display (void);
286 		return Str.toString(gdk_get_display());
287 	}
288 	
289 	/**
290 	 * Flushes the output buffers of all display connections and waits
291 	 * until all requests have been processed.
292 	 * This is rarely needed by applications.
293 	 */
294 	public static void flush()
295 	{
296 		// void gdk_flush (void);
297 		gdk_flush();
298 	}
299 	
300 	/**
301 	 * Returns the width of the default screen in pixels.
302 	 * Returns: the width of the default screen in pixels.
303 	 */
304 	public static int screenWidth()
305 	{
306 		// gint gdk_screen_width (void);
307 		return gdk_screen_width();
308 	}
309 	
310 	/**
311 	 * Returns the height of the default screen in pixels.
312 	 * Returns: the height of the default screen in pixels.
313 	 */
314 	public static int screenHeight()
315 	{
316 		// gint gdk_screen_height (void);
317 		return gdk_screen_height();
318 	}
319 	
320 	/**
321 	 * Returns the width of the default screen in millimeters.
322 	 * Note that on many X servers this value will not be correct.
323 	 * Returns: the width of the default screen in millimeters, though it is not always correct.
324 	 */
325 	public static int screenWidthMm()
326 	{
327 		// gint gdk_screen_width_mm (void);
328 		return gdk_screen_width_mm();
329 	}
330 	
331 	/**
332 	 * Returns the height of the default screen in millimeters.
333 	 * Note that on many X servers this value will not be correct.
334 	 * Returns: the height of the default screen in millimeters, though it is not always correct.
335 	 */
336 	public static int screenHeightMm()
337 	{
338 		// gint gdk_screen_height_mm (void);
339 		return gdk_screen_height_mm();
340 	}
341 	
342 	/**
343 	 * Warning
344 	 * gdk_pointer_grab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_grab() instead.
345 	 * Grabs the pointer (usually a mouse) so that all events are passed to this
346 	 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
347 	 * the grab window becomes unviewable.
348 	 * This overrides any previous pointer grab by this client.
349 	 * Pointer grabs are used for operations which need complete control over mouse
350 	 * events, even if the mouse leaves the application.
351 	 * For example in GTK+ it is used for Drag and Drop, for dragging the handle in
352 	 * the GtkHPaned and GtkVPaned widgets.
353 	 * Note that if the event mask of an X window has selected both button press and
354 	 * button release events, then a button press event will cause an automatic
355 	 * pointer grab until the button is released.
356 	 * X does this automatically since most applications expect to receive button
357 	 * press and release events in pairs.
358 	 * It is equivalent to a pointer grab on the window with owner_events set to
359 	 * TRUE.
360 	 * If you set up anything at the time you take the grab that needs to be cleaned
361 	 * up when the grab ends, you should handle the GdkEventGrabBroken events that
362 	 * are emitted when the grab ends unvoluntarily.
363 	 * Params:
364 	 * window = the GdkWindow which will own the grab (the grab window).
365 	 * ownerEvents = if FALSE then all pointer events are reported with respect to
366 	 * window and are only reported if selected by event_mask. If TRUE then pointer
367 	 * events for this application are reported as normal, but pointer events outside
368 	 * this application are reported with respect to window and only if selected by
369 	 * event_mask. In either mode, unreported events are discarded.
370 	 * eventMask = specifies the event mask, which is used in accordance with
371 	 * owner_events. Note that only pointer events (i.e. button and motion events)
372 	 * may be selected.
373 	 * confineTo = If non-NULL, the pointer will be confined to this
374 	 * window during the grab. If the pointer is outside confine_to, it will
375 	 * automatically be moved to the closest edge of confine_to and enter
376 	 * and leave events will be generated as necessary. [allow-none]
377 	 * cursor = the cursor to display while the grab is active. If this is NULL then
378 	 * the normal cursors are used for window and its descendants, and the cursor
379 	 * for window is used for all other windows. [allow-none]
380 	 * time = the timestamp of the event which led to this pointer grab. This usually
381 	 * comes from a GdkEventButton struct, though GDK_CURRENT_TIME can be used if
382 	 * the time isn't known.
383 	 * Returns: GDK_GRAB_SUCCESS if the grab was successful.
384 	 */
385 	public static GdkGrabStatus pointerGrab(Window window, int ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)
386 	{
387 		// GdkGrabStatus gdk_pointer_grab (GdkWindow *window,  gboolean owner_events,  GdkEventMask event_mask,  GdkWindow *confine_to,  GdkCursor *cursor,  guint32 time_);
388 		return gdk_pointer_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, eventMask, (confineTo is null) ? null : confineTo.getWindowStruct(), (cursor is null) ? null : cursor.getCursorStruct(), time);
389 	}
390 	
391 	/**
392 	 * Warning
393 	 * gdk_pointer_ungrab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_ungrab(), together with gdk_device_grab()
394 	 *  instead.
395 	 * Ungrabs the pointer on the default display, if it is grabbed by this
396 	 * application.
397 	 * Params:
398 	 * time = a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
399 	 * timestamp is available.
400 	 */
401 	public static void pointerUngrab(uint time)
402 	{
403 		// void gdk_pointer_ungrab (guint32 time_);
404 		gdk_pointer_ungrab(time);
405 	}
406 	
407 	/**
408 	 * Warning
409 	 * gdk_pointer_is_grabbed has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_display_device_is_grabbed() instead.
410 	 * Returns TRUE if the pointer on the default display is currently
411 	 * grabbed by this application.
412 	 * Note that this does not take the inmplicit pointer grab on button
413 	 * presses into account.
414 	 * Returns: TRUE if the pointer is currently grabbed by this application.
415 	 */
416 	public static int pointerIsGrabbed()
417 	{
418 		// gboolean gdk_pointer_is_grabbed (void);
419 		return gdk_pointer_is_grabbed();
420 	}
421 	
422 	/**
423 	 * Set the double click time for the default display. See
424 	 * gdk_display_set_double_click_time().
425 	 * See also gdk_display_set_double_click_distance().
426 	 * Applications should not set this, it is a
427 	 * global user-configured setting.
428 	 * Params:
429 	 * msec = double click time in milliseconds (thousandths of a second)
430 	 */
431 	public static void setDoubleClickTime(uint msec)
432 	{
433 		// void gdk_set_double_click_time (guint msec);
434 		gdk_set_double_click_time(msec);
435 	}
436 	
437 	/**
438 	 * Warning
439 	 * gdk_keyboard_grab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_grab() instead.
440 	 * Grabs the keyboard so that all events are passed to this
441 	 * application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
442 	 * This overrides any previous keyboard grab by this client.
443 	 * If you set up anything at the time you take the grab that needs to be cleaned
444 	 * up when the grab ends, you should handle the GdkEventGrabBroken events that
445 	 * are emitted when the grab ends unvoluntarily.
446 	 * Params:
447 	 * window = the GdkWindow which will own the grab (the grab window).
448 	 * ownerEvents = if FALSE then all keyboard events are reported with respect to
449 	 * window. If TRUE then keyboard events for this application are
450 	 * reported as normal, but keyboard events outside this application
451 	 * are reported with respect to window. Both key press and key
452 	 * release events are always reported, independant of the event mask
453 	 * set by the application.
454 	 * time = a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no timestamp is
455 	 * available.
456 	 * Returns: GDK_GRAB_SUCCESS if the grab was successful.
457 	 */
458 	public static GdkGrabStatus keyboardGrab(Window window, int ownerEvents, uint time)
459 	{
460 		// GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,  gboolean owner_events,  guint32 time_);
461 		return gdk_keyboard_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, time);
462 	}
463 	
464 	/**
465 	 * Warning
466 	 * gdk_keyboard_ungrab has been deprecated since version 3.0 and should not be used in newly-written code. Use gdk_device_ungrab(), together with gdk_device_grab()
467 	 *  instead.
468 	 * Ungrabs the keyboard on the default display, if it is grabbed by this
469 	 * application.
470 	 * Params:
471 	 * time = a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
472 	 * timestamp is available.
473 	 */
474 	public static void keyboardUngrab(uint time)
475 	{
476 		// void gdk_keyboard_ungrab (guint32 time_);
477 		gdk_keyboard_ungrab(time);
478 	}
479 	
480 	/**
481 	 * Emits a short beep on the default display.
482 	 */
483 	public static void beep()
484 	{
485 		// void gdk_beep (void);
486 		gdk_beep();
487 	}
488 	
489 	/**
490 	 * This function allows X errors to be trapped instead of the normal
491 	 * behavior of exiting the application. It should only be used if it
492 	 * is not possible to avoid the X error in any other way. Errors are
493 	 * ignored on all GdkDisplay currently known to the
494 	 * GdkDisplayManager. If you don't care which error happens and just
495 	 * want to ignore everything, pop with gdk_error_trap_pop_ignored().
496 	 * If you need the error code, use gdk_error_trap_pop() which may have
497 	 * to block and wait for the error to arrive from the X server.
498 	 * This API exists on all platforms but only does anything on X.
499 	 * You can use gdk_x11_display_error_trap_push() to ignore errors
500 	 * on only a single display.
501 	 * $(DDOC_COMMENT example)
502 	 */
503 	public static void errorTrapPush()
504 	{
505 		// void gdk_error_trap_push (void);
506 		gdk_error_trap_push();
507 	}
508 	
509 	/**
510 	 * Removes an error trap pushed with gdk_error_trap_push().
511 	 * May block until an error has been definitively received
512 	 * or not received from the X server. gdk_error_trap_pop_ignored()
513 	 * is preferred if you don't need to know whether an error
514 	 * occurred, because it never has to block. If you don't
515 	 * need the return value of gdk_error_trap_pop(), use
516 	 * gdk_error_trap_pop_ignored().
517 	 * Prior to GDK 3.0, this function would not automatically
518 	 * sync for you, so you had to gdk_flush() if your last
519 	 * call to Xlib was not a blocking round trip.
520 	 * Returns: X error code or 0 on success
521 	 */
522 	public static int errorTrapPop()
523 	{
524 		// gint gdk_error_trap_pop (void);
525 		return gdk_error_trap_pop();
526 	}
527 	
528 	/**
529 	 * Removes an error trap pushed with gdk_error_trap_push(), but
530 	 * without bothering to wait and see whether an error occurred. If an
531 	 * error arrives later asynchronously that was triggered while the
532 	 * trap was pushed, that error will be ignored.
533 	 * Since 3.0
534 	 */
535 	public static void errorTrapPopIgnored()
536 	{
537 		// void gdk_error_trap_pop_ignored (void);
538 		gdk_error_trap_pop_ignored();
539 	}
540 }