GTK+ 3 Reference Manual: GtkViewport

## GtkViewport GtkViewport — An adapter which makes widgets scrollable |

## Synopsis

    #include <gtk/gtk.h>

    struct              GtkViewport;
    GtkWidget *         gtk_viewport_new                    (GtkAdjustment *hadjustment,
                                                             GtkAdjustment *vadjustment);
    GtkAdjustment *     gtk_viewport_get_hadjustment        (GtkViewport *viewport);
    GtkAdjustment *     gtk_viewport_get_vadjustment        (GtkViewport *viewport);
    void                gtk_viewport_set_hadjustment        (GtkViewport *viewport,
                                                             GtkAdjustment *adjustment);
    void                gtk_viewport_set_vadjustment        (GtkViewport *viewport,
                                                             GtkAdjustment *adjustment);
    void                gtk_viewport_set_shadow_type        (GtkViewport *viewport,
                                                             GtkShadowType type);
    GtkShadowType       gtk_viewport_get_shadow_type        (GtkViewport *viewport);
    GdkWindow *         gtk_viewport_get_bin_window         (GtkViewport *viewport);
    GdkWindow *         gtk_viewport_get_view_window        (GtkViewport *viewport);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkWidget
                   +----GtkContainer
                         +----GtkBin
                               +----GtkViewport

## Implemented Interfaces

GtkViewport implements AtkImplementorIface, GtkBuildable and GtkScrollable.

## Properties

      "shadow-type"              GtkShadowType         : Read / Write

## Description

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, such as GtkTextView, GtkTreeView or GtkIconView, it can be added to a GtkScrolledWindow with `gtk_container_add()`. If a widget does not, you must first add the widget to a GtkViewport, then add the viewport to the scrolled window. `gtk_container_add()` does this automatically if a child that does not implement GtkScrollable is added to a GtkScrolledWindow, so you can ignore the presence of the viewport.

The GtkViewport will start scrolling content only if allocated less than the child widget's minimum size in a given orientation.

## Details

### struct GtkViewport

    struct GtkViewport;

### gtk_viewport_new ()

    GtkWidget *         gtk_viewport_new                    (GtkAdjustment *hadjustment,
                                                             GtkAdjustment *vadjustment);

Creates a new GtkViewport with the given adjustments, or with default adjustments if none are given.

`hadjustment` : | horizontal adjustment. [allow-none]
`vadjustment` : | vertical adjustment. [allow-none]
Returns : | a new GtkViewport

### gtk_viewport_get_hadjustment ()

    GtkAdjustment *     gtk_viewport_get_hadjustment        (GtkViewport *viewport);

### Warning

`gtk_viewport_get_hadjustment` has been deprecated since version 3.0 and should not be used in newly-written code. Use `gtk_scrollable_get_hadjustment()`

Returns the horizontal adjustment of the viewport.

`viewport` : | a GtkViewport.
Returns : | the horizontal adjustment of `viewport`. [transfer none]

### gtk_viewport_get_vadjustment ()

    GtkAdjustment *     gtk_viewport_get_vadjustment        (GtkViewport *viewport);

### Warning

`gtk_viewport_get_vadjustment` has been deprecated since version 3.0 and should not be used in newly-written code. Use `gtk_scrollable_get_vadjustment()`

Returns the vertical adjustment of the viewport.

`viewport` : | a GtkViewport.
Returns : | the vertical adjustment of `viewport`. [transfer none]

### gtk_viewport_set_hadjustment ()

    void                gtk_viewport_set_hadjustment        (GtkViewport *viewport,
                                                             GtkAdjustment *adjustment);

### Warning

`gtk_viewport_set_hadjustment` has been deprecated since version 3.0 and should not be used in newly-written code. Use `gtk_scrollable_set_hadjustment()`

Sets the horizontal adjustment of the viewport.

`viewport` : | a GtkViewport.
`adjustment` : | a GtkAdjustment. [allow-none]

### gtk_viewport_set_vadjustment ()

    void                gtk_viewport_set_vadjustment        (GtkViewport *viewport,
                                                             GtkAdjustment *adjustment);

### Warning

`gtk_viewport_set_vadjustment` has been deprecated since version 3.0 and should not be used in newly-written code. Use `gtk_scrollable_set_vadjustment()`

Sets the vertical adjustment of the viewport.

`viewport` : | a GtkViewport.
`adjustment` : | a GtkAdjustment. [allow-none]

### gtk_viewport_set_shadow_type ()

    void                gtk_viewport_set_shadow_type        (GtkViewport *viewport,
                                                             GtkShadowType type);

Sets the shadow type of the viewport.

`viewport` : | a GtkViewport.
`type` : | the new shadow type.

### gtk_viewport_get_shadow_type ()

    GtkShadowType       gtk_viewport_get_shadow_type        (GtkViewport *viewport);

Gets the shadow type of the GtkViewport. See `gtk_viewport_set_shadow_type()`.

`viewport` : | a GtkViewport
Returns : | the shadow type

### gtk_viewport_get_bin_window ()

    GdkWindow *         gtk_viewport_get_bin_window         (GtkViewport *viewport);

Gets the bin window of the GtkViewport.

`viewport` : | a GtkViewport
Returns : | a GdkWindow. [transfer none]

Since 2.20

### gtk_viewport_get_view_window ()

    GdkWindow *         gtk_viewport_get_view_window        (GtkViewport *viewport);

Gets the view window of the GtkViewport.

`viewport` : | a GtkViewport
Returns : | a GdkWindow. [transfer none]

Since 2.22

## Property Details

### The `"shadow-type"` property

      "shadow-type"              GtkShadowType         : Read / Write

Determines how the shadowed box around the viewport is drawn.

Default value: GTK_SHADOW_IN

## See Also

GtkScrolledWindow, GtkAdjustment