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