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