Skip to content

CefScrollView

Header: cef_scroll_view.h
Category: Views Framework

Overview

Browser-process UI toolkit: windows, panels, layouts, buttons, textfields, and their delegates.

CefScrollView

Source File: include/views/cef_scroll_view.h

Process / Thread Context: Browser Process / UI Thread.

Purpose: A scroll view shows horizontal and/or vertical scrollbars when

Methods

static CefRefPtr<CefScrollView> CreateScrollView(CefRefPtr<CefViewDelegate> delegate)

Parameters:

  • delegate: Optional delegate for this scroll view (may be NULL).

Return Value: A new CefScrollView instance.

Usage Instruction: Static factory. The returned view is not yet

Threading Constraint: Browser process UI thread.

virtual void SetContentView(CefRefPtr<CefView> view) = 0

Parameters:

  • view: The content view. Must have a specified size (e.g., via

Return Value: void.

Usage Instruction: Provide the content that the scroll view will

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefView> GetContentView() = 0

Parameters:

  • none.

Return Value: The currently set content view (may be NULL).

Usage Instruction: Inspect/replace the content view.

Threading Constraint: Browser process UI thread.

virtual CefRect GetVisibleContentRect() = 0

Parameters:

  • none.

Return Value: The visible region of the content view (in content

Usage Instruction: Determine what part of a large content is on

Threading Constraint: Browser process UI thread.

virtual bool HasHorizontalScrollbar() = 0

Parameters:

  • none.

Return Value: True if the horizontal scrollbar is currently shown.

Usage Instruction: UI introspection.

Threading Constraint: Browser process UI thread.

virtual int GetHorizontalScrollbarHeight() = 0

Parameters:

  • none.

Return Value: Height of the horizontal scrollbar in DIP.

Usage Instruction: Layout calculations outside the scroll view.

Threading Constraint: Browser process UI thread.

virtual bool HasVerticalScrollbar() = 0

Parameters:

  • none.

Return Value: True if the vertical scrollbar is currently shown.

Usage Instruction: UI introspection.

Threading Constraint: Browser process UI thread.

virtual int GetVerticalScrollbarWidth() = 0

Parameters:

  • none.

Return Value: Width of the vertical scrollbar in DIP.

Usage Instruction: Layout calculations outside the scroll view.

Threading Constraint: Browser process UI thread.

Usage Example

cpp
CefRefPtr<CefScrollView> scroll = CefScrollView::CreateScrollView(nullptr);

CefRefPtr<CefPanel> content = CefPanel::CreatePanel(nullptr);
CefRefPtr<CefBoxLayout> box = content->SetToBoxLayout(CefBoxLayoutSettings{});
for (int i = 0; i < 50; ++i) {
  content->AddChildView(MakeLabelButton("Item " + std::to_string(i)));
}
content->SetBounds(CefRect(0, 0, 400, 2000));   // taller than viewport
scroll->SetContentView(content);

window->AddChildView(scroll);

Derived from the CEF C++ headers — © Marshall A. Greenblatt, Google Inc. & contributors (BSD-style license). Not an official CEF project.