gtk.scrolled_window
Module for [ScrolledWindow] class
Types 3
GtkScrolledWindow is a container that accepts a single child widget and makes that child scrollable using either internally added scrollbars or externally associated adjustments.
Widgets with native scrolling support, i.e. those whose classes implement the #GtkScrollable interface, are added directly. For other types of widget, the class #GtkViewport acts as an adaptor, giving scrollability to other widgets. GtkScrolledWindow’s implementation of gtk.container.Container.add intelligently accounts for whether or not the added child is a #GtkScrollable. If it isn’t, #GtkScrolledWindow wraps the child in a #GtkViewport and adds that for you. Therefore, you can just add any child widget and not worry about the details.
If gtk.container.Container.add has added a #GtkViewport for you, you can remove both your added child widget from the #GtkViewport, and the #GtkViewport from the GtkScrolledWindow, like this:
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
GtkWidget *child_widget = gtk_button_new ();
// GtkButton is not a GtkScrollable, so GtkScrolledWindow will automatically
// add a GtkViewport.
gtk_container_add (GTK_CONTAINER (scrolled_window),
child_widget);
// Either of these will result in child_widget being unparented:
gtk_container_remove (GTK_CONTAINER (scrolled_window),
child_widget);
// or
gtk_container_remove (GTK_CONTAINER (scrolled_window),
gtk_bin_get_child (GTK_BIN (scrolled_window)));Unless #GtkScrolledWindow:policy is GTK_POLICY_NEVER or GTK_POLICY_EXTERNAL, GtkScrolledWindow adds internal #GtkScrollbar widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the #GtkScrolledWindow:hadjustment and #GtkScrolledWindow:vadjustment that are associated with the GtkScrolledWindow. See the docs on #GtkScrollbar 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 GtkScrolledWindow 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 #GtkScrollbar and for example a #GtkGrid.
Touch support
GtkScrolledWindow 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 #GtkScrolledWindow:kinetic-scrolling property if it is undesired.
GtkScrolledWindow also displays visual 'overshoot' indication when the content is pulled beyond the end, and this situation can be captured with the #GtkScrolledWindow::edge-overshot signal.
If no mouse device is present, the scrollbars will overlayed 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 #GtkScrolledWindow:overlay-scrolling property.
CSS nodes
GtkScrolledWindow has a main CSS node with name scrolledwindow.
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.
GtkScrolledWindow 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.
ScrolledWindowGidBuilder builder() static nothrowGet builder for [gtk.scrolled_window.ScrolledWindow] Returns: New builder objectbool kineticScrolling() @property nothrowGet `kineticScrolling` property. Returns: Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].void kineticScrolling(bool propval) @property nothrowSet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].int maxContentHeight() @property nothrowGet `maxContentHeight` property. Returns: The maximum content height of @scrolled_window, or -1 if not set.void maxContentHeight(int propval) @property nothrowSet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window, or -1 if not set.int maxContentWidth() @property nothrowGet `maxContentWidth` property. Returns: The maximum content width of @scrolled_window, or -1 if not set.void maxContentWidth(int propval) @property nothrowSet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window, or -1 if not set.int minContentHeight() @property nothrowGet `minContentHeight` property. Returns: The minimum content height of @scrolled_window, or -1 if not set.void minContentHeight(int propval) @property nothrowSet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window, or -1 if not set.int minContentWidth() @property nothrowGet `minContentWidth` property. Returns: The minimum content width of @scrolled_window, or -1 if not set.void minContentWidth(int propval) @property nothrowSet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window, or -1 if not set.bool overlayScrolling() @property nothrowGet `overlayScrolling` property. Returns: Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, they are ov...void overlayScrolling(bool propval) @property nothrowSet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, th...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.bool windowPlacementSet() @property nothrowGet `windowPlacementSet` property. Returns: Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.void windowPlacementSet(bool propval) @property nothrowSet `windowPlacementSet` property. Params: propval = Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.void addWithViewport(gtk.widget.Widget child) nothrowUsed to add children without native scrolling capabilities. This is simply a convenience function; it is equivalent to adding the unscrollable child to a viewport, then adding the viewport to the s...bool getCaptureButtonPress() nothrowReturn whether button presses are captured during kinetic scrolling. See [gtk.scrolled_window.ScrolledWindow.setCaptureButtonPress]. Returns: true if button presses are captured during kinetic scro...gtk.adjustment.Adjustment getHadjustment() nothrowReturns the horizontal scrollbar’s adjustment, used to connect the horizontal scrollbar to the child widget’s horizontal scroll functionality. Returns: the horizontal #GtkAdjustmentgtk.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, or -1 if not set. Returns: the minimal content heightint getMinContentWidth() nothrowGets the minimum content width of scrolled_window, or -1 if not set. 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 for the scrolled window. See [gtk.scrolled_window.ScrolledWindow.setPlacement]. 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. See [gtk.scrolled_window.ScrolledWindow.setPolicy].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.types.ShadowType getShadowType() nothrowGets the shadow type of the scrolled window. See [gtk.scrolled_window.ScrolledWindow.setShadowType]. Returns: the current shadow typegtk.adjustment.Adjustment getVadjustment() nothrowReturns the vertical scrollbar’s adjustment, used to connect the vertical scrollbar to the child widget’s vertical scroll functionality. Returns: the vertical #GtkAdjustmentgtk.widget.Widget getVscrollbar() nothrowReturns the vertical scrollbar of scrolled_window. Returns: the vertical scrollbar of the scrolled window.void setCaptureButtonPress(bool captureButtonPress) nothrowChanges the behaviour of scrolled_window with regard to the initial event that possibly starts kinetic scrolling. When capture_button_press is set to true, the event is captured by the scrolled win...void setHadjustment(gtk.adjustment.Adjustment hadjustment = null) nothrowSets the #GtkAdjustment for the horizontal scrollbar.void setKineticScrolling(bool kineticScrolling) nothrowTurns kinetic scrolling on or off. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].void setMaxContentHeight(int height) nothrowSets the maximum height that scrolled_window should keep visible. The scrolled_window will grow up to this height before it starts scrolling the content.void setMaxContentWidth(int width) nothrowSets the maximum width that scrolled_window should keep visible. The scrolled_window will grow up to this width before it starts scrolling the content.void setMinContentHeight(int height) nothrowSets the minimum height that scrolled_window should keep visible. Note that this can and (usually will) be smaller than the minimum size of the content.void setMinContentWidth(int width) nothrowSets the minimum width that scrolled_window should keep visible. Note that this can and (usually will) be smaller than the minimum size of the content.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 setShadowType(gtk.types.ShadowType type) nothrowChanges the type of shadow drawn around the contents of scrolled_window.void setVadjustment(gtk.adjustment.Adjustment vadjustment = null) nothrowSets the #GtkAdjustment for the vertical scrollbar.void unsetPlacement() nothrowUnsets the placement of the contents with respect to the scrollbars for the scrolled window. If no window placement is set for a scrolled window, it defaults to [gtk.types.CornerType.TopLeft].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.this(gtk.adjustment.Adjustment hadjustment = null, gtk.adjustment.Adjustment vadjustment = null)Creates a new scrolled window.Fluent builder implementation template for gtk.scrolled_window.ScrolledWindow
T hadjustment(gtk.adjustment.Adjustment propval) nothrowT hscrollbarPolicy(gtk.types.PolicyType propval) nothrowT kineticScrolling(bool propval) nothrowSet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen]. Returns: B...T maxContentHeight(int propval) nothrowSet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT maxContentWidth(int propval) nothrowSet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT minContentHeight(int propval) nothrowSet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT minContentWidth(int propval) nothrowSet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT overlayScrolling(bool propval) nothrowSet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, th...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 shadowType(gtk.types.ShadowType propval) nothrowT vadjustment(gtk.adjustment.Adjustment propval) nothrowT vscrollbarPolicy(gtk.types.PolicyType propval) nothrowT windowPlacement(gtk.types.CornerType propval) nothrowT windowPlacementSet(bool propval) nothrowSet `windowPlacementSet` property. Params: propval = Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars. Returns: Builder instance fo...Fluent builder for gtk.scrolled_window.ScrolledWindow