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