ScrolledWindowRef

public struct ScrolledWindowRef : ScrolledWindowProtocol, GWeakCapturing

GtkScrolledWindow 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 [ifaceGtk.Scrollable] interface, are added directly. For other types of widget, the class [classGtk.Viewport] acts as an adaptor, giving scrollability to other widgets. [methodGtk.ScrolledWindow.set_child] intelligently accounts for whether or not the added child is a GtkScrollable. If it isn’t, then it wraps the child in a GtkViewport. Therefore, you can just add any child widget and not worry about the details.

If [methodGtk.ScrolledWindow.set_child] 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 ();
GtkWidget *child_widget = gtk_button_new ();

// GtkButton is not a GtkScrollable, so GtkScrolledWindow will automatically
// add a GtkViewport.
gtk_box_append (GTK_BOX (scrolled_window), child_widget);

// Either of these will result in child_widget being unparented:
gtk_box_remove (GTK_BOX (scrolled_window), child_widget);
// or
gtk_box_remove (GTK_BOX (scrolled_window),
                      gtk_bin_get_child (GTK_BIN (scrolled_window)));

Unless [propertyGtk.ScrolledWindow:hscrollbar-policy] and [propertyGtk.ScrolledWindow:vscrollbar-policy] are 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 [propertyGtk.ScrolledWindow:hadjustment] and [propertyGtk.ScrolledWindow:vadjustment] that are associated with the GtkScrolledWindow. See the docs on [classGtk.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 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 [propertyGtk.ScrolledWindow: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 [signalGtk.ScrolledWindow::edge-overshot] 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 [propertyGtk.ScrolledWindow:overlay-scrolling] property.

CSS nodes

GtkScrolledWindow has a main CSS node with name scrolledwindow. It gets a .frame style class added when [propertyGtk.ScrolledWindow:has-frame] 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.

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.

Accessibility

GtkScrolledWindow uses the GTK_ACCESSIBLE_ROLE_GROUP role.

The ScrolledWindowRef type acts as a lightweight Swift reference to an underlying GtkScrolledWindow instance. It exposes methods that can operate on this data type through ScrolledWindowProtocol conformance. Use ScrolledWindowRef only as an unowned reference to an existing GtkScrolledWindow instance.

  • ptr
    Untyped pointer to the underlying `GtkScrolledWindow` instance.
    

    For type-safe access, use the generated, typed pointer scrolled_window_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

ScrolledWindow Class

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GtkScrolledWindow>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GtkScrolledWindow>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GtkScrolledWindow>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GtkScrolledWindow>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements ScrolledWindowProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : ScrolledWindowProtocol
  • This factory is syntactic sugar for setting weak pointers wrapped in GWeak<T>

    Declaration

    Swift

    @inlinable
    static func unowned<T>(_ other: T) -> ScrolledWindowRef where T : ScrolledWindowProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ScrolledWindowProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ScrolledWindowProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ScrolledWindowProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ScrolledWindowProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ScrolledWindowProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • Creates a new scrolled window.

    Declaration

    Swift

    @inlinable
    init()