Skip to content

CefPanel

Header: cef_panel.h
Category: Views Framework

Overview

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

CefPanel

Source File: include/views/cef_panel.h

Process / Thread Context: Browser Process / UI Thread.

Purpose: A container in the views hierarchy that can contain other views

Methods

static CefRefPtr<CefPanel> CreatePanel(CefRefPtr<CefPanelDelegate> delegate)

Parameters:

  • delegate: Optional CefPanelDelegate for receiving panel events.

Return Value: A new panel instance.

Usage Instruction: Static factory.

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefWindow> AsWindow() = 0

Parameters:

  • none.

Return Value: This panel as a CefWindow, or NULL if not a window.

Usage Instruction: Down-cast helper. Windows are panels.

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefFillLayout> SetToFillLayout() = 0

Parameters:

  • none.

Return Value: The new CefFillLayout associated with this panel.

Usage Instruction: Switch this panel to a fill layout (single child

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefBoxLayout> SetToBoxLayout(const CefBoxLayoutSettings& settings) = 0

Parameters:

  • settings: Configuration for the new box layout (orientation, spacing,

Return Value: The new CefBoxLayout instance.

Usage Instruction: Switch this panel to a box layout (row/column).

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefLayout> GetLayout() = 0

Parameters:

  • none.

Return Value: The current layout (may be NULL if none has been set).

Usage Instruction: Inspect the active layout.

Threading Constraint: Browser process UI thread.

virtual void Layout() = 0

Parameters:

  • none.

Return Value: void.

Usage Instruction: Force the layout to reposition child views

Threading Constraint: Browser process UI thread.

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

Parameters:

  • view: The child view to add at the end of the child list.

Return Value: void.

Usage Instruction: Append a child.

Threading Constraint: Browser process UI thread.

virtual void AddChildViewAt(CefRefPtr<CefView> view, int index) = 0

Parameters:

  • view: The child view to insert.
  • index: The insertion index. If it equals GetChildViewCount(), the

Return Value: void.

Usage Instruction: Insert at a specific position.

Threading Constraint: Browser process UI thread.

virtual void ReorderChildView(CefRefPtr<CefView> view, int index) = 0

Parameters:

  • view: An existing child view to move.
  • index: The target index; a negative value moves the view to the end.

Return Value: void.

Usage Instruction: Reorder existing children (e.g., bring to front).

Threading Constraint: Browser process UI thread.

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

Parameters:

  • view: The child view to remove.

Return Value: void. The view can be added to another panel after

Usage Instruction: Detach a child.

Threading Constraint: Browser process UI thread.

virtual void RemoveAllChildViews() = 0

Parameters:

  • none.

Return Value: void. Removed views are deleted if no client references

Usage Instruction: Clear children.

Threading Constraint: Browser process UI thread.

virtual size_t GetChildViewCount() = 0

Parameters:

  • none.

Return Value: Number of child views.

Usage Instruction: Iterate children.

Threading Constraint: Browser process UI thread.

virtual CefRefPtr<CefView> GetChildViewAt(int index) = 0

Parameters:

  • index: Index of the child to retrieve.

Return Value: The child view at that index.

Usage Instruction: Iterate children.

Threading Constraint: Browser process UI thread.

Usage Example

cpp
CefRefPtr<CefPanel> panel = CefPanel::CreatePanel(nullptr);
CefBoxLayoutSettings s;
s.horizontal = false;
auto box = panel->SetToBoxLayout(s);
panel->AddChildView(CefLabelButton::CreateLabelButton(btn_delegate, "OK"));
panel->AddChildView(CefTextfield::CreateTextfield(tf_delegate));
panel->Layout();

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