2020-04-29 19:14:44 +02:00
|
|
|
unit uCEFPanelDelegate;
|
|
|
|
|
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 19:56:41 +02: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, uCEFViewDelegate;
|
|
|
|
|
|
|
|
type
|
|
|
|
TCefPanelDelegateRef = class(TCefViewDelegateRef, ICefPanelDelegate)
|
|
|
|
public
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns a ICefPanelDelegate instance using a PCefPanelDelegate data pointer.
|
|
|
|
/// </summary>
|
2020-04-29 19:14:44 +02:00
|
|
|
class function UnWrap(data: Pointer): ICefPanelDelegate;
|
|
|
|
end;
|
|
|
|
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Implement this interface to handle Panel events. The functions of this
|
|
|
|
/// interface will 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_delegate_capi.h">CEF source file: /include/capi/views/cef_panel_delegate_capi.h (cef_panel_delegate_t)</see></para>
|
|
|
|
/// </remarks>
|
2020-04-30 17:28:41 +02:00
|
|
|
TCefPanelDelegateOwn = class(TCefViewDelegateOwn, ICefPanelDelegate)
|
|
|
|
public
|
|
|
|
constructor Create; override;
|
|
|
|
end;
|
|
|
|
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// This class handles all the ICefPanelDelegate methods which call the ICefPanelDelegateEvents methods.
|
|
|
|
/// ICefPanelDelegateEvents will be implemented by the control receiving the ICefPanelDelegate events.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
TCustomPanelDelegate = class(TCefPanelDelegateOwn)
|
|
|
|
protected
|
|
|
|
FEvents : Pointer;
|
|
|
|
|
|
|
|
// ICefViewDelegate
|
|
|
|
procedure OnGetPreferredSize(const view: ICefView; var aResult : TCefSize); override;
|
|
|
|
procedure OnGetMinimumSize(const view: ICefView; var aResult : TCefSize); override;
|
|
|
|
procedure OnGetMaximumSize(const view: ICefView; var aResult : TCefSize); override;
|
|
|
|
procedure OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); override;
|
|
|
|
procedure OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); override;
|
|
|
|
procedure OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); override;
|
2021-04-18 19:36:20 +02:00
|
|
|
procedure OnWindowChanged(const view: ICefView; added: boolean); override;
|
2021-09-27 12:04:33 +02:00
|
|
|
procedure OnLayoutChanged(const view: ICefView; new_bounds: TCefRect); override;
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure OnFocus(const view: ICefView); override;
|
|
|
|
procedure OnBlur(const view: ICefView); override;
|
2024-05-01 18:19:19 +02:00
|
|
|
procedure OnThemeChanged(const view: ICefView); override;
|
2020-05-05 18:10:33 +02:00
|
|
|
|
|
|
|
public
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates an instance of this class liked to an interface that's implemented by a control receiving the events.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
constructor Create(const events: ICefPanelDelegateEvents); reintroduce;
|
|
|
|
end;
|
|
|
|
|
2020-04-29 19:14:44 +02:00
|
|
|
implementation
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
uses
|
|
|
|
uCEFLibFunctions, uCEFMiscFunctions;
|
|
|
|
|
2020-04-30 17:28:41 +02:00
|
|
|
// **************************************************************
|
|
|
|
// ******************** TCefPanelDelegateRef ********************
|
|
|
|
// **************************************************************
|
|
|
|
|
2020-04-29 19:14:44 +02:00
|
|
|
class function TCefPanelDelegateRef.UnWrap(data: Pointer): ICefPanelDelegate;
|
|
|
|
begin
|
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefPanelDelegate
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
2020-04-30 17:28:41 +02:00
|
|
|
// **************************************************************
|
|
|
|
// ******************** TCefPanelDelegateOwn ********************
|
|
|
|
// **************************************************************
|
|
|
|
|
|
|
|
constructor TCefPanelDelegateOwn.Create;
|
|
|
|
begin
|
|
|
|
inherited CreateData(SizeOf(TCefPanelDelegate));
|
|
|
|
|
|
|
|
InitializeCEFMethods;
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
// **************************************************************
|
|
|
|
// ******************** TCustomPanelDelegate ********************
|
|
|
|
// **************************************************************
|
|
|
|
|
|
|
|
constructor TCustomPanelDelegate.Create(const events: ICefPanelDelegateEvents);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FEvents := Pointer(events);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
|
|
|
begin
|
2023-09-24 11:21:05 +02:00
|
|
|
inherited OnGetPreferredSize(view, aResult);
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnGetPreferredSize', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
|
|
|
begin
|
2023-09-24 11:21:05 +02:00
|
|
|
inherited OnGetMinimumSize(view, aResult);
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnGetMinimumSize', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
|
|
|
begin
|
2023-09-24 11:21:05 +02:00
|
|
|
inherited OnGetMaximumSize(view, aResult);
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnGetMaximumSize', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
|
|
|
begin
|
2023-09-24 11:21:05 +02:00
|
|
|
inherited OnGetHeightForWidth(view, width, aResult);
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnGetHeightForWidth', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnParentViewChanged', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnChildViewChanged', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2021-04-18 19:36:20 +02:00
|
|
|
procedure TCustomPanelDelegate.OnWindowChanged(const view: ICefView; added: boolean);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnWindowChanged(view, added);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnWindowChanged', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2021-09-27 12:04:33 +02:00
|
|
|
procedure TCustomPanelDelegate.OnLayoutChanged(const view: ICefView; new_bounds: TCefRect);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnLayoutChanged(view, new_bounds);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnLayoutChanged', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure TCustomPanelDelegate.OnFocus(const view: ICefView);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnFocus(view);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnFocus', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPanelDelegate.OnBlur(const view: ICefView);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnBlur(view);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnBlur', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2024-05-01 18:19:19 +02:00
|
|
|
procedure TCustomPanelDelegate.OnThemeChanged(const view: ICefView);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
if (FEvents <> nil) then
|
|
|
|
ICefPanelDelegateEvents(FEvents).doOnThemeChanged(view);
|
|
|
|
except
|
|
|
|
on e : exception do
|
|
|
|
if CustomExceptionHandler('TCustomPanelDelegate.OnThemeChanged', e) then raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-04-29 19:14:44 +02:00
|
|
|
end.
|
|
|
|
|