gtk.scrolled_window
Module for [ScrolledWindow] class
Types 3
gtk.scrolled_window.ScrolledWindow is a container that makes its child scrollable.
It does so using either internally added scrollbars or externally associated adjustments, and optionally draws a frame around the child.
Widgets with native scrolling support, i.e. those whose classes implement the gtk.scrollable.Scrollable interface, are added directly. For other types of widget, the class gtk.viewport.Viewport acts as an adaptor, giving scrollability to other widgets. gtk.scrolled_window.ScrolledWindow.setChild intelligently accounts for whether or not the added child is a gtk.scrollable.Scrollable. If it isn’t, then it wraps the child in a gtk.viewport.Viewport. Therefore, you can just add any child widget and not worry about the details.
If gtk.scrolled_window.ScrolledWindow.setChild has added a gtk.viewport.Viewport for you, it will be automatically removed when you unset the child. Unless gtk.scrolled_window.ScrolledWindow.hscrollbarPolicy and gtk.scrolled_window.ScrolledWindow.vscrollbarPolicy are gtk.types.PolicyType.Never or gtk.types.PolicyType.External, gtk.scrolled_window.ScrolledWindow adds internal gtk.scrollbar.Scrollbar widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the gtk.scrolled_window.ScrolledWindow.hadjustment and gtk.scrolled_window.ScrolledWindow.vadjustment that are associated with the gtk.scrolled_window.ScrolledWindow. See the docs on gtk.scrollbar.Scrollbar for the details, but note that the “step_increment” and “page_increment” fields are only effective if the policy causes scrollbars to be present.
If a gtk.scrolled_window.ScrolledWindow doesn’t behave quite as you would like, or doesn’t have exactly the right layout, it’s very possible to set up your own scrolling with gtk.scrollbar.Scrollbar and for example a gtk.grid.Grid.
Touch support
gtk.scrolled_window.ScrolledWindow has built-in support for touch devices. When a touchscreen is used, swiping will move the scrolled window, and will expose 'kinetic' behavior. This can be turned off with the gtk.scrolled_window.ScrolledWindow.kineticScrolling property if it is undesired.
gtk.scrolled_window.ScrolledWindow also displays visual 'overshoot' indication when the content is pulled beyond the end, and this situation can be captured with the gtk.scrolled_window.ScrolledWindow.edgeOvershot signal.
If no mouse device is present, the scrollbars will overlaid as narrow, auto-hiding indicators over the content. If traditional scrollbars are desired although no mouse is present, this behaviour can be turned off with the gtk.scrolled_window.ScrolledWindow.overlayScrolling property.
CSS nodes
gtk.scrolled_window.ScrolledWindow has a main CSS node with name scrolledwindow. It gets a .frame style class added when gtk.scrolled_window.ScrolledWindow.hasFrame is true.
It uses subnodes with names overshoot and undershoot to draw the overflow and underflow indications. These nodes get the .left, .right, .top or .bottom style class added depending on where the indication is drawn.
gtk.scrolled_window.ScrolledWindow also sets the positional style classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars.
If both scrollbars are visible, the area where they meet is drawn with a subnode named junction.
Accessibility
Until GTK 4.10, gtk.scrolled_window.ScrolledWindow used the gtk.types.AccessibleRole.Group role.
Starting from GTK 4.12, gtk.scrolled_window.ScrolledWindow uses the gtk.types.AccessibleRole.Generic role.
ScrolledWindowGidBuilder builder() static nothrowGet builder for [gtk.scrolled_window.ScrolledWindow] Returns: New builder objectvoid child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.bool hasFrame() @property nothrowGet `hasFrame` property. Returns: Whether to draw a frame around the contents.void hasFrame(bool propval) @property nothrowSet `hasFrame` property. Params: propval = Whether to draw a frame around the contents.gtk.types.PolicyType hscrollbarPolicy() @property nothrowGet `hscrollbarPolicy` property. Returns: When the horizontal scrollbar is displayed.void hscrollbarPolicy(gtk.types.PolicyType propval) @property nothrowSet `hscrollbarPolicy` property. Params: propval = When the horizontal scrollbar is displayed.bool kineticScrolling() @property nothrowGet `kineticScrolling` property. Returns: Whether kinetic scrolling is enabled or not.void kineticScrolling(bool propval) @property nothrowSet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not.int maxContentHeight() @property nothrowGet `maxContentHeight` property. Returns: The maximum content height of @scrolled_window.void maxContentHeight(int propval) @property nothrowSet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window.int maxContentWidth() @property nothrowGet `maxContentWidth` property. Returns: The maximum content width of @scrolled_window.void maxContentWidth(int propval) @property nothrowSet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window.int minContentHeight() @property nothrowGet `minContentHeight` property. Returns: The minimum content height of @scrolled_window.void minContentHeight(int propval) @property nothrowSet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window.int minContentWidth() @property nothrowGet `minContentWidth` property. Returns: The minimum content width of @scrolled_window.void minContentWidth(int propval) @property nothrowSet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window.bool overlayScrolling() @property nothrowGet `overlayScrolling` property. Returns: Whether overlay scrolling is enabled or not.void overlayScrolling(bool propval) @property nothrowSet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not.bool propagateNaturalHeight() @property nothrowGet `propagateNaturalHeight` property. Returns: Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void propagateNaturalHeight(bool propval) @property nothrowSet `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.bool propagateNaturalWidth() @property nothrowGet `propagateNaturalWidth` property. Returns: Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void propagateNaturalWidth(bool propval) @property nothrowSet `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.gtk.types.PolicyType vscrollbarPolicy() @property nothrowGet `vscrollbarPolicy` property. Returns: When the vertical scrollbar is displayed.void vscrollbarPolicy(gtk.types.PolicyType propval) @property nothrowSet `vscrollbarPolicy` property. Params: propval = When the vertical scrollbar is displayed.gtk.types.CornerType windowPlacement() @property nothrowGet `windowPlacement` property. Returns: Where the contents are located with respect to the scrollbars.void windowPlacement(gtk.types.CornerType propval) @property nothrowSet `windowPlacement` property. Params: propval = Where the contents are located with respect to the scrollbars.bool getHasFrame() nothrowGets whether the scrolled window draws a frame. Returns: true if the scrolled_window has a framegtk.widget.Widget getHscrollbar() nothrowReturns the horizontal scrollbar of scrolled_window. Returns: the horizontal scrollbar of the scrolled window.bool getKineticScrolling() nothrowReturns the specified kinetic scrolling behavior. Returns: the scrolling behavior flags.int getMaxContentHeight() nothrowReturns the maximum content height set. Returns: the maximum content height, or -1int getMaxContentWidth() nothrowReturns the maximum content width set. Returns: the maximum content width, or -1int getMinContentHeight() nothrowGets the minimal content height of scrolled_window. Returns: the minimal content heightint getMinContentWidth() nothrowGets the minimum content width of scrolled_window. Returns: the minimum content widthbool getOverlayScrolling() nothrowReturns whether overlay scrolling is enabled for this scrolled window. Returns: true if overlay scrolling is enabledgtk.types.CornerType getPlacement() nothrowGets the placement of the contents with respect to the scrollbars. Returns: the current placement value.void getPolicy(out gtk.types.PolicyType hscrollbarPolicy, out gtk.types.PolicyType vscrollbarPolicy) nothrowRetrieves the current policy values for the horizontal and vertical scrollbars.bool getPropagateNaturalHeight() nothrowReports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height. Returns: whether natural height propagation is enabled.bool getPropagateNaturalWidth() nothrowReports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width. Returns: whether natural width propagation is enabled.gtk.widget.Widget getVscrollbar() nothrowReturns the vertical scrollbar of scrolled_window. Returns: the vertical scrollbar of the scrolled window.void setHadjustment(gtk.adjustment.Adjustment hadjustment = null) nothrowSets the [gtk.adjustment.Adjustment] for the horizontal scrollbar.void setHasFrame(bool hasFrame) nothrowChanges the frame drawn around the contents of scrolled_window.void setMaxContentHeight(int height) nothrowSets the maximum height that scrolled_window should keep visible.void setMaxContentWidth(int width) nothrowSets the maximum width that scrolled_window should keep visible.void setMinContentHeight(int height) nothrowSets the minimum height that scrolled_window should keep visible.void setMinContentWidth(int width) nothrowSets the minimum width that scrolled_window should keep visible.void setOverlayScrolling(bool overlayScrolling) nothrowEnables or disables overlay scrolling for this scrolled window.void setPlacement(gtk.types.CornerType windowPlacement) nothrowSets the placement of the contents with respect to the scrollbars for the scrolled window.void setPolicy(gtk.types.PolicyType hscrollbarPolicy, gtk.types.PolicyType vscrollbarPolicy) nothrowSets the scrollbar policy for the horizontal and vertical scrollbars.void setPropagateNaturalHeight(bool propagate) nothrowSets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void setPropagateNaturalWidth(bool propagate) nothrowSets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void setVadjustment(gtk.adjustment.Adjustment vadjustment = null) nothrowSets the [gtk.adjustment.Adjustment] for the vertical scrollbar.gulong connectEdgeOvershot(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3) nothrowConnect to `EdgeOvershot` signal.gulong connectEdgeReached(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3) nothrowConnect to `EdgeReached` signal.gulong connectMoveFocusOut(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.DirectionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3) nothrowConnect to `MoveFocusOut` signal.gulong connectScrollChild(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.ScrollType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == bool)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 4) nothrowConnect to `ScrollChild` signal.Fluent builder implementation template for gtk.scrolled_window.ScrolledWindow
T hadjustment(gtk.adjustment.Adjustment propval) nothrowT hasFrame(bool propval) nothrowSet `hasFrame` property. Params: propval = Whether to draw a frame around the contents. Returns: Builder instance for fluent chainingT hscrollbarPolicy(gtk.types.PolicyType propval) nothrowSet `hscrollbarPolicy` property. Params: propval = When the horizontal scrollbar is displayed.T kineticScrolling(bool propval) nothrowSet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not.T maxContentHeight(int propval) nothrowSet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window. Returns: Builder instance for fluent chainingT maxContentWidth(int propval) nothrowSet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window. Returns: Builder instance for fluent chainingT minContentHeight(int propval) nothrowSet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window. Returns: Builder instance for fluent chainingT minContentWidth(int propval) nothrowSet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window. Returns: Builder instance for fluent chainingT overlayScrolling(bool propval) nothrowSet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not.T propagateNaturalHeight(bool propval) nothrowSet `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.T propagateNaturalWidth(bool propval) nothrowSet `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.T vadjustment(gtk.adjustment.Adjustment propval) nothrowT vscrollbarPolicy(gtk.types.PolicyType propval) nothrowSet `vscrollbarPolicy` property. Params: propval = When the vertical scrollbar is displayed.T windowPlacement(gtk.types.CornerType propval) nothrowSet `windowPlacement` property. Params: propval = Where the contents are located with respect to the scrollbars. Returns: Builder instance for fluent chainingFluent builder for gtk.scrolled_window.ScrolledWindow