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  = gdk-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.Window
48  * 	- gdk.Cursor
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 
66 private import glib.Str;
67 private import gdk.Window;
68 private import gdk.Cursor;
69 
70 
71 
72 
73 /**
74  * Description
75  * This section describes the GDK initialization functions and miscellaneous
76  * utility functions.
77  */
78 public class Gdk
79 {
80 	
81 	/**
82 	 */
83 	
84 	/**
85 	 * Initializes the GDK library and connects to the X server.
86 	 * If initialization fails, a warning message is output and the application
87 	 * terminates with a call to exit(1).
88 	 * Any arguments used by GDK are removed from the array and argc and argv are
89 	 * updated accordingly.
90 	 * GTK+ initializes GDK in gtk_init() and so this function is not usually needed
91 	 * by GTK+ applications.
92 	 * Params:
93 	 * argv = . [array length=argc][inout]
94 	 */
95 	public static void init(ref string[] argv)
96 	{
97 		// void gdk_init (gint *argc,  gchar ***argv);
98 		char** outargv = Str.toStringzArray(argv);
99 		int argc = cast(int) argv.length;
100 		
101 		gdk_init(&argc, &outargv);
102 		
103 		argv = null;
104 		foreach ( cstr; outargv[0 .. argc] )
105 		{
106 			argv ~= Str.toString(cstr);
107 		}
108 	}
109 	
110 	/**
111 	 * Initialize the library for use.
112 	 * Params:
113 	 * argv = . [array length=argc][inout]
114 	 * Returns: TRUE if initialization succeeded.
115 	 */
116 	public static int initCheck(ref string[] argv)
117 	{
118 		// gboolean gdk_init_check (gint *argc,  gchar ***argv);
119 		char** outargv = Str.toStringzArray(argv);
120 		int argc = cast(int) argv.length;
121 		
122 		auto p = gdk_init_check(&argc, &outargv);
123 		
124 		argv = null;
125 		foreach ( cstr; outargv[0 .. argc] )
126 		{
127 			argv ~= Str.toString(cstr);
128 		}
129 		return p;
130 	}
131 	
132 	/**
133 	 * Parse command line arguments, and store for future
134 	 * use by calls to gdk_display_open().
135 	 * Any arguments used by GDK are removed from the array and argc and argv are
136 	 * updated accordingly.
137 	 * You shouldn't call this function explicitely if you are using
138 	 * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
139 	 * Since 2.2
140 	 * Params:
141 	 * argv = the array of command line arguments. [inout][array length=argc]
142 	 */
143 	public static void parseArgs(ref string[] argv)
144 	{
145 		// void gdk_parse_args (gint *argc,  gchar ***argv);
146 		char** outargv = Str.toStringzArray(argv);
147 		int argc = cast(int) argv.length;
148 		
149 		gdk_parse_args(&argc, &outargv);
150 		
151 		argv = null;
152 		foreach ( cstr; outargv[0 .. argc] )
153 		{
154 			argv ~= Str.toString(cstr);
155 		}
156 	}
157 	
158 	/**
159 	 * Gets the display name specified in the command line arguments passed
160 	 * to gdk_init() or gdk_parse_args(), if any.
161 	 * Since 2.2
162 	 * Returns: the display name, if specified explicitely, otherwise NULL this string is owned by GTK+ and must not be modified or freed.
163 	 */
164 	public static string getDisplayArgName()
165 	{
166 		// const gchar * gdk_get_display_arg_name (void);
167 		return Str.toString(gdk_get_display_arg_name());
168 	}
169 	
170 	/**
171 	 * Warning
172 	 * gdk_set_locale has been deprecated since version 2.24 and should not be used in newly-written code. Use setlocale() directly
173 	 * Initializes the support for internationalization by calling the setlocale()
174 	 * system call. This function is called by gtk_set_locale() and so GTK+
175 	 * applications should use that instead.
176 	 * The locale to use is determined by the LANG environment variable,
177 	 * Returns: the resulting locale.
178 	 */
179 	public static string setLocale()
180 	{
181 		// gchar * gdk_set_locale (void);
182 		return Str.toString(gdk_set_locale());
183 	}
184 	
185 	/**
186 	 * Warning
187 	 * gdk_set_sm_client_id has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_x11_set_sm_client_id() instead
188 	 * Sets the SM_CLIENT_ID property on the application's leader window so that
189 	 * the window manager can save the application's state using the X11R6 ICCCM
190 	 * session management protocol.
191 	 * See the X Session Management Library documentation for more information on
192 	 * session management and the Inter-Client Communication Conventions Manual
193 	 * (ICCCM) for information on the WM_CLIENT_LEADER property.
194 	 * (Both documents are part of the X Window System distribution.)
195 	 * Params:
196 	 * smClientId = the client id assigned by the session manager when the
197 	 * connection was opened, or NULL to remove the property.
198 	 */
199 	public static void setSmClientId(string smClientId)
200 	{
201 		// void gdk_set_sm_client_id (const gchar *sm_client_id);
202 		gdk_set_sm_client_id(Str.toStringz(smClientId));
203 	}
204 	
205 	/**
206 	 * Warning
207 	 * gdk_exit is deprecated and should not be used in newly-written code.
208 	 * Exits the application using the exit() system call.
209 	 * This routine is provided mainly for backwards compatibility, since it used to
210 	 * perform tasks necessary to exit the application cleanly. Those tasks are now
211 	 * performed in a function which is automatically called on exit (via the use
212 	 * of g_atexit()).
213 	 * Params:
214 	 * errorCode = the error code to pass to the exit() call.
215 	 */
216 	public static void exit(int errorCode)
217 	{
218 		// void gdk_exit (gint error_code);
219 		gdk_exit(errorCode);
220 	}
221 	
222 	/**
223 	 * Indicates to the GUI environment that the application has finished
224 	 * loading. If the applications opens windows, this function is
225 	 * normally called after opening the application's initial set of
226 	 * windows.
227 	 * GTK+ will call this function automatically after opening the first
228 	 * GtkWindow unless gtk_window_set_auto_startup_notification() is called
229 	 * to disable that feature.
230 	 * Since 2.2
231 	 */
232 	public static void notifyStartupComplete()
233 	{
234 		// void gdk_notify_startup_complete (void);
235 		gdk_notify_startup_complete();
236 	}
237 	
238 	/**
239 	 * Indicates to the GUI environment that the application has finished
240 	 * loading, using a given identifier.
241 	 * GTK+ will call this function automatically for GtkWindow with custom
242 	 * startup-notification identifier unless
243 	 * gtk_window_set_auto_startup_notification() is called to disable
244 	 * that feature.
245 	 * Since 2.12
246 	 * Params:
247 	 * startupId = a startup-notification identifier, for which notification
248 	 * process should be completed
249 	 */
250 	public static void notifyStartupCompleteWithId(string startupId)
251 	{
252 		// void gdk_notify_startup_complete_with_id (const gchar *startup_id);
253 		gdk_notify_startup_complete_with_id(Str.toStringz(startupId));
254 	}
255 	
256 	/**
257 	 * Gets the program class. Unless the program class has explicitly
258 	 * been set with gdk_set_program_class() or with the --class
259 	 * commandline option, the default value is the program name (determined
260 	 * with g_get_prgname()) with the first character converted to uppercase.
261 	 * Returns: the program class.
262 	 */
263 	public static string getProgramClass()
264 	{
265 		// const char * gdk_get_program_class (void);
266 		return Str.toString(gdk_get_program_class());
267 	}
268 	
269 	/**
270 	 * Sets the program class. The X11 backend uses the program class to set
271 	 * the class name part of the WM_CLASS property on
272 	 * toplevel windows; see the ICCCM.
273 	 * Params:
274 	 * programClass = a string.
275 	 */
276 	public static void setProgramClass(string programClass)
277 	{
278 		// void gdk_set_program_class (const char *program_class);
279 		gdk_set_program_class(Str.toStringz(programClass));
280 	}
281 	
282 	/**
283 	 * Gets the name of the display, which usually comes from the DISPLAY
284 	 * environment variable or the --display command line option.
285 	 * Returns: the name of the display.
286 	 */
287 	public static string getDisplay()
288 	{
289 		// gchar * gdk_get_display (void);
290 		return Str.toString(gdk_get_display());
291 	}
292 	
293 	/**
294 	 * Flushes the X output buffer and waits until all requests have been processed
295 	 * by the server. This is rarely needed by applications. It's main use is for
296 	 * trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
297 	 */
298 	public static void flush()
299 	{
300 		// void gdk_flush (void);
301 		gdk_flush();
302 	}
303 	
304 	/**
305 	 * Returns the width of the default screen in pixels.
306 	 * Returns: the width of the default screen in pixels.
307 	 */
308 	public static int screenWidth()
309 	{
310 		// gint gdk_screen_width (void);
311 		return gdk_screen_width();
312 	}
313 	
314 	/**
315 	 * Returns the height of the default screen in pixels.
316 	 * Returns: the height of the default screen in pixels.
317 	 */
318 	public static int screenHeight()
319 	{
320 		// gint gdk_screen_height (void);
321 		return gdk_screen_height();
322 	}
323 	
324 	/**
325 	 * Returns the width of the default screen in millimeters.
326 	 * Note that on many X servers this value will not be correct.
327 	 * Returns: the width of the default screen in millimeters, though it is not always correct.
328 	 */
329 	public static int screenWidthMm()
330 	{
331 		// gint gdk_screen_width_mm (void);
332 		return gdk_screen_width_mm();
333 	}
334 	
335 	/**
336 	 * Returns the height of the default screen in millimeters.
337 	 * Note that on many X servers this value will not be correct.
338 	 * Returns: the height of the default screen in millimeters, though it is not always correct.
339 	 */
340 	public static int screenHeightMm()
341 	{
342 		// gint gdk_screen_height_mm (void);
343 		return gdk_screen_height_mm();
344 	}
345 	
346 	/**
347 	 * Grabs the pointer (usually a mouse) so that all events are passed to this
348 	 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
349 	 * the grab window becomes unviewable.
350 	 * This overrides any previous pointer grab by this client.
351 	 * Pointer grabs are used for operations which need complete control over mouse
352 	 * events, even if the mouse leaves the application.
353 	 * For example in GTK+ it is used for Drag and Drop, for dragging the handle in
354 	 * the GtkHPaned and GtkVPaned widgets, and for resizing columns in GtkCList
355 	 * widgets.
356 	 * Note that if the event mask of an X window has selected both button press and
357 	 * button release events, then a button press event will cause an automatic
358 	 * pointer grab until the button is released.
359 	 * X does this automatically since most applications expect to receive button
360 	 * press and release events in pairs.
361 	 * It is equivalent to a pointer grab on the window with owner_events set to
362 	 * TRUE.
363 	 * If you set up anything at the time you take the grab that needs to be cleaned
364 	 * up when the grab ends, you should handle the GdkEventGrabBroken events that
365 	 * are emitted when the grab ends unvoluntarily.
366 	 * Params:
367 	 * window = the GdkWindow which will own the grab (the grab window).
368 	 * ownerEvents = if FALSE then all pointer events are reported with respect to
369 	 * window and are only reported if selected by event_mask. If TRUE then pointer
370 	 * events for this application are reported as normal, but pointer events outside
371 	 * this application are reported with respect to window and only if selected by
372 	 * event_mask. In either mode, unreported events are discarded.
373 	 * eventMask = specifies the event mask, which is used in accordance with
374 	 * owner_events. Note that only pointer events (i.e. button and motion events)
375 	 * may be selected.
376 	 * confineTo = If non-NULL, the pointer will be confined to this
377 	 * window during the grab. If the pointer is outside confine_to, it will
378 	 * automatically be moved to the closest edge of confine_to and enter
379 	 * and leave events will be generated as necessary.
380 	 * cursor = the cursor to display while the grab is active. If this is NULL then
381 	 * the normal cursors are used for window and its descendants, and the cursor
382 	 * for window is used for all other windows.
383 	 * time = the timestamp of the event which led to this pointer grab. This usually
384 	 * comes from a GdkEventButton struct, though GDK_CURRENT_TIME can be used if
385 	 * the time isn't known.
386 	 * Returns: GDK_GRAB_SUCCESS if the grab was successful.
387 	 */
388 	public static GdkGrabStatus pointerGrab(Window window, int ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)
389 	{
390 		// GdkGrabStatus gdk_pointer_grab (GdkWindow *window,  gboolean owner_events,  GdkEventMask event_mask,  GdkWindow *confine_to,  GdkCursor *cursor,  guint32 time_);
391 		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);
392 	}
393 	
394 	/**
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 	 * Returns TRUE if the pointer on the default display is currently
409 	 * grabbed by this application.
410 	 * Note that this does not take the inmplicit pointer grab on button
411 	 * presses into account.
412 	 * Returns: TRUE if the pointer is currently grabbed by this application.*
413 	 */
414 	public static int pointerIsGrabbed()
415 	{
416 		// gboolean gdk_pointer_is_grabbed (void);
417 		return gdk_pointer_is_grabbed();
418 	}
419 	
420 	/**
421 	 * Set the double click time for the default display. See
422 	 * gdk_display_set_double_click_time().
423 	 * See also gdk_display_set_double_click_distance().
424 	 * Applications should not set this, it is a
425 	 * global user-configured setting.
426 	 * Params:
427 	 * msec = double click time in milliseconds (thousandths of a second)
428 	 */
429 	public static void setDoubleClickTime(uint msec)
430 	{
431 		// void gdk_set_double_click_time (guint msec);
432 		gdk_set_double_click_time(msec);
433 	}
434 	
435 	/**
436 	 * Grabs the keyboard so that all events are passed to this
437 	 * application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
438 	 * This overrides any previous keyboard grab by this client.
439 	 * If you set up anything at the time you take the grab that needs to be cleaned
440 	 * up when the grab ends, you should handle the GdkEventGrabBroken events that
441 	 * are emitted when the grab ends unvoluntarily.
442 	 * Params:
443 	 * window = the GdkWindow which will own the grab (the grab window).
444 	 * ownerEvents = if FALSE then all keyboard events are reported with respect to
445 	 * window. If TRUE then keyboard events for this application are reported as
446 	 * normal, but keyboard events outside this application are reported with respect
447 	 * to window. Both key press and key release events are always reported,
448 	 * independant of the event mask set by the application.
449 	 * time = a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no timestamp is
450 	 * available.
451 	 * Returns: GDK_GRAB_SUCCESS if the grab was successful.
452 	 */
453 	public static GdkGrabStatus keyboardGrab(Window window, int ownerEvents, uint time)
454 	{
455 		// GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,  gboolean owner_events,  guint32 time_);
456 		return gdk_keyboard_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, time);
457 	}
458 	
459 	/**
460 	 * Ungrabs the keyboard on the default display, if it is grabbed by this
461 	 * application.
462 	 * Params:
463 	 * time = a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
464 	 * timestamp is available.
465 	 */
466 	public static void keyboardUngrab(uint time)
467 	{
468 		// void gdk_keyboard_ungrab (guint32 time_);
469 		gdk_keyboard_ungrab(time);
470 	}
471 	
472 	/**
473 	 * Emits a short beep on the default display.
474 	 */
475 	public static void beep()
476 	{
477 		// void gdk_beep (void);
478 		gdk_beep();
479 	}
480 	
481 	/**
482 	 * Warning
483 	 * gdk_get_use_xshm is deprecated and should not be used in newly-written code.
484 	 * Returns TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
485 	 * The shared memory extension is used for GdkImage, and consequently for
486 	 * GdkRGB.
487 	 * It enables much faster drawing by communicating with the X server through
488 	 * SYSV shared memory calls. However, it can only be used if the X client and
489 	 * server are on the same machine and the server supports it.
490 	 * Returns: TRUE if use of the MIT shared memory extension will be attempted.
491 	 */
492 	public static int getUseXshm()
493 	{
494 		// gboolean gdk_get_use_xshm (void);
495 		return gdk_get_use_xshm();
496 	}
497 	
498 	/**
499 	 * Warning
500 	 * gdk_set_use_xshm is deprecated and should not be used in newly-written code.
501 	 * Sets whether the use of the MIT shared memory extension should be attempted.
502 	 * This function is mainly for internal use. It is only safe for an application
503 	 * to set this to FALSE, since if it is set to TRUE and the server does not
504 	 * support the extension it may cause warning messages to be output.
505 	 * Params:
506 	 * useXshm = TRUE if use of the MIT shared memory extension should be attempted.
507 	 */
508 	public static void setUseXshm(int useXshm)
509 	{
510 		// void gdk_set_use_xshm (gboolean use_xshm);
511 		gdk_set_use_xshm(useXshm);
512 	}
513 	
514 	/**
515 	 * This function allows X errors to be trapped instead of the normal behavior
516 	 * of exiting the application. It should only be used if it is not possible to
517 	 * avoid the X error in any other way.
518 	 * $(DDOC_COMMENT example)
519 	 */
520 	public static void errorTrapPush()
521 	{
522 		// void gdk_error_trap_push (void);
523 		gdk_error_trap_push();
524 	}
525 	
526 	/**
527 	 * Removes the X error trap installed with gdk_error_trap_push().
528 	 * Returns: the X error code, or 0 if no error occurred.
529 	 */
530 	public static int errorTrapPop()
531 	{
532 		// gint gdk_error_trap_pop (void);
533 		return gdk_error_trap_pop();
534 	}
535 }