ScrolledWindow

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.

class ScrolledWindow : Bin {}

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this(gtk.adjustment.Adjustment hadjustment, gtk.adjustment.Adjustment vadjustment)

Creates a new scrolled window.

Members

Functions

addWithViewport
void addWithViewport(gtk.widget.Widget child)

Used 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 scrolled window. If a child has native scrolling, use gtk.container.Container.add instead of this function.

connectEdgeOvershot
gulong connectEdgeOvershot(T callback, Flag!"After" after)

Connect to EdgeOvershot signal.

connectEdgeReached
gulong connectEdgeReached(T callback, Flag!"After" after)

Connect to EdgeReached signal.

connectMoveFocusOut
gulong connectMoveFocusOut(T callback, Flag!"After" after)

Connect to MoveFocusOut signal.

connectScrollChild
gulong connectScrollChild(T callback, Flag!"After" after)

Connect to ScrollChild signal.

getCaptureButtonPress
bool getCaptureButtonPress()

Return whether button presses are captured during kinetic scrolling. See gtk.scrolled_window.ScrolledWindow.setCaptureButtonPress.

getHadjustment
gtk.adjustment.Adjustment getHadjustment()

Returns the horizontal scrollbar’s adjustment, used to connect the horizontal scrollbar to the child widget’s horizontal scroll functionality.

getHscrollbar
gtk.widget.Widget getHscrollbar()

Returns the horizontal scrollbar of scrolled_window.

getKineticScrolling
bool getKineticScrolling()

Returns the specified kinetic scrolling behavior.

getMaxContentHeight
int getMaxContentHeight()

Returns the maximum content height set.

getMaxContentWidth
int getMaxContentWidth()

Returns the maximum content width set.

getMinContentHeight
int getMinContentHeight()

Gets the minimal content height of scrolled_window, or -1 if not set.

getMinContentWidth
int getMinContentWidth()

Gets the minimum content width of scrolled_window, or -1 if not set.

getOverlayScrolling
bool getOverlayScrolling()

Returns whether overlay scrolling is enabled for this scrolled window.

getPlacement
gtk.types.CornerType getPlacement()

Gets the placement of the contents with respect to the scrollbars for the scrolled window. See gtk.scrolled_window.ScrolledWindow.setPlacement.

getPolicy
void getPolicy(gtk.types.PolicyType hscrollbarPolicy, gtk.types.PolicyType vscrollbarPolicy)

Retrieves the current policy values for the horizontal and vertical scrollbars. See gtk.scrolled_window.ScrolledWindow.setPolicy.

getPropagateNaturalHeight
bool getPropagateNaturalHeight()

Reports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height.

getPropagateNaturalWidth
bool getPropagateNaturalWidth()

Reports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width.

getShadowType
gtk.types.ShadowType getShadowType()

Gets the shadow type of the scrolled window. See gtk.scrolled_window.ScrolledWindow.setShadowType.

getVadjustment
gtk.adjustment.Adjustment getVadjustment()

Returns the vertical scrollbar’s adjustment, used to connect the vertical scrollbar to the child widget’s vertical scroll functionality.

getVscrollbar
gtk.widget.Widget getVscrollbar()

Returns the vertical scrollbar of scrolled_window.

self
ScrolledWindow self()

Returns this, for use in with statements.

setCaptureButtonPress
void setCaptureButtonPress(bool captureButtonPress)

Changes 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 window, and then later replayed if it is meant to go to the child widget.

setHadjustment
void setHadjustment(gtk.adjustment.Adjustment hadjustment)

Sets the #GtkAdjustment for the horizontal scrollbar.

setKineticScrolling
void setKineticScrolling(bool kineticScrolling)

Turns kinetic scrolling on or off. Kinetic scrolling only applies to devices with source gdk.types.InputSource.Touchscreen.

setMaxContentHeight
void setMaxContentHeight(int height)

Sets the maximum height that scrolled_window should keep visible. The scrolled_window will grow up to this height before it starts scrolling the content.

setMaxContentWidth
void setMaxContentWidth(int width)

Sets the maximum width that scrolled_window should keep visible. The scrolled_window will grow up to this width before it starts scrolling the content.

setMinContentHeight
void setMinContentHeight(int height)

Sets 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.

setMinContentWidth
void setMinContentWidth(int width)

Sets 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.

setOverlayScrolling
void setOverlayScrolling(bool overlayScrolling)

Enables or disables overlay scrolling for this scrolled window.

setPlacement
void setPlacement(gtk.types.CornerType windowPlacement)

Sets the placement of the contents with respect to the scrollbars for the scrolled window.

setPolicy
void setPolicy(gtk.types.PolicyType hscrollbarPolicy, gtk.types.PolicyType vscrollbarPolicy)

Sets the scrollbar policy for the horizontal and vertical scrollbars.

setPropagateNaturalHeight
void setPropagateNaturalHeight(bool propagate)

Sets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.

setPropagateNaturalWidth
void setPropagateNaturalWidth(bool propagate)

Sets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.

setShadowType
void setShadowType(gtk.types.ShadowType type)

Changes the type of shadow drawn around the contents of scrolled_window.

setVadjustment
void setVadjustment(gtk.adjustment.Adjustment vadjustment)

Sets the #GtkAdjustment for the vertical scrollbar.

unsetPlacement
void unsetPlacement()

Unsets 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.

Properties

_gType
GType _gType [@property getter]
hadjustment
gtk.adjustment.Adjustment hadjustment [@property getter]
hadjustment
gtk.adjustment.Adjustment hadjustment [@property setter]
hscrollbarPolicy
gtk.types.PolicyType hscrollbarPolicy [@property getter]
hscrollbarPolicy
gtk.types.PolicyType hscrollbarPolicy [@property setter]
kineticScrolling
bool kineticScrolling [@property getter]

Get kineticScrolling property.

kineticScrolling
bool kineticScrolling [@property setter]

Set kineticScrolling property.

maxContentHeight
int maxContentHeight [@property getter]

Get maxContentHeight property.

maxContentHeight
int maxContentHeight [@property setter]

Set maxContentHeight property.

maxContentWidth
int maxContentWidth [@property getter]

Get maxContentWidth property.

maxContentWidth
int maxContentWidth [@property setter]

Set maxContentWidth property.

minContentHeight
int minContentHeight [@property getter]

Get minContentHeight property.

minContentHeight
int minContentHeight [@property setter]

Set minContentHeight property.

minContentWidth
int minContentWidth [@property getter]

Get minContentWidth property.

minContentWidth
int minContentWidth [@property setter]

Set minContentWidth property.

overlayScrolling
bool overlayScrolling [@property getter]

Get overlayScrolling property.

overlayScrolling
bool overlayScrolling [@property setter]

Set overlayScrolling property.

propagateNaturalHeight
bool propagateNaturalHeight [@property getter]

Get propagateNaturalHeight property.

propagateNaturalHeight
bool propagateNaturalHeight [@property setter]

Set propagateNaturalHeight property.

propagateNaturalWidth
bool propagateNaturalWidth [@property getter]

Get propagateNaturalWidth property.

propagateNaturalWidth
bool propagateNaturalWidth [@property setter]

Set propagateNaturalWidth property.

shadowType
gtk.types.ShadowType shadowType [@property getter]
shadowType
gtk.types.ShadowType shadowType [@property setter]
vadjustment
gtk.adjustment.Adjustment vadjustment [@property getter]
vadjustment
gtk.adjustment.Adjustment vadjustment [@property setter]
vscrollbarPolicy
gtk.types.PolicyType vscrollbarPolicy [@property getter]
vscrollbarPolicy
gtk.types.PolicyType vscrollbarPolicy [@property setter]
windowPlacement
gtk.types.CornerType windowPlacement [@property getter]
windowPlacement
gtk.types.CornerType windowPlacement [@property setter]
windowPlacementSet
bool windowPlacementSet [@property getter]

Get windowPlacementSet property.

windowPlacementSet
bool windowPlacementSet [@property setter]

Set windowPlacementSet property.

Static functions

_getGType
GType _getGType()
builder
ScrolledWindowGidBuilder builder()

Get builder for gtk.scrolled_window.ScrolledWindow

Inherited Members

From Bin

_getGType
GType _getGType()
_gType
GType _gType [@property getter]
self
Bin self()

Returns this, for use in with statements.

builder
BinGidBuilder builder()

Get builder for gtk.bin.Bin

getChild
gtk.widget.Widget getChild()

Gets the child of the #GtkBin, or null if the bin contains no child widget. The returned widget does not have a reference added, so you do not need to unref it.