alternative to assert
[gtkD.git] / gtkD / src / gdk / Gdk.d
blob828881241e943277091f9584d787ef5325149089
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-General.html
26 * outPack = gdk
27 * outFile = Gdk
28 * strct =
29 * realStrct=
30 * ctorStrct=
31 * clss = Gdk
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gdk.Window
46 * - gdk.Cursor
47 * structWrap:
48 * - GdkCursor* -> Cursor
49 * - GdkWindow* -> Window
50 * module aliases:
51 * local aliases:
54 module gdk.Gdk;
56 version(noAssert)
58 version(Tango)
60 import tango.io.Stdout; // use the tango loging?
64 private import gtkc.gdktypes;
66 private import gtkc.gdk;
69 private import glib.Str;
70 private import gdk.Window;
71 private import gdk.Cursor;
76 /**
77 * Description
78 * This section describes the GDK initialization functions and miscellaneous
79 * utility functions.
81 public class Gdk
84 /**
87 /**
88 * Initializes the GDK library and connects to the X server.
89 * If initialization fails, a warning message is output and the application
90 * terminates with a call to exit(1).
91 * Any arguments used by GDK are removed from the array and argc and argv are
92 * updated accordingly.
93 * GTK+ initializes GDK in gtk_init() and so this function is not usually needed
94 * by GTK+ applications.
95 * argc:
96 * the number of command line arguments.
97 * argv:
98 * the array of command line arguments.
100 public static void init(int* argc, char*** argv)
102 // void gdk_init (gint *argc, gchar ***argv);
103 gdk_init(argc, argv);
107 * Initializes the GDK library and connects to the X server, returning TRUE on
108 * success.
109 * Any arguments used by GDK are removed from the array and argc and argv are
110 * updated accordingly.
111 * GTK+ initializes GDK in gtk_init() and so this function is not usually needed
112 * by GTK+ applications.
113 * argc:
114 * the number of command line arguments.
115 * argv:
116 * the array of command line arguments.
117 * Returns:
118 * TRUE if initialization succeeded.
120 public static int initCheck(int* argc, char*** argv)
122 // gboolean gdk_init_check (gint *argc, gchar ***argv);
123 return gdk_init_check(argc, argv);
127 * Parse command line arguments, and store for future
128 * use by calls to gdk_display_open().
129 * Any arguments used by GDK are removed from the array and argc and argv are
130 * updated accordingly.
131 * You shouldn't call this function explicitely if you are using
132 * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
133 * argc:
134 * the number of command line arguments.
135 * argv:
136 * the array of command line arguments.
137 * Since 2.2
139 public static void parseArgs(int* argc, char*** argv)
141 // void gdk_parse_args (gint *argc, gchar ***argv);
142 gdk_parse_args(argc, argv);
146 * Gets the display name specified in the command line arguments passed
147 * to gdk_init() or gdk_parse_args(), if any.
148 * Returns:
149 * the display name, if specified explicitely, otherwise NULL
150 * this string is owned by GTK+ and must not be modified or freed.
151 * Since 2.2
153 public static char[] getDisplayArgName()
155 // const gchar* gdk_get_display_arg_name (void);
156 return Str.toString(gdk_get_display_arg_name() );
160 * Initializes the support for internationalization by calling the setlocale()
161 * system call. This function is called by gtk_set_locale() and so GTK+
162 * applications should use that instead.
163 * The locale to use is determined by the LANG environment variable,
164 * so to run an application in a certain locale you can do something like this:
165 * export LANG="fr"
166 * ... run application ...
167 * If the locale is not supported by X then it is reset to the standard "C"
168 * locale.
169 * Returns:
170 * the resulting locale.
172 public static char[] setLocale()
174 // gchar* gdk_set_locale (void);
175 return Str.toString(gdk_set_locale() );
179 * Sets the SM_CLIENT_ID property on the application's leader window so that
180 * the window manager can save the application's state using the X11R6 ICCCM
181 * session management protocol.
182 * See the X Session Management Library documentation for more information on
183 * session management and the Inter-Client Communication Conventions Manual
184 * (ICCCM) for information on the WM_CLIENT_LEADER property.
185 * (Both documents are part of the X Window System distribution.)
186 * sm_client_id:
187 * the client id assigned by the session manager when the
188 * connection was opened, or NULL to remove the property.
190 public static void setSmClientId(char[] smClientId)
192 // void gdk_set_sm_client_id (const gchar *sm_client_id);
193 gdk_set_sm_client_id(Str.toStringz(smClientId));
197 * Warning
198 * gdk_exit is deprecated and should not be used in newly-written code.
199 * Exits the application using the exit() system call.
200 * This routine is provided mainly for backwards compatibility, since it used to
201 * perform tasks necessary to exit the application cleanly. Those tasks are now
202 * performed in a function which is automatically called on exit (via the use
203 * of g_atexit()).
204 * error_code:
205 * the error code to pass to the exit() call.
207 public static void exit(int errorCode)
209 // void gdk_exit (gint error_code);
210 gdk_exit(errorCode);
214 * Indicates to the GUI environment that the application has finished
215 * loading. If the applications opens windows, this function is
216 * normally called after opening the application's initial set of
217 * windows.
218 * GTK+ will call this function automatically after opening the first
219 * GtkWindow unless gtk_window_set_auto_startup_notification() is called
220 * to disable that feature.
221 * Since 2.2
223 public static void notifyStartupComplete()
225 // void gdk_notify_startup_complete (void);
226 gdk_notify_startup_complete();
230 * Gets the program class. Unless the program class has explicitly
231 * been set with gdk_set_program_class() or with the --class
232 * commandline option, the default value is the program name (determined
233 * with g_get_prgname()) with the first character converted to uppercase.
234 * Returns:
235 * the program class.
237 public static char[] getProgramClass()
239 // const char* gdk_get_program_class (void);
240 return Str.toString(gdk_get_program_class() );
244 * Sets the program class. The X11 backend uses the program class to set
245 * the class name part of the WM_CLASS property on
246 * toplevel windows; see the ICCCM.
247 * program_class:
248 * a string.
250 public static void setProgramClass(char[] programClass)
252 // void gdk_set_program_class (const char *program_class);
253 gdk_set_program_class(Str.toStringz(programClass));
257 * Gets the name of the display, which usually comes from the DISPLAY
258 * environment variable or the --display command line option.
259 * Returns:
260 * the name of the display.
262 public static char[] getDisplay()
264 // gchar* gdk_get_display (void);
265 return Str.toString(gdk_get_display() );
269 * Flushes the X output buffer and waits until all requests have been processed
270 * by the server. This is rarely needed by applications. It's main use is for
271 * trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
273 public static void flush()
275 // void gdk_flush (void);
276 gdk_flush();
280 * Returns the width of the default screen in pixels.
281 * Returns:
282 * the width of the default screen in pixels.
284 public static int screenWidth()
286 // gint gdk_screen_width (void);
287 return gdk_screen_width();
291 * Returns the height of the default screen in pixels.
292 * Returns:
293 * the height of the default screen in pixels.
295 public static int screenHeight()
297 // gint gdk_screen_height (void);
298 return gdk_screen_height();
302 * Returns the width of the default screen in millimeters.
303 * Note that on many X servers this value will not be correct.
304 * Returns:
305 * the width of the default screen in millimeters,
306 * though it is not always correct.
308 public static int screenWidthMm()
310 // gint gdk_screen_width_mm (void);
311 return gdk_screen_width_mm();
315 * Returns the height of the default screen in millimeters.
316 * Note that on many X servers this value will not be correct.
317 * Returns:
318 * the height of the default screen in millimeters,
319 * though it is not always correct.
321 public static int screenHeightMm()
323 // gint gdk_screen_height_mm (void);
324 return gdk_screen_height_mm();
328 * Grabs the pointer (usually a mouse) so that all events are passed to this
329 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
330 * the grab window becomes unviewable.
331 * This overrides any previous pointer grab by this client.
332 * Pointer grabs are used for operations which need complete control over mouse
333 * events, even if the mouse leaves the application.
334 * For example in GTK+ it is used for Drag and Drop, for dragging the handle in
335 * the GtkHPaned and GtkVPaned widgets, and for resizing columns in GtkCList
336 * widgets.
337 * Note that if the event mask of an X window has selected both button press and
338 * button release events, then a button press event will cause an automatic
339 * pointer grab until the button is released.
340 * X does this automatically since most applications expect to receive button
341 * press and release events in pairs.
342 * It is equivalent to a pointer grab on the window with owner_events set to
343 * TRUE.
344 * If you set up anything at the time you take the grab that needs to be cleaned
345 * up when the grab ends, you should handle the GdkEventGrabBroken events that
346 * are emitted when the grab ends unvoluntarily.
347 * window:
348 * the GdkWindow which will own the grab (the grab window).
349 * owner_events:
350 * if FALSE then all pointer events are reported with respect to
351 * window and are only reported if selected by event_mask. If TRUE then pointer
352 * events for this application are reported as normal, but pointer events outside
353 * this application are reported with respect to window and only if selected by
354 * event_mask. In either mode, unreported events are discarded.
355 * event_mask:
356 * specifies the event mask, which is used in accordance with
357 * owner_events. Note that only pointer events (i.e. button and motion events)
358 * may be selected.
359 * confine_to:
360 * If non-NULL, the pointer will be confined to this
361 * window during the grab. If the pointer is outside confine_to, it will
362 * automatically be moved to the closest edge of confine_to and enter
363 * and leave events will be generated as necessary.
364 * cursor:
365 * the cursor to display while the grab is active. If this is NULL then
366 * the normal cursors are used for window and its descendants, and the cursor
367 * for window is used for all other windows.
368 * time_:
369 * the timestamp of the event which led to this pointer grab. This usually
370 * comes from a GdkEventButton struct, though GDK_CURRENT_TIME can be used if
371 * the time isn't known.
372 * Returns:
373 * GDK_GRAB_SUCCESS if the grab was successful.
375 public static GdkGrabStatus pointerGrab(Window window, int ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)
377 // GdkGrabStatus gdk_pointer_grab (GdkWindow *window, gboolean owner_events, GdkEventMask event_mask, GdkWindow *confine_to, GdkCursor *cursor, guint32 time_);
378 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);
383 * Ungrabs the pointer on the default display, if it is grabbed by this
384 * application.
385 * time_:
386 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
387 * timestamp is available.
389 public static void pointerUngrab(uint time)
391 // void gdk_pointer_ungrab (guint32 time_);
392 gdk_pointer_ungrab(time);
396 * Returns TRUE if the pointer on the default display is currently
397 * grabbed by this application.
398 * Note that this does not take the inmplicit pointer grab on button
399 * presses into account.
400 * Returns:
401 * TRUE if the pointer is currently grabbed by this application.*
403 public static int pointerIsGrabbed()
405 // gboolean gdk_pointer_is_grabbed (void);
406 return gdk_pointer_is_grabbed();
410 * Set the double click time for the default display. See
411 * gdk_display_set_double_click_time().
412 * See also gdk_display_set_double_click_distance().
413 * Applications should not set this, it is a
414 * global user-configured setting.
415 * msec:
416 * double click time in milliseconds (thousandths of a second)
418 public static void setDoubleClickTime(uint msec)
420 // void gdk_set_double_click_time (guint msec);
421 gdk_set_double_click_time(msec);
425 * Grabs the keyboard so that all events are passed to this
426 * application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
427 * This overrides any previous keyboard grab by this client.
428 * If you set up anything at the time you take the grab that needs to be cleaned
429 * up when the grab ends, you should handle the GdkEventGrabBroken events that
430 * are emitted when the grab ends unvoluntarily.
431 * window:
432 * the GdkWindow which will own the grab (the grab window).
433 * owner_events:
434 * if FALSE then all keyboard events are reported with respect to
435 * window. If TRUE then keyboard events for this application are reported as
436 * normal, but keyboard events outside this application are reported with respect
437 * to window. Both key press and key release events are always reported,
438 * independant of the event mask set by the application.
439 * time_:
440 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no timestamp is
441 * available.
442 * Returns:
443 * GDK_GRAB_SUCCESS if the grab was successful.
445 public static GdkGrabStatus keyboardGrab(Window window, int ownerEvents, uint time)
447 // GdkGrabStatus gdk_keyboard_grab (GdkWindow *window, gboolean owner_events, guint32 time_);
448 return gdk_keyboard_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, time);
452 * Ungrabs the keyboard on the default display, if it is grabbed by this
453 * application.
454 * time_:
455 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
456 * timestamp is available.
458 public static void keyboardUngrab(uint time)
460 // void gdk_keyboard_ungrab (guint32 time_);
461 gdk_keyboard_ungrab(time);
465 * Emits a short beep on the default display.
467 public static void beep()
469 // void gdk_beep (void);
470 gdk_beep();
474 * Warning
475 * gdk_get_use_xshm is deprecated and should not be used in newly-written code.
476 * Returns TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
477 * The shared memory extension is used for GdkImage, and consequently for
478 * GdkRGB.
479 * It enables much faster drawing by communicating with the X server through
480 * SYSV shared memory calls. However, it can only be used if the X client and
481 * server are on the same machine and the server supports it.
482 * Returns:
483 * TRUE if use of the MIT shared memory extension will be attempted.
485 public static int getUseXshm()
487 // gboolean gdk_get_use_xshm (void);
488 return gdk_get_use_xshm();
492 * Warning
493 * gdk_set_use_xshm is deprecated and should not be used in newly-written code.
494 * Sets whether the use of the MIT shared memory extension should be attempted.
495 * This function is mainly for internal use. It is only safe for an application
496 * to set this to FALSE, since if it is set to TRUE and the server does not
497 * support the extension it may cause warning messages to be output.
498 * use_xshm:
499 * TRUE if use of the MIT shared memory extension should be attempted.
501 public static void setUseXshm(int useXshm)
503 // void gdk_set_use_xshm (gboolean use_xshm);
504 gdk_set_use_xshm(useXshm);
508 * This function allows X errors to be trapped instead of the normal behavior
509 * of exiting the application. It should only be used if it is not possible to
510 * avoid the X error in any other way.
511 * Example1.Trapping an X error
512 * gdk_error_trap_push ();
513 * /+* ... Call the X function which may cause an error here ... +/
514 * /+* Flush the X queue to catch errors now. +/
515 * gdk_flush ();
516 * if (gdk_error_trap_pop ())
518 * /+* ... Handle the error here ... +/
521 public static void errorTrapPush()
523 // void gdk_error_trap_push (void);
524 gdk_error_trap_push();
528 * Removes the X error trap installed with gdk_error_trap_push().
529 * Returns:
530 * the X error code, or 0 if no error occurred.
532 public static int errorTrapPop()
534 // gint gdk_error_trap_pop (void);
535 return gdk_error_trap_pop();