ScrolledWindow

GtkScrolledWindow is a #GtkBin subclass: it’s a container the accepts a single child widget. GtkScrolledWindow adds scrollbars to the child widget and optionally draws a beveled frame around the child widget.

The scrolled window can work in two ways. Some widgets have native scrolling support; these widgets implement the #GtkScrollable interface. Widgets with native scroll support include #GtkTreeView, #GtkTextView, and #GtkLayout.

For widgets that lack native scrolling support, the #GtkViewport widget acts as an adaptor class, implementing scrollability for child widgets that lack their own scrolling capabilities. Use #GtkViewport to scroll child widgets such as #GtkGrid, #GtkBox, and so on.

If a widget has native scrolling abilities, it can be added to the GtkScrolledWindow with gtk_container_add(). If a widget does not, you must first add the widget to a #GtkViewport, then add the #GtkViewport to the scrolled window. gtk_container_add() will do this for you for widgets that don’t implement #GtkScrollable natively, so you can ignore the presence of the viewport.

The position of the scrollbars is controlled by the scroll adjustments. See #GtkAdjustment for the fields in an adjustment — for #GtkScrollbar, used by GtkScrolledWindow, the “value” field represents the position of the scrollbar, which must be between the “lower” field and “upper - page_size.” The “page_size” field represents the size of the visible scrollable area. The “step_increment” and “page_increment” fields are used when the user asks to step down (using the small stepper arrows) or page down (using for example the PageDown key).

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(GtkScrolledWindow* gtkScrolledWindow, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()
this
this(Widget widget)
this
this(PolicyType hPolicy, PolicyType vPolicy)

Creates a new Scrolled window and set the policy type

this
this(Adjustment hadjustment, Adjustment vadjustment)

Creates a new scrolled window.

Members

Functions

addOnEdgeOvershot
void addOnEdgeOvershot(void delegate(GtkPositionType, ScrolledWindow) dlg, ConnectFlags connectFlags)

The ::edge-overshot signal is emitted whenever user initiated scrolling makes the scrolledwindow firmly surpass (ie. with some edge resistance) the lower or upper limits defined by the adjustment in that orientation.

addOnEdgeReached
void addOnEdgeReached(void delegate(GtkPositionType, ScrolledWindow) dlg, ConnectFlags connectFlags)

The ::edge-reached signal is emitted whenever user-initiated scrolling makes the scrolledwindow exactly reaches the lower or upper limits defined by the adjustment in that orientation.

addOnMoveFocusOut
void addOnMoveFocusOut(void delegate(GtkDirectionType, ScrolledWindow) dlg, ConnectFlags connectFlags)

The ::move-focus-out signal is a [keybinding signal]GtkBindingSignal which gets emitted when focus is moved away from the scrolled window by a keybinding. The #GtkWidget::move-focus signal is emitted with @direction_type on this scrolled windows toplevel parent in the container hierarchy. The default bindings for this signal are Tab + Ctrl and Tab + Ctrl + Shift.

addOnScrollChild
void addOnScrollChild(bool delegate(GtkScrollType, bool, ScrolledWindow) dlg, ConnectFlags connectFlags)

The ::scroll-child signal is a [keybinding signal]GtkBindingSignal which gets emitted when a keybinding that scrolls is pressed. The horizontal or vertical adjustment is updated which triggers a signal that the scrolled windows child may listen to and scroll itself.

addWithViewport
void addWithViewport(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_add() instead of this function.

getCaptureButtonPress
bool getCaptureButtonPress()

Return whether button presses are captured during kinetic scrolling. See gtk_scrolled_window_set_capture_button_press().

getHadjustment
Adjustment getHadjustment()

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

getHscrollbar
Widget getHscrollbar()

Returns the horizontal scrollbar of @scrolled_window.

getKineticScrolling
bool getKineticScrolling()

Returns the specified kinetic scrolling behavior.

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
GtkCornerType getPlacement()

Gets the placement of the contents with respect to the scrollbars for the scrolled window. See gtk_scrolled_window_set_placement().

getPolicy
void getPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy)

Retrieves the current policy values for the horizontal and vertical scrollbars. See gtk_scrolled_window_set_policy().

getScrolledWindowStruct
GtkScrolledWindow* getScrolledWindowStruct()

Get the main Gtk struct

getShadowType
GtkShadowType getShadowType()

Gets the shadow type of the scrolled window. See gtk_scrolled_window_set_shadow_type().

getStruct
void* getStruct()

the main Gtk struct as a void*

getVadjustment
Adjustment getVadjustment()

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

getVscrollbar
Widget getVscrollbar()

Returns the vertical scrollbar of @scrolled_window.

setCaptureButtonPress
void setCaptureButtonPress(bool captureButtonPress)

Changes the behaviour of @scrolled_window wrt. 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(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_SOURCE_TOUCHSCREEN.

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(GtkCornerType windowPlacement)

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

setPolicy
void setPolicy(GtkPolicyType hscrollbarPolicy, GtkPolicyType vscrollbarPolicy)

Sets the scrollbar policy for the horizontal and vertical scrollbars.

setShadowType
void setShadowType(GtkShadowType type)

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

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setVadjustment
void setVadjustment(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_CORNER_TOP_LEFT.

Static functions

callBackEdgeOvershot
void callBackEdgeOvershot(GtkScrolledWindow* scrolledwindowStruct, GtkPositionType pos, ScrolledWindow _scrolledwindow)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackEdgeReached
void callBackEdgeReached(GtkScrolledWindow* scrolledwindowStruct, GtkPositionType pos, ScrolledWindow _scrolledwindow)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackMoveFocusOut
void callBackMoveFocusOut(GtkScrolledWindow* scrolledwindowStruct, GtkDirectionType directionType, ScrolledWindow _scrolledwindow)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackScrollChild
int callBackScrollChild(GtkScrolledWindow* scrolledwindowStruct, GtkScrollType scroll, bool horizontal, ScrolledWindow _scrolledwindow)
Undocumented in source. Be warned that the author may not have intended to support it.
getType
GType getType()

Variables

connectedSignals
int[string] connectedSignals;
Undocumented in source.
gtkScrolledWindow
GtkScrolledWindow* gtkScrolledWindow;

the main Gtk struct

onEdgeOvershotListeners
void delegate(GtkPositionType, ScrolledWindow)[] onEdgeOvershotListeners;
Undocumented in source.
onEdgeReachedListeners
void delegate(GtkPositionType, ScrolledWindow)[] onEdgeReachedListeners;
Undocumented in source.
onMoveFocusOutListeners
void delegate(GtkDirectionType, ScrolledWindow)[] onMoveFocusOutListeners;
Undocumented in source.
onScrollChildListeners
bool delegate(GtkScrollType, bool, ScrolledWindow)[] onScrollChildListeners;
Undocumented in source.

Inherited Members

From Bin

gtkBin
GtkBin* gtkBin;

the main Gtk struct

getBinStruct
GtkBin* getBinStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
getType
GType getType()
getChild
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.

Meta