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