2020-04-29 19:14:44 +02:00
|
|
|
unit uCEFPanel;
|
|
|
|
|
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2020-04-29 19:14:44 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF DELPHI16_UP}
|
|
|
|
System.Classes, System.SysUtils,
|
|
|
|
{$ELSE}
|
|
|
|
Classes, SysUtils,
|
|
|
|
{$ENDIF}
|
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes, uCEFView;
|
|
|
|
|
|
|
|
type
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A Panel is a container in the views hierarchy that can contain other Views
|
|
|
|
/// as children. Methods must be called on the browser process UI thread unless
|
|
|
|
/// otherwise indicated.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/views/cef_panel_capi.h">CEF source file: /include/capi/views/cef_panel_capi.h (cef_panel_t)</see></para>
|
|
|
|
/// </remarks>
|
2020-04-29 19:14:44 +02:00
|
|
|
TCefPanelRef = class(TCefViewRef, ICefPanel)
|
|
|
|
protected
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this Panel as a Window or NULL if this is not a Window.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function GetAsWindow : ICefWindow;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Set this Panel's Layout to FillLayout and return the FillLayout object.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
function SetToFillLayout : ICefFillLayout;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Set this Panel's Layout to BoxLayout and return the BoxLayout object.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the Layout.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
function GetLayout : ICefLayout;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Lay out the child Views (set their bounds based on sizing heuristics
|
|
|
|
/// specific to the current Layout).
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure Layout;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Add a child View.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure AddChildView(const view: ICefView);
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Add a child View at the specified |index|. If |index| matches the result
|
|
|
|
/// of GetChildCount() then the View will be added at the end.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure AddChildViewAt(const view: ICefView; index: Integer);
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Move the child View to the specified |index|. A negative value for |index|
|
|
|
|
/// will move the View to the end.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure ReorderChildView(const view: ICefView; index: Integer);
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Remove a child View. The View can then be added to another Panel.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure RemoveChildView(const view: ICefView);
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Remove all child Views. The removed Views will be deleted if the client
|
|
|
|
/// holds no references to them.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
procedure RemoveAllChildViews;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the number of child Views.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
function GetChildViewCount : NativeUInt;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the child View at the specified |index|.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
function GetChildViewAt(index: Integer): ICefView;
|
|
|
|
|
|
|
|
public
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns a ICefPanel instance using a PCefPanel data pointer.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
class function UnWrap(data: Pointer): ICefPanel;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Create a new Panel.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
class function CreatePanel(const delegate: ICefPanelDelegate): ICefPanel;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFLibFunctions, uCEFMiscFunctions, uCEFWindow, uCEFLayout, uCEFFillLayout,
|
|
|
|
uCEFBoxLayout;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
function TCefPanelRef.GetAsWindow : ICefWindow;
|
2020-04-29 19:14:44 +02:00
|
|
|
begin
|
|
|
|
Result := TCefWindowRef.UnWrap(PCefPanel(FData)^.as_window(PCefPanel(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPanelRef.SetToFillLayout : ICefFillLayout;
|
|
|
|
begin
|
|
|
|
Result := TCefFillLayoutRef.UnWrap(PCefPanel(FData)^.set_to_fill_layout(PCefPanel(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPanelRef.SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
|
|
|
begin
|
|
|
|
Result := TCefBoxLayoutRef.UnWrap(PCefPanel(FData)^.set_to_box_layout(PCefPanel(FData), @settings));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPanelRef.GetLayout : ICefLayout;
|
|
|
|
begin
|
|
|
|
Result := TCefLayoutRef.UnWrap(PCefPanel(FData)^.get_layout(PCefPanel(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.Layout;
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.layout(PCefPanel(FData));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.AddChildView(const view: ICefView);
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.add_child_view(PCefPanel(FData), CefGetData(view));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.AddChildViewAt(const view: ICefView; index: Integer);
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.add_child_view_at(PCefPanel(FData), CefGetData(view), index);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.ReorderChildView(const view: ICefView; index: Integer);
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.reorder_child_view(PCefPanel(FData), CefGetData(view), index);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.RemoveChildView(const view: ICefView);
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.remove_child_view(PCefPanel(FData), CefGetData(view));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefPanelRef.RemoveAllChildViews;
|
|
|
|
begin
|
|
|
|
PCefPanel(FData)^.remove_all_child_views(PCefPanel(FData));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPanelRef.GetChildViewCount : NativeUInt;
|
|
|
|
begin
|
|
|
|
Result := PCefPanel(FData)^.get_child_view_count(PCefPanel(FData));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefPanelRef.GetChildViewAt(index: Integer): ICefView;
|
|
|
|
begin
|
|
|
|
Result := TCefViewRef.UnWrap(PCefPanel(FData)^.get_child_view_at(PCefPanel(FData), index));
|
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefPanelRef.UnWrap(data: Pointer): ICefPanel;
|
|
|
|
begin
|
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefPanel
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefPanelRef.CreatePanel(const delegate: ICefPanelDelegate): ICefPanel;
|
2020-05-05 18:10:33 +02:00
|
|
|
var
|
|
|
|
TempPanel : PCefPanel;
|
2020-04-29 19:14:44 +02:00
|
|
|
begin
|
2020-05-05 18:10:33 +02:00
|
|
|
Result := nil;
|
|
|
|
|
|
|
|
if (delegate <> nil) then
|
|
|
|
begin
|
|
|
|
TempPanel := cef_panel_create(CefGetData(delegate));
|
|
|
|
|
|
|
|
if (TempPanel <> nil) then
|
|
|
|
Result := Create(TempPanel) as ICefPanel;
|
|
|
|
end;
|
2020-04-29 19:14:44 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|