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