CtkViewport: CTK+ 3 Reference Manual

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

## Functions

CtkWidget * | ctk_viewport_new ()
CtkAdjustment * | ctk_viewport_get_hadjustment ()
CtkAdjustment * | ctk_viewport_get_vadjustment ()
void | ctk_viewport_set_hadjustment ()
void | ctk_viewport_set_vadjustment ()
void | ctk_viewport_set_shadow_type ()
CtkShadowType | ctk_viewport_get_shadow_type ()
CdkWindow * | ctk_viewport_get_bin_window ()
CdkWindow * | ctk_viewport_get_view_window ()

## Properties

CtkShadowType | shadow-type | Read / Write

## Types and Values

struct | CtkViewport
struct | CtkViewportClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── CtkWidget
                ╰── CtkContainer
                    ╰── CtkBin
                        ╰── CtkViewport

## Implemented Interfaces

CtkViewport implements AtkImplementorIface, CtkBuildable and CtkScrollable.

## Includes

    #include <ctk/ctk.h>

## Description

The CtkViewport widget acts as an adaptor class, implementing scrollability for child widgets that lack their own scrolling capabilities. Use CtkViewport to scroll child widgets such as CtkGrid, CtkBox, and so on.

If a widget has native scrolling abilities, such as CtkTextView, CtkTreeView or CtkIconView, it can be added to a CtkScrolledWindow with `ctk_container_add()`. If a widget does not, you must first add the widget to a CtkViewport, then add the viewport to the scrolled window. `ctk_container_add()` does this automatically if a child that does not implement CtkScrollable is added to a CtkScrolledWindow, so you can ignore the presence of the viewport.

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

### CSS nodes

CtkViewport has a single CSS node with name viewport.

## Functions

### ctk_viewport_new ()

    CtkWidget *
    ctk_viewport_new (CtkAdjustment *hadjustment,
                      CtkAdjustment *vadjustment);

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

#### Parameters

hadjustment | horizontal adjustment. | [allow-none]
vadjustment | vertical adjustment. | [allow-none]

#### Returns

a new CtkViewport

### ctk_viewport_get_hadjustment ()

    CtkAdjustment *
    ctk_viewport_get_hadjustment (CtkViewport *viewport);

`ctk_viewport_get_hadjustment` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `ctk_scrollable_get_hadjustment()`

Returns the horizontal adjustment of the viewport.

#### Parameters

viewport | a CtkViewport. |

#### Returns

the horizontal adjustment of `viewport` .

[transfer none]

### ctk_viewport_get_vadjustment ()

    CtkAdjustment *
    ctk_viewport_get_vadjustment (CtkViewport *viewport);

`ctk_viewport_get_vadjustment` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `ctk_scrollable_get_vadjustment()`

Returns the vertical adjustment of the viewport.

#### Parameters

viewport | a CtkViewport. |

#### Returns

the vertical adjustment of `viewport` .

[transfer none]

### ctk_viewport_set_hadjustment ()

    void
    ctk_viewport_set_hadjustment (CtkViewport *viewport,
                                  CtkAdjustment *adjustment);

`ctk_viewport_set_hadjustment` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `ctk_scrollable_set_hadjustment()`

Sets the horizontal adjustment of the viewport.

#### Parameters

viewport | a CtkViewport. |
adjustment | a CtkAdjustment. | [allow-none]

### ctk_viewport_set_vadjustment ()

    void
    ctk_viewport_set_vadjustment (CtkViewport *viewport,
                                  CtkAdjustment *adjustment);

`ctk_viewport_set_vadjustment` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `ctk_scrollable_set_vadjustment()`

Sets the vertical adjustment of the viewport.

#### Parameters

viewport | a CtkViewport. |
adjustment | a CtkAdjustment. | [allow-none]

### ctk_viewport_set_shadow_type ()

    void
    ctk_viewport_set_shadow_type (CtkViewport *viewport,
                                  CtkShadowType type);

Sets the shadow type of the viewport.

#### Parameters

viewport | a CtkViewport. |
type | the new shadow type. |

### ctk_viewport_get_shadow_type ()

    CtkShadowType
    ctk_viewport_get_shadow_type (CtkViewport *viewport);

Gets the shadow type of the CtkViewport. See `ctk_viewport_set_shadow_type()`.

#### Parameters

viewport | a CtkViewport |

#### Returns

the shadow type

### ctk_viewport_get_bin_window ()

    CdkWindow *
    ctk_viewport_get_bin_window (CtkViewport *viewport);

Gets the bin window of the CtkViewport.

#### Parameters

viewport | a CtkViewport |

#### Returns

a CdkWindow.

[transfer none]

Since: 2.20

### ctk_viewport_get_view_window ()

    CdkWindow *
    ctk_viewport_get_view_window (CtkViewport *viewport);

Gets the view window of the CtkViewport.

#### Parameters

viewport | a CtkViewport |

#### Returns

a CdkWindow.

[transfer none]

Since: 2.22

## Types and Values

### struct CtkViewport

    struct CtkViewport;

### struct CtkViewportClass

    struct CtkViewportClass {
      CtkBinClass parent_class;
    };

#### Members

## Property Details

### The `“shadow-type”` property

      “shadow-type”              CtkShadowType

Determines how the shadowed box around the viewport is drawn.

Owner: CtkViewport

Flags: Read / Write

Default value: CTK_SHADOW_IN

## See Also

CtkScrolledWindow, CtkAdjustment