alternative to assert
[gtkD.git] / src / gdk / Gdk.d
blob9ca0178bec3a9645d1ab7da132db7e01a11675f9
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 * local aliases:
53 module gdk.Gdk;
55 private import gdk.gdktypes;
57 private import lib.gdk;
59 private import glib.Str;
60 private import gdk.Window;
61 private import gdk.Cursor;
63 /**
64 * Description
65 * This section describes the GDK initialization functions and miscellaneous
66 * utility functions.
68 public class Gdk
71 /**
74 /**
75 * Initializes the GDK library and connects to the X server.
76 * If initialization fails, a warning message is output and the application
77 * terminates with a call to exit(1).
78 * Any arguments used by GDK are removed from the array and argc and argv are
79 * updated accordingly.
80 * GTK+ initializes GDK in gtk_init() and so this function is not usually needed
81 * by GTK+ applications.
82 * argc:
83 * the number of command line arguments.
84 * argv:
85 * the array of command line arguments.
87 public static void init(int* argc, char*** argv)
89 // void gdk_init (gint *argc, gchar ***argv);
90 gdk_init(argc, argv);
93 /**
94 * Initializes the GDK library and connects to the X server, returning TRUE on
95 * success.
96 * Any arguments used by GDK are removed from the array and argc and argv are
97 * updated accordingly.
98 * GTK+ initializes GDK in gtk_init() and so this function is not usually needed
99 * by GTK+ applications.
100 * argc:
101 * the number of command line arguments.
102 * argv:
103 * the array of command line arguments.
104 * Returns:
105 * TRUE if initialization succeeded.
107 public static int initCheck(int* argc, char*** argv)
109 // gboolean gdk_init_check (gint *argc, gchar ***argv);
110 return gdk_init_check(argc, argv);
114 * Parse command line arguments, and store for future
115 * use by calls to gdk_display_open().
116 * Any arguments used by GDK are removed from the array and argc and argv are
117 * updated accordingly.
118 * You shouldn't call this function explicitely if you are using
119 * gtk_init(), gtk_init_check(), gdk_init(), or gdk_init_check().
120 * argc:
121 * the number of command line arguments.
122 * argv:
123 * the array of command line arguments.
124 * Since 2.2
126 public static void parseArgs(int* argc, char*** argv)
128 // void gdk_parse_args (gint *argc, gchar ***argv);
129 gdk_parse_args(argc, argv);
133 * Gets the display name specified in the command line arguments passed
134 * to gdk_init() or gdk_parse_args(), if any.
135 * Returns:
136 * the display name, if specified explicitely, otherwise NULL
137 * this string is owned by GTK+ and must not be modified or freed.
138 * Since 2.2
140 public static char[] getDisplayArgName()
142 // const gchar* gdk_get_display_arg_name (void);
143 return Str.toString(gdk_get_display_arg_name() );
147 * Initializes the support for internationalization by calling the setlocale()
148 * system call. This function is called by gtk_set_locale() and so GTK+
149 * applications should use that instead.
150 * The locale to use is determined by the LANG environment variable,
151 * so to run an application in a certain locale you can do something like this:
152 * export LANG="fr"
153 * ... run application ...
154 * If the locale is not supported by X then it is reset to the standard "C"
155 * locale.
156 * Returns:
157 * the resulting locale.
159 public static char[] setLocale()
161 // gchar* gdk_set_locale (void);
162 return Str.toString(gdk_set_locale() );
166 * Sets the SM_CLIENT_ID property on the application's leader window so that
167 * the window manager can save the application's state using the X11R6 ICCCM
168 * session management protocol.
169 * See the X Session Management Library documentation for more information on
170 * session management and the Inter-Client Communication Conventions Manual
171 * (ICCCM) for information on the WM_CLIENT_LEADER property.
172 * (Both documents are part of the X Window System distribution.)
173 * sm_client_id:
174 * the client id assigned by the session manager when the
175 * connection was opened, or NULL to remove the property.
177 public static void setSmClientId(char[] smClientId)
179 // void gdk_set_sm_client_id (const gchar *sm_client_id);
180 gdk_set_sm_client_id(Str.toStringz(smClientId));
184 * Warning
185 * gdk_exit is deprecated and should not be used in newly-written code.
186 * Exits the application using the exit() system call.
187 * This routine is provided mainly for backwards compatibility, since it used to
188 * perform tasks necessary to exit the application cleanly. Those tasks are now
189 * performed in a function which is automatically called on exit (via the use
190 * of g_atexit()).
191 * error_code:
192 * the error code to pass to the exit() call.
194 public static void exit(int errorCode)
196 // void gdk_exit (gint error_code);
197 gdk_exit(errorCode);
201 * Indicates to the GUI environment that the application has finished
202 * loading. If the applications opens windows, this function is
203 * normally called after opening the application's initial set of
204 * windows.
205 * GTK+ will call this function automatically after opening the first
206 * GtkWindow unless gtk_window_set_auto_startup_notification() is called
207 * to disable that feature.
208 * Since 2.2
210 public static void notifyStartupComplete()
212 // void gdk_notify_startup_complete (void);
213 gdk_notify_startup_complete();
217 * Gets the program class. Unless the program class has explicitly
218 * been set with gdk_set_program_class() or with the --class
219 * commandline option, the default value is the program name (determined
220 * with g_get_prgname()) with the first character converted to uppercase.
221 * Returns:
222 * the program class.
224 public static char[] getProgramClass()
226 // const char* gdk_get_program_class (void);
227 return Str.toString(gdk_get_program_class() );
231 * Sets the program class. The X11 backend uses the program class to set
232 * the class name part of the WM_CLASS property on
233 * toplevel windows; see the ICCCM.
234 * program_class:
235 * a string.
237 public static void setProgramClass(char[] programClass)
239 // void gdk_set_program_class (const char *program_class);
240 gdk_set_program_class(Str.toStringz(programClass));
244 * Gets the name of the display, which usually comes from the DISPLAY
245 * environment variable or the --display command line option.
246 * Returns:
247 * the name of the display.
249 public static char[] getDisplay()
251 // gchar* gdk_get_display (void);
252 return Str.toString(gdk_get_display() );
256 * Flushes the X output buffer and waits until all requests have been processed
257 * by the server. This is rarely needed by applications. It's main use is for
258 * trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
260 public static void flush()
262 // void gdk_flush (void);
263 gdk_flush();
267 * Returns the width of the default screen in pixels.
268 * Returns:
269 * the width of the default screen in pixels.
271 public static int screenWidth()
273 // gint gdk_screen_width (void);
274 return gdk_screen_width();
278 * Returns the height of the default screen in pixels.
279 * Returns:
280 * the height of the default screen in pixels.
282 public static int screenHeight()
284 // gint gdk_screen_height (void);
285 return gdk_screen_height();
289 * Returns the width of the default screen in millimeters.
290 * Note that on many X servers this value will not be correct.
291 * Returns:
292 * the width of the default screen in millimeters,
293 * though it is not always correct.
295 public static int screenWidthMm()
297 // gint gdk_screen_width_mm (void);
298 return gdk_screen_width_mm();
302 * Returns the height of the default screen in millimeters.
303 * Note that on many X servers this value will not be correct.
304 * Returns:
305 * the height of the default screen in millimeters,
306 * though it is not always correct.
308 public static int screenHeightMm()
310 // gint gdk_screen_height_mm (void);
311 return gdk_screen_height_mm();
315 * Grabs the pointer (usually a mouse) so that all events are passed to this
316 * application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
317 * the grab window becomes unviewable.
318 * This overrides any previous pointer grab by this client.
319 * Pointer grabs are used for operations which need complete control over mouse
320 * events, even if the mouse leaves the application.
321 * For example in GTK+ it is used for Drag and Drop, for dragging the handle in
322 * the GtkHPaned and GtkVPaned widgets, and for resizing columns in GtkCList
323 * widgets.
324 * Note that if the event mask of an X window has selected both button press and
325 * button release events, then a button press event will cause an automatic
326 * pointer grab until the button is released.
327 * X does this automatically since most applications expect to receive button
328 * press and release events in pairs.
329 * It is equivalent to a pointer grab on the window with owner_events set to
330 * TRUE.
331 * If you set up anything at the time you take the grab that needs to be cleaned
332 * up when the grab ends, you should handle the GdkEventGrabBroken events that
333 * are emitted when the grab ends unvoluntarily.
334 * window:
335 * the GdkWindow which will own the grab (the grab window).
336 * owner_events:
337 * if FALSE then all pointer events are reported with respect to
338 * window and are only reported if selected by event_mask. If TRUE then pointer
339 * events for this application are reported as normal, but pointer events outside
340 * this application are reported with respect to window and only if selected by
341 * event_mask. In either mode, unreported events are discarded.
342 * event_mask:
343 * specifies the event mask, which is used in accordance with
344 * owner_events. Note that only pointer events (i.e. button and motion events)
345 * may be selected.
346 * confine_to:
347 * If non-NULL, the pointer will be confined to this
348 * window during the grab. If the pointer is outside confine_to, it will
349 * automatically be moved to the closest edge of confine_to and enter
350 * and leave events will be generated as necessary.
351 * cursor:
352 * the cursor to display while the grab is active. If this is NULL then
353 * the normal cursors are used for window and its descendants, and the cursor
354 * for window is used for all other windows.
355 * time_:
356 * the timestamp of the event which led to this pointer grab. This usually
357 * comes from a GdkEventButton struct, though GDK_CURRENT_TIME can be used if
358 * the time isn't known.
359 * Returns:
360 * GDK_GRAB_SUCCESS if the grab was successful.
362 public static GdkGrabStatus pointerGrab(Window window, int ownerEvents, GdkEventMask eventMask, Window confineTo, Cursor cursor, uint time)
364 // GdkGrabStatus gdk_pointer_grab (GdkWindow *window, gboolean owner_events, GdkEventMask event_mask, GdkWindow *confine_to, GdkCursor *cursor, guint32 time_);
365 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);
370 * Ungrabs the pointer, if it is grabbed by this application.
371 * time_:
372 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
373 * timestamp is available.
375 public static void pointerUngrab(uint time)
377 // void gdk_pointer_ungrab (guint32 time_);
378 gdk_pointer_ungrab(time);
382 * Returns TRUE if the pointer is currently grabbed by this application.
383 * Note that this does not take the inmplicit pointer grab on button
384 * presses into account.
385 * Returns:
386 * TRUE if the pointer is currently grabbed by this application.*
388 public static int pointerIsGrabbed()
390 // gboolean gdk_pointer_is_grabbed (void);
391 return gdk_pointer_is_grabbed();
395 * Set the double click time for the default display. See
396 * gdk_display_set_double_click_time().
397 * See also gdk_display_set_double_click_distance().
398 * Applications should not set this, it is a
399 * global user-configured setting.
400 * msec:
401 * double click time in milliseconds (thousandths of a second)
403 public static void setDoubleClickTime(uint msec)
405 // void gdk_set_double_click_time (guint msec);
406 gdk_set_double_click_time(msec);
410 * Grabs the keyboard so that all events are passed to this
411 * application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
412 * This overrides any previous keyboard grab by this client.
413 * If you set up anything at the time you take the grab that needs to be cleaned
414 * up when the grab ends, you should handle the GdkEventGrabBroken events that
415 * are emitted when the grab ends unvoluntarily.
416 * window:
417 * the GdkWindow which will own the grab (the grab window).
418 * owner_events:
419 * if FALSE then all keyboard events are reported with respect to
420 * window. If TRUE then keyboard events for this application are reported as
421 * normal, but keyboard events outside this application are reported with respect
422 * to window. Both key press and key release events are always reported,
423 * independant of the event mask set by the application.
424 * time_:
425 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no timestamp is
426 * available.
427 * Returns:
428 * GDK_GRAB_SUCCESS if the grab was successful.
430 public static GdkGrabStatus keyboardGrab(Window window, int ownerEvents, uint time)
432 // GdkGrabStatus gdk_keyboard_grab (GdkWindow *window, gboolean owner_events, guint32 time_);
433 return gdk_keyboard_grab((window is null) ? null : window.getWindowStruct(), ownerEvents, time);
437 * Ungrabs the keyboard, if it is grabbed by this application.
438 * time_:
439 * a timestamp from a GdkEvent, or GDK_CURRENT_TIME if no
440 * timestamp is available.
442 public static void keyboardUngrab(uint time)
444 // void gdk_keyboard_ungrab (guint32 time_);
445 gdk_keyboard_ungrab(time);
449 * Emits a short beep.
451 public static void beep()
453 // void gdk_beep (void);
454 gdk_beep();
458 * Warning
459 * gdk_get_use_xshm is deprecated and should not be used in newly-written code.
460 * Returns TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
461 * The shared memory extension is used for GdkImage, and consequently for
462 * GdkRGB.
463 * It enables much faster drawing by communicating with the X server through
464 * SYSV shared memory calls. However, it can only be used if the X client and
465 * server are on the same machine and the server supports it.
466 * Returns:
467 * TRUE if use of the MIT shared memory extension will be attempted.
469 public static int getUseXshm()
471 // gboolean gdk_get_use_xshm (void);
472 return gdk_get_use_xshm();
476 * Warning
477 * gdk_set_use_xshm is deprecated and should not be used in newly-written code.
478 * Sets whether the use of the MIT shared memory extension should be attempted.
479 * This function is mainly for internal use. It is only safe for an application
480 * to set this to FALSE, since if it is set to TRUE and the server does not
481 * support the extension it may cause warning messages to be output.
482 * use_xshm:
483 * TRUE if use of the MIT shared memory extension should be attempted.
485 public static void setUseXshm(int useXshm)
487 // void gdk_set_use_xshm (gboolean use_xshm);
488 gdk_set_use_xshm(useXshm);
492 * This function allows X errors to be trapped instead of the normal behavior
493 * of exiting the application. It should only be used if it is not possible to
494 * avoid the X error in any other way.
495 * Example1.Trapping an X error
496 * gdk_error_trap_push ();
497 * /+* ... Call the X function which may cause an error here ... +/
498 * /+* Flush the X queue to catch errors now. +/
499 * gdk_flush ();
500 * if (gdk_error_trap_pop ())
502 * /+* ... Handle the error here ... +/
505 public static void errorTrapPush()
507 // void gdk_error_trap_push (void);
508 gdk_error_trap_push();
512 * Removes the X error trap installed with gdk_error_trap_push().
513 * Returns:
514 * the X error code, or 0 if no error occurred.
516 public static int errorTrapPop()
518 // gint gdk_error_trap_pop (void);
519 return gdk_error_trap_pop();