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 module gtk.ScrolledWindow; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.Adjustment; 31 private import gtk.Bin; 32 private import gtk.Widget; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 public import gtkc.gtktypes; 36 private import std.algorithm; 37 38 39 /** 40 * GtkScrolledWindow is a container that accepts a single child widget, makes 41 * that child scrollable using either internally added scrollbars or externally 42 * associated adjustments, and optionally draws a frame around the child. 43 * 44 * Widgets with native scrolling support, i.e. those whose classes implement the 45 * #GtkScrollable interface, are added directly. For other types of widget, the 46 * class #GtkViewport acts as an adaptor, giving scrollability to other widgets. 47 * GtkScrolledWindow’s implementation of gtk_container_add() intelligently 48 * accounts for whether or not the added child is a #GtkScrollable. If it isn’t, 49 * #GtkScrolledWindow wraps the child in a #GtkViewport and adds that for you. 50 * Therefore, you can just add any child widget and not worry about the details. 51 * 52 * If gtk_container_add() has added a #GtkViewport for you, you can remove 53 * both your added child widget from the #GtkViewport, and the #GtkViewport 54 * from the GtkScrolledWindow, with either of these calls: 55 * |[<!-- language="C" --> 56 * gtk_container_remove (GTK_CONTAINER (scrolled_window), 57 * child_widget); 58 * // or 59 * gtk_container_remove (GTK_CONTAINER (scrolled_window), 60 * gtk_bin_get_child (GTK_BIN (scrolled_window))); 61 * ]| 62 * 63 * Unless #GtkScrolledWindow:policy is GTK_POLICY_NEVER or GTK_POLICY_EXTERNAL, 64 * GtkScrolledWindow adds internal #GtkScrollbar widgets around its child. The 65 * scroll position of the child, and if applicable the scrollbars, is controlled 66 * by the #GtkScrolledWindow:hadjustment and #GtkScrolledWindow:vadjustment 67 * that are associated with the GtkScrolledWindow. See the docs on #GtkScrollbar 68 * for the details, but note that the “step_increment” and “page_increment” 69 * fields are only effective if the policy causes scrollbars to be present. 70 * 71 * If a GtkScrolledWindow doesn’t behave quite as you would like, or 72 * doesn’t have exactly the right layout, it’s very possible to set up 73 * your own scrolling with #GtkScrollbar and for example a #GtkGrid. 74 * 75 * # Touch support 76 * 77 * GtkScrolledWindow has built-in support for touch devices. When a 78 * touchscreen is used, swiping will move the scrolled window, and will 79 * expose 'kinetic' behavior. This can be turned off with the 80 * #GtkScrolledWindow:kinetic-scrolling property if it is undesired. 81 * 82 * GtkScrolledWindow also displays visual 'overshoot' indication when 83 * the content is pulled beyond the end, and this situation can be 84 * captured with the #GtkScrolledWindow::edge-overshot signal. 85 * 86 * If no mouse device is present, the scrollbars will overlayed as 87 * narrow, auto-hiding indicators over the content. If traditional 88 * scrollbars are desired although no mouse is present, this behaviour 89 * can be turned off with the #GtkScrolledWindow:overlay-scrolling 90 * property. 91 * 92 * # CSS nodes 93 * 94 * GtkScrolledWindow has a main CSS node with name scrolledwindow. 95 * 96 * It uses subnodes with names overshoot and undershoot to 97 * draw the overflow and underflow indications. These nodes get 98 * the .left, .right, .top or .bottom style class added depending 99 * on where the indication is drawn. 100 * 101 * GtkScrolledWindow also sets the positional style classes (.left, 102 * .right, .top, .bottom) and style classes related to overlay 103 * scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars. 104 * 105 * If both scrollbars are visible, the area where they meet is drawn 106 * with a subnode named junction. 107 */ 108 public class ScrolledWindow : Bin 109 { 110 /** the main Gtk struct */ 111 protected GtkScrolledWindow* gtkScrolledWindow; 112 113 /** Get the main Gtk struct */ 114 public GtkScrolledWindow* getScrolledWindowStruct(bool transferOwnership = false) 115 { 116 if (transferOwnership) 117 ownedRef = false; 118 return gtkScrolledWindow; 119 } 120 121 /** the main Gtk struct as a void* */ 122 protected override void* getStruct() 123 { 124 return cast(void*)gtkScrolledWindow; 125 } 126 127 protected override void setStruct(GObject* obj) 128 { 129 gtkScrolledWindow = cast(GtkScrolledWindow*)obj; 130 super.setStruct(obj); 131 } 132 133 /** 134 * Sets our main struct and passes it to the parent class. 135 */ 136 public this (GtkScrolledWindow* gtkScrolledWindow, bool ownedRef = false) 137 { 138 this.gtkScrolledWindow = gtkScrolledWindow; 139 super(cast(GtkBin*)gtkScrolledWindow, ownedRef); 140 } 141 142 /** */ 143 public this() 144 { 145 this(null, null); 146 } 147 148 /** */ 149 public this(Widget widget) 150 { 151 this(); 152 add(widget); 153 } 154 155 /** 156 * Creates a new Scrolled window and set the policy type 157 * Params: 158 * hPolicy = the horizontal policy 159 * vPolicy = the vertical policy 160 */ 161 this(PolicyType hPolicy, PolicyType vPolicy) 162 { 163 this(); 164 setPolicy(hPolicy, vPolicy); 165 } 166 167 /** 168 */ 169 170 /** */ 171 public static GType getType() 172 { 173 return gtk_scrolled_window_get_type(); 174 } 175 176 /** 177 * Creates a new scrolled window. 178 * 179 * The two arguments are the scrolled window’s adjustments; these will be 180 * shared with the scrollbars and the child widget to keep the bars in sync 181 * with the child. Usually you want to pass %NULL for the adjustments, which 182 * will cause the scrolled window to create them for you. 183 * 184 * Params: 185 * hadjustment = horizontal adjustment 186 * vadjustment = vertical adjustment 187 * 188 * Returns: a new scrolled window 189 * 190 * Throws: ConstructionException GTK+ fails to create the object. 191 */ 192 public this(Adjustment hadjustment, Adjustment vadjustment) 193 { 194 auto p = gtk_scrolled_window_new((hadjustment is null) ? null : hadjustment.getAdjustmentStruct(), (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 195 196 if(p is null) 197 { 198 throw new ConstructionException("null returned by new"); 199 } 200 201 this(cast(GtkScrolledWindow*) p); 202 } 203 204 /** 205 * Used to add children without native scrolling capabilities. This 206 * is simply a convenience function; it is equivalent to adding the 207 * unscrollable child to a viewport, then adding the viewport to the 208 * scrolled window. If a child has native scrolling, use 209 * gtk_container_add() instead of this function. 210 * 211 * The viewport scrolls the child by moving its #GdkWindow, and takes 212 * the size of the child to be the size of its toplevel #GdkWindow. 213 * This will be very wrong for most widgets that support native scrolling; 214 * for example, if you add a widget such as #GtkTreeView with a viewport, 215 * the whole widget will scroll, including the column headings. Thus, 216 * widgets with native scrolling support should not be used with the 217 * #GtkViewport proxy. 218 * 219 * A widget supports scrolling natively if it implements the 220 * #GtkScrollable interface. 221 * 222 * Deprecated: gtk_container_add() will automatically add 223 * a #GtkViewport if the child doesn’t implement #GtkScrollable. 224 * 225 * Params: 226 * child = the widget you want to scroll 227 */ 228 public void addWithViewport(Widget child) 229 { 230 gtk_scrolled_window_add_with_viewport(gtkScrolledWindow, (child is null) ? null : child.getWidgetStruct()); 231 } 232 233 /** 234 * Return whether button presses are captured during kinetic 235 * scrolling. See gtk_scrolled_window_set_capture_button_press(). 236 * 237 * Returns: %TRUE if button presses are captured during kinetic scrolling 238 * 239 * Since: 3.4 240 */ 241 public bool getCaptureButtonPress() 242 { 243 return gtk_scrolled_window_get_capture_button_press(gtkScrolledWindow) != 0; 244 } 245 246 /** 247 * Returns the horizontal scrollbar’s adjustment, used to connect the 248 * horizontal scrollbar to the child widget’s horizontal scroll 249 * functionality. 250 * 251 * Returns: the horizontal #GtkAdjustment 252 */ 253 public Adjustment getHadjustment() 254 { 255 auto p = gtk_scrolled_window_get_hadjustment(gtkScrolledWindow); 256 257 if(p is null) 258 { 259 return null; 260 } 261 262 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 263 } 264 265 /** 266 * Returns the horizontal scrollbar of @scrolled_window. 267 * 268 * Returns: the horizontal scrollbar of the scrolled window. 269 * 270 * Since: 2.8 271 */ 272 public Widget getHscrollbar() 273 { 274 auto p = gtk_scrolled_window_get_hscrollbar(gtkScrolledWindow); 275 276 if(p is null) 277 { 278 return null; 279 } 280 281 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 282 } 283 284 /** 285 * Returns the specified kinetic scrolling behavior. 286 * 287 * Returns: the scrolling behavior flags. 288 * 289 * Since: 3.4 290 */ 291 public bool getKineticScrolling() 292 { 293 return gtk_scrolled_window_get_kinetic_scrolling(gtkScrolledWindow) != 0; 294 } 295 296 /** 297 * Returns the maximum content height set. 298 * 299 * Returns: the maximum content height, or -1 300 * 301 * Since: 3.22 302 */ 303 public int getMaxContentHeight() 304 { 305 return gtk_scrolled_window_get_max_content_height(gtkScrolledWindow); 306 } 307 308 /** 309 * Returns the maximum content width set. 310 * 311 * Returns: the maximum content width, or -1 312 * 313 * Since: 3.22 314 */ 315 public int getMaxContentWidth() 316 { 317 return gtk_scrolled_window_get_max_content_width(gtkScrolledWindow); 318 } 319 320 /** 321 * Gets the minimal content height of @scrolled_window, or -1 if not set. 322 * 323 * Returns: the minimal content height 324 * 325 * Since: 3.0 326 */ 327 public int getMinContentHeight() 328 { 329 return gtk_scrolled_window_get_min_content_height(gtkScrolledWindow); 330 } 331 332 /** 333 * Gets the minimum content width of @scrolled_window, or -1 if not set. 334 * 335 * Returns: the minimum content width 336 * 337 * Since: 3.0 338 */ 339 public int getMinContentWidth() 340 { 341 return gtk_scrolled_window_get_min_content_width(gtkScrolledWindow); 342 } 343 344 /** 345 * Returns whether overlay scrolling is enabled for this scrolled window. 346 * 347 * Returns: %TRUE if overlay scrolling is enabled 348 * 349 * Since: 3.16 350 */ 351 public bool getOverlayScrolling() 352 { 353 return gtk_scrolled_window_get_overlay_scrolling(gtkScrolledWindow) != 0; 354 } 355 356 /** 357 * Gets the placement of the contents with respect to the scrollbars 358 * for the scrolled window. See gtk_scrolled_window_set_placement(). 359 * 360 * Returns: the current placement value. 361 * 362 * See also gtk_scrolled_window_set_placement() and 363 * gtk_scrolled_window_unset_placement(). 364 */ 365 public GtkCornerType getPlacement() 366 { 367 return gtk_scrolled_window_get_placement(gtkScrolledWindow); 368 } 369 370 /** 371 * Retrieves the current policy values for the horizontal and vertical 372 * scrollbars. See gtk_scrolled_window_set_policy(). 373 * 374 * Params: 375 * hscrollbarPolicy = location to store the policy 376 * for the horizontal scrollbar, or %NULL 377 * vscrollbarPolicy = location to store the policy 378 * for the vertical scrollbar, or %NULL 379 */ 380 public void getPolicy(out GtkPolicyType hscrollbarPolicy, out GtkPolicyType vscrollbarPolicy) 381 { 382 gtk_scrolled_window_get_policy(gtkScrolledWindow, &hscrollbarPolicy, &vscrollbarPolicy); 383 } 384 385 /** 386 * Reports whether the natural height of the child will be calculated and propagated 387 * through the scrolled windows requested natural height. 388 * 389 * Returns: whether natural height propagation is enabled. 390 * 391 * Since: 3.22 392 */ 393 public bool getPropagateNaturalHeight() 394 { 395 return gtk_scrolled_window_get_propagate_natural_height(gtkScrolledWindow) != 0; 396 } 397 398 /** 399 * Reports whether the natural width of the child will be calculated and propagated 400 * through the scrolled windows requested natural width. 401 * 402 * Returns: whether natural width propagation is enabled. 403 * 404 * Since: 3.22 405 */ 406 public bool getPropagateNaturalWidth() 407 { 408 return gtk_scrolled_window_get_propagate_natural_width(gtkScrolledWindow) != 0; 409 } 410 411 /** 412 * Gets the shadow type of the scrolled window. See 413 * gtk_scrolled_window_set_shadow_type(). 414 * 415 * Returns: the current shadow type 416 */ 417 public GtkShadowType getShadowType() 418 { 419 return gtk_scrolled_window_get_shadow_type(gtkScrolledWindow); 420 } 421 422 /** 423 * Returns the vertical scrollbar’s adjustment, used to connect the 424 * vertical scrollbar to the child widget’s vertical scroll functionality. 425 * 426 * Returns: the vertical #GtkAdjustment 427 */ 428 public Adjustment getVadjustment() 429 { 430 auto p = gtk_scrolled_window_get_vadjustment(gtkScrolledWindow); 431 432 if(p is null) 433 { 434 return null; 435 } 436 437 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 438 } 439 440 /** 441 * Returns the vertical scrollbar of @scrolled_window. 442 * 443 * Returns: the vertical scrollbar of the scrolled window. 444 * 445 * Since: 2.8 446 */ 447 public Widget getVscrollbar() 448 { 449 auto p = gtk_scrolled_window_get_vscrollbar(gtkScrolledWindow); 450 451 if(p is null) 452 { 453 return null; 454 } 455 456 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 457 } 458 459 /** 460 * Changes the behaviour of @scrolled_window with regard to the initial 461 * event that possibly starts kinetic scrolling. When @capture_button_press 462 * is set to %TRUE, the event is captured by the scrolled window, and 463 * then later replayed if it is meant to go to the child widget. 464 * 465 * This should be enabled if any child widgets perform non-reversible 466 * actions on #GtkWidget::button-press-event. If they don't, and handle 467 * additionally handle #GtkWidget::grab-broken-event, it might be better 468 * to set @capture_button_press to %FALSE. 469 * 470 * This setting only has an effect if kinetic scrolling is enabled. 471 * 472 * Params: 473 * captureButtonPress = %TRUE to capture button presses 474 * 475 * Since: 3.4 476 */ 477 public void setCaptureButtonPress(bool captureButtonPress) 478 { 479 gtk_scrolled_window_set_capture_button_press(gtkScrolledWindow, captureButtonPress); 480 } 481 482 /** 483 * Sets the #GtkAdjustment for the horizontal scrollbar. 484 * 485 * Params: 486 * hadjustment = horizontal scroll adjustment 487 */ 488 public void setHadjustment(Adjustment hadjustment) 489 { 490 gtk_scrolled_window_set_hadjustment(gtkScrolledWindow, (hadjustment is null) ? null : hadjustment.getAdjustmentStruct()); 491 } 492 493 /** 494 * Turns kinetic scrolling on or off. 495 * Kinetic scrolling only applies to devices with source 496 * %GDK_SOURCE_TOUCHSCREEN. 497 * 498 * Params: 499 * kineticScrolling = %TRUE to enable kinetic scrolling 500 * 501 * Since: 3.4 502 */ 503 public void setKineticScrolling(bool kineticScrolling) 504 { 505 gtk_scrolled_window_set_kinetic_scrolling(gtkScrolledWindow, kineticScrolling); 506 } 507 508 /** 509 * Sets the maximum height that @scrolled_window should keep visible. The 510 * @scrolled_window will grow up to this height before it starts scrolling 511 * the content. 512 * 513 * It is a programming error to set the maximum content height to a value 514 * smaller than #GtkScrolledWindow:min-content-height. 515 * 516 * Params: 517 * height = the maximum content height 518 * 519 * Since: 3.22 520 */ 521 public void setMaxContentHeight(int height) 522 { 523 gtk_scrolled_window_set_max_content_height(gtkScrolledWindow, height); 524 } 525 526 /** 527 * Sets the maximum width that @scrolled_window should keep visible. The 528 * @scrolled_window will grow up to this width before it starts scrolling 529 * the content. 530 * 531 * It is a programming error to set the maximum content width to a value 532 * smaller than #GtkScrolledWindow:min-content-width. 533 * 534 * Params: 535 * width = the maximum content width 536 * 537 * Since: 3.22 538 */ 539 public void setMaxContentWidth(int width) 540 { 541 gtk_scrolled_window_set_max_content_width(gtkScrolledWindow, width); 542 } 543 544 /** 545 * Sets the minimum height that @scrolled_window should keep visible. 546 * Note that this can and (usually will) be smaller than the minimum 547 * size of the content. 548 * 549 * It is a programming error to set the minimum content height to a 550 * value greater than #GtkScrolledWindow:max-content-height. 551 * 552 * Params: 553 * height = the minimal content height 554 * 555 * Since: 3.0 556 */ 557 public void setMinContentHeight(int height) 558 { 559 gtk_scrolled_window_set_min_content_height(gtkScrolledWindow, height); 560 } 561 562 /** 563 * Sets the minimum width that @scrolled_window should keep visible. 564 * Note that this can and (usually will) be smaller than the minimum 565 * size of the content. 566 * 567 * It is a programming error to set the minimum content width to a 568 * value greater than #GtkScrolledWindow:max-content-width. 569 * 570 * Params: 571 * width = the minimal content width 572 * 573 * Since: 3.0 574 */ 575 public void setMinContentWidth(int width) 576 { 577 gtk_scrolled_window_set_min_content_width(gtkScrolledWindow, width); 578 } 579 580 /** 581 * Enables or disables overlay scrolling for this scrolled window. 582 * 583 * Params: 584 * overlayScrolling = whether to enable overlay scrolling 585 * 586 * Since: 3.16 587 */ 588 public void setOverlayScrolling(bool overlayScrolling) 589 { 590 gtk_scrolled_window_set_overlay_scrolling(gtkScrolledWindow, overlayScrolling); 591 } 592 593 /** 594 * Sets the placement of the contents with respect to the scrollbars 595 * for the scrolled window. 596 * 597 * The default is %GTK_CORNER_TOP_LEFT, meaning the child is 598 * in the top left, with the scrollbars underneath and to the right. 599 * Other values in #GtkCornerType are %GTK_CORNER_TOP_RIGHT, 600 * %GTK_CORNER_BOTTOM_LEFT, and %GTK_CORNER_BOTTOM_RIGHT. 601 * 602 * See also gtk_scrolled_window_get_placement() and 603 * gtk_scrolled_window_unset_placement(). 604 * 605 * Params: 606 * windowPlacement = position of the child window 607 */ 608 public void setPlacement(GtkCornerType windowPlacement) 609 { 610 gtk_scrolled_window_set_placement(gtkScrolledWindow, windowPlacement); 611 } 612 613 /** 614 * Sets the scrollbar policy for the horizontal and vertical scrollbars. 615 * 616 * The policy determines when the scrollbar should appear; it is a value 617 * from the #GtkPolicyType enumeration. If %GTK_POLICY_ALWAYS, the 618 * scrollbar is always present; if %GTK_POLICY_NEVER, the scrollbar is 619 * never present; if %GTK_POLICY_AUTOMATIC, the scrollbar is present only 620 * if needed (that is, if the slider part of the bar would be smaller 621 * than the trough — the display is larger than the page size). 622 * 623 * Params: 624 * hscrollbarPolicy = policy for horizontal bar 625 * vscrollbarPolicy = policy for vertical bar 626 */ 627 public void setPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy) 628 { 629 gtk_scrolled_window_set_policy(gtkScrolledWindow, hscrollbarPolicy, vscrollbarPolicy); 630 } 631 632 /** 633 * Sets whether the natural height of the child should be calculated and propagated 634 * through the scrolled windows requested natural height. 635 * 636 * Params: 637 * propagate = whether to propagate natural height 638 * 639 * Since: 3.22 640 */ 641 public void setPropagateNaturalHeight(bool propagate) 642 { 643 gtk_scrolled_window_set_propagate_natural_height(gtkScrolledWindow, propagate); 644 } 645 646 /** 647 * Sets whether the natural width of the child should be calculated and propagated 648 * through the scrolled windows requested natural width. 649 * 650 * Params: 651 * propagate = whether to propagate natural width 652 * 653 * Since: 3.22 654 */ 655 public void setPropagateNaturalWidth(bool propagate) 656 { 657 gtk_scrolled_window_set_propagate_natural_width(gtkScrolledWindow, propagate); 658 } 659 660 /** 661 * Changes the type of shadow drawn around the contents of 662 * @scrolled_window. 663 * 664 * Params: 665 * type = kind of shadow to draw around scrolled window contents 666 */ 667 public void setShadowType(GtkShadowType type) 668 { 669 gtk_scrolled_window_set_shadow_type(gtkScrolledWindow, type); 670 } 671 672 /** 673 * Sets the #GtkAdjustment for the vertical scrollbar. 674 * 675 * Params: 676 * vadjustment = vertical scroll adjustment 677 */ 678 public void setVadjustment(Adjustment vadjustment) 679 { 680 gtk_scrolled_window_set_vadjustment(gtkScrolledWindow, (vadjustment is null) ? null : vadjustment.getAdjustmentStruct()); 681 } 682 683 /** 684 * Unsets the placement of the contents with respect to the scrollbars 685 * for the scrolled window. If no window placement is set for a scrolled 686 * window, it defaults to %GTK_CORNER_TOP_LEFT. 687 * 688 * See also gtk_scrolled_window_set_placement() and 689 * gtk_scrolled_window_get_placement(). 690 * 691 * Since: 2.10 692 */ 693 public void unsetPlacement() 694 { 695 gtk_scrolled_window_unset_placement(gtkScrolledWindow); 696 } 697 698 protected class OnEdgeOvershotDelegateWrapper 699 { 700 void delegate(GtkPositionType, ScrolledWindow) dlg; 701 gulong handlerId; 702 703 this(void delegate(GtkPositionType, ScrolledWindow) dlg) 704 { 705 this.dlg = dlg; 706 onEdgeOvershotListeners ~= this; 707 } 708 709 void remove(OnEdgeOvershotDelegateWrapper source) 710 { 711 foreach(index, wrapper; onEdgeOvershotListeners) 712 { 713 if (wrapper.handlerId == source.handlerId) 714 { 715 onEdgeOvershotListeners[index] = null; 716 onEdgeOvershotListeners = std.algorithm.remove(onEdgeOvershotListeners, index); 717 break; 718 } 719 } 720 } 721 } 722 OnEdgeOvershotDelegateWrapper[] onEdgeOvershotListeners; 723 724 /** 725 * The ::edge-overshot signal is emitted whenever user initiated scrolling 726 * makes the scrolledwindow firmly surpass (ie. with some edge resistance) 727 * the lower or upper limits defined by the adjustment in that orientation. 728 * 729 * A similar behavior without edge resistance is provided by the 730 * #GtkScrolledWindow::edge-reached signal. 731 * 732 * Note: The @pos argument is LTR/RTL aware, so callers should be aware too 733 * if intending to provide behavior on horizontal edges. 734 * 735 * Params: 736 * pos = edge side that was hit 737 * 738 * Since: 3.16 739 */ 740 gulong addOnEdgeOvershot(void delegate(GtkPositionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 741 { 742 auto wrapper = new OnEdgeOvershotDelegateWrapper(dlg); 743 wrapper.handlerId = Signals.connectData( 744 this, 745 "edge-overshot", 746 cast(GCallback)&callBackEdgeOvershot, 747 cast(void*)wrapper, 748 cast(GClosureNotify)&callBackEdgeOvershotDestroy, 749 connectFlags); 750 return wrapper.handlerId; 751 } 752 753 extern(C) static void callBackEdgeOvershot(GtkScrolledWindow* scrolledwindowStruct, GtkPositionType pos, OnEdgeOvershotDelegateWrapper wrapper) 754 { 755 wrapper.dlg(pos, wrapper.outer); 756 } 757 758 extern(C) static void callBackEdgeOvershotDestroy(OnEdgeOvershotDelegateWrapper wrapper, GClosure* closure) 759 { 760 wrapper.remove(wrapper); 761 } 762 763 protected class OnEdgeReachedDelegateWrapper 764 { 765 void delegate(GtkPositionType, ScrolledWindow) dlg; 766 gulong handlerId; 767 768 this(void delegate(GtkPositionType, ScrolledWindow) dlg) 769 { 770 this.dlg = dlg; 771 onEdgeReachedListeners ~= this; 772 } 773 774 void remove(OnEdgeReachedDelegateWrapper source) 775 { 776 foreach(index, wrapper; onEdgeReachedListeners) 777 { 778 if (wrapper.handlerId == source.handlerId) 779 { 780 onEdgeReachedListeners[index] = null; 781 onEdgeReachedListeners = std.algorithm.remove(onEdgeReachedListeners, index); 782 break; 783 } 784 } 785 } 786 } 787 OnEdgeReachedDelegateWrapper[] onEdgeReachedListeners; 788 789 /** 790 * The ::edge-reached signal is emitted whenever user-initiated scrolling 791 * makes the scrolledwindow exactly reaches the lower or upper limits 792 * defined by the adjustment in that orientation. 793 * 794 * A similar behavior with edge resistance is provided by the 795 * #GtkScrolledWindow::edge-overshot signal. 796 * 797 * Note: The @pos argument is LTR/RTL aware, so callers should be aware too 798 * if intending to provide behavior on horizontal edges. 799 * 800 * Params: 801 * pos = edge side that was reached 802 * 803 * Since: 3.16 804 */ 805 gulong addOnEdgeReached(void delegate(GtkPositionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 806 { 807 auto wrapper = new OnEdgeReachedDelegateWrapper(dlg); 808 wrapper.handlerId = Signals.connectData( 809 this, 810 "edge-reached", 811 cast(GCallback)&callBackEdgeReached, 812 cast(void*)wrapper, 813 cast(GClosureNotify)&callBackEdgeReachedDestroy, 814 connectFlags); 815 return wrapper.handlerId; 816 } 817 818 extern(C) static void callBackEdgeReached(GtkScrolledWindow* scrolledwindowStruct, GtkPositionType pos, OnEdgeReachedDelegateWrapper wrapper) 819 { 820 wrapper.dlg(pos, wrapper.outer); 821 } 822 823 extern(C) static void callBackEdgeReachedDestroy(OnEdgeReachedDelegateWrapper wrapper, GClosure* closure) 824 { 825 wrapper.remove(wrapper); 826 } 827 828 protected class OnMoveFocusOutDelegateWrapper 829 { 830 void delegate(GtkDirectionType, ScrolledWindow) dlg; 831 gulong handlerId; 832 833 this(void delegate(GtkDirectionType, ScrolledWindow) dlg) 834 { 835 this.dlg = dlg; 836 onMoveFocusOutListeners ~= this; 837 } 838 839 void remove(OnMoveFocusOutDelegateWrapper source) 840 { 841 foreach(index, wrapper; onMoveFocusOutListeners) 842 { 843 if (wrapper.handlerId == source.handlerId) 844 { 845 onMoveFocusOutListeners[index] = null; 846 onMoveFocusOutListeners = std.algorithm.remove(onMoveFocusOutListeners, index); 847 break; 848 } 849 } 850 } 851 } 852 OnMoveFocusOutDelegateWrapper[] onMoveFocusOutListeners; 853 854 /** 855 * The ::move-focus-out signal is a 856 * [keybinding signal][GtkBindingSignal] which gets 857 * emitted when focus is moved away from the scrolled window by a 858 * keybinding. The #GtkWidget::move-focus signal is emitted with 859 * @direction_type on this scrolled windows toplevel parent in the 860 * container hierarchy. The default bindings for this signal are 861 * `Tab + Ctrl` and `Tab + Ctrl + Shift`. 862 * 863 * Params: 864 * directionType = either %GTK_DIR_TAB_FORWARD or 865 * %GTK_DIR_TAB_BACKWARD 866 */ 867 gulong addOnMoveFocusOut(void delegate(GtkDirectionType, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 868 { 869 auto wrapper = new OnMoveFocusOutDelegateWrapper(dlg); 870 wrapper.handlerId = Signals.connectData( 871 this, 872 "move-focus-out", 873 cast(GCallback)&callBackMoveFocusOut, 874 cast(void*)wrapper, 875 cast(GClosureNotify)&callBackMoveFocusOutDestroy, 876 connectFlags); 877 return wrapper.handlerId; 878 } 879 880 extern(C) static void callBackMoveFocusOut(GtkScrolledWindow* scrolledwindowStruct, GtkDirectionType directionType, OnMoveFocusOutDelegateWrapper wrapper) 881 { 882 wrapper.dlg(directionType, wrapper.outer); 883 } 884 885 extern(C) static void callBackMoveFocusOutDestroy(OnMoveFocusOutDelegateWrapper wrapper, GClosure* closure) 886 { 887 wrapper.remove(wrapper); 888 } 889 890 protected class OnScrollChildDelegateWrapper 891 { 892 bool delegate(GtkScrollType, bool, ScrolledWindow) dlg; 893 gulong handlerId; 894 895 this(bool delegate(GtkScrollType, bool, ScrolledWindow) dlg) 896 { 897 this.dlg = dlg; 898 onScrollChildListeners ~= this; 899 } 900 901 void remove(OnScrollChildDelegateWrapper source) 902 { 903 foreach(index, wrapper; onScrollChildListeners) 904 { 905 if (wrapper.handlerId == source.handlerId) 906 { 907 onScrollChildListeners[index] = null; 908 onScrollChildListeners = std.algorithm.remove(onScrollChildListeners, index); 909 break; 910 } 911 } 912 } 913 } 914 OnScrollChildDelegateWrapper[] onScrollChildListeners; 915 916 /** 917 * The ::scroll-child signal is a 918 * [keybinding signal][GtkBindingSignal] 919 * which gets emitted when a keybinding that scrolls is pressed. 920 * The horizontal or vertical adjustment is updated which triggers a 921 * signal that the scrolled windows child may listen to and scroll itself. 922 * 923 * Params: 924 * scroll = a #GtkScrollType describing how much to scroll 925 * horizontal = whether the keybinding scrolls the child 926 * horizontally or not 927 */ 928 gulong addOnScrollChild(bool delegate(GtkScrollType, bool, ScrolledWindow) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 929 { 930 auto wrapper = new OnScrollChildDelegateWrapper(dlg); 931 wrapper.handlerId = Signals.connectData( 932 this, 933 "scroll-child", 934 cast(GCallback)&callBackScrollChild, 935 cast(void*)wrapper, 936 cast(GClosureNotify)&callBackScrollChildDestroy, 937 connectFlags); 938 return wrapper.handlerId; 939 } 940 941 extern(C) static int callBackScrollChild(GtkScrolledWindow* scrolledwindowStruct, GtkScrollType scroll, bool horizontal, OnScrollChildDelegateWrapper wrapper) 942 { 943 return wrapper.dlg(scroll, horizontal, wrapper.outer); 944 } 945 946 extern(C) static void callBackScrollChildDestroy(OnScrollChildDelegateWrapper wrapper, GClosure* closure) 947 { 948 wrapper.remove(wrapper); 949 } 950 }