2020-05-05 18:10:33 +02:00
|
|
|
unit uCEFViewComponent;
|
|
|
|
|
|
|
|
{$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-05-05 18:10:33 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF DELPHI16_UP}
|
|
|
|
{$IFDEF MSWINDOWS}WinApi.Windows,{$ENDIF} System.Classes,
|
|
|
|
{$ELSE}
|
|
|
|
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes,
|
|
|
|
{$IFDEF FPC}
|
|
|
|
LCLProc, LCLType, LCLIntf, LResources, InterfaceBase,
|
|
|
|
{$ENDIF}
|
|
|
|
{$ENDIF}
|
|
|
|
uCEFTypes, uCEFInterfaces, uCEFViewsFrameworkEvents;
|
|
|
|
|
|
|
|
type
|
|
|
|
TCEFViewComponent = class(TComponent, ICefViewDelegateEvents)
|
|
|
|
protected
|
|
|
|
// ICefViewDelegateEvents
|
|
|
|
FOnGetPreferredSize : TOnGetPreferredSizeEvent;
|
|
|
|
FOnGetMinimumSize : TOnGetMinimumSizeEvent;
|
|
|
|
FOnGetMaximumSize : TOnGetMaximumSizeEvent;
|
|
|
|
FOnGetHeightForWidth : TOnGetHeightForWidthEvent;
|
|
|
|
FOnParentViewChanged : TOnParentViewChangedEvent;
|
|
|
|
FOnChildViewChanged : TOnChildViewChangedEvent;
|
2021-04-18 19:36:20 +02:00
|
|
|
FOnWindowChanged : TOnWindowChangedEvent;
|
2021-09-27 12:04:33 +02:00
|
|
|
FOnLayoutChanged : TOnLayoutChangedEvent;
|
2020-05-05 18:10:33 +02:00
|
|
|
FOnFocus : TOnFocusEvent;
|
|
|
|
FOnBlur : TOnBlurEvent;
|
2024-05-01 18:19:19 +02:00
|
|
|
FOnThemeChanged : TOnThemeChangedEvent;
|
2020-05-05 18:10:33 +02:00
|
|
|
|
2023-11-29 13:04:33 +01:00
|
|
|
FComponentID : integer;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure CreateView; virtual;
|
|
|
|
procedure DestroyView; virtual;
|
|
|
|
procedure Initialize; virtual;
|
|
|
|
|
|
|
|
function GetInitialized : boolean; virtual;
|
|
|
|
function GetAsView : ICefView; virtual;
|
|
|
|
function GetTypeString : ustring;
|
|
|
|
function GetAsBrowserView : ICefBrowserView; virtual;
|
|
|
|
function GetAsButton : ICefButton; virtual;
|
|
|
|
function GetAsPanel : ICefPanel; virtual;
|
|
|
|
function GetAsScrollView : ICefScrollView; virtual;
|
|
|
|
function GetAsTextfield : ICefTextfield; virtual;
|
|
|
|
function GetIsValid : boolean;
|
|
|
|
function GetIsAttached : boolean;
|
|
|
|
function GetDelegate : ICefViewDelegate;
|
|
|
|
function GetWindow : ICefWindow;
|
|
|
|
function GetID : Integer;
|
|
|
|
function GetGroupID : Integer;
|
|
|
|
function GetParentView : ICefView;
|
|
|
|
function GetBounds : TCefRect;
|
|
|
|
function GetBoundsInScreen : TCefRect;
|
|
|
|
function GetSize : TCefSize;
|
|
|
|
function GetPosition : TCefPoint;
|
|
|
|
function GetPreferredSize : TCefSize;
|
|
|
|
function GetMinimumSize : TCefSize;
|
|
|
|
function GetMaximumSize : TCefSize;
|
|
|
|
function GetIsVisible : boolean;
|
|
|
|
function GetIsDrawn : boolean;
|
|
|
|
function GetIsEnabled : boolean;
|
|
|
|
function GetIsFocusable : boolean;
|
|
|
|
function GetIsAccessibilityFocusable : boolean;
|
|
|
|
function GetBackgroundColor : TCefColor;
|
|
|
|
function GetViewForID(id_: Integer): ICefView;
|
|
|
|
function GetHeightForWidth(width: Integer): Integer;
|
2023-09-29 19:23:38 +02:00
|
|
|
function GetInsets: TCefInsets;
|
2023-11-29 13:04:33 +01:00
|
|
|
function GetComponentID : integer;
|
2020-05-05 18:10:33 +02:00
|
|
|
|
|
|
|
procedure SetID(id_: Integer);
|
|
|
|
procedure SetGroupID(group_id: Integer);
|
|
|
|
procedure SetBounds(const bounds_: TCefRect);
|
|
|
|
procedure SetSize(const size_: TCefSize);
|
|
|
|
procedure SetPosition(const position_: TCefPoint);
|
|
|
|
procedure SetVisible(visible_: boolean);
|
|
|
|
procedure SetEnabled(enabled_: boolean);
|
|
|
|
procedure SetFocusable(focusable_: boolean);
|
|
|
|
procedure SetBackgroundColor(color: TCefColor);
|
2023-09-29 19:23:38 +02:00
|
|
|
procedure SetInsets(const insets: TCefInsets);
|
2020-05-05 18:10:33 +02:00
|
|
|
|
|
|
|
// ICefViewDelegateEvents
|
|
|
|
procedure doOnGetPreferredSize(const view: ICefView; var aResult : TCefSize); virtual;
|
|
|
|
procedure doOnGetMinimumSize(const view: ICefView; var aResult : TCefSize); virtual;
|
|
|
|
procedure doOnGetMaximumSize(const view: ICefView; var aResult : TCefSize); virtual;
|
|
|
|
procedure doOnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer); virtual;
|
|
|
|
procedure doOnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView); virtual;
|
|
|
|
procedure doOnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView); virtual;
|
2021-04-18 19:36:20 +02:00
|
|
|
procedure doOnWindowChanged(const view: ICefView; added: boolean); virtual;
|
2021-09-27 12:04:33 +02:00
|
|
|
procedure doOnLayoutChanged(const view: ICefView; new_bounds: TCefRect); virtual;
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure doOnFocus(const view: ICefView); virtual;
|
|
|
|
procedure doOnBlur(const view: ICefView); virtual;
|
2024-05-01 18:19:19 +02:00
|
|
|
procedure doOnThemeChanged(const view: ICefView); virtual;
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure doCreateCustomView; virtual;
|
|
|
|
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
2023-11-29 13:04:33 +01:00
|
|
|
procedure AfterConstruction; override;
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure BeforeDestruction; override;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns a string representation of this View which includes the type and
|
|
|
|
/// various type-specific identifying attributes. If |include_children| is
|
|
|
|
/// true (1) any child Views will also be included. Used primarily for testing
|
|
|
|
/// purposes.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ToStringEx(include_children: boolean): ustring;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true (1) if this View is the same as |that| View.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function IsSame(const that: ICefView): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Size this View to its preferred size. Size is in parent coordinates, or
|
|
|
|
/// DIP screen coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure SizeToPreferredSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Indicate that this View and all parent Views require a re-layout. This
|
|
|
|
/// ensures the next call to layout() will propagate to this View even if the
|
|
|
|
/// bounds of parent Views do not change.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure InvalidateLayout;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Request keyboard focus. If this View is focusable it will become the
|
|
|
|
/// focused View.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure RequestFocus;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
2024-05-01 18:19:19 +02:00
|
|
|
/// Returns the current theme color associated with |color_id|, or the
|
|
|
|
/// placeholder color (red) if unset. See cef_color_ids.h for standard ID
|
|
|
|
/// values. Standard colors can be overridden and custom colors can be added
|
|
|
|
/// using ICefWindow.SetThemeColor.
|
|
|
|
/// </summary>
|
|
|
|
function GetThemeColor(color_id: integer): TCefColor;
|
|
|
|
/// <summary>
|
2023-09-29 19:23:38 +02:00
|
|
|
/// Convert |point| from this View's coordinate system to DIP screen
|
|
|
|
/// coordinates. This View must belong to a Window when calling this function.
|
|
|
|
/// Returns true (1) if the conversion is successful or false (0) otherwise.
|
|
|
|
/// Use ICefDisplay.ConvertPointToPixels() after calling this function
|
|
|
|
/// if further conversion to display-specific pixel coordinates is desired.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointToScreen(var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Convert |point| to this View's coordinate system from DIP screen
|
|
|
|
/// coordinates. This View must belong to a Window when calling this function.
|
|
|
|
/// Returns true (1) if the conversion is successful or false (0) otherwise.
|
|
|
|
/// Use ICefDisplay.ConvertPointFromPixels() before calling this
|
|
|
|
/// function if conversion from display-specific pixel coordinates is
|
|
|
|
/// necessary.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointFromScreen(var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Convert |point| from this View's coordinate system to that of the Window.
|
|
|
|
/// This View must belong to a Window when calling this function. Returns true
|
|
|
|
/// (1) if the conversion is successful or false (0) otherwise.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointToWindow(var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Convert |point| to this View's coordinate system from that of the Window.
|
|
|
|
/// This View must belong to a Window when calling this function. Returns true
|
|
|
|
/// (1) if the conversion is successful or false (0) otherwise.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointFromWindow(var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Convert |point| from this View's coordinate system to that of |view|.
|
|
|
|
/// |view| needs to be in the same Window but not necessarily the same view
|
|
|
|
/// hierarchy. Returns true (1) if the conversion is successful or false (0)
|
|
|
|
/// otherwise.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Convert |point| to this View's coordinate system from that |view|. |view|
|
|
|
|
/// needs to be in the same Window but not necessarily the same view
|
|
|
|
/// hierarchy. Returns true (1) if the conversion is successful or false (0)
|
|
|
|
/// otherwise.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
function ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true when the control is fully initialized.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Initialized : boolean read GetInitialized;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this control as a View.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsView : ICefView read GetAsView;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this View as a BrowserView or NULL if this is not a BrowserView.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsBrowserView : ICefBrowserView read GetAsBrowserView;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this View as a Button or NULL if this is not a Button.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsButton : ICefButton read GetAsButton;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this View as a Panel or NULL if this is not a Panel.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsPanel : ICefPanel read GetAsPanel;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this View as a ScrollView or NULL if this is not a ScrollView.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsScrollView : ICefScrollView read GetAsScrollView;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns this View as a Textfield or NULL if this is not a Textfield.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AsTextfield : ICefTextfield read GetAsTextfield;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Recursively descends the view tree starting at this View, and returns the
|
|
|
|
/// first child that it encounters with the given ID. Returns NULL if no
|
|
|
|
/// matching child view is found.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property ViewForID[id_: Integer] : ICefView read GetViewForID;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true (1) if this View is valid.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Valid : boolean read GetIsValid;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns true (1) if this View is currently attached to another View. A
|
|
|
|
/// View can only be attached to one View at a time.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Attached : boolean read GetIsAttached;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the delegate associated with this View, if any.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Delegate : ICefViewDelegate read GetDelegate;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the top-level Window hosting this View, if any.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Window : ICefWindow read GetWindow;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the View that contains this View, if any.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property ParentView : ICefView read GetParentView;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the bounds (size and position) of this View in DIP screen
|
|
|
|
/// coordinates.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property BoundsInScreen : TCefRect read GetBoundsInScreen;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the size this View would like to be if enough space is available.
|
|
|
|
/// Size is in parent coordinates, or DIP screen coordinates if there is no
|
|
|
|
/// parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property PreferredSize : TCefSize read GetPreferredSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the minimum size for this View. Size is in parent coordinates, or
|
|
|
|
/// DIP screen coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property MinimumSize : TCefSize read GetMinimumSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the maximum size for this View. Size is in parent coordinates, or
|
|
|
|
/// DIP screen coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property MaximumSize : TCefSize read GetMaximumSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns whether this View is visible. A view may be visible but still not
|
|
|
|
/// drawn in a Window if any parent views are hidden. If this View is a Window
|
|
|
|
/// then a return value of true (1) indicates that this Window is currently
|
|
|
|
/// visible to the user on-screen. If this View is not a Window then call
|
|
|
|
/// is_drawn() to determine whether this View and all parent views are visible
|
|
|
|
/// and will be drawn.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Visible : boolean read GetIsVisible write SetVisible;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns whether this View is visible and drawn in a Window. A view is
|
|
|
|
/// drawn if it and all parent views are visible. If this View is a Window
|
|
|
|
/// then calling this function is equivalent to calling is_visible().
|
|
|
|
/// Otherwise, to determine if the containing Window is visible to the user
|
|
|
|
/// on-screen call is_visible() on the Window.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Drawn : boolean read GetIsDrawn;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get or set whether this View is enabled. A disabled View does not receive
|
|
|
|
/// keyboard or mouse inputs. If |enabled| differs from the current value the
|
|
|
|
/// View will be repainted. Also, clears focus if the focused View is
|
|
|
|
/// disabled.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Enabled : boolean read GetIsEnabled write SetEnabled;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Gets and sets whether this View is capable of taking focus. It will clear focus if
|
|
|
|
/// the focused View is set to be non-focusable. This is false (0) by default
|
|
|
|
/// so that a View used as a container does not get the focus.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Focusable : boolean read GetIsFocusable write SetFocusable;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return whether this View is focusable when the user requires full keyboard
|
|
|
|
/// access, even though it may not be normally focusable.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property AccessibilityFocusable : boolean read GetIsAccessibilityFocusable;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
2024-05-01 18:19:19 +02:00
|
|
|
/// Returns the background color for this View. If the background color is
|
|
|
|
/// unset then the current `GetThemeColor(CEF_ColorPrimaryBackground)` value
|
|
|
|
/// will be returned. If this View belongs to an overlay (created with
|
|
|
|
/// ICefWindow.AddOverlayView), and the background color is unset, then a
|
|
|
|
/// value of transparent (0) will be returned.
|
2023-09-29 19:23:38 +02:00
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property BackgroundColor : TCefColor read GetBackgroundColor write SetBackgroundColor;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the ID for this View. ID should be unique within the subtree that you
|
|
|
|
/// intend to search for it. 0 is the default ID for views.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property ID : integer read GetID write SetID;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the group id of this View, or -1 if not set.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property GroupID : integer read GetGroupID write SetGroupID;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the bounds (size and position) of this View in parent coordinates,
|
|
|
|
/// or DIP screen coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Bounds : TCefRect read GetBounds write SetBounds;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the size of this View in parent coordinates, or DIP screen
|
|
|
|
/// coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Size : TCefSize read GetSize write SetSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the position of this View. Position is in parent coordinates, or
|
|
|
|
/// DIP screen coordinates if there is no parent.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property Position : TCefPoint read GetPosition write SetPosition;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the insets for this View in parent coordinates, or DIP screen
|
|
|
|
/// coordinates if there is no parent.
|
|
|
|
/// </summary>
|
|
|
|
property Insets : TCefInsets read GetInsets write SetInsets;
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the type of this View as a string. Used primarily for testing
|
|
|
|
/// purposes.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property TypeString : ustring read GetTypeString;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the height necessary to display this View with the provided width.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property HeightForWidth[width: Integer] : Integer read GetHeightForWidth;
|
|
|
|
|
|
|
|
published
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return the preferred size for |view|. The Layout will use this information
|
|
|
|
/// to determine the display size.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnGetPreferredSize : TOnGetPreferredSizeEvent read FOnGetPreferredSize write FOnGetPreferredSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return the minimum size for |view|.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnGetMinimumSize : TOnGetMinimumSizeEvent read FOnGetMinimumSize write FOnGetMinimumSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return the maximum size for |view|.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnGetMaximumSize : TOnGetMaximumSizeEvent read FOnGetMaximumSize write FOnGetMaximumSize;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Return the height necessary to display |view| with the provided |width|.
|
|
|
|
/// If not specified the result of get_preferred_size().height will be used by
|
|
|
|
/// default. Override if |view|'s preferred height depends upon the width (for
|
|
|
|
/// example, with Labels).
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnGetHeightForWidth : TOnGetHeightForWidthEvent read FOnGetHeightForWidth write FOnGetHeightForWidth;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the parent of |view| has changed. If |view| is being added to
|
|
|
|
/// |parent| then |added| will be true (1). If |view| is being removed from
|
|
|
|
/// |parent| then |added| will be false (0). If |view| is being reparented the
|
|
|
|
/// remove notification will be sent before the add notification. Do not
|
|
|
|
/// modify the view hierarchy in this callback.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnParentViewChanged : TOnParentViewChangedEvent read FOnParentViewChanged write FOnParentViewChanged;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when a child of |view| has changed. If |child| is being added to
|
|
|
|
/// |view| then |added| will be true (1). If |child| is being removed from
|
|
|
|
/// |view| then |added| will be false (0). If |child| is being reparented the
|
|
|
|
/// remove notification will be sent to the old parent before the add
|
|
|
|
/// notification is sent to the new parent. Do not modify the view hierarchy
|
|
|
|
/// in this callback.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnChildViewChanged : TOnChildViewChangedEvent read FOnChildViewChanged write FOnChildViewChanged;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when |view| is added or removed from the ICefWindow.
|
|
|
|
/// </summary>
|
2021-04-18 19:36:20 +02:00
|
|
|
property OnWindowChanged : TOnWindowChangedEvent read FOnWindowChanged write FOnWindowChanged;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when the layout of |view| has changed.
|
|
|
|
/// </summary>
|
2021-09-27 12:04:33 +02:00
|
|
|
property OnLayoutChanged : TOnLayoutChangedEvent read FOnLayoutChanged write FOnLayoutChanged;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when |view| gains focus.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnFocus : TOnFocusEvent read FOnFocus write FOnFocus;
|
2023-09-29 19:23:38 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Called when |view| loses focus.
|
|
|
|
/// </summary>
|
2020-05-05 18:10:33 +02:00
|
|
|
property OnBlur : TOnBlurEvent read FOnBlur write FOnBlur;
|
2024-05-01 18:19:19 +02:00
|
|
|
/// <summary>
|
|
|
|
/// <para>Called when the theme for |view| has changed, after the new theme colors
|
|
|
|
/// have already been applied. Views are notified via the component hierarchy
|
|
|
|
/// in depth-first reverse order (children before parents).</para>
|
|
|
|
/// <para>This will be called in the following cases:</para>
|
|
|
|
/// <code>
|
|
|
|
/// 1. When |view|, or a parent of |view|, is added to a Window.
|
|
|
|
/// 2. When the native/OS or Chrome theme changes for the Window that contains
|
|
|
|
/// |view|. See ICefWindowDelegate.OnThemeColorsChanged documentation.
|
|
|
|
/// 3. When the client explicitly calls ICefWindow.ThemeChanged on the
|
|
|
|
/// Window that contains |view|.
|
|
|
|
/// </code>
|
|
|
|
/// <para>Optionally use this callback to override the new per-View theme colors by
|
|
|
|
/// calling ICefView.SetBackgroundColor or the appropriate component-
|
|
|
|
/// specific function. See ICefWindow.SetThemeColor documentation for how
|
|
|
|
/// to customize additional Window theme colors.</para>
|
|
|
|
/// <summary>
|
|
|
|
property OnThemeChanged : TOnThemeChangedEvent read FOnThemeChanged write FOnThemeChanged;
|
2020-05-05 18:10:33 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
// *********************************************************
|
|
|
|
// ********************** ATTENTION ! **********************
|
|
|
|
// *********************************************************
|
|
|
|
// ** **
|
|
|
|
// ** MANY OF THE EVENTS IN CEF4DELPHI COMPONENTS LIKE **
|
|
|
|
// ** TCHROMIUM, TFMXCHROMIUM OR TCEFAPPLICATION ARE **
|
|
|
|
// ** EXECUTED IN A CEF THREAD BY DEFAULT. **
|
|
|
|
// ** **
|
|
|
|
// ** WINDOWS CONTROLS MUST BE CREATED AND DESTROYED IN **
|
|
|
|
// ** THE SAME THREAD TO AVOID ERRORS. **
|
|
|
|
// ** SOME OF THEM RECREATE THE HANDLERS IF THEY ARE **
|
|
|
|
// ** MODIFIED AND CAN CAUSE THE SAME ERRORS. **
|
|
|
|
// ** **
|
|
|
|
// ** DON'T CREATE, MODIFY OR DESTROY WINDOWS CONTROLS **
|
|
|
|
// ** INSIDE THE CEF4DELPHI EVENTS AND USE **
|
|
|
|
// ** SYNCHRONIZATION OBJECTS TO PROTECT VARIABLES AND **
|
|
|
|
// ** FIELDS IF THEY ARE ALSO USED IN THE MAIN THREAD. **
|
|
|
|
// ** **
|
|
|
|
// ** READ THIS FOR MORE INFORMATION : **
|
|
|
|
// ** https://www.briskbard.com/index.php?pageid=cef **
|
|
|
|
// ** **
|
|
|
|
// ** USE OUR FORUMS FOR MORE QUESTIONS : **
|
|
|
|
// ** https://www.briskbard.com/forum/ **
|
|
|
|
// ** **
|
|
|
|
// *********************************************************
|
|
|
|
// *********************************************************
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2023-11-29 13:04:33 +01:00
|
|
|
uCEFViewDelegate, uCEFMiscFunctions, uCEFTask, uCEFApplicationCore;
|
2020-05-05 18:10:33 +02:00
|
|
|
|
|
|
|
constructor TCEFViewComponent.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(aOwner);
|
|
|
|
|
|
|
|
Initialize;
|
2023-11-29 13:04:33 +01:00
|
|
|
FComponentID := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.AfterConstruction;
|
|
|
|
begin
|
|
|
|
inherited AfterConstruction;
|
|
|
|
|
|
|
|
if assigned(GlobalCEFApp) then
|
|
|
|
FComponentID := GlobalCEFApp.NextComponentID;
|
2020-05-05 18:10:33 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.BeforeDestruction;
|
|
|
|
begin
|
2023-11-29 13:04:33 +01:00
|
|
|
if assigned(GlobalCEFApp) then
|
|
|
|
GlobalCEFApp.RemoveComponentID(FComponentID);
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
DestroyView;
|
|
|
|
|
|
|
|
inherited BeforeDestruction;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.Initialize;
|
|
|
|
begin
|
|
|
|
FOnGetPreferredSize := nil;
|
|
|
|
FOnGetMinimumSize := nil;
|
|
|
|
FOnGetMaximumSize := nil;
|
|
|
|
FOnGetHeightForWidth := nil;
|
|
|
|
FOnParentViewChanged := nil;
|
|
|
|
FOnChildViewChanged := nil;
|
2021-04-18 19:36:20 +02:00
|
|
|
FOnWindowChanged := nil;
|
2021-09-27 12:04:33 +02:00
|
|
|
FOnLayoutChanged := nil;
|
2020-05-05 18:10:33 +02:00
|
|
|
FOnFocus := nil;
|
|
|
|
FOnBlur := nil;
|
2024-05-01 18:19:19 +02:00
|
|
|
FOnThemeChanged := nil;
|
2020-05-05 18:10:33 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.CreateView;
|
|
|
|
var
|
|
|
|
TempTask : ICefTask;
|
|
|
|
begin
|
|
|
|
if CefCurrentlyOn(TID_UI) then
|
|
|
|
doCreateCustomView
|
|
|
|
else
|
|
|
|
try
|
|
|
|
TempTask := TCefCreateCustomViewTask.Create(self);
|
|
|
|
CefPostTask(TID_UI, TempTask);
|
|
|
|
finally
|
|
|
|
TempTask := nil;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.DestroyView;
|
|
|
|
begin
|
|
|
|
//
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetInitialized : boolean;
|
|
|
|
begin
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
2023-11-29 13:04:33 +01:00
|
|
|
function TCEFViewComponent.GetComponentID : integer;
|
|
|
|
begin
|
|
|
|
Result := FComponentID;
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
function TCEFViewComponent.GetAsView : ICefView;
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetAsBrowserView : ICefBrowserView;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.AsBrowserView
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetAsButton : ICefButton;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.AsButton
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetAsPanel : ICefPanel;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.AsPanel
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetAsScrollView : ICefScrollView;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.AsScrollView
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetAsTextfield : ICefTextfield;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.AsTextfield
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetTypeString : ustring;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetTypeString
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ToStringEx(include_children: boolean): ustring;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.ToStringEx(include_children)
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsValid : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsValid;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsAttached : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsAttached;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.IsSame(const that: ICefView): boolean;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.IsSame(that)
|
|
|
|
else
|
|
|
|
Result := False;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetDelegate : ICefViewDelegate;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetDelegate
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetWindow : ICefWindow;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetWindow
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetID : Integer;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetID
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetID(id_: Integer);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetID(id_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetGroupID : Integer;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetGroupID
|
|
|
|
else
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetGroupID(group_id: Integer);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetGroupID(group_id);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetParentView : ICefView;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetParentView
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetViewForID(id_: Integer): ICefView;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetViewForID(id_)
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetBounds(const bounds_: TCefRect);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetBounds(bounds_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetBounds : TCefRect;
|
|
|
|
var
|
|
|
|
TempRect : TCefRect;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempRect := AsView.GetBounds
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempRect.x := 0;
|
|
|
|
TempRect.y := 0;
|
|
|
|
TempRect.width := 0;
|
|
|
|
TempRect.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetBoundsInScreen : TCefRect;
|
|
|
|
var
|
|
|
|
TempRect : TCefRect;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempRect := AsView.GetBoundsInScreen
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempRect.x := 0;
|
|
|
|
TempRect.y := 0;
|
|
|
|
TempRect.width := 0;
|
|
|
|
TempRect.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetSize(const size_: TCefSize);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetSize(size_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetSize : TCefSize;
|
|
|
|
var
|
|
|
|
TempSize : TCefSize;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempSize := AsView.GetSize
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempSize.width := 0;
|
|
|
|
TempSize.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetPosition(const position_: TCefPoint);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetPosition(position_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetPosition : TCefPoint;
|
|
|
|
var
|
|
|
|
TempPoint : TCefPoint;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempPoint := AsView.GetPosition
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempPoint.x := 0;
|
|
|
|
TempPoint.y := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempPoint;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetPreferredSize : TCefSize;
|
|
|
|
var
|
|
|
|
TempSize : TCefSize;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempSize := AsView.GetPreferredSize
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempSize.width := 0;
|
|
|
|
TempSize.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SizeToPreferredSize;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SizeToPreferredSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetMinimumSize : TCefSize;
|
|
|
|
var
|
|
|
|
TempSize : TCefSize;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempSize := AsView.GetMinimumSize
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempSize.width := 0;
|
|
|
|
TempSize.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetMaximumSize : TCefSize;
|
|
|
|
var
|
|
|
|
TempSize : TCefSize;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
TempSize := AsView.GetMaximumSize
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
TempSize.width := 0;
|
|
|
|
TempSize.height := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TempSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetHeightForWidth(width: Integer): Integer;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetHeightForWidth(width)
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
2023-09-29 19:23:38 +02:00
|
|
|
function TCEFViewComponent.GetInsets: TCefInsets;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetInsets
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Result.top := 0;
|
|
|
|
Result.left := 0;
|
|
|
|
Result.bottom := 0;
|
|
|
|
Result.right := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure TCEFViewComponent.InvalidateLayout;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.InvalidateLayout;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetVisible(visible_: boolean);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetVisible(visible_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsVisible : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsVisible;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsDrawn : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsDrawn;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetEnabled(enabled_: boolean);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetEnabled(enabled_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsEnabled : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsEnabled;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetFocusable(focusable_: boolean);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetFocusable(focusable_);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsFocusable : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsFocusable;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.GetIsAccessibilityFocusable : boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.IsAccessibilityFocusable;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.RequestFocus;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.RequestFocus;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.SetBackgroundColor(color: TCefColor);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetBackgroundColor(color);
|
|
|
|
end;
|
|
|
|
|
2023-09-29 19:23:38 +02:00
|
|
|
procedure TCEFViewComponent.SetInsets(const insets: TCefInsets);
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
AsView.SetInsets(insets);
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
function TCEFViewComponent.GetBackgroundColor : TCefColor;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetBackgroundColor
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
2024-05-01 18:19:19 +02:00
|
|
|
function TCEFViewComponent.GetThemeColor(color_id: integer): TCefColor;
|
|
|
|
begin
|
|
|
|
if Initialized then
|
|
|
|
Result := AsView.GetThemeColor(color_id)
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
function TCEFViewComponent.ConvertPointToScreen(var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointToScreen(point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ConvertPointFromScreen(var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointFromScreen(point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ConvertPointToWindow(var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointToWindow(point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ConvertPointFromWindow(var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointFromWindow(point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointToView(view, point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCEFViewComponent.ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean;
|
|
|
|
begin
|
|
|
|
Result := Initialized and AsView.ConvertPointFromView(view, point);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnGetPreferredSize(const view : ICefView;
|
|
|
|
var aResult : TCefSize);
|
|
|
|
begin
|
|
|
|
if assigned(FOnGetPreferredSize) then
|
|
|
|
FOnGetPreferredSize(self, view, aResult);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnGetMinimumSize(const view : ICefView;
|
|
|
|
var aResult : TCefSize);
|
|
|
|
begin
|
|
|
|
if assigned(FOnGetMinimumSize) then
|
|
|
|
FOnGetMinimumSize(self, view, aResult);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnGetMaximumSize(const view : ICefView;
|
|
|
|
var aResult : TCefSize);
|
|
|
|
begin
|
|
|
|
if assigned(FOnGetMaximumSize) then
|
|
|
|
FOnGetMaximumSize(self, view, aResult);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnGetHeightForWidth(const view : ICefView;
|
|
|
|
width : Integer;
|
|
|
|
var aResult : Integer);
|
|
|
|
begin
|
|
|
|
if assigned(FOnGetHeightForWidth) then
|
|
|
|
FOnGetHeightForWidth(self, view, width, aResult);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnParentViewChanged(const view : ICefView;
|
|
|
|
added : boolean;
|
|
|
|
const parent : ICefView);
|
|
|
|
begin
|
|
|
|
if assigned(FOnParentViewChanged) then
|
|
|
|
FOnParentViewChanged(self, view, added, Parent);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnChildViewChanged(const view : ICefView;
|
|
|
|
added : boolean;
|
|
|
|
const child : ICefView);
|
|
|
|
begin
|
|
|
|
if assigned(FOnChildViewChanged) then
|
|
|
|
FOnChildViewChanged(self, view, added, child);
|
|
|
|
end;
|
|
|
|
|
2021-04-18 19:36:20 +02:00
|
|
|
procedure TCEFViewComponent.doOnWindowChanged(const view : ICefView;
|
|
|
|
added : boolean);
|
|
|
|
begin
|
|
|
|
if assigned(FOnWindowChanged) then
|
|
|
|
FOnWindowChanged(self, view, added);
|
|
|
|
end;
|
|
|
|
|
2021-09-27 12:04:33 +02:00
|
|
|
procedure TCEFViewComponent.doOnLayoutChanged(const view: ICefView; new_bounds: TCefRect);
|
|
|
|
begin
|
|
|
|
if assigned(FOnLayoutChanged) then
|
|
|
|
FOnLayoutChanged(self, view, new_bounds);
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure TCEFViewComponent.doOnFocus(const view: ICefView);
|
|
|
|
begin
|
|
|
|
if assigned(FOnFocus) then
|
|
|
|
FOnFocus(self, view);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCEFViewComponent.doOnBlur(const view: ICefView);
|
|
|
|
begin
|
|
|
|
if assigned(FOnBlur) then
|
|
|
|
FOnBlur(self, view);
|
|
|
|
end;
|
|
|
|
|
2024-05-01 18:19:19 +02:00
|
|
|
procedure TCEFViewComponent.doOnThemeChanged(const view: ICefView);
|
|
|
|
begin
|
|
|
|
if assigned(FOnThemeChanged) then
|
|
|
|
FOnThemeChanged(self, view);
|
|
|
|
end;
|
|
|
|
|
2020-05-05 18:10:33 +02:00
|
|
|
procedure TCEFViewComponent.doCreateCustomView;
|
|
|
|
begin
|
|
|
|
//
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|