Added Views Framework support #244
Added ToolBoxBrowser2 demo Added TCEFBrowserViewComponent. Added TCEFLabelButtonComponent. Added TCEFMenuButtonComponent. Added TCEFPanelComponent. Added TCEFTextfieldComponent. Added TCEFScrollViewComponent. Added TCEFWindowComponent.
@ -50,7 +50,8 @@ uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, SyncObjs,
|
||||
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
|
||||
{$ENDIF}
|
||||
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFWindowParent, uCEFWinControl;
|
||||
uCEFChromium, uCEFTypes, uCEFInterfaces, uCEFConstants, uCEFWindowParent, uCEFWinControl,
|
||||
uCEFChromiumCore;
|
||||
|
||||
type
|
||||
TChildForm = class(TForm)
|
||||
|
18
demos/Delphi_VCL/ToolBoxBrowser2/00-DeleteDCUs.bat
Normal file
@ -0,0 +1,18 @@
|
||||
del /s /q *.dcu
|
||||
del /s /q *.exe
|
||||
del /s /q *.res
|
||||
del /s /q *.rsm
|
||||
del /s /q *.log
|
||||
del /s /q *.dsk
|
||||
del /s /q *.identcache
|
||||
del /s /q *.stat
|
||||
del /s /q *.local
|
||||
del /s /q *.~*
|
||||
rmdir Win32\Debug
|
||||
rmdir Win32\Release
|
||||
rmdir Win32
|
||||
rmdir Win64\Debug
|
||||
rmdir Win64\Release
|
||||
rmdir Win64
|
||||
rmdir __history
|
||||
rmdir __recovery
|
30
demos/Delphi_VCL/ToolBoxBrowser2/ToolBoxBrowser2.dpr
Normal file
@ -0,0 +1,30 @@
|
||||
program ToolBoxBrowser2;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Vcl.Forms,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
uCEFApplication,
|
||||
uMainForm in 'uMainForm.pas' {MainForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
begin
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.MainFormOnTaskbar := True;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
1004
demos/Delphi_VCL/ToolBoxBrowser2/ToolBoxBrowser2.dproj
Normal file
409
demos/Delphi_VCL/ToolBoxBrowser2/cef.inc
Normal file
@ -0,0 +1,409 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2017 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
// The complete list of compiler versions is here :
|
||||
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
|
||||
|
||||
{$DEFINE DELPHI_VERSION_UNKNOW}
|
||||
|
||||
// Delphi 5
|
||||
{$IFDEF VER130}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 6
|
||||
{$IFDEF VER140}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 7
|
||||
{$IFDEF VER150}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 8
|
||||
{$IFDEF VER160}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2005
|
||||
{$IFDEF VER170}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER180}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
// Delphi 2007
|
||||
{$IFDEF VER185}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
// Delphi 2006
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2009
|
||||
{$IFDEF VER200}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//Delphi 2010
|
||||
{$IFDEF VER210}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE
|
||||
{$IFDEF VER220}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE2 (First FireMonkey and 64bit compiler)
|
||||
{$IFDEF VER230}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE3
|
||||
{$IFDEF VER240}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE4
|
||||
{$IFDEF VER250}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE5
|
||||
{$IFDEF VER260}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE6
|
||||
{$IFDEF VER270}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE7
|
||||
{$IFDEF VER280}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE8
|
||||
{$IFDEF VER290}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$ENDIF VER290}
|
||||
|
||||
// Rad Studio 10 - Delphi Seattle
|
||||
{$IFDEF VER300}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.1 - Delphi Berlin
|
||||
{$IFDEF VER310}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.2 - Delphi Tokyo
|
||||
{$IFDEF VER320}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.3 - Delphi Rio
|
||||
{$IFDEF VER330}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ELSE}
|
||||
{$IFDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
64
demos/Delphi_VCL/ToolBoxBrowser2/uMainForm.dfm
Normal file
@ -0,0 +1,64 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'ToolBox Browser 2'
|
||||
ClientHeight = 37
|
||||
ClientWidth = 357
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poScreenCenter
|
||||
OnShow = FormShow
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object ButtonPnl: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 357
|
||||
Height = 37
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
object Edit1: TEdit
|
||||
Left = 8
|
||||
Top = 8
|
||||
Width = 286
|
||||
Height = 21
|
||||
TabOrder = 0
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 300
|
||||
Top = 6
|
||||
Width = 51
|
||||
Height = 25
|
||||
Caption = 'Open'
|
||||
TabOrder = 1
|
||||
OnClick = Button1Click
|
||||
end
|
||||
end
|
||||
object CEFWindowComponent1: TCEFWindowComponent
|
||||
OnGetPreferredSize = CEFWindowComponent1GetPreferredSize
|
||||
OnWindowCreated = CEFWindowComponent1WindowCreated
|
||||
OnWindowDestroyed = CEFWindowComponent1WindowDestroyed
|
||||
OnCanClose = CEFWindowComponent1CanClose
|
||||
Left = 48
|
||||
end
|
||||
object CEFBrowserViewComponent1: TCEFBrowserViewComponent
|
||||
Left = 152
|
||||
Top = 65528
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnTitleChange = Chromium1TitleChange
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
Left = 256
|
||||
Top = 8
|
||||
end
|
||||
end
|
215
demos/Delphi_VCL/ToolBoxBrowser2/uMainForm.pas
Normal file
@ -0,0 +1,215 @@
|
||||
unit uMainForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.ComCtrls,
|
||||
{$ELSE}
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||
{$ENDIF}
|
||||
uCEFInterfaces, uCEFTypes, uCEFConstants, uCEFViewComponent,
|
||||
uCEFPanelComponent, uCEFWindowComponent,
|
||||
uCEFBrowserViewComponent, uCEFChromiumCore, uCEFChromium;
|
||||
|
||||
const
|
||||
CEFBROWSER_INITIALIZED = WM_APP + $100;
|
||||
|
||||
DEFAULT_WINDOW_VIEW_WIDTH = 800;
|
||||
DEFAULT_WINDOW_VIEW_HEIGHT = 600;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
ButtonPnl: TPanel;
|
||||
Edit1: TEdit;
|
||||
Button1: TButton;
|
||||
CEFWindowComponent1: TCEFWindowComponent;
|
||||
CEFBrowserViewComponent1: TCEFBrowserViewComponent;
|
||||
Chromium1: TChromium;
|
||||
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
|
||||
procedure CEFWindowComponent1GetPreferredSize(const Sender: TObject; const view: ICefView; var aResult: TCefSize);
|
||||
procedure CEFWindowComponent1WindowCreated(const Sender: TObject; const window: ICefWindow);
|
||||
procedure CEFWindowComponent1WindowDestroyed(const Sender: TObject; const window: ICefWindow);
|
||||
procedure CEFWindowComponent1CanClose(const Sender: TObject; const window: ICefWindow; var aResult: Boolean);
|
||||
|
||||
procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
|
||||
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean);
|
||||
|
||||
protected
|
||||
procedure CEFInitializedMsg(var aMessage : TMessage); message CEFBROWSER_INITIALIZED;
|
||||
|
||||
procedure EnableInterface;
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
uCEFApplication;
|
||||
|
||||
// This demo uses the Views Framework in CEF to create a child window with a
|
||||
// web browser.
|
||||
|
||||
// CEF4Delphi has several components to facilitate the creation of several views
|
||||
// and this demo uses these :
|
||||
|
||||
// TCEFWindowComponent : Has a ICefWindow and a ICefWindowDelegate to call
|
||||
// the methods of a "CefWindow" and the events from the "CefWindowDelegate".
|
||||
// Read the linked documents bellow for more details about them.
|
||||
|
||||
// TCEFBrowserViewComponent : Has a ICefBrowserView and a ICefBrowserViewDelegate
|
||||
// to call the methods of a "CefBrowserView" and the events from the
|
||||
// "CefBrowserViewDelegate".
|
||||
|
||||
// TChromium : Is used to create the browser and to handle all its events.
|
||||
|
||||
// All the views have a hierarchy and they inherit methods or events from their
|
||||
// parents. See the diagram in the uCEFTypes.pas file (line 2900 aprox.)
|
||||
|
||||
// This demo creates a window when the user clicks on the "Open" button.
|
||||
// Most of the methods in the Views Framework must be used in the CEF UI thread
|
||||
// but most of the procedures used to create the CEF4Delphi components create a
|
||||
// task if they are called in a different thread. The rest of the methods *MUST*
|
||||
// be called in the CEF UI thread or they won't work.
|
||||
|
||||
// TCEFWindowComponent.CreateTopLevelWindow triggers the
|
||||
// TCEFWindowComponent.OnWindowCreated event which is executed in the CEF UI
|
||||
// thread and you can use it to create the child views in the window, in this
|
||||
// case a browser view.
|
||||
|
||||
// TCEFWindowComponent.OnGetPreferredSize will alse be triggered when you create
|
||||
// the window to get the window size in DIPs.
|
||||
|
||||
// REFERENCES :
|
||||
// ------------
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/1749
|
||||
// https://www.chromium.org/developers/design-documents/chromeviews
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefView.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefViewDelegate.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefWindow.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefWindowDelegate.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowserView.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowserViewDelegate.html
|
||||
|
||||
procedure GlobalCEFApp_OnContextInitialized;
|
||||
begin
|
||||
if (MainForm <> nil) and MainForm.HandleAllocated then
|
||||
PostMessage(MainForm.Handle, CEFBROWSER_INITIALIZED, 0, 0);
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
end;
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
begin
|
||||
CEFWindowComponent1.CreateTopLevelWindow;
|
||||
ButtonPnl.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFInitializedMsg(var aMessage : TMessage);
|
||||
begin
|
||||
EnableInterface;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1CanClose(const Sender: TObject;
|
||||
const window: ICefWindow; var aResult: Boolean);
|
||||
begin
|
||||
aResult := Chromium1.TryCloseBrowser;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1GetPreferredSize(const Sender: TObject;
|
||||
const view: ICefView; var aResult: TCefSize);
|
||||
begin
|
||||
// This is the initial window size
|
||||
aResult.width := DEFAULT_WINDOW_VIEW_WIDTH;
|
||||
aResult.height := DEFAULT_WINDOW_VIEW_HEIGHT;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1WindowCreated(const Sender: TObject;
|
||||
const window: ICefWindow);
|
||||
var
|
||||
TempURL : ustring;
|
||||
TempWorkArea : TCefRect;
|
||||
TempPosition : TCefPoint;
|
||||
TempDisplay : ICefDisplay;
|
||||
begin
|
||||
TempURL := trim(Edit1.Text);
|
||||
if (length(TempURL) = 0) then TempURL := 'about:blank';
|
||||
|
||||
// This event is executed in the CEF UI thread and we can call all these other
|
||||
// functions on this thread. In fact, all of these functions only work when
|
||||
// you call them on this thread.
|
||||
|
||||
if Chromium1.CreateBrowser(TempURL, CEFBrowserViewComponent1) then
|
||||
begin
|
||||
CEFWindowComponent1.AddChildView(CEFBrowserViewComponent1.BrowserView);
|
||||
CEFWindowComponent1.Show;
|
||||
|
||||
// This centers the window on the screen
|
||||
TempDisplay := CEFWindowComponent1.Display;
|
||||
if (TempDisplay <> nil) then
|
||||
begin
|
||||
TempWorkArea := TempDisplay.WorkArea;
|
||||
TempPosition.x := ((TempWorkArea.width - DEFAULT_WINDOW_VIEW_WIDTH) div 2) + TempWorkArea.x;
|
||||
TempPosition.y := ((TempWorkArea.height - DEFAULT_WINDOW_VIEW_HEIGHT) div 2) + TempWorkArea.y;
|
||||
|
||||
CEFWindowComponent1.Position := TempPosition;
|
||||
end;
|
||||
|
||||
CEFBrowserViewComponent1.RequestFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1WindowDestroyed(const Sender: TObject;
|
||||
const window: ICefWindow);
|
||||
begin
|
||||
ButtonPnl.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TMainForm.Chromium1BeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
var windowInfo: TCefWindowInfo; var client: ICefClient;
|
||||
var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
var noJavascriptAccess, Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TMainForm.Chromium1TitleChange(Sender: TObject;
|
||||
const browser: ICefBrowser; const title: ustring);
|
||||
begin
|
||||
CEFWindowComponent1.Title := title;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
|
||||
EnableInterface;
|
||||
end;
|
||||
|
||||
procedure TMainForm.EnableInterface;
|
||||
begin
|
||||
Caption := 'ToolBox Browser 2';
|
||||
ButtonPnl.Enabled := True;
|
||||
cursor := crDefault;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -4,7 +4,7 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="13">
|
||||
<Units Count="22">
|
||||
<Unit0>
|
||||
<Filename Value="MiniBrowser.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -119,6 +119,68 @@
|
||||
<CursorPos X="62" Y="124"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\..\source\uCEFBrowserViewComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="238"/>
|
||||
<CursorPos X="23" Y="257"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="..\..\..\source\uCEFButtonComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="177"/>
|
||||
<CursorPos X="55" Y="202"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="..\..\..\source\uCEFWindowComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="528"/>
|
||||
<CursorPos X="47" Y="547"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="..\..\..\source\uCEFTextfieldComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="424"/>
|
||||
<CursorPos X="47" Y="442"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="..\..\..\source\uCEFViewComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="685"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="..\..\..\source\uCEFScrollViewComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="219"/>
|
||||
<CursorPos X="47" Y="238"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="..\..\..\source\uCEFPanelComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="241"/>
|
||||
<CursorPos X="53" Y="251"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
<Filename Value="..\..\..\source\uCEFLabelButtonComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="244"/>
|
||||
<CursorPos X="47" Y="263"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
<Filename Value="..\..\..\source\uCEFMenuButtonComponent.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="200"/>
|
||||
<CursorPos X="47" Y="219"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit21>
|
||||
</Units>
|
||||
<JumpHistory Count="5" HistoryIndex="4">
|
||||
<Position1>
|
||||
|
2
demos/Lazarus/ToolBoxBrowser2/00-Delete.bat
Normal file
@ -0,0 +1,2 @@
|
||||
rmdir /S /Q lib
|
||||
rmdir /S /Q backup
|
91
demos/Lazarus/ToolBoxBrowser2/ToolBoxBrowser2.lpi
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="ToolBoxBrowser2"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="CEF4Delphi_Lazarus"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="ToolBoxBrowser2.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="..\..\..\bin\ToolBoxBrowser2"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
33
demos/Lazarus/ToolBoxBrowser2/ToolBoxBrowser2.lpr
Normal file
@ -0,0 +1,33 @@
|
||||
program ToolBoxBrowser2;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Vcl.Forms,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
Forms,
|
||||
LCLIntf, LCLType, LMessages, Interfaces,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uMainForm in 'uMainForm.pas' {MainForm};
|
||||
|
||||
{.$R *.res}
|
||||
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
begin
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.MainFormOnTaskbar := True;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
44
demos/Lazarus/ToolBoxBrowser2/ToolBoxBrowser2.lps
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectSession>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="ToolBoxBrowser2.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="10"/>
|
||||
<CursorPos X="63" Y="20"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="82"/>
|
||||
<CursorPos X="87" Y="105"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
<JumpHistory Count="1">
|
||||
<Position1>
|
||||
<Filename Value="uMainForm.pas"/>
|
||||
<Caret Line="13" Column="49"/>
|
||||
</Position1>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0" ActiveMode=""/>
|
||||
</RunParams>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
409
demos/Lazarus/ToolBoxBrowser2/cef.inc
Normal file
@ -0,0 +1,409 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2017 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
// The complete list of compiler versions is here :
|
||||
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
|
||||
|
||||
{$DEFINE DELPHI_VERSION_UNKNOW}
|
||||
|
||||
// Delphi 5
|
||||
{$IFDEF VER130}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 6
|
||||
{$IFDEF VER140}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 7
|
||||
{$IFDEF VER150}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 8
|
||||
{$IFDEF VER160}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2005
|
||||
{$IFDEF VER170}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER180}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
// Delphi 2007
|
||||
{$IFDEF VER185}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
// Delphi 2006
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2009
|
||||
{$IFDEF VER200}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//Delphi 2010
|
||||
{$IFDEF VER210}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE
|
||||
{$IFDEF VER220}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE2 (First FireMonkey and 64bit compiler)
|
||||
{$IFDEF VER230}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE3
|
||||
{$IFDEF VER240}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE4
|
||||
{$IFDEF VER250}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE5
|
||||
{$IFDEF VER260}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE6
|
||||
{$IFDEF VER270}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE7
|
||||
{$IFDEF VER280}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE8
|
||||
{$IFDEF VER290}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$ENDIF VER290}
|
||||
|
||||
// Rad Studio 10 - Delphi Seattle
|
||||
{$IFDEF VER300}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.1 - Delphi Berlin
|
||||
{$IFDEF VER310}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.2 - Delphi Tokyo
|
||||
{$IFDEF VER320}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.3 - Delphi Rio
|
||||
{$IFDEF VER330}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ELSE}
|
||||
{$IFDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
64
demos/Lazarus/ToolBoxBrowser2/uMainForm.lfm
Normal file
@ -0,0 +1,64 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 559
|
||||
Height = 37
|
||||
Top = 278
|
||||
Width = 357
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'ToolBox Browser 2'
|
||||
ClientHeight = 37
|
||||
ClientWidth = 357
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
OnShow = FormShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.0.8.0'
|
||||
object ButtonPnl: TPanel
|
||||
Left = 0
|
||||
Height = 37
|
||||
Top = 0
|
||||
Width = 357
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 37
|
||||
ClientWidth = 357
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
object Edit1: TEdit
|
||||
Left = 6
|
||||
Height = 21
|
||||
Top = 6
|
||||
Width = 286
|
||||
TabOrder = 0
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 298
|
||||
Height = 25
|
||||
Top = 4
|
||||
Width = 51
|
||||
Caption = 'Open'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object CEFWindowComponent1: TCEFWindowComponent
|
||||
OnGetPreferredSize = CEFWindowComponent1GetPreferredSize
|
||||
OnWindowCreated = CEFWindowComponent1WindowCreated
|
||||
OnWindowDestroyed = CEFWindowComponent1WindowDestroyed
|
||||
OnCanClose = CEFWindowComponent1CanClose
|
||||
left = 48
|
||||
end
|
||||
object CEFBrowserViewComponent1: TCEFBrowserViewComponent
|
||||
left = 152
|
||||
top = 65528
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnTitleChange = Chromium1TitleChange
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
left = 256
|
||||
top = 8
|
||||
end
|
||||
end
|
217
demos/Lazarus/ToolBoxBrowser2/uMainForm.pas
Normal file
@ -0,0 +1,217 @@
|
||||
unit uMainForm;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.ComCtrls,
|
||||
{$ELSE}
|
||||
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
|
||||
{$ENDIF}
|
||||
uCEFInterfaces, uCEFTypes, uCEFConstants, uCEFViewComponent,
|
||||
uCEFPanelComponent, uCEFWindowComponent,
|
||||
uCEFBrowserViewComponent, uCEFChromiumCore, uCEFChromium;
|
||||
|
||||
const
|
||||
CEFBROWSER_INITIALIZED = WM_APP + $100;
|
||||
|
||||
DEFAULT_WINDOW_VIEW_WIDTH = 800;
|
||||
DEFAULT_WINDOW_VIEW_HEIGHT = 600;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
ButtonPnl: TPanel;
|
||||
Edit1: TEdit;
|
||||
Button1: TButton;
|
||||
CEFWindowComponent1: TCEFWindowComponent;
|
||||
CEFBrowserViewComponent1: TCEFBrowserViewComponent;
|
||||
Chromium1: TChromium;
|
||||
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
|
||||
procedure CEFWindowComponent1GetPreferredSize(const Sender: TObject; const view: ICefView; var aResult: TCefSize);
|
||||
procedure CEFWindowComponent1WindowCreated(const Sender: TObject; const window: ICefWindow);
|
||||
procedure CEFWindowComponent1WindowDestroyed(const Sender: TObject; const window: ICefWindow);
|
||||
procedure CEFWindowComponent1CanClose(const Sender: TObject; const window: ICefWindow; var aResult: Boolean);
|
||||
|
||||
procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
|
||||
procedure Chromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean);
|
||||
|
||||
protected
|
||||
procedure CEFInitializedMsg(var aMessage : TMessage); message CEFBROWSER_INITIALIZED;
|
||||
|
||||
procedure EnableInterface;
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
uCEFApplication;
|
||||
|
||||
// This demo uses the Views Framework in CEF to create a child window with a
|
||||
// web browser.
|
||||
|
||||
// CEF4Delphi has several components to facilitate the creation of several views
|
||||
// and this demo uses these :
|
||||
|
||||
// TCEFWindowComponent : Has a ICefWindow and a ICefWindowDelegate to call
|
||||
// the methods of a "CefWindow" and the events from the "CefWindowDelegate".
|
||||
// Read the linked documents bellow for more details about them.
|
||||
|
||||
// TCEFBrowserViewComponent : Has a ICefBrowserView and a ICefBrowserViewDelegate
|
||||
// to call the methods of a "CefBrowserView" and the events from the
|
||||
// "CefBrowserViewDelegate".
|
||||
|
||||
// TChromium : Is used to create the browser and to handle all its events.
|
||||
|
||||
// All the views have a hierarchy and they inherit methods or events from their
|
||||
// parents. See the diagram in the uCEFTypes.pas file (line 2900 aprox.)
|
||||
|
||||
// This demo creates a window when the user clicks on the "Open" button.
|
||||
// Most of the methods in the Views Framework must be used in the CEF UI thread
|
||||
// but most of the procedures used to create the CEF4Delphi components create a
|
||||
// task if they are called in a different thread. The rest of the methods *MUST*
|
||||
// be called in the CEF UI thread or they won't work.
|
||||
|
||||
// TCEFWindowComponent.CreateTopLevelWindow triggers the
|
||||
// TCEFWindowComponent.OnWindowCreated event which is executed in the CEF UI
|
||||
// thread and you can use it to create the child views in the window, in this
|
||||
// case a browser view.
|
||||
|
||||
// TCEFWindowComponent.OnGetPreferredSize will alse be triggered when you create
|
||||
// the window to get the window size in DIPs.
|
||||
|
||||
// REFERENCES :
|
||||
// ------------
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/1749
|
||||
// https://www.chromium.org/developers/design-documents/chromeviews
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefView.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefViewDelegate.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefWindow.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefWindowDelegate.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowserView.html
|
||||
// https://magpcss.org/ceforum/apidocs3/projects/(default)/CefBrowserViewDelegate.html
|
||||
|
||||
procedure GlobalCEFApp_OnContextInitialized;
|
||||
begin
|
||||
if (MainForm <> nil) and MainForm.HandleAllocated then
|
||||
PostMessage(MainForm.Handle, CEFBROWSER_INITIALIZED, 0, 0);
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
end;
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
begin
|
||||
CEFWindowComponent1.CreateTopLevelWindow;
|
||||
ButtonPnl.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFInitializedMsg(var aMessage : TMessage);
|
||||
begin
|
||||
EnableInterface;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1CanClose(const Sender: TObject;
|
||||
const window: ICefWindow; var aResult: Boolean);
|
||||
begin
|
||||
aResult := Chromium1.TryCloseBrowser;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1GetPreferredSize(const Sender: TObject;
|
||||
const view: ICefView; var aResult: TCefSize);
|
||||
begin
|
||||
// This is the initial window size
|
||||
aResult.width := DEFAULT_WINDOW_VIEW_WIDTH;
|
||||
aResult.height := DEFAULT_WINDOW_VIEW_HEIGHT;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1WindowCreated(const Sender: TObject;
|
||||
const window: ICefWindow);
|
||||
var
|
||||
TempURL : ustring;
|
||||
TempWorkArea : TCefRect;
|
||||
TempPosition : TCefPoint;
|
||||
TempDisplay : ICefDisplay;
|
||||
begin
|
||||
TempURL := trim(Edit1.Text);
|
||||
if (length(TempURL) = 0) then TempURL := 'about:blank';
|
||||
|
||||
// This event is executed in the CEF UI thread and we can call all these other
|
||||
// functions on this thread. In fact, all of these functions only work when
|
||||
// you call them on this thread.
|
||||
|
||||
if Chromium1.CreateBrowser(TempURL, CEFBrowserViewComponent1) then
|
||||
begin
|
||||
CEFWindowComponent1.AddChildView(CEFBrowserViewComponent1.BrowserView);
|
||||
CEFWindowComponent1.Show;
|
||||
|
||||
// This centers the window on the screen
|
||||
TempDisplay := CEFWindowComponent1.Display;
|
||||
if (TempDisplay <> nil) then
|
||||
begin
|
||||
TempWorkArea := TempDisplay.WorkArea;
|
||||
TempPosition.x := ((TempWorkArea.width - DEFAULT_WINDOW_VIEW_WIDTH) div 2) + TempWorkArea.x;
|
||||
TempPosition.y := ((TempWorkArea.height - DEFAULT_WINDOW_VIEW_HEIGHT) div 2) + TempWorkArea.y;
|
||||
|
||||
CEFWindowComponent1.Position := TempPosition;
|
||||
end;
|
||||
|
||||
CEFBrowserViewComponent1.RequestFocus;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CEFWindowComponent1WindowDestroyed(const Sender: TObject;
|
||||
const window: ICefWindow);
|
||||
begin
|
||||
ButtonPnl.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TMainForm.Chromium1BeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
var windowInfo: TCefWindowInfo; var client: ICefClient;
|
||||
var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
var noJavascriptAccess, Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TMainForm.Chromium1TitleChange(Sender: TObject;
|
||||
const browser: ICefBrowser; const title: ustring);
|
||||
begin
|
||||
CEFWindowComponent1.Title := title;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
|
||||
EnableInterface;
|
||||
end;
|
||||
|
||||
procedure TMainForm.EnableInterface;
|
||||
begin
|
||||
Caption := 'ToolBox Browser 2';
|
||||
ButtonPnl.Enabled := True;
|
||||
cursor := crDefault;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -203,7 +203,17 @@ contains
|
||||
uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas',
|
||||
uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas',
|
||||
uCEFWindow in '..\source\uCEFWindow.pas',
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas';
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas',
|
||||
uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas',
|
||||
uCEFViewComponent in '..\source\uCEFViewComponent.pas',
|
||||
uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas',
|
||||
uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas',
|
||||
uCEFPanelComponent in '..\source\uCEFPanelComponent.pas',
|
||||
uCEFWindowComponent in '..\source\uCEFWindowComponent.pas',
|
||||
uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas',
|
||||
uCEFButtonComponent in '..\source\uCEFButtonComponent.pas',
|
||||
uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas',
|
||||
uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas';
|
||||
|
||||
end.
|
||||
|
||||
|
@ -200,6 +200,16 @@ contains
|
||||
uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas',
|
||||
uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas',
|
||||
uCEFWindow in '..\source\uCEFWindow.pas',
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas';
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas',
|
||||
uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas',
|
||||
uCEFViewComponent in '..\source\uCEFViewComponent.pas',
|
||||
uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas',
|
||||
uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas',
|
||||
uCEFPanelComponent in '..\source\uCEFPanelComponent.pas',
|
||||
uCEFWindowComponent in '..\source\uCEFWindowComponent.pas',
|
||||
uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas',
|
||||
uCEFButtonComponent in '..\source\uCEFButtonComponent.pas',
|
||||
uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas',
|
||||
uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas';
|
||||
|
||||
end.
|
||||
|
@ -50,13 +50,22 @@ implementation
|
||||
uses
|
||||
Classes,
|
||||
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel, uCEFWorkScheduler,
|
||||
uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, uCEFSentinel;
|
||||
uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent, uCEFSentinel,
|
||||
uCEFBrowserViewComponent, uCEFLabelButtonComponent,
|
||||
uCEFMenuButtonComponent, uCEFPanelComponent, uCEFTextfieldComponent,
|
||||
uCEFScrollViewComponent, uCEFWindowComponent;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel,
|
||||
TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent,
|
||||
TCEFUrlRequestClientComponent, TCEFSentinel]);
|
||||
|
||||
RegisterComponents('Chromium Views Framework',
|
||||
[TCEFBrowserViewComponent, TCEFLabelButtonComponent,
|
||||
TCEFMenuButtonComponent, TCEFPanelComponent,
|
||||
TCEFTextfieldComponent, TCEFScrollViewComponent,
|
||||
TCEFWindowComponent]);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -208,7 +208,17 @@ contains
|
||||
uCEFMenuButtonPressedLock in '..\source\uCEFMenuButtonPressedLock.pas',
|
||||
uCEFMenuButtonDelegate in '..\source\uCEFMenuButtonDelegate.pas',
|
||||
uCEFWindow in '..\source\uCEFWindow.pas',
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas';
|
||||
uCEFWindowDelegate in '..\source\uCEFWindowDelegate.pas',
|
||||
uCEFViewsFrameworkEvents in '..\source\uCEFViewsFrameworkEvents.pas',
|
||||
uCEFViewComponent in '..\source\uCEFViewComponent.pas',
|
||||
uCEFTextfieldComponent in '..\source\uCEFTextfieldComponent.pas',
|
||||
uCEFScrollViewComponent in '..\source\uCEFScrollViewComponent.pas',
|
||||
uCEFPanelComponent in '..\source\uCEFPanelComponent.pas',
|
||||
uCEFWindowComponent in '..\source\uCEFWindowComponent.pas',
|
||||
uCEFBrowserViewComponent in '..\source\uCEFBrowserViewComponent.pas',
|
||||
uCEFButtonComponent in '..\source\uCEFButtonComponent.pas',
|
||||
uCEFLabelButtonComponent in '..\source\uCEFLabelButtonComponent.pas',
|
||||
uCEFMenuButtonComponent in '..\source\uCEFMenuButtonComponent.pas';
|
||||
|
||||
end.
|
||||
|
||||
|
@ -324,6 +324,16 @@
|
||||
<DCCReference Include="..\source\uCEFMenuButtonDelegate.pas"/>
|
||||
<DCCReference Include="..\source\uCEFWindow.pas"/>
|
||||
<DCCReference Include="..\source\uCEFWindowDelegate.pas"/>
|
||||
<DCCReference Include="..\source\uCEFViewsFrameworkEvents.pas"/>
|
||||
<DCCReference Include="..\source\uCEFViewComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFTextfieldComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFScrollViewComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFPanelComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFWindowComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFBrowserViewComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFButtonComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFLabelButtonComponent.pas"/>
|
||||
<DCCReference Include="..\source\uCEFMenuButtonComponent.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
|
@ -52,16 +52,25 @@ uses
|
||||
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel,
|
||||
uCEFWorkScheduler, uCEFFMXBufferPanel, uCEFFMXChromium, uCEFFMXWorkScheduler,
|
||||
uCEFServerComponent, uCEFLinkedWindowParent, uCEFUrlRequestClientComponent,
|
||||
uCEFSentinel;
|
||||
uCEFSentinel, uCEFBrowserViewComponent, uCEFLabelButtonComponent,
|
||||
uCEFMenuButtonComponent, uCEFPanelComponent, uCEFTextfieldComponent,
|
||||
uCEFScrollViewComponent, uCEFWindowComponent;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow,
|
||||
TBufferPanel, TFMXBufferPanel, TFMXChromium,
|
||||
TFMXWorkScheduler, TCEFWorkScheduler,
|
||||
TCEFServerComponent, TCEFLinkedWindowParent,
|
||||
TCEFUrlRequestClientComponent,
|
||||
TCEFSentinel]);
|
||||
RegisterComponents('Chromium',
|
||||
[TChromium, TCEFWindowParent, TChromiumWindow,
|
||||
TBufferPanel, TFMXBufferPanel, TFMXChromium,
|
||||
TFMXWorkScheduler, TCEFWorkScheduler,
|
||||
TCEFServerComponent, TCEFLinkedWindowParent,
|
||||
TCEFUrlRequestClientComponent,
|
||||
TCEFSentinel]);
|
||||
|
||||
RegisterComponents('Chromium Views Framework',
|
||||
[TCEFBrowserViewComponent, TCEFLabelButtonComponent,
|
||||
TCEFMenuButtonComponent, TCEFPanelComponent,
|
||||
TCEFTextfieldComponent, TCEFScrollViewComponent,
|
||||
TCEFWindowComponent]);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -55,7 +55,9 @@ uses
|
||||
{$ENDIF}
|
||||
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFBufferPanel,
|
||||
uCEFWorkScheduler, uCEFServerComponent, uCEFLinkedWindowParent,
|
||||
uCEFUrlRequestClientComponent, uCEFSentinel;
|
||||
uCEFUrlRequestClientComponent, uCEFSentinel, uCEFBrowserViewComponent,
|
||||
uCEFLabelButtonComponent, uCEFMenuButtonComponent, uCEFPanelComponent,
|
||||
uCEFTextfieldComponent, uCEFScrollViewComponent, uCEFWindowComponent;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
@ -63,6 +65,12 @@ begin
|
||||
TBufferPanel, TCEFWorkScheduler,
|
||||
TCEFServerComponent, TCEFLinkedWindowParent,
|
||||
TCEFUrlRequestClientComponent, TCEFSentinel]);
|
||||
|
||||
RegisterComponents('Chromium Views Framework',
|
||||
[TCEFBrowserViewComponent, TCEFLabelButtonComponent,
|
||||
TCEFMenuButtonComponent, TCEFPanelComponent,
|
||||
TCEFTextfieldComponent, TCEFScrollViewComponent,
|
||||
TCEFWindowComponent]);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -22,7 +22,7 @@
|
||||
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Major="81" Minor="3" Release="1"/>
|
||||
<Files Count="175">
|
||||
<Files Count="185">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
<UnitName Value="uCEFAccessibilityHandler"/>
|
||||
@ -732,6 +732,53 @@
|
||||
<Filename Value="..\source\uCEFDisplay.pas"/>
|
||||
<UnitName Value="uCEFDisplay"/>
|
||||
</Item175>
|
||||
<Item176>
|
||||
<Filename Value="..\source\uCEFMenuButtonComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFMenuButtonComponent"/>
|
||||
</Item176>
|
||||
<Item177>
|
||||
<Filename Value="..\source\uCEFLabelButtonComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFLabelButtonComponent"/>
|
||||
</Item177>
|
||||
<Item178>
|
||||
<Filename Value="..\source\uCEFButtonComponent.pas"/>
|
||||
<UnitName Value="uCEFButtonComponent"/>
|
||||
</Item178>
|
||||
<Item179>
|
||||
<Filename Value="..\source\uCEFBrowserViewComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFBrowserViewComponent"/>
|
||||
</Item179>
|
||||
<Item180>
|
||||
<Filename Value="..\source\uCEFWindowComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFWindowComponent"/>
|
||||
</Item180>
|
||||
<Item181>
|
||||
<Filename Value="..\source\uCEFPanelComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFPanelComponent"/>
|
||||
</Item181>
|
||||
<Item182>
|
||||
<Filename Value="..\source\uCEFScrollViewComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFScrollViewComponent"/>
|
||||
</Item182>
|
||||
<Item183>
|
||||
<Filename Value="..\source\uCEFTextfieldComponent.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFTextfieldComponent"/>
|
||||
</Item183>
|
||||
<Item184>
|
||||
<Filename Value="..\source\uCEFViewComponent.pas"/>
|
||||
<UnitName Value="uCEFViewComponent"/>
|
||||
</Item184>
|
||||
<Item185>
|
||||
<Filename Value="..\source\uCEFViewsFrameworkEvents.pas"/>
|
||||
<UnitName Value="uCEFViewsFrameworkEvents"/>
|
||||
</Item185>
|
||||
</Files>
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
|
@ -57,7 +57,11 @@ uses
|
||||
uCEFLabelButton, uCEFButtonDelegate, uCEFButton, uCEFBrowserViewDelegate,
|
||||
uCEFBrowserView, uCEFPanelDelegate, uCEFPanel, uCEFScrollView,
|
||||
uCEFTextfieldDelegate, uCEFTextfield, uCEFViewDelegate, uCEFView,
|
||||
uCEFFillLayout, uCEFBoxLayout, uCEFLayout, uCEFDisplay, LazarusPackageIntf;
|
||||
uCEFFillLayout, uCEFBoxLayout, uCEFLayout, uCEFDisplay,
|
||||
uCEFMenuButtonComponent, uCEFLabelButtonComponent, uCEFButtonComponent,
|
||||
uCEFBrowserViewComponent, uCEFWindowComponent, uCEFPanelComponent,
|
||||
uCEFScrollViewComponent, uCEFTextfieldComponent, uCEFViewComponent,
|
||||
uCEFViewsFrameworkEvents, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
@ -73,6 +77,13 @@ begin
|
||||
RegisterUnit('uCEFUrlRequestClientComponent',
|
||||
@uCEFUrlRequestClientComponent.Register);
|
||||
RegisterUnit('uCEFSentinel', @uCEFSentinel.Register);
|
||||
RegisterUnit('uCEFMenuButtonComponent', @uCEFMenuButtonComponent.Register);
|
||||
RegisterUnit('uCEFLabelButtonComponent', @uCEFLabelButtonComponent.Register);
|
||||
RegisterUnit('uCEFBrowserViewComponent', @uCEFBrowserViewComponent.Register);
|
||||
RegisterUnit('uCEFWindowComponent', @uCEFWindowComponent.Register);
|
||||
RegisterUnit('uCEFPanelComponent', @uCEFPanelComponent.Register);
|
||||
RegisterUnit('uCEFScrollViewComponent', @uCEFScrollViewComponent.Register);
|
||||
RegisterUnit('uCEFTextfieldComponent', @uCEFTextfieldComponent.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
@ -6,5 +6,11 @@ c:\lazarus\tools\lazres.exe ..\..\source\res\tcefworkscheduler.lrs tcefworksched
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tchromium.lrs tchromium.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tchromiumwindow.lrs tchromiumwindow.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefurlrequestclientcomponent.lrs tcefurlrequestclientcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefmediaobservercomponent.lrs tcefmediaobservercomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tceftextfieldcomponent.lrs tceftextfieldcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefscrollviewcomponent.lrs tcefscrollviewcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefpanelcomponent.lrs tcefpanelcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowcomponent.lrs tcefwindowcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefbrowserviewcomponent.lrs tcefbrowserviewcomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tceflabelbuttoncomponent.lrs tceflabelbuttoncomponent.png
|
||||
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefmenubuttoncomponent.lrs tcefmenubuttoncomponent.png
|
||||
pause
|
@ -10,4 +10,10 @@ TFMXWorkScheduler BITMAP "workscheduler.bmp"
|
||||
TCEFServerComponent BITMAP "server.bmp"
|
||||
TCEFUrlRequestClientComponent BITMAP "tcefurlrequestclientcomponent.bmp"
|
||||
TCEFSentinel BITMAP "tcefsentinel.bmp"
|
||||
TCEFMediaObserverComponent BITMAP "tcefmediaobservercomponent.bmp"
|
||||
TCEFTextfieldComponent BITMAP "tceftextfieldcomponent.bmp"
|
||||
TCEFScrollViewComponent BITMAP "tcefscrollviewcomponent.bmp"
|
||||
TCEFPanelComponent BITMAP "tcefpanelcomponent.bmp"
|
||||
TCEFWindowComponent BITMAP "tcefwindowcomponent.bmp"
|
||||
TCEFBrowserViewComponent BITMAP "tcefbrowserviewcomponent.bmp"
|
||||
TCEFLabelButtonComponent BITMAP "tceflabelbuttoncomponent.bmp"
|
||||
TCEFMenuButtonComponent BITMAP "tcefmenubuttoncomponent.bmp"
|
BIN
packages/res/tcefbrowserviewcomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tcefbrowserviewcomponent.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
packages/res/tceflabelbuttoncomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tceflabelbuttoncomponent.png
Normal file
After Width: | Height: | Size: 529 B |
BIN
packages/res/tcefmenubuttoncomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tcefmenubuttoncomponent.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
packages/res/tcefpanelcomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tcefpanelcomponent.png
Normal file
After Width: | Height: | Size: 499 B |
BIN
packages/res/tcefscrollviewcomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tcefscrollviewcomponent.png
Normal file
After Width: | Height: | Size: 762 B |
BIN
packages/res/tceftextfieldcomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tceftextfieldcomponent.png
Normal file
After Width: | Height: | Size: 619 B |
BIN
packages/res/tcefwindowcomponent.bmp
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
packages/res/tcefwindowcomponent.png
Normal file
After Width: | Height: | Size: 496 B |
59
source/res/tcefbrowserviewcomponent.lrs
Normal file
@ -0,0 +1,59 @@
|
||||
LazarusResources.Add('tcefbrowserviewcomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#12'-_'#141#12'\'#0#0#4#227'IDA'
|
||||
+'TH'#199#189#150'{'#136'TU'#28#199'?'#231#220#199'<'#246'5'#179#179#179#174
|
||||
+#235#234#170#227'+'#219'v'#181'B7'#203'P37'#133'D+D4'#11'2L!'#177'$'#9#162
|
||||
+#168'?R$EDB'#194'L'#5'I'#162'-+'#237'af'#178#153#230#163#215#154#175'|'#174
|
||||
+#142#235#234#248'Xgg'#156#199#157#153'{O'#127#236#154#174#146#134'A?8p'#206
|
||||
+#189#240#253#240#253#241';'#247'{'#197#170'5k'#244#130#194#194'nV:'#141#226
|
||||
+#191#151#148#18#183#203#21#127'r'#226#196'V'#0#189#165#165#165#239#240'P'#232
|
||||
+'`I '#240#159#1#2#16'B'#176'o'#255#254#221'@-'#128#30'>u'#202#19#156'8'#17
|
||||
+#191#191#24';'#151'C'#8'q[!'#5#160'T'#187#226'ue'#219#14'='#186'W'#240'{cc'
|
||||
+#197#213'g'#186#163#20#10#16'(bI'#11']'#147#183#22'W'#10'C'#215'0t'#13#199'v'
|
||||
+':'#189's'#156#246#179#195#181'f'#232'W7.'#211'`'#199#129#22#220#166'v'#139#6
|
||||
+#128#163#20#161'r'#31#161#174'>'#28')'#175'RA'#128'm'#223#236'^G)P'#138#156
|
||||
+'m'#243#204#136#16#226'o'#223#170'}'''#4'J'#129#165#4#134'i'#162'T;$i'#229
|
||||
+#200's'#27#216#182'C:'#147#195#235'1I'#166#172'k'#192#27#29#20#25#130#217#7
|
||||
+#203#232#162'E'#16'H'#18'"'#136#14'H''BV'#148'P'#215'U'#177#237#171'M'#4'J'#3
|
||||
+'$'#173','#179#198'V3w'#249#22'zW'#150'1'#163#174#138#185#203#183'0iT'#21#163
|
||||
+#130']n'#6'(@H'#141#144#247#28#243#210#247#3'&'#11#138'NPd'#157#196#21#30'C:'
|
||||
+#127#10#249#158#183'x'#160#170#2'o~'#30#202'Ql'#219#223#204#178#217'u|'#179
|
||||
+#231'8'#187#14#159'e'#202#163'5x]'#237#237#189'~N'#244#235#6#152#2']BT'#128
|
||||
+#150'Oa'#16#236#227'or'#197#242'`['#27#177#227#147'x'#168'&'#132#144' '#20'H'
|
||||
+#161'0<:'#227#134#244'F'#211'5p'#28'rY'#187#3' n'#6'H'#4#186#187#148#149'w'
|
||||
+#159'F*'#8'X'#167'9|v='#166#167#146'L6'#138'Hl'#230#157#205'wQ'#26', '#147
|
||||
+#181#217#30#177'8'#167#231's'#224't'#4'M'#19'H'#161'3'#162'W'#144'EO'#212'Ph'
|
||||
+#200#27#0'J!'#164'FI'#30'xe'#135'Eww'#24#246#17#151#214#190'H'#193#228#5#4
|
||||
+#186'=Fu'#239'S'#20#21#23#176#238'D'#154'1CS'#140#173'NP'#234#9'q'#238#138
|
||||
+#143#230'd'#132'X'#226'7'#230#127'_N['#216#184'yL'#133'+'#143#163#135'FP'#228
|
||||
+#14#0#2#129'@'#250#242'P'#191'dI?'#189#137'h\'#240#212#232')'#12'Y'#214#192
|
||||
+#156#209#131#24'Z'#153'#'#161#246#178#241'X'#21#210'UOs'#252#28'G'#218'Zxv'
|
||||
+#244#28#246#253#241'q'#215'Of'#174#157#206'{'#211'>'#184#230'EB'#252'|+'#177
|
||||
+#11'Qb'#231#163'D'#207#183#210'z'#180#25#235#213'*'#162'G'#195#24'v'#150#9
|
||||
+#139#191#230#158#202#18#250#150#251#176#229'>'#28'}'#3'~'#255#219#152#158#21
|
||||
+#20#22#174'$'#145#241#179'pg>'#181#213#175#232'#'#6#214'<''&'#207#247#233#215
|
||||
+'_'#138#154#224#167#148#5#253'8'#202#193#212'5'#10#221':'#145#182#20#178'D'
|
||||
+#210#211'_D'#179'k'#23#179#135#244#227#208#165#28'A'#247'H'#242#11#235'Q'#230
|
||||
+'j'#154'"'#15#163#180'#D'#226#195'9'#28'y'#153#133'{f'#241#224#128#147#195#26
|
||||
+#26#140#178'N'#128#186#218#30'h'#154#134#16#144#181#29#188#166'Ne'#206#11#10
|
||||
+#188'n'#131#230'h'#138'Cq'#19'igHe'#161'W'#209'N.gZ'#240'x'#235#209'D'#26#175
|
||||
+'y'#2'S'#171'd'#239#153'YTT|'#136#150'.'#246't'#2#188#180#244'3'#6#246#169' '
|
||||
+#145#206'0'#245#145'j'#222']'#255#19#229'A?y^'#147#251#186#251#137#197'l'#142
|
||||
+'%'#182'#'#173'{'#17#142'IY'#143'Fr'#10'<'#6#236'n'#154#195#159'g'#167#226
|
||||
+#208'D,'#237#226#219'c'#181#20#232#191#10#29')'#145'Z'#251#5'Y'#249#218#228
|
||||
+'N'#223#145'%'#179#199'w:'#15#222#149'&ko r%'#136#149#233#135#235#248'<'#250
|
||||
+#151#173' '#220':'#136'X'#170#130#140'}'#153'K'#201#0#241#140#27#203#234#129
|
||||
+')~tt'#151'a'#208#212#212'D8'#28'F'#169#127'N'#4#175'.'#152#16'P,'#217'QG'
|
||||
+#159#158'>'#132's'#129#29#199#230'q'#250'r'#136#193#221#23#209#150#244#242'x'
|
||||
+#245'xR'#25#193#217'X7~h'#152#209#152#10#31#138#10#192#15#148#3#238#127#145
|
||||
+')'#185#210'7'#190#248'2'#208'k@'#133'a'#186'Q'#128#149#241'p&'#22#228#253
|
||||
+#169#130#132#5'9G'#178#244#243#213#234'bc'#250#245'K'#171'^X'#162#1#25#160#13
|
||||
+#184'p'#187'%t3'#158'i'#252'n'#171#209#175'vd'#214'p'#21#167#28'I'#210#201
|
||||
+#146#206'9'#8#217'B'#206'r'#177'n'#235'|Z~'#22#203'.'#175#153#190'X'#184#242
|
||||
+#146#226#14#146'1_/.'#27#224#27'7s'#154#167#255#144#231#165#233#241':'#170'C'
|
||||
+#166#245#248#158#139#13#155#150#165#246#212'7 d'#4#229#228#196#29'e'#175#225
|
||||
+#242#168#172'U'#12#248#0'WG'#26#217#192#21#160#181#163'#'#246#181#152#186#195
|
||||
+#31#8#192#184'A#'#215#177#254#191#250#11'6q'#245#154#205'O'#27#207#0#0#0#0'I'
|
||||
+'END'#174'B`'#130
|
||||
]);
|
23
source/res/tceflabelbuttoncomponent.lrs
Normal file
@ -0,0 +1,23 @@
|
||||
LazarusResources.Add('tceflabelbuttoncomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13#1'tNQ'#254#0#0#1#158'IDATH'
|
||||
+#199#237#149#177'j'#149'A'#16#133#191#217#127's'#249'I'#8')'#180#189#22#150
|
||||
+#193'('#130#160'>'#193'-'#172'E'#240#5#196#202#218#222#23#176#18#219't'#226
|
||||
+#19#216#132'X'#10#130#8'!'#22#222'"D'#196#198'p'#137#185#145#127#255#221#153
|
||||
+#177#216#128'v'#22'w;='#15'p'#14'g'#206#156#25#248#143#191'@'#0'n=z'#177'1Xw'
|
||||
+#169'('#2#190'2e'#236#240'>'#232#201#251#151#143#207#229#250#195'g'#155'7o\{'
|
||||
+'}{{:'#139'!'#208'B'#160#152#241#238#240#203#155#15#31#15#238#199#31#139#239
|
||||
+#211';'#219'Wf'#247#238#238'p>'#148#11'O+'#192'a'#163#143#8'2{'#187#191'?'
|
||||
+#141#227'r'#209#175#197#192'rP'#210'h'#200#138#2#238#224'(k10.'#23'}'#4#199
|
||||
+#28#198#162#140#170#248#138#19#18#1')`^'#237'D'#17'A'#29'RQR'#214'f'#171#163
|
||||
+#14'"B'#20#192#20'R1R'#177'6'#2'A0'#173'qF'#17'(n'#140'E'#201#165#141#3#9#149
|
||||
+'S'#4#162' '#152#193#152#141#164#214'bK!WNA'#136#8#20'3'#134'b'#140#185#205
|
||||
+#136#252#162#11#8#196' `'#6')+9k'#19#3'N'#229#12#2#17#4'U'#175#25'h'#155#12
|
||||
+'\@'#213#235#217#168'!;'#169#24'9['#147'&'#27'Bq'#255#29'r'#23#2#169'(?S!'
|
||||
+#172'p'#238#132'Z'#176'u'#129'.'#132#26'r'#160#232#241#183#19#30#236'\eht*'
|
||||
+#250'I'#224#213#225'g'#2'E'#227'|o'#247'h}'#235#242#211#131#249#241#19'w'#15
|
||||
+'-'#20'D'#196#206#190'~z>'#223#219'='#146'8'#233#187'2'#14'['#192'&'#208'5'
|
||||
+#250'3'#10#156#197'I'#127'*'#127#140'Oh'#11'o'#240'\'#254#5#252#2'|'#157#212
|
||||
+#191'x:}'#193#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
50
source/res/tcefmenubuttoncomponent.lrs
Normal file
@ -0,0 +1,50 @@
|
||||
LazarusResources.Add('tcefmenubuttoncomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13#28#23'H='''#0#0#4#18'IDATH'
|
||||
+#199#173#148#205'oTU'#24#198#127#231#227#222';'#31'm-M'#234'\'#166#138#141'-'
|
||||
+#26#252#128#208')E '#209#5#160#209#248#181#194#134#13';'#227'?`'#252#7#220#24
|
||||
+#227#127#192#2'w'#238'X'#209#13'1'#177'$l*('#198#0'*'#132#206#20'Z'#194#135
|
||||
+#216'N3'#237#220'{'#206'='#199#197'0'#183#182#20'H'#13'Or'#146#155#156's'#207
|
||||
+'s'#222#231'y'#223'G|p'#226#171#234#208#142#225'KJ'#169'A'#231'@'#176#30#30
|
||||
+#144#18'l'#150#185#133#185#250#200#212#247#223#212#217#2#244#252#205#198#224
|
||||
+#137#201'O'#7'k'#251'v'#147#164#217#166#135#162'Pq'#241#194#239#242#235's?'
|
||||
+#246#179'Eh'#155#182'U+14'#155'+$'#169'El('#193'{'#136'BM'#171#157#146#153'T'
|
||||
+'m'#153#192#3'JH*'#253'e'#140#177#155'J'#20#4#26'!$'#137#177'n'#203#4'='#133
|
||||
+#144'?o'#204#177#188#178'J'#230'6'#255'_I'#201#236#220#2#239#31'z'#243#139
|
||||
+#193#15''''#22#188#247#226'i'#23#23#139'%e'#140#249'N'#191#208'gx'#231#141#10
|
||||
+#187'v'#189#134#203#30#186#236'7!y'#251'u'#2#249#222#231#30#240#222'?'#241'r'
|
||||
+#165'$'#151'/_'#230#212#169'S?'#232',s'#244#150#10#152#180#141'M'#13#198'Z'
|
||||
+#194' D'#8#240#248'\'#178#164#13'&5'#232'@#'#165#196'='#166'Z'#239'=a'#24#18
|
||||
+'E'#17'KKK'#145#6'p'#30#148#210#24'a'#153#157#189#129#177#150'8'#142'I'#147
|
||||
+#20'!'#4#198#26#138#197'"W'#175'^'#161'R'#137#233#237#233#165':4D'#16#134'x'
|
||||
+#231'p'#206#161#148#198'Z'#3#128'T'#154'n'#145#186#195#234#144#178#163#205
|
||||
+#221#187'w'#16'B'#176#180#248#15'I'#146'000@'#24'E'#172#174#172#16'Wbn'#223
|
||||
+'^`>s'#236'xi'#7#191'^'#248#153'J'#28#19#199#219#249#229#226#12#251'&'#246'c'
|
||||
+#173'E)'#137#247'n'#141#160#163#155#162'\.'#243#209#199#159'0'#215'hP'#238
|
||||
+#237'e['#127'?'#222'{<'#29'k'#164#148'H)1'#198#144'e'#25#251#15#28#192'{'#143
|
||||
+'s'#142#183#14#28#196#24#131#148#18#165'd.Y'#254#165#132#196'{'#207'\'#163
|
||||
+#129#177#134#161#237'U'#180#210'('#169#136#130#16'k-'#215#174#253#197#226#226
|
||||
+'"'#133#168#144#251#224#157'G p'#153'CI'#133'R'#10')'#215#8'tw'#152#164#146
|
||||
+'`<RJn'#221#188#197#189';'#247'h'''#9'q'#181#194#31'W'#174#176#243#149'W'#185
|
||||
+#217#152'c'#254#214'<'#222';'#14#30'<D'#169'T'#194#229#30'('#140'1k'#143#221
|
||||
+'X'#129#148#10#132#160'^'#175'c'#172'!I'#219#148#203'E'#22#255'~'#192's'#253
|
||||
+#219'('#149#202#188#188's'#20#249#176#173#194#168#192#244#185'i'#234#245'Y'
|
||||
+#156#247'LO'#255'D'#24#21#16'R"'#180#202'[='#247'@*I'#169'T'#226#240#145#163
|
||||
+'H):'#251#15'[A'#8'A'#150'urj'#207#238'='#0#164'i'#202#225#195'G'#242#10#142
|
||||
+#28'}'#151'4MQJ'#161'6J'#212#29#14'! '#8#212'c'#135'g'#253#164#22#30'9'#19
|
||||
+#134#1#222'C'#150#153'<ht'#247'CIE{'#181#205#212#153'3'#132'a'#200#255'E'#146
|
||||
+'$'#28';'#246'YgP=h'#239'=B'#8#148'R'#244#244#244'p'#252#248'q'#156#243'd'
|
||||
+#153'['#151#25'R*'#148#18'x'#15#214#218''''#146't'#229#220'`'#178#192'Z'#195
|
||||
+#212#212#20#205#230#18'A'#160#8#2#157#175'Vk'#153#211#167'O'#211'h'#212#9#2
|
||||
+#141's'#25#198#164#155'.)'#197#163#30't'#6'D'#17#199'1''O'#158'dxx'#152'f'
|
||||
+#179'I'#161'P'#164#221'^att'''#206'9'#206#159'?'#207#217#179'g'#153#156#156
|
||||
+#196'9'#135#214#1'a'#24#208'j'#181#242#182#221'd'#14'<R)'#148#210'x'#239#25
|
||||
+#27#171'Q('#132#140#140#140#208#219#215'G!'#138'p.ctt'#148#251#247#239#147'e'
|
||||
+#25#165'R'#137'K'#151'~'#163'R'#169#240'|'#165#194#245#235#215#25#171#141'c'
|
||||
+#141'AJ'#149''''#238'Z'#5'B'#16'E!'#181'Z'#13'c:y'#242#223#151'tQ'#173'V'#243
|
||||
+#212#172#213#198#242#139#198#199#199#241#206#163#181'^/'#145#16#194#27'cX^^'
|
||||
+#238#228#206'S'#178#190#11'!'#196#19#247#140'1'#8'!'#188#216#187'w'#239#139
|
||||
+#19#19#19'_&I2'#192'3D'#20'E'#15'fff'#190#21'@'#8#244#1#1#207#22#6'h'#254#11
|
||||
+#19#216#229#26#139#255'>'#140#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
22
source/res/tcefpanelcomponent.lrs
Normal file
@ -0,0 +1,22 @@
|
||||
LazarusResources.Add('tcefpanelcomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#13'1R'#151'aR'#0#0#1#128'IDATH'
|
||||
+#199#173#149#191'.DA'#20#198#127#231#156#185#132'H('#196#18'TZ%'#149#135#240
|
||||
+#12'Z'#141#202'SP'#240#4#158#129'J'#167'RH4'#18'o@"'#132'D'#178#254#132#189
|
||||
+'3G'#177#139'{'#215#18#217#185'S'#206#220#156'o'#190#243#251#230#30#1#216'?8'
|
||||
+#28#127#237#164#233'2F'#193#201'['#2#193#204#199#10#189#223#218'X'#127#9#0
|
||||
+#237#151#215#205#181#149#229#157#209#145'@'#19#2'o'#239'%'#167#231#151#219
|
||||
+#192'nW'#160#253#220'Z]^'#226#234#254#9'3'#205#170#31'cbqz'#130#227#147#179
|
||||
+#22'@'#0#240#20#197#221#137#201'Q'#241#161'M'#8#16#147#227#238'x'#138#242'%'
|
||||
+#208'='#2#19'ATQ'#247#175#189#255'/'#199'E'#176#228'Tk'#134#234'''fFP'#25#162
|
||||
+#248'wA'#204'j'#187'5'#1'UAD'#178#24'h'#31#194#240'm'#16'L'#133'L'#198'@='
|
||||
+#233'?'#28#168#230'9'#232#143'H'#157#129#8#154#217#162'~|u'#129#160#217#2#162
|
||||
+#127':'#128#134#13#244#30#218''''#3#209'l'#1#239'I'#248#143#20'9'#152#229#199
|
||||
+#212#189#251#146#7#167'H'#26#16#248#188#237'`'#200'V;'#28#146'2'#177#147'~'
|
||||
+#135#156#253#183#22#136#131'S'#228#168'*'#141#12#4'~iQP!e'#214#239#127'G'#161
|
||||
+#130#6#17#193'rsZ'#199#221#21'PU'#138'"'#208'T'#237#162#8'ho4'#6#128#137'Q{'
|
||||
+#216';8'#186'+'#203'r'#200'YP'#191#185#153#190'w'#218#15#23#128'HknAno'#174
|
||||
+''''#129')@'#27#234'O'#9'<'#206#204#206#183#165#130#190#169#230'W!'#248#7#23
|
||||
+'^uMW'#166#136#214#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
34
source/res/tcefscrollviewcomponent.lrs
Normal file
@ -0,0 +1,34 @@
|
||||
LazarusResources.Add('tcefscrollviewcomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14#4'/'#9#246#178#0#0#2#135'ID'
|
||||
+'ATH'#199#181#148'Ak'#149'G'#20#134#159'sf'#238#229'ZSj'#23#1#17'Z'#16'q#'
|
||||
+#182'va'#151']'#21#196#181#136#160#221'tS'#127#129#11#255'@'#215']'#185'T'
|
||||
+#251#15#10#197#186'i'#161'EP,B'#13#130#136'Q'#131#130'&'#132'D'#19'5'#198'k'
|
||||
+#190'o'#206#219#197#220#27#147'v'#211#239'V'#15#204'f'#152#225#204#251#188's'
|
||||
+'^;'#251#253#185'={'#247#237#159#201#201#167'E'#247'r3'#214#214#135'k'#31#238
|
||||
+#220'1U"0'#0#131#210#198#210#220#220#189'/8'#249#221#153'C'#215'gf'#245#127
|
||||
+#234#135#31'/'#253'k'#239#250#204#172'N'#157'>s'#200#135#175'_'#165#182#4#0
|
||||
+#165'D'#167#21'Q'#239'!1l'#196#221#251#143#248#233#231#203#0#172#15'7x3\Oy'
|
||||
+#140'%'#2#162'+#'#129';$7'#158',-s'#233#151#203#172#174'<#H'#236#218#253')'
|
||||
+#201#156'l'#21#25'!'#213#23#153'u'#247#193#157#141#226#28#255#230'['#204#140
|
||||
+#166'm'#184'}'#231'>'#238'Ffd'#138'$B'#2'u'#149#145#232#245'2'#191'_'#185#129
|
||||
+'$4R'#229#230#184#161'<>V'#164#238#136#198'xKp'#248#240'A'#154#166#173#239'5'
|
||||
+'cqq'#25'a'#182#217' Bl~'#179#255'nA'#189#171'j'#160'"'#144' %'#3#9'I'#21#145
|
||||
+#1#17'AL*'#1#200#217#137'pD5'#221#204#16#240'V'#193'$'#248'G*$'#200')'#17')'
|
||||
+#144'DJ'#142#187#215#198'['#17'uU '#170#169#8'z='''#138'#D'#242#132'['#197
|
||||
+#148'1'#192#140'PP'#20#221#21#168'6'#234'y'#162#164'2B'#228#184#179#29#145
|
||||
+#162#174'I'#240#128#232#229'L'#219#150#17#162#132'['#237#176'm'#208#138':'
|
||||
+#254'"'#189#197#148#179#147#147'oQ'#240#15#147#139'D'#196#4'3 '#144'A?%'#154
|
||||
+#148#128#177#2#3#180#5#209#232#223'vG$'#146#25'Mi)Q='#16#163'T'#192#200#140
|
||||
+#160#132'T'#7#166'#'#162#136#192#220'y0'#247#152#166'-'#155#147#188#186#250#2
|
||||
+#219#26#21'Q'#160#148#238#136'J'#136#141#141#150#175#190'<'#176'm'#255#218
|
||||
+#205'YJ'#137#237'Q1'#17'"'#192#221'XZY'#227#226#133#243','#204'?'#225#235'#G'
|
||||
+#249'h'#250#19#204#141'<'#14#148'Pt'#142#235#26#190#194#205'Xo'#10#199'N'#156
|
||||
+'baa'#129#131#159'}'#206#181#27'3'#184#25#217#12'z91'#24#12'*'#195#142'i'#247
|
||||
+#193#160'O'#191#151'y'#254'jH'#219#22#166'>'#158#230#225#227'yJ'#136#148#220
|
||||
+#178'Q'#154'?'#254#188#181#210#182#127'5`'#157#211'T'#18#131'A'#159'_'#127
|
||||
+#187#186#153#174'5<'#155#229#167#139#243'/'#13#152#2'v'#1'}'#222'm'#13#129
|
||||
+#149#241' '#27#239#167#226'o'#7#159#225'V'#180#27'y'#213#0#0#0#0'IEND'#174'B'
|
||||
+'`'#130
|
||||
]);
|
27
source/res/tceftextfieldcomponent.lrs
Normal file
@ -0,0 +1,27 @@
|
||||
LazarusResources.Add('tceftextfieldcomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14#19#172#218'su'#0#0#1#248'ID'
|
||||
+'ATH'#199#213#150'1o'#211'P'#20#133#191#251#252#226#16'Z'#181'M CQ'#165'vJ~'
|
||||
+#1#12', '#22#22'`'#129#165#191' '#127#129#10#137#13'!'#196#128'D'#197#144'-'
|
||||
+#12'H,H'#8#169#3#19'bA'#192#208'!C'#165'X'#136#165'-S'#221#8#136#161#196#207
|
||||
+#190#12'i'#147'4'#237#208'4^'#250'&'#235#13#231#220's'#238#241#177#225#172#31
|
||||
+'i4'#26#11#197'b'#241'k'#183#219#237'f'#9#236#251#190#223'n'#183#175#216'f'
|
||||
+#179'Y'#170#213'j'#243#149'J%'#211#201#131' '#160'^'#175#151'l'#20'EVU'#217
|
||||
+#220#218#198'9'#151#9#184#181#22'U%'#138'"k'#135'/'#141'1'#168'N'#232#185#128
|
||||
+'1f@v'#240#224#25#131#239#9'"2'#17#129'j'#138#211#17#2'U'#165'8'#229's'#255
|
||||
+#221#6'q'#146'"BO'#137#142#15'>S'#154#227#225#181#5#218#187'#'#10'r'#231'|'
|
||||
+#234#159#183#248#241#244#30#127#156#162#10#255#246#246#24'G'#208'y+'#220'~'
|
||||
+#187#201'#k'#250#211#245#20#0'xB'#222'z'#172#127'X'#227#217#139':'#139#139'K'
|
||||
+#172#172'<'#224'w'#167'sb'#130'K'#243#23#240's'#30'xrt'#7#224#145'&'#9#215'o'
|
||||
+#222#226#229#235'7<_]e'''#220#165#148'/'#158#204')'#133'\'#161'@'#154'*'#136
|
||||
+'w<'#193'A'#132#146'$'#1'`vn'#150#177'bem'#143#201#152#254'P'#150#190'GB'#223
|
||||
+'pU:'#157#14#211#211#211#167#136#17#224#13'Rd'#6#183#130#160#236'|'#223'`'
|
||||
+#249#238#29'>'#190'_;'#221'K'#230#201#0#246#176'E'#208#206#151'X^'#159#194'%'
|
||||
+#151'QR'#30#191#250'6'#22'x'#206#19#190'l'#255#236#17#168#30'&H]'#140'>'#185
|
||||
+#1#164#19#22#197#18#137'K'#143'*H'#197#144#196#217't'#145#152'cRd'#196#144'J'
|
||||
+'6Mjdh'#7'"'#189#254'1F0C'#204#19#171#216#199#181'q'#28'''a'#24#18#4#1':i'
|
||||
+#149#14#129#135'aH'#28#199#137#148#203#229#139#213'j'#245#170'sn&'#203#15#142
|
||||
+#181#246'W'#171#213#250'$'#251'{('#140'F6'#131#227#128#191'g'#254#167#130#255
|
||||
+#186#155#181#212#227'?'#176#215#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
22
source/res/tcefwindowcomponent.lrs
Normal file
@ -0,0 +1,22 @@
|
||||
LazarusResources.Add('tcefwindowcomponent','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147#0#0#0#9'pHYs'#0#0#11#19#0#0#11
|
||||
+#19#1#0#154#156#24#0#0#0#7'tIME'#7#228#5#5#13#14'!d'#13'"'#245#0#0#1'}IDATH'
|
||||
+#199#237#148#189'N[A'#16#133#191#217#157#189#246#181#177#242#135#4#18#138#168
|
||||
+#226#146'2]"'#165#8'R'#202'('#188#2'o'#144#151#8#13'-'#18#21#15#128'h'#163
|
||||
+#164' u'#164'TtN'#149'"'#2'E'#209#5'$'#192#216#185#187'CqcL'#137#228'u'#199
|
||||
+'<'#192#249#230#156'3'#26#152#243#200#202#199#189#238'e'#249't'#243#170#142
|
||||
+#143'-'#129#204'(h'#128'8'#232#168'?'#235#14#171']'#173'N~?'#127#187#190#182
|
||||
+#253#230#197'2"y'#182'6'#131#195#159'''|'#253'r'#244'Y'#199#213'qg'#169'W'
|
||||
+#176#243#163#226'|T#6'#163#184#192#163#150#242'z'#165'`\'#29'w4'#166#132#23
|
||||
+'G'#127#177#228'b\g'#137'h'#161'P'#188#12#137')'#161'DxV:>'#189'['#165'N'#150
|
||||
+'%"u'#194#214#183#1'DP'#12'T='#127'~'#13#24#142#254#205#220#131#25#148#173
|
||||
+#128#170#7#3#5#3'3'#202#178#196'i'#145#197'A+x'#176#17'`'#232'$'#185#160'J'
|
||||
+#196#253'Oq'#166#203''''#168#3#174#155#184'&'#197#4#13'$IY'#28#4#239'n'#215
|
||||
+'T'#172'!'#132'BIu&'#128':&'#186#141#3'3'#130#22'$b&'#128#199#204#166#17#1'h'
|
||||
+'P'#162#184',W'#164#234#166''';'#233#192#135'@'#145#169#3#175'w;'#152#190#168
|
||||
+#230'v'#179'M'#131'p'#243'~'#215#15#128#251#1'd'#14#194'r'#11#240'N'#218#193
|
||||
+'g'#7#180#131#7#239'Dz'#175'6'#250#241#229#135#131#171#218'-'#146#242#229#210
|
||||
+#209#244#215#127#223#127'/@'#9'<'#1#218#153'M\'#3#167'2'#231#178#211#13'''Au'
|
||||
+#232#241#15'<v'#0#0#0#0'IEND'#174'B`'#130
|
||||
]);
|
@ -78,6 +78,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function SameAs(aData : Pointer) : boolean; overload;
|
||||
function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload;
|
||||
procedure DestroyOtherRefs;
|
||||
function Wrap: Pointer;
|
||||
end;
|
||||
|
||||
@ -93,6 +94,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function SameAs(aData : Pointer) : boolean; overload;
|
||||
function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload;
|
||||
procedure DestroyOtherRefs;
|
||||
function Wrap: Pointer;
|
||||
class function UnWrap(data: Pointer): ICefBaseRefCounted;
|
||||
end;
|
||||
@ -243,6 +245,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefBaseRefCountedOwn.DestroyOtherRefs;
|
||||
begin
|
||||
while HasAtLeastOneRef and not(HasOneRef) do
|
||||
_Release;
|
||||
end;
|
||||
|
||||
function TCefBaseRefCountedOwn.Wrap: Pointer;
|
||||
begin
|
||||
Result := FData;
|
||||
@ -353,6 +361,11 @@ begin
|
||||
Result := (PCefBaseRefCounted(FData)^.has_at_least_one_ref(PCefBaseRefCounted(FData)) <> 0);
|
||||
end;
|
||||
|
||||
procedure TCefBaseRefCountedRef.DestroyOtherRefs;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// ************************************************
|
||||
// *********** TLoggingInterfacedObject ***********
|
||||
|
@ -100,20 +100,39 @@ class function TCefBrowserViewRef.CreateBrowserView(const client : ICef
|
||||
const delegate : ICefBrowserViewDelegate): ICefBrowserView;
|
||||
|
||||
var
|
||||
TempURL : TCefString;
|
||||
TempURL : TCefString;
|
||||
TempBrowserView : PCefBrowserView;
|
||||
begin
|
||||
TempURL := CefString(url);
|
||||
Result := UnWrap(cef_browser_view_create(CefGetData(client),
|
||||
@TempURL,
|
||||
@settings,
|
||||
CefGetData(extra_info),
|
||||
CefGetData(request_context),
|
||||
CefGetData(delegate)));
|
||||
Result := nil;
|
||||
|
||||
if (client <> nil) and (delegate <> nil) then
|
||||
begin
|
||||
TempURL := CefString(url);
|
||||
TempBrowserView := cef_browser_view_create(CefGetData(client),
|
||||
@TempURL,
|
||||
@settings,
|
||||
CefGetData(extra_info),
|
||||
CefGetData(request_context),
|
||||
CefGetData(delegate));
|
||||
|
||||
if (TempBrowserView <> nil) then
|
||||
Result := Create(TempBrowserView) as ICefBrowserView;
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TCefBrowserViewRef.GetForBrowser(const browser: ICefBrowser): ICefBrowserView;
|
||||
var
|
||||
TempBrowserView : PCefBrowserView;
|
||||
begin
|
||||
Result := UnWrap(cef_browser_view_get_for_browser(CefGetData(browser)));
|
||||
Result := nil;
|
||||
|
||||
if (browser <> nil) then
|
||||
begin
|
||||
TempBrowserView := cef_browser_view_get_for_browser(CefGetData(browser));
|
||||
|
||||
if (TempBrowserView <> nil) then
|
||||
Result := Create(TempBrowserView) as ICefBrowserView;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
261
source/uCEFBrowserViewComponent.pas
Normal file
@ -0,0 +1,261 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFBrowserViewComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFViewComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFBrowserViewComponent = class(TCEFViewComponent, ICefBrowserViewDelegateEvents)
|
||||
protected
|
||||
FBrowserView : ICefBrowserView;
|
||||
FBrowserViewDlg : ICefBrowserViewDelegate;
|
||||
|
||||
// ICefBrowserViewDelegateEvents
|
||||
FOnBrowserCreated : TOnBrowserCreatedEvent;
|
||||
FOnBrowserDestroyed : TOnBrowserDestroyedEvent;
|
||||
FOnGetDelegateForPopupBrowserView : TOnGetDelegateForPopupBrowserViewEvent;
|
||||
FOnPopupBrowserViewCreated : TOnPopupBrowserViewCreatedEvent;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsBrowserView : ICefBrowserView; override;
|
||||
function GetBrowser : ICefBrowser;
|
||||
|
||||
// ICefBrowserViewDelegateEvents
|
||||
procedure doOnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure doOnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure doOnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
procedure doOnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
|
||||
public
|
||||
function CreateBrowserView(const client: ICefClient; const url: ustring; const settings: TCefBrowserSettings; const extra_info: ICefDictionaryValue; const request_context: ICefRequestContext): boolean;
|
||||
function GetForBrowser(const browser: ICefBrowser): boolean;
|
||||
procedure SetPreferAccelerators(prefer_accelerators: boolean);
|
||||
|
||||
property Browser : ICefBrowser read GetBrowser;
|
||||
property BrowserView : ICefBrowserView read FBrowserView;
|
||||
|
||||
published
|
||||
property OnBrowserCreated : TOnBrowserCreatedEvent read FOnBrowserCreated write FOnBrowserCreated;
|
||||
property OnBrowserDestroyed : TOnBrowserDestroyedEvent read FOnBrowserDestroyed write FOnBrowserDestroyed;
|
||||
property OnGetDelegateForPopupBrowserView : TOnGetDelegateForPopupBrowserViewEvent read FOnGetDelegateForPopupBrowserView write FOnGetDelegateForPopupBrowserView;
|
||||
property OnPopupBrowserViewCreated : TOnPopupBrowserViewCreatedEvent read FOnPopupBrowserViewCreated write FOnPopupBrowserViewCreated;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFBrowserView, uCEFBrowserViewDelegate, uCEFMiscFunctions;
|
||||
|
||||
procedure TCEFBrowserViewComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FBrowserView := nil;
|
||||
FBrowserViewDlg := nil;
|
||||
FOnBrowserCreated := nil;
|
||||
FOnBrowserDestroyed := nil;
|
||||
FOnGetDelegateForPopupBrowserView := nil;
|
||||
FOnPopupBrowserViewCreated := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.DestroyView;
|
||||
begin
|
||||
if (FBrowserViewDlg <> nil) then
|
||||
begin
|
||||
FBrowserViewDlg.DestroyOtherRefs;
|
||||
FBrowserViewDlg := nil;
|
||||
end;
|
||||
|
||||
FBrowserView := nil;
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.CreateBrowserView(const client : ICefClient;
|
||||
const url : ustring;
|
||||
const settings : TCefBrowserSettings;
|
||||
const extra_info : ICefDictionaryValue;
|
||||
const request_context : ICefRequestContext): boolean;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if CefCurrentlyOn(TID_UI) and (client <> nil) then
|
||||
begin
|
||||
if (FBrowserViewDlg = nil) then
|
||||
FBrowserViewDlg := TCustomBrowserViewDelegate.Create(self);
|
||||
|
||||
FBrowserView := TCefBrowserViewRef.CreateBrowserView(client, url, settings, extra_info, request_context, FBrowserViewDlg);
|
||||
Result := (FBrowserView <> nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.GetForBrowser(const browser: ICefBrowser): boolean;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if CefCurrentlyOn(TID_UI) and (browser <> nil) then
|
||||
begin
|
||||
FBrowserView := TCefBrowserViewRef.GetForBrowser(browser);
|
||||
Result := (FBrowserView <> nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FBrowserView <> nil);
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FBrowserView as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.GetAsBrowserView : ICefBrowserView;
|
||||
begin
|
||||
Result := FBrowserView;
|
||||
end;
|
||||
|
||||
function TCEFBrowserViewComponent.GetBrowser : ICefBrowser;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FBrowserView.GetBrowser
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.SetPreferAccelerators(prefer_accelerators: boolean);
|
||||
begin
|
||||
if Initialized then FBrowserView.SetPreferAccelerators(prefer_accelerators);
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.doOnBrowserCreated(const browser_view : ICefBrowserView;
|
||||
const browser : ICefBrowser);
|
||||
begin
|
||||
if assigned(FOnBrowserCreated) then
|
||||
FOnBrowserCreated(self, browser_view, browser);
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.doOnBrowserDestroyed(const browser_view : ICefBrowserView;
|
||||
const browser : ICefBrowser);
|
||||
begin
|
||||
if assigned(FOnBrowserDestroyed) then
|
||||
FOnBrowserDestroyed(self, browser_view, browser);
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.doOnGetDelegateForPopupBrowserView(const browser_view : ICefBrowserView;
|
||||
const settings : TCefBrowserSettings;
|
||||
const client : ICefClient;
|
||||
is_devtools : boolean;
|
||||
var aResult : ICefBrowserViewDelegate);
|
||||
begin
|
||||
if assigned(FOnGetDelegateForPopupBrowserView) then
|
||||
FOnGetDelegateForPopupBrowserView(self, browser_view, settings, client, is_devtools, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFBrowserViewComponent.doOnPopupBrowserViewCreated(const browser_view : ICefBrowserView;
|
||||
const popup_browser_view : ICefBrowserView;
|
||||
is_devtools : boolean;
|
||||
var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnPopupBrowserViewCreated) then
|
||||
FOnPopupBrowserViewCreated(self, browser_view, popup_browser_view, is_devtools, aResult);
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tcefbrowserviewcomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFBrowserViewComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -61,17 +61,59 @@ type
|
||||
protected
|
||||
procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
function GetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean): ICefBrowserViewDelegate;
|
||||
function OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean): boolean;
|
||||
procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefBrowserViewDelegate;
|
||||
end;
|
||||
|
||||
TCefBrowserViewDelegateOwn = class(TCefViewDelegateOwn, ICefBrowserViewDelegate)
|
||||
protected
|
||||
procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); virtual;
|
||||
procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); virtual;
|
||||
procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); virtual;
|
||||
procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); virtual;
|
||||
|
||||
procedure InitializeCEFMethods; override;
|
||||
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
TCustomBrowserViewDelegate = class(TCefBrowserViewDelegateOwn)
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
// ICefBrowserViewDelegate
|
||||
procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser); override;
|
||||
procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser); override;
|
||||
procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate); override;
|
||||
procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefBrowserViewDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions;
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFBrowserView, uCEFBrowser, uCEFClient;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCefBrowserViewDelegateRef ******************
|
||||
// **************************************************************
|
||||
|
||||
procedure TCefBrowserViewDelegateRef.OnBrowserCreated(const browser_view : ICefBrowserView;
|
||||
const browser : ICefBrowser);
|
||||
@ -89,26 +131,28 @@ begin
|
||||
CefGetData(browser));
|
||||
end;
|
||||
|
||||
function TCefBrowserViewDelegateRef.GetDelegateForPopupBrowserView(const browser_view : ICefBrowserView;
|
||||
const settings : TCefBrowserSettings;
|
||||
const client : ICefClient;
|
||||
is_devtools : boolean): ICefBrowserViewDelegate;
|
||||
procedure TCefBrowserViewDelegateRef.OnGetDelegateForPopupBrowserView(const browser_view : ICefBrowserView;
|
||||
const settings : TCefBrowserSettings;
|
||||
const client : ICefClient;
|
||||
is_devtools : boolean;
|
||||
var aResult : ICefBrowserViewDelegate);
|
||||
begin
|
||||
Result := UnWrap((PCefBrowserViewDelegate(FData)^.get_delegate_for_popup_browser_view(PCefBrowserViewDelegate(FData),
|
||||
CefGetData(browser_view),
|
||||
@settings,
|
||||
CefGetData(client),
|
||||
ord(is_devtools))));
|
||||
aResult := UnWrap((PCefBrowserViewDelegate(FData)^.get_delegate_for_popup_browser_view(PCefBrowserViewDelegate(FData),
|
||||
CefGetData(browser_view),
|
||||
@settings,
|
||||
CefGetData(client),
|
||||
ord(is_devtools))));
|
||||
end;
|
||||
|
||||
function TCefBrowserViewDelegateRef.OnPopupBrowserViewCreated(const browser_view : ICefBrowserView;
|
||||
const popup_browser_view : ICefBrowserView;
|
||||
is_devtools : boolean): boolean;
|
||||
procedure TCefBrowserViewDelegateRef.OnPopupBrowserViewCreated(const browser_view : ICefBrowserView;
|
||||
const popup_browser_view : ICefBrowserView;
|
||||
is_devtools : boolean;
|
||||
var aResult : boolean);
|
||||
begin
|
||||
Result := (PCefBrowserViewDelegate(FData)^.on_popup_browser_view_created(PCefBrowserViewDelegate(FData),
|
||||
CefGetData(browser_view),
|
||||
CefGetData(popup_browser_view),
|
||||
ord(is_devtools)) <> 0);
|
||||
aResult := (PCefBrowserViewDelegate(FData)^.on_popup_browser_view_created(PCefBrowserViewDelegate(FData),
|
||||
CefGetData(browser_view),
|
||||
CefGetData(popup_browser_view),
|
||||
ord(is_devtools)) <> 0);
|
||||
end;
|
||||
|
||||
class function TCefBrowserViewDelegateRef.UnWrap(data: Pointer): ICefBrowserViewDelegate;
|
||||
@ -119,5 +163,263 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCefBrowserViewDelegateOwn ******************
|
||||
// **************************************************************
|
||||
|
||||
procedure cef_browserview_delegate_on_browser_created(self : PCefBrowserViewDelegate;
|
||||
browser_view : PCefBrowserView;
|
||||
browser : PCefBrowser); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then
|
||||
TCefBrowserViewDelegateOwn(TempObject).OnBrowserCreated(TCefBrowserViewRef.UnWrap(browser_view),
|
||||
TCefBrowserRef.UnWrap(browser));
|
||||
end;
|
||||
|
||||
procedure cef_browserview_delegate_on_browser_destroyed(self : PCefBrowserViewDelegate;
|
||||
browser_view : PCefBrowserView;
|
||||
browser : PCefBrowser); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then
|
||||
TCefBrowserViewDelegateOwn(TempObject).OnBrowserDestroyed(TCefBrowserViewRef.UnWrap(browser_view),
|
||||
TCefBrowserRef.UnWrap(browser));
|
||||
end;
|
||||
|
||||
function cef_browserview_delegate_get_delegate_for_popup_browser_view( self : PCefBrowserViewDelegate;
|
||||
browser_view : PCefBrowserView;
|
||||
const settings : PCefBrowserSettings;
|
||||
client : PCefClient;
|
||||
is_devtools : Integer): PCefBrowserViewDelegate; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempDelegate : ICefBrowserViewDelegate;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempDelegate := nil;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then
|
||||
TCefBrowserViewDelegateOwn(TempObject).OnGetDelegateForPopupBrowserView(TCefBrowserViewRef.UnWrap(browser_view),
|
||||
settings^,
|
||||
TCefClientRef.UnWrap(client),
|
||||
is_devtools <> 0,
|
||||
TempDelegate);
|
||||
|
||||
Result := CefGetData(TempDelegate);
|
||||
end;
|
||||
|
||||
function cef_browserview_delegate_on_popup_browser_view_created(self : PCefBrowserViewDelegate;
|
||||
browser_view : PCefBrowserView;
|
||||
popup_browser_view : PCefBrowserView;
|
||||
is_devtools : Integer): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempResult : boolean;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempResult := False;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefBrowserViewDelegateOwn) then
|
||||
TCefBrowserViewDelegateOwn(TempObject).OnPopupBrowserViewCreated(TCefBrowserViewRef.UnWrap(browser_view),
|
||||
TCefBrowserViewRef.UnWrap(popup_browser_view),
|
||||
is_devtools <> 0,
|
||||
TempResult);
|
||||
|
||||
Result := ord(TempResult);
|
||||
end;
|
||||
|
||||
constructor TCefBrowserViewDelegateOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefBrowserViewDelegate));
|
||||
|
||||
InitializeCEFMethods;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserViewDelegateOwn.InitializeCEFMethods;
|
||||
begin
|
||||
inherited InitializeCEFMethods;
|
||||
|
||||
with PCefBrowserViewDelegate(FData)^ do
|
||||
begin
|
||||
on_browser_created := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_browser_created;
|
||||
on_browser_destroyed := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_browser_destroyed;
|
||||
get_delegate_for_popup_browser_view := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_get_delegate_for_popup_browser_view;
|
||||
on_popup_browser_view_created := {$IFDEF FPC}@{$ENDIF}cef_browserview_delegate_on_popup_browser_view_created;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserViewDelegateOwn.OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefBrowserViewDelegateOwn.OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefBrowserViewDelegateOwn.OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefBrowserViewDelegateOwn.OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCustomBrowserViewDelegate ******************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomBrowserViewDelegate.Create(const events: ICefBrowserViewDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnBrowserCreated(browser_view, browser);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBrowserCreated', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnBrowserDestroyed(browser_view, browser);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnBrowserDestroyed', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnGetDelegateForPopupBrowserView(browser_view, settings, client, is_devtools, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnGetDelegateForPopupBrowserView', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomBrowserViewDelegate.OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefBrowserViewDelegateEvents(FEvents).doOnPopupBrowserViewCreated(browser_view, popup_browser_view, is_devtools, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomBrowserViewDelegate.OnPopupBrowserViewCreated', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
206
source/uCEFButtonComponent.pas
Normal file
@ -0,0 +1,206 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFButtonComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFViewComponent;
|
||||
|
||||
type
|
||||
TCEFButtonComponent = class(TCEFViewComponent, ICefButtonDelegateEvents)
|
||||
protected
|
||||
FButton : ICefButton;
|
||||
|
||||
// ICefButtonDelegateEvents
|
||||
FOnButtonPressed : TOnButtonPressedEvent;
|
||||
FOnButtonStateChanged : TOnButtonStateChangedEvent;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetState : TCefButtonState;
|
||||
function GetAsButton : ICefButton; override;
|
||||
function GetAsLabelButton : ICefLabelButton; virtual;
|
||||
|
||||
procedure SetState(state_: TCefButtonState);
|
||||
|
||||
// ICefButtonDelegateEvents
|
||||
procedure doOnButtonPressed(const button: ICefButton);
|
||||
procedure doOnButtonStateChanged(const button: ICefButton);
|
||||
|
||||
public
|
||||
procedure SetInkDropEnabled(enabled_: boolean);
|
||||
procedure SetTooltipText(const tooltip_text: ustring);
|
||||
procedure SetAccessibleName(const name_: ustring);
|
||||
|
||||
property AsLabelButton : ICefLabelButton read GetAsLabelButton;
|
||||
property State : TCefButtonState read GetState write SetState;
|
||||
|
||||
published
|
||||
property OnButtonPressed : TOnButtonPressedEvent read FOnButtonPressed write FOnButtonPressed;
|
||||
property OnButtonStateChanged : TOnButtonStateChangedEvent read FOnButtonStateChanged write FOnButtonStateChanged;
|
||||
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
|
||||
uCEFButtonDelegate;
|
||||
|
||||
procedure TCEFButtonComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FButton := nil;
|
||||
FOnButtonPressed := nil;
|
||||
FOnButtonStateChanged := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.DestroyView;
|
||||
begin
|
||||
FButton := nil;
|
||||
end;
|
||||
|
||||
function TCEFButtonComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FButton <> nil);
|
||||
end;
|
||||
|
||||
function TCEFButtonComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FButton as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFButtonComponent.GetAsButton : ICefButton;
|
||||
begin
|
||||
Result := FButton;
|
||||
end;
|
||||
|
||||
function TCEFButtonComponent.GetAsLabelButton : ICefLabelButton;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.doOnButtonPressed(const button: ICefButton);
|
||||
begin
|
||||
if assigned(FOnButtonPressed) then
|
||||
FOnButtonPressed(self, button);
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.doOnButtonStateChanged(const button: ICefButton);
|
||||
begin
|
||||
if assigned(FOnButtonStateChanged) then
|
||||
FOnButtonStateChanged(self, button);
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.SetState(state_: TCefButtonState);
|
||||
begin
|
||||
if Initialized then AsButton.SetState(state_);
|
||||
end;
|
||||
|
||||
function TCEFButtonComponent.GetState : TCefButtonState;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsButton.GetState
|
||||
else
|
||||
Result := CEF_BUTTON_STATE_NORMAL;
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.SetInkDropEnabled(enabled_: boolean);
|
||||
begin
|
||||
if Initialized then AsButton.SetInkDropEnabled(enabled_);
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.SetTooltipText(const tooltip_text: ustring);
|
||||
begin
|
||||
if Initialized then AsButton.SetTooltipText(tooltip_text);
|
||||
end;
|
||||
|
||||
procedure TCEFButtonComponent.SetAccessibleName(const name_: ustring);
|
||||
begin
|
||||
if Initialized then AsButton.SetAccessibleName(name_);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
@ -66,10 +66,47 @@ type
|
||||
class function UnWrap(data: Pointer): ICefButtonDelegate;
|
||||
end;
|
||||
|
||||
TCefButtonDelegateOwn = class(TCefViewDelegateOwn, ICefButtonDelegate)
|
||||
protected
|
||||
procedure OnButtonPressed(const button: ICefButton); virtual;
|
||||
procedure OnButtonStateChanged(const button: ICefButton); virtual;
|
||||
|
||||
procedure InitializeCEFMethods; override;
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
TCustomButtonDelegate = class(TCefButtonDelegateOwn)
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
// ICefButtonDelegate
|
||||
procedure OnButtonPressed(const button: ICefButton); override;
|
||||
procedure OnButtonStateChanged(const button: ICefButton); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefButtonDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions;
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFButton;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// ****************** TCefButtonDelegateRef *********************
|
||||
// **************************************************************
|
||||
|
||||
procedure TCefButtonDelegateRef.OnButtonPressed(const button: ICefButton);
|
||||
begin
|
||||
@ -91,5 +128,179 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
// **************************************************************
|
||||
// ****************** TCefButtonDelegateOwn *********************
|
||||
// **************************************************************
|
||||
|
||||
procedure cef_button_delegate_on_button_pressed(self: PCefButtonDelegate; button: PCefButton); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefButtonDelegateOwn) then
|
||||
TCefButtonDelegateOwn(TempObject).OnButtonPressed(TCefButtonRef.UnWrap(button));
|
||||
end;
|
||||
|
||||
procedure cef_button_delegate_on_button_state_changed(self: PCefButtonDelegate; button: PCefButton); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefButtonDelegateOwn) then
|
||||
TCefButtonDelegateOwn(TempObject).OnButtonStateChanged(TCefButtonRef.UnWrap(button));
|
||||
end;
|
||||
|
||||
|
||||
constructor TCefButtonDelegateOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefButtonDelegate));
|
||||
|
||||
InitializeCEFMethods;
|
||||
end;
|
||||
|
||||
procedure TCefButtonDelegateOwn.InitializeCEFMethods;
|
||||
begin
|
||||
inherited InitializeCEFMethods;
|
||||
|
||||
with PCefButtonDelegate(FData)^ do
|
||||
begin
|
||||
on_button_pressed := {$IFDEF FPC}@{$ENDIF}cef_button_delegate_on_button_pressed;
|
||||
on_button_state_changed := {$IFDEF FPC}@{$ENDIF}cef_button_delegate_on_button_state_changed;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefButtonDelegateOwn.OnButtonPressed(const button: ICefButton);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefButtonDelegateOwn.OnButtonStateChanged(const button: ICefButton);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
// **************************************************************
|
||||
// ****************** TCustomButtonDelegate *********************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomButtonDelegate.Create(const events: ICefButtonDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnButtonPressed(const button: ICefButton);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnButtonPressed(button);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnButtonPressed', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonDelegate.OnButtonStateChanged(const button: ICefButton);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefButtonDelegateEvents(FEvents).doOnButtonStateChanged(button);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomButtonDelegate.OnButtonStateChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -64,7 +64,8 @@ uses
|
||||
uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient,
|
||||
uCEFConstants, uCEFTask, uCEFDomVisitor, uCEFChromiumEvents,
|
||||
{$IFDEF MSWINDOWS}uCEFDragAndDropMgr,{$ENDIF}
|
||||
uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions;
|
||||
uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions,
|
||||
uCEFBrowserViewComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
@ -588,6 +589,7 @@ type
|
||||
function CreateClientHandler(aIsOSR : boolean = True) : boolean; overload;
|
||||
function CreateClientHandler(var aClient : ICefClient; aIsOSR : boolean = True) : boolean; overload;
|
||||
procedure CloseBrowser(aForceClose : boolean);
|
||||
function TryCloseBrowser : boolean;
|
||||
function ShareRequestContext(var aContext : ICefRequestContext; const aHandler : ICefRequestContextHandler = nil) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure InitializeDragAndDrop(const aDropTargetWnd : HWND);
|
||||
@ -596,6 +598,7 @@ type
|
||||
{$ENDIF MSWINDOWS}
|
||||
|
||||
function CreateBrowser(aParentHandle : TCefWindowHandle; aParentRect : TRect; const aWindowName : ustring = ''; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual;
|
||||
function CreateBrowser(const aURL : ustring; const aBrowserViewComp : TCEFBrowserViewComponent; const aContext : ICefRequestContext = nil; const aExtraInfo : ICefDictionaryValue = nil) : boolean; overload; virtual;
|
||||
|
||||
procedure LoadURL(const aURL : ustring; const aFrameName : ustring = ''); overload;
|
||||
procedure LoadURL(const aURL : ustring; const aFrame : ICefFrame); overload;
|
||||
@ -1524,13 +1527,13 @@ begin
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
|
||||
if not(csDesigning in ComponentState) and
|
||||
not(FClosing) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(not(ValidCefWindowHandle(aParentHandle))) then
|
||||
begin
|
||||
FClosing := False;
|
||||
GetSettings(FBrowserSettings);
|
||||
InitializeWindowInfo(aParentHandle, aParentRect, aWindowName);
|
||||
CreateResourceRequestHandler;
|
||||
@ -1564,6 +1567,62 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.CreateBrowser(const aURL : ustring;
|
||||
const aBrowserViewComp : TCEFBrowserViewComponent;
|
||||
const aContext : ICefRequestContext;
|
||||
const aExtraInfo : ICefDictionaryValue) : boolean;
|
||||
var
|
||||
TempNewContext, TempGlobalContext : ICefRequestContext;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
try
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// even if you use a custom request context.
|
||||
// If you create a browser in the initialization of your app, make sure you call this
|
||||
// function when GlobalCEFApp.GlobalContextInitialized is TRUE.
|
||||
// Use the GlobalCEFApp.OnContextInitialized event to know when
|
||||
// GlobalCEFApp.GlobalContextInitialized is set to TRUE.
|
||||
|
||||
if not(csDesigning in ComponentState) and
|
||||
(aBrowserViewComp <> nil) and
|
||||
(FBrowser = nil) and
|
||||
(FBrowserId = 0) and
|
||||
(GlobalCEFApp <> nil) and
|
||||
GlobalCEFApp.GlobalContextInitialized and
|
||||
CreateClientHandler(False) then
|
||||
begin
|
||||
FClosing := False;
|
||||
GetSettings(FBrowserSettings);
|
||||
CreateResourceRequestHandler;
|
||||
CreateMediaObserver;
|
||||
|
||||
if (aContext = nil) then
|
||||
begin
|
||||
CreateReqContextHandler;
|
||||
|
||||
if (FReqContextHandler <> nil) then
|
||||
begin
|
||||
TempGlobalContext := TCefRequestContextRef.Global();
|
||||
TempNewContext := TCefRequestContextRef.Shared(TempGlobalContext, FReqContextHandler);
|
||||
end;
|
||||
end
|
||||
else
|
||||
TempNewContext := aContext;
|
||||
|
||||
Result := aBrowserViewComp.CreateBrowserView(FHandler, aURL, FBrowserSettings, aExtraInfo, TempNewContext);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChromiumCore.CreateBrowser', e) then raise;
|
||||
end;
|
||||
finally
|
||||
TempGlobalContext := nil;
|
||||
TempNewContext := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.InitializeWindowInfo( aParentHandle : TCefWindowHandle;
|
||||
aParentRect : TRect;
|
||||
const aWindowName : ustring);
|
||||
@ -1732,6 +1791,14 @@ begin
|
||||
if Initialized then FBrowser.Host.CloseBrowser(aForceClose);
|
||||
end;
|
||||
|
||||
function TChromiumCore.TryCloseBrowser : boolean;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FBrowser.Host.TryCloseBrowser
|
||||
else
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TChromiumCore.CreateBrowserHost( aWindowInfo : PCefWindowInfo;
|
||||
const aURL : ustring;
|
||||
const aSettings : PCefBrowserSettings;
|
||||
|
@ -504,6 +504,7 @@ type
|
||||
function SameAs(const aBaseRefCounted : ICefBaseRefCounted) : boolean; overload;
|
||||
function HasOneRef : boolean;
|
||||
function HasAtLeastOneRef : boolean;
|
||||
procedure DestroyOtherRefs;
|
||||
end;
|
||||
|
||||
// TCefRunFileDialogCallback
|
||||
@ -2515,6 +2516,7 @@ type
|
||||
property Bounds : TCefRect read GetBounds write SetBounds;
|
||||
property Size : TCefSize read GetSize write SetSize;
|
||||
property Position : TCefPoint read GetPosition write SetPosition;
|
||||
property TypeString : ustring read GetTypeString;
|
||||
end;
|
||||
|
||||
// TCefViewDelegate
|
||||
@ -2531,6 +2533,22 @@ type
|
||||
procedure OnBlur(const view: ICefView);
|
||||
end;
|
||||
|
||||
ICefViewDelegateEvents = interface
|
||||
['{74DDDB37-8F08-4672-BDB6-55CA2CD374ED}']
|
||||
// ICefViewDelegate
|
||||
procedure doOnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
procedure doOnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
procedure doOnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
procedure doOnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
procedure doOnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
procedure doOnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
procedure doOnFocus(const view: ICefView);
|
||||
procedure doOnBlur(const view: ICefView);
|
||||
|
||||
// Custom
|
||||
procedure doCreateCustomView;
|
||||
end;
|
||||
|
||||
// TCefTextfield
|
||||
// /include/capi/views/cef_textfield_capi.h (cef_textfield_t)
|
||||
ICefTextfield = interface(ICefView)
|
||||
@ -2581,10 +2599,16 @@ type
|
||||
// /include/capi/views/cef_textfield_delegate_capi.h (cef_textfield_delegate_t)
|
||||
ICefTextfieldDelegate = interface(ICefViewDelegate)
|
||||
['{72612994-92BB-4DE9-BB38-6F49FB45F94B}']
|
||||
function OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent): boolean;
|
||||
procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
procedure OnAfterUserAction(const textfield: ICefTextfield);
|
||||
end;
|
||||
|
||||
ICefTextfieldDelegateEvents = interface(ICefViewDelegateEvents)
|
||||
['{682480E0-C786-4E65-B950-4FF2B13B97B9}']
|
||||
procedure doOnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
procedure doOnAfterUserAction(const textfield: ICefTextfield);
|
||||
end;
|
||||
|
||||
// TCefScrollView
|
||||
// /include/capi/views/cef_scroll_view_capi.h (cef_scroll_view_t)
|
||||
ICefScrollView = interface(ICefView)
|
||||
@ -2607,7 +2631,7 @@ type
|
||||
// /include/capi/views/cef_panel_capi.h (cef_panel_t)
|
||||
ICefPanel = interface(ICefView)
|
||||
['{6F2F680A-3637-4438-81B8-79AD6C02252D}']
|
||||
function AsWindow : ICefWindow;
|
||||
function GetAsWindow : ICefWindow;
|
||||
function SetToFillLayout : ICefFillLayout;
|
||||
function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
||||
function GetLayout : ICefLayout;
|
||||
@ -2619,6 +2643,8 @@ type
|
||||
procedure RemoveAllChildViews;
|
||||
function GetChildViewCount : NativeUInt;
|
||||
function GetChildViewAt(index: Integer): ICefView;
|
||||
|
||||
property AsWindow : ICefWindow read GetAsWindow;
|
||||
end;
|
||||
|
||||
// TCefPanelDelegate
|
||||
@ -2627,6 +2653,10 @@ type
|
||||
['{305D453F-FEBA-48ED-AE33-5D978823EA96}']
|
||||
end;
|
||||
|
||||
ICefPanelDelegateEvents = interface(ICefViewDelegateEvents)
|
||||
['{F1F2963F-82C3-48F0-9B9C-7C213BACB96B}']
|
||||
end;
|
||||
|
||||
// TCefBrowserView
|
||||
// /include/capi/views/cef_browser_view_capi.h (cef_browser_view_t)
|
||||
ICefBrowserView = interface(ICefView)
|
||||
@ -2641,8 +2671,16 @@ type
|
||||
['{578A0DD4-2E7D-4061-B4DB-7C3CDC7A90C0}']
|
||||
procedure OnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure OnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
function GetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean): ICefBrowserViewDelegate;
|
||||
function OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean): boolean;
|
||||
procedure OnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
procedure OnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
end;
|
||||
|
||||
ICefBrowserViewDelegateEvents = interface(ICefViewDelegateEvents)
|
||||
['{AB94B875-63C6-4FEF-BB30-0816402ABA1C}']
|
||||
procedure doOnBrowserCreated(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure doOnBrowserDestroyed(const browser_view: ICefBrowserView; const browser: ICefBrowser);
|
||||
procedure doOnGetDelegateForPopupBrowserView(const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate);
|
||||
procedure doOnPopupBrowserViewCreated(const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean);
|
||||
end;
|
||||
|
||||
// TCefButton
|
||||
@ -2667,6 +2705,12 @@ type
|
||||
procedure OnButtonStateChanged(const button: ICefButton);
|
||||
end;
|
||||
|
||||
ICefButtonDelegateEvents = interface(ICefViewDelegateEvents)
|
||||
['{E8DF70BE-5DEB-42CF-AF86-B0FF1040498E}']
|
||||
procedure doOnButtonPressed(const button: ICefButton);
|
||||
procedure doOnButtonStateChanged(const button: ICefButton);
|
||||
end;
|
||||
|
||||
// TCefLabelButton
|
||||
// /include/capi/views/cef_label_button_capi.h (cef_label_button_t)
|
||||
ICefLabelButton = interface(ICefButton)
|
||||
@ -2707,6 +2751,11 @@ type
|
||||
procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock);
|
||||
end;
|
||||
|
||||
ICefMenuButtonDelegateEvents = interface(ICefButtonDelegateEvents)
|
||||
['{DA36DD60-7609-4576-BB8E-6A55FD48C680}']
|
||||
procedure doOnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock);
|
||||
end;
|
||||
|
||||
// TCefWindow
|
||||
// /include/capi/views/cef_window_capi.h (cef_window_t)
|
||||
ICefWindow = interface(ICefPanel)
|
||||
@ -2741,7 +2790,7 @@ type
|
||||
function GetClientAreaBoundsInScreen : TCefRect;
|
||||
procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray);
|
||||
function GetWindowHandle : TCefWindowHandle;
|
||||
procedure SendKeyPress(key_code: Integer; event_flags: uint32);
|
||||
procedure SendKeyPress(key_code: Integer; event_flags: cardinal);
|
||||
procedure SendMouseMove(screen_x, screen_y: Integer);
|
||||
procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean);
|
||||
procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean);
|
||||
@ -2772,6 +2821,20 @@ type
|
||||
procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean);
|
||||
end;
|
||||
|
||||
ICefWindowDelegateEvents = interface(ICefPanelDelegateEvents)
|
||||
['{05C19A41-E75D-459E-AD4D-C8A0CA4A49D3}']
|
||||
procedure doOnWindowCreated(const window: ICefWindow);
|
||||
procedure doOnWindowDestroyed(const window: ICefWindow);
|
||||
procedure doOnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow);
|
||||
procedure doOnIsFrameless(const window: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanResize(const window: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanMaximize(const window: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanMinimize(const window: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanClose(const window: ICefWindow; var aResult : boolean);
|
||||
procedure doOnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean);
|
||||
procedure doOnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
@ -153,10 +153,19 @@ end;
|
||||
class function TCefLabelButtonRef.CreateLabelButton(const delegate : ICefButtonDelegate;
|
||||
const text : ustring): ICefLabelButton;
|
||||
var
|
||||
TempText : TCefString;
|
||||
TempText : TCefString;
|
||||
TempButton : PCefLabelButton;
|
||||
begin
|
||||
TempText := CefString(text);
|
||||
UnWrap(cef_label_button_create(CefGetData(delegate), @TempText));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempText := CefString(text);
|
||||
TempButton := cef_label_button_create(CefGetData(delegate), @TempText);
|
||||
|
||||
if (TempButton <> nil) then
|
||||
Result := Create(TempButton) as ICefLabelButton;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
267
source/uCEFLabelButtonComponent.pas
Normal file
@ -0,0 +1,267 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLabelButtonComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFButtonComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFLabelButtonComponent = class(TCEFButtonComponent)
|
||||
protected
|
||||
FLabelButton : ICefLabelButton;
|
||||
FText : ustring;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsButton : ICefButton; override;
|
||||
function GetAsLabelButton : ICefLabelButton; override;
|
||||
function GetAsMenuButton : ICefMenuButton; virtual;
|
||||
function GetText : ustring;
|
||||
function GetImage(button_state: TCefButtonState): ICefImage;
|
||||
|
||||
procedure SetText(const text_: ustring);
|
||||
procedure SetImage(button_state: TCefButtonState; const image: ICefImage);
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreateLabelButton(const aText : ustring);
|
||||
procedure SetTextColor(for_state: TCefButtonState; color: TCefColor);
|
||||
procedure SetEnabledTextColors(color: TCefColor);
|
||||
procedure SetFontList(const font_list: ustring);
|
||||
procedure SetHorizontalAlignment(alignment: TCefHorizontalAlignment);
|
||||
procedure SetMinimumSize(const size_: TCefSize);
|
||||
procedure SetMaximumSize(const size_: TCefSize);
|
||||
|
||||
property Text : ustring read GetText write SetText;
|
||||
property Image[button_state : TCefButtonState] : ICefImage read GetImage write SetImage;
|
||||
property AsMenuButton : ICefMenuButton read GetAsMenuButton;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFLabelButton, uCEFMiscFunctions, uCEFButtonDelegate;
|
||||
|
||||
procedure TCEFLabelButtonComponent.CreateLabelButton(const aText : ustring);
|
||||
begin
|
||||
FText := aText;
|
||||
CreateView;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.doCreateCustomView;
|
||||
var
|
||||
TempDelegate : ICefButtonDelegate;
|
||||
begin
|
||||
if (FLabelButton = nil) then
|
||||
try
|
||||
TempDelegate := TCustomButtonDelegate.Create(self);
|
||||
FLabelButton := TCefLabelButtonRef.CreateLabelButton(TempDelegate, FText);
|
||||
finally
|
||||
TempDelegate := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.DestroyView;
|
||||
begin
|
||||
inherited DestroyView;
|
||||
|
||||
FLabelButton := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FLabelButton := nil;
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FLabelButton <> nil);
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetAsView : ICefView;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FLabelButton as ICefView
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetAsButton : ICefButton;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FLabelButton as ICefButton
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetAsLabelButton : ICefLabelButton;
|
||||
begin
|
||||
Result := FLabelButton;
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetAsMenuButton : ICefMenuButton;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetText(const text_: ustring);
|
||||
begin
|
||||
FText := text_;
|
||||
|
||||
if Initialized then
|
||||
AsLabelButton.SetText(FText);
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetText : ustring;
|
||||
begin
|
||||
if Initialized then
|
||||
FText := AsLabelButton.GetText;
|
||||
|
||||
Result := FText;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetImage(button_state: TCefButtonState; const image: ICefImage);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetImage(button_state, image);
|
||||
end;
|
||||
|
||||
function TCEFLabelButtonComponent.GetImage(button_state: TCefButtonState): ICefImage;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsLabelButton.GetImage(button_state)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetTextColor(for_state: TCefButtonState; color: TCefColor);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetTextColor(for_state, color);
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetEnabledTextColors(color: TCefColor);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetEnabledTextColors(color);
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetFontList(const font_list: ustring);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetFontList(font_list);
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetHorizontalAlignment(alignment: TCefHorizontalAlignment);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetHorizontalAlignment(alignment);
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetMinimumSize(const size_: TCefSize);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetMinimumSize(size_);
|
||||
end;
|
||||
|
||||
procedure TCEFLabelButtonComponent.SetMaximumSize(const size_: TCefSize);
|
||||
begin
|
||||
if Initialized then AsLabelButton.SetMaximumSize(size_);
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tceflabelbuttoncomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFLabelButtonComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -98,10 +98,19 @@ end;
|
||||
class function TCefMenuButtonRef.CreateMenuButton(const delegate : ICefMenuButtonDelegate;
|
||||
const text : ustring): ICefMenuButton;
|
||||
var
|
||||
TempText : TCefString;
|
||||
TempText : TCefString;
|
||||
TempButton : PCefMenuButton;
|
||||
begin
|
||||
TempText := CefString(text);
|
||||
UnWrap(cef_menu_button_create(CefGetData(delegate), @TempText));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempText := CefString(text);
|
||||
TempButton := cef_menu_button_create(CefGetData(delegate), @TempText);
|
||||
|
||||
if (TempButton <> nil) then
|
||||
Result := Create(TempButton) as ICefMenuButton;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
223
source/uCEFMenuButtonComponent.pas
Normal file
@ -0,0 +1,223 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFMenuButtonComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFLabelButtonComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFMenuButtonComponent = class(TCEFLabelButtonComponent, ICefMenuButtonDelegateEvents)
|
||||
protected
|
||||
FMenuButton : ICefMenuButton;
|
||||
|
||||
// ICefMenuButtonDelegateEvents
|
||||
FOnMenuButtonPressed : TOnMenuButtonPressedEvent;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsButton : ICefButton; override;
|
||||
function GetAsLabelButton : ICefLabelButton; override;
|
||||
function GetAsMenuButton : ICefMenuButton; override;
|
||||
|
||||
// ICefMenuButtonDelegateEvents
|
||||
procedure doOnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock);
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreateMenuButton(const aText : ustring);
|
||||
procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position: TCefMenuAnchorPosition);
|
||||
procedure TriggerMenu;
|
||||
|
||||
published
|
||||
property OnMenuButtonPressed : TOnMenuButtonPressedEvent read FOnMenuButtonPressed write FOnMenuButtonPressed;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFMenuButtonDelegate, uCEFMenuButton;
|
||||
|
||||
procedure TCEFMenuButtonComponent.CreateMenuButton(const aText : ustring);
|
||||
begin
|
||||
CreateLabelButton(aText);
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.doCreateCustomView;
|
||||
var
|
||||
TempDelegate : ICefMenuButtonDelegate;
|
||||
begin
|
||||
if (FMenuButton = nil) then
|
||||
try
|
||||
TempDelegate := TCustomMenuButtonDelegate.Create(self);
|
||||
FMenuButton := TCefMenuButtonRef.CreateMenuButton(TempDelegate, FText);
|
||||
finally
|
||||
TempDelegate := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FMenuButton := nil;
|
||||
FOnMenuButtonPressed := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.DestroyView;
|
||||
begin
|
||||
FMenuButton := nil;
|
||||
end;
|
||||
|
||||
function TCEFMenuButtonComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FMenuButton <> nil);
|
||||
end;
|
||||
|
||||
function TCEFMenuButtonComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FMenuButton as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFMenuButtonComponent.GetAsButton : ICefButton;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FMenuButton as ICefButton
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFMenuButtonComponent.GetAsLabelButton : ICefLabelButton;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FMenuButton as ICefLabelButton
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFMenuButtonComponent.GetAsMenuButton : ICefMenuButton;
|
||||
begin
|
||||
Result := FMenuButton;
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.doOnMenuButtonPressed(const menu_button : ICefMenuButton;
|
||||
const screen_point : TCefPoint;
|
||||
const button_pressed_lock : ICefMenuButtonPressedLock);
|
||||
begin
|
||||
if assigned(FOnMenuButtonPressed) then
|
||||
FOnMenuButtonPressed(self, menu_button, screen_point, button_pressed_lock);
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.ShowMenu(const menu_model : ICefMenuModel;
|
||||
const screen_point : TCefPoint;
|
||||
anchor_position : TCefMenuAnchorPosition);
|
||||
begin
|
||||
if Initialized then
|
||||
FMenuButton.ShowMenu(menu_model, screen_point, anchor_position);
|
||||
end;
|
||||
|
||||
procedure TCEFMenuButtonComponent.TriggerMenu;
|
||||
begin
|
||||
if Initialized then
|
||||
FMenuButton.TriggerMenu;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tcefmenubuttoncomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFMenuButtonComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -65,10 +65,49 @@ type
|
||||
class function UnWrap(data: Pointer): ICefMenuButtonDelegate;
|
||||
end;
|
||||
|
||||
TCefMenuButtonDelegateOwn = class(TCefButtonDelegateOwn, ICefMenuButtonDelegate)
|
||||
protected
|
||||
procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); virtual;
|
||||
|
||||
procedure InitializeCEFMethods; override;
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
TCustomMenuButtonDelegate = class(TCefMenuButtonDelegateOwn)
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
// ICefButtonDelegate
|
||||
procedure OnButtonPressed(const button: ICefButton); override;
|
||||
procedure OnButtonStateChanged(const button: ICefButton); override;
|
||||
|
||||
// ICefMenuButtonDelegate
|
||||
procedure OnMenuButtonPressed(const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefMenuButtonDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions;
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFMenuButton, uCEFMenuButtonPressedLock;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCefMenuButtonDelegateRef *******************
|
||||
// **************************************************************
|
||||
|
||||
procedure TCefMenuButtonDelegateRef.OnMenuButtonPressed(const menu_button : ICefMenuButton;
|
||||
const screen_point : TCefPoint;
|
||||
@ -88,5 +127,182 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCefMenuButtonDelegateOwn *******************
|
||||
// **************************************************************
|
||||
|
||||
procedure cef_menubutton_delegate_on_menu_button_pressed( self : PCefMenuButtonDelegate;
|
||||
menu_button : PCefMenuButton;
|
||||
const screen_point : PCefPoint;
|
||||
button_pressed_lock : PCefMenuButtonPressedLock); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefMenuButtonDelegateOwn) then
|
||||
TCefMenuButtonDelegateOwn(TempObject).OnMenuButtonPressed(TCefMenuButtonRef.UnWrap(menu_button),
|
||||
screen_point^,
|
||||
TCefMenuButtonPressedLockRef.UnWrap(button_pressed_lock));
|
||||
end;
|
||||
|
||||
constructor TCefMenuButtonDelegateOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefMenuButtonDelegate));
|
||||
|
||||
InitializeCEFMethods;
|
||||
end;
|
||||
|
||||
procedure TCefMenuButtonDelegateOwn.InitializeCEFMethods;
|
||||
begin
|
||||
inherited InitializeCEFMethods;
|
||||
|
||||
with PCefMenuButtonDelegate(FData)^ do
|
||||
on_menu_button_pressed := {$IFDEF FPC}@{$ENDIF}cef_menubutton_delegate_on_menu_button_pressed;
|
||||
end;
|
||||
|
||||
procedure TCefMenuButtonDelegateOwn.OnMenuButtonPressed(const menu_button : ICefMenuButton;
|
||||
const screen_point : TCefPoint;
|
||||
const button_pressed_lock : ICefMenuButtonPressedLock);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// **************** TCustomMenuButtonDelegate *******************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomMenuButtonDelegate.Create(const events: ICefMenuButtonDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnButtonPressed(const button: ICefButton);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnButtonPressed(button);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnButtonPressed', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnButtonStateChanged(const button: ICefButton);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnButtonStateChanged(button);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnButtonStateChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomMenuButtonDelegate.OnMenuButtonPressed(const menu_button : ICefMenuButton;
|
||||
const screen_point : TCefPoint;
|
||||
const button_pressed_lock : ICefMenuButtonPressedLock);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefMenuButtonDelegateEvents(FEvents).doOnMenuButtonPressed(menu_button, screen_point, button_pressed_lock);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomMenuButtonDelegate.OnMenuButtonPressed', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -300,7 +300,7 @@ function CefGetDataURI(const aString, aMimeType : ustring) : ustring; overload;
|
||||
function CefGetDataURI(aData : pointer; aSize : integer; const aMimeType : ustring; const aCharset : ustring = '') : ustring; overload;
|
||||
|
||||
function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean;
|
||||
|
||||
procedure InitializeWindowHandle(var aHandle : TCefWindowHandle);
|
||||
|
||||
implementation
|
||||
|
||||
@ -2416,4 +2416,13 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure InitializeWindowHandle(var aHandle : TCefWindowHandle);
|
||||
begin
|
||||
{$IFDEF MACOS}
|
||||
aHandle := nil;
|
||||
{$ELSE}
|
||||
aHandle := 0;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -59,7 +59,7 @@ uses
|
||||
type
|
||||
TCefPanelRef = class(TCefViewRef, ICefPanel)
|
||||
protected
|
||||
function AsWindow : ICefWindow;
|
||||
function GetAsWindow : ICefWindow;
|
||||
function SetToFillLayout : ICefFillLayout;
|
||||
function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
||||
function GetLayout : ICefLayout;
|
||||
@ -83,7 +83,7 @@ uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFWindow, uCEFLayout, uCEFFillLayout,
|
||||
uCEFBoxLayout;
|
||||
|
||||
function TCefPanelRef.AsWindow : ICefWindow;
|
||||
function TCefPanelRef.GetAsWindow : ICefWindow;
|
||||
begin
|
||||
Result := TCefWindowRef.UnWrap(PCefPanel(FData)^.as_window(PCefPanel(FData)));
|
||||
end;
|
||||
@ -152,8 +152,18 @@ begin
|
||||
end;
|
||||
|
||||
class function TCefPanelRef.CreatePanel(const delegate: ICefPanelDelegate): ICefPanel;
|
||||
var
|
||||
TempPanel : PCefPanel;
|
||||
begin
|
||||
UnWrap(cef_panel_create(CefGetData(delegate)));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempPanel := cef_panel_create(CefGetData(delegate));
|
||||
|
||||
if (TempPanel <> nil) then
|
||||
Result := Create(TempPanel) as ICefPanel;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
264
source/uCEFPanelComponent.pas
Normal file
@ -0,0 +1,264 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFPanelComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFViewComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFPanelComponent = class(TCEFViewComponent, ICefPanelDelegateEvents)
|
||||
protected
|
||||
FPanel : ICefPanel;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsPanel : ICefPanel; override;
|
||||
function GetAsWindow : ICefWindow; virtual;
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreatePanel;
|
||||
function SetToFillLayout : ICefFillLayout;
|
||||
function SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
||||
function GetLayout : ICefLayout;
|
||||
procedure Layout;
|
||||
procedure AddChildView(const view: ICefView);
|
||||
procedure AddChildViewAt(const view: ICefView; index: Integer);
|
||||
procedure ReorderChildView(const view: ICefView; index: Integer);
|
||||
procedure RemoveChildView(const view: ICefView);
|
||||
procedure RemoveAllChildViews;
|
||||
function GetChildViewCount : NativeUInt;
|
||||
function GetChildViewAt(index: Integer): ICefView;
|
||||
|
||||
property AsWindow : ICefWindow read GetAsWindow;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFPanelDelegate, uCEFPanel, uCEFMiscFunctions, uCEFTask;
|
||||
|
||||
procedure TCEFPanelComponent.CreatePanel;
|
||||
begin
|
||||
CreateView;
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.doCreateCustomView;
|
||||
var
|
||||
TempDelegate : ICefPanelDelegate;
|
||||
begin
|
||||
if (FPanel = nil) then
|
||||
try
|
||||
TempDelegate := TCustomPanelDelegate.Create(self);
|
||||
FPanel := TCefPanelRef.CreatePanel(TempDelegate);
|
||||
finally
|
||||
TempDelegate := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.DestroyView;
|
||||
begin
|
||||
FPanel := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FPanel := nil;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FPanel <> nil);
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FPanel as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetAsPanel : ICefPanel;
|
||||
begin
|
||||
Result := FPanel;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetAsWindow : ICefWindow;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.AsWindow
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.SetToFillLayout : ICefFillLayout;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.SetToFillLayout
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.SetToBoxLayout(const settings: TCefBoxLayoutSettings): ICefBoxLayout;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.SetToBoxLayout(settings)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetLayout : ICefLayout;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.GetLayout
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.Layout;
|
||||
begin
|
||||
if Initialized then AsPanel.Layout;
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.AddChildView(const view: ICefView);
|
||||
begin
|
||||
if Initialized then AsPanel.AddChildView(view);
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.AddChildViewAt(const view: ICefView; index: Integer);
|
||||
begin
|
||||
if Initialized then AsPanel.AddChildViewAt(view, index);
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.ReorderChildView(const view: ICefView; index: Integer);
|
||||
begin
|
||||
if Initialized then AsPanel.ReorderChildView(view, index);
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.RemoveChildView(const view: ICefView);
|
||||
begin
|
||||
if Initialized then AsPanel.RemoveChildView(view);
|
||||
end;
|
||||
|
||||
procedure TCEFPanelComponent.RemoveAllChildViews;
|
||||
begin
|
||||
if Initialized then AsPanel.RemoveAllChildViews;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetChildViewCount : NativeUInt;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.GetChildViewCount
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFPanelComponent.GetChildViewAt(index: Integer): ICefView;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsPanel.GetChildViewAt(index)
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tcefpanelcomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFPanelComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -67,8 +67,29 @@ type
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefPanelDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions;
|
||||
|
||||
// **************************************************************
|
||||
// ******************** TCefPanelDelegateRef ********************
|
||||
// **************************************************************
|
||||
@ -92,5 +113,104 @@ begin
|
||||
InitializeCEFMethods;
|
||||
end;
|
||||
|
||||
// **************************************************************
|
||||
// ******************** TCustomPanelDelegate ********************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomPanelDelegate.Create(const events: ICefPanelDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomPanelDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
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
|
||||
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
|
||||
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
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -122,8 +122,18 @@ begin
|
||||
end;
|
||||
|
||||
class function TCefScrollViewRef.CreateScrollView(const delegate: ICefViewDelegate): ICefScrollView;
|
||||
var
|
||||
TempScrollView : PCefScrollView;
|
||||
begin
|
||||
UnWrap(cef_scroll_view_create(CefGetData(delegate)));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempScrollView := cef_scroll_view_create(CefGetData(delegate));
|
||||
|
||||
if (TempScrollView <> nil) then
|
||||
Result := Create(TempScrollView) as ICefScrollView;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
242
source/uCEFScrollViewComponent.pas
Normal file
@ -0,0 +1,242 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFScrollViewComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFViewComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFScrollViewComponent = class(TCEFViewComponent)
|
||||
protected
|
||||
FScrollView : ICefScrollView;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsScrollView : ICefScrollView; override;
|
||||
function GetContentView : ICefView;
|
||||
function GetVisibleContentRect : TCefRect;
|
||||
function GetHasHorizontalScrollbar : boolean;
|
||||
function GetHorizontalScrollbarHeight : Integer;
|
||||
function GetHasVerticalScrollbar : boolean;
|
||||
function GetVerticalScrollbarWidth : Integer;
|
||||
|
||||
procedure SetContentView(const view: ICefView);
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreateScrollView;
|
||||
|
||||
property ContentView : ICefView read GetContentView write SetContentView;
|
||||
property VisibleContentRect : TCefRect read GetVisibleContentRect;
|
||||
property HorizontalScrollbarHeight : Integer read GetHorizontalScrollbarHeight;
|
||||
property VerticalScrollbarWidth : Integer read GetVerticalScrollbarWidth;
|
||||
property HasHorizontalScrollbar : boolean read GetHasHorizontalScrollbar;
|
||||
property HasVerticalScrollbar : boolean read GetHasVerticalScrollbar;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFScrollView, uCEFMiscFunctions, uCEFViewDelegate;
|
||||
|
||||
procedure TCEFScrollViewComponent.CreateScrollView;
|
||||
begin
|
||||
CreateView;
|
||||
end;
|
||||
|
||||
procedure TCEFScrollViewComponent.doCreateCustomView;
|
||||
var
|
||||
TempDelegate : ICefViewDelegate;
|
||||
begin
|
||||
if (FScrollView = nil) then
|
||||
try
|
||||
TempDelegate := TCustomViewDelegate.Create(self);
|
||||
FScrollView := TCefScrollViewRef.CreateScrollView(TempDelegate);
|
||||
finally
|
||||
TempDelegate := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFScrollViewComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FScrollView := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFScrollViewComponent.DestroyView;
|
||||
begin
|
||||
FScrollView := nil;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FScrollView <> nil);
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FScrollView as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetAsScrollView : ICefScrollView;
|
||||
begin
|
||||
Result := FScrollView;
|
||||
end;
|
||||
|
||||
procedure TCEFScrollViewComponent.SetContentView(const view: ICefView);
|
||||
begin
|
||||
if Initialized then FScrollView.SetContentView(view);
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetContentView : ICefView;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FScrollView.GetContentView
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetVisibleContentRect : TCefRect;
|
||||
var
|
||||
TempRect : TCefRect;
|
||||
begin
|
||||
if Initialized then
|
||||
TempRect := FScrollView.GetVisibleContentRect
|
||||
else
|
||||
begin
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := 0;
|
||||
TempRect.height := 0;
|
||||
end;
|
||||
|
||||
Result := TempRect;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetHasHorizontalScrollbar : boolean;
|
||||
begin
|
||||
Result := Initialized and FScrollView.HasHorizontalScrollbar;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetHorizontalScrollbarHeight : Integer;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FScrollView.GetHorizontalScrollbarHeight
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetHasVerticalScrollbar : boolean;
|
||||
begin
|
||||
Result := Initialized and FScrollView.HasVerticalScrollbar;
|
||||
end;
|
||||
|
||||
function TCEFScrollViewComponent.GetVerticalScrollbarWidth : Integer;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FScrollView.GetVerticalScrollbarWidth
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tcefscrollviewcomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFScrollViewComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -196,6 +196,18 @@ type
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefCreateCustomViewTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : ICefViewDelegateEvents); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -595,4 +607,35 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
// TCefCreateCustomViewTask
|
||||
|
||||
procedure TCefCreateCustomViewTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then ICefViewDelegateEvents(FEvents).doCreateCustomView;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('ICefViewDelegateEvents.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefCreateCustomViewTask.Create(const aEvents : ICefViewDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
end;
|
||||
|
||||
destructor TCefCreateCustomViewTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -285,8 +285,18 @@ begin
|
||||
end;
|
||||
|
||||
class function TCefTextfieldRef.CreateTextField(const delegate: ICefTextfieldDelegate): ICefTextfield;
|
||||
var
|
||||
TempTextfield : PCefTextfield;
|
||||
begin
|
||||
Result := UnWrap(cef_textfield_create(CefGetData(delegate)));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempTextfield := cef_textfield_create(CefGetData(delegate));
|
||||
|
||||
if (TempTextfield <> nil) then
|
||||
Result := Create(TempTextfield) as ICefTextfield;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
447
source/uCEFTextfieldComponent.pas
Normal file
@ -0,0 +1,447 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFTextfieldComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFViewComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFTextfieldComponent = class(TCEFViewComponent, ICefTextfieldDelegateEvents)
|
||||
protected
|
||||
FTextfield : ICefTextfield;
|
||||
|
||||
// ICefTextfieldDelegateEvents
|
||||
FOnTextfieldKeyEvent : TOnTextfieldKeyEventEvent;
|
||||
FOnAfterUserAction : TOnAfterUserActionEvent;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsTextfield : ICefTextfield; override;
|
||||
function GetIsPasswordInput : boolean;
|
||||
function GetIsReadOnly : boolean;
|
||||
function GetText : ustring;
|
||||
function GetHasSelection : boolean;
|
||||
function GetSelectedText : ustring;
|
||||
function GetSelectedRange : TCefRange;
|
||||
function GetCursorPosition : NativeUInt;
|
||||
function GetTextColor : TCefColor;
|
||||
function GetSelectionTextColor : TCefColor;
|
||||
function GetSelectionBackgroundColor : TCefColor;
|
||||
function GetPlaceholderText : ustring;
|
||||
|
||||
procedure SetPasswordInput(password_input: boolean);
|
||||
procedure SetReadOnly(read_only: boolean);
|
||||
procedure SetText(const text_: ustring);
|
||||
procedure SetTextColor(color: TCefColor);
|
||||
procedure SetSelectionTextColor(color: TCefColor);
|
||||
procedure SetSelectionBackgroundColor(color: TCefColor);
|
||||
procedure SetPlaceholderText(const text_: ustring);
|
||||
|
||||
// ICefTextfieldDelegateEvents
|
||||
procedure doOnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
procedure doOnAfterUserAction(const textfield: ICefTextfield);
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreateTextField;
|
||||
procedure AppendText(const text_: ustring);
|
||||
procedure InsertOrReplaceText(const text_: ustring);
|
||||
procedure SelectAll(reversed: boolean);
|
||||
procedure ClearSelection;
|
||||
procedure SelectRange(const range: TCefRange);
|
||||
procedure SetFontList(const font_list: ustring);
|
||||
procedure ApplyTextColor(color: TCefColor; const range: TCefRange);
|
||||
procedure ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange);
|
||||
function IsCommandEnabled(command_id: Integer): boolean;
|
||||
procedure ExecuteCommand(command_id: Integer);
|
||||
procedure ClearEditHistory;
|
||||
procedure SetAccessibleName(const name_: ustring);
|
||||
procedure SetPlaceholderTextColor(color: TCefColor);
|
||||
|
||||
property PasswordInput : boolean read GetIsPasswordInput write SetPasswordInput;
|
||||
property ReadOnly : boolean read GetIsReadOnly write SetReadOnly;
|
||||
property Text : ustring read GetText write SetText;
|
||||
property SelectedText : ustring read GetSelectedText;
|
||||
property TextColor : TCefColor read GetTextColor write SetTextColor;
|
||||
property SelectionTextColor : TCefColor read GetSelectionTextColor write SetSelectionTextColor;
|
||||
property SelectionBackgroundColor : TCefColor read GetSelectionBackgroundColor write SetSelectionBackgroundColor;
|
||||
property PlaceholderText : ustring read GetPlaceholderText write SetPlaceholderText;
|
||||
property HasSelection : boolean read GetHasSelection;
|
||||
|
||||
published
|
||||
property OnTextfieldKeyEvent : TOnTextfieldKeyEventEvent read FOnTextfieldKeyEvent write FOnTextfieldKeyEvent;
|
||||
property OnAfterUserAction : TOnAfterUserActionEvent read FOnAfterUserAction write FOnAfterUserAction;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFTextfieldDelegate, uCEFMiscFunctions, uCEFTask, uCEFTextfield;
|
||||
|
||||
procedure TCEFTextfieldComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FTextfield := nil;
|
||||
FOnTextfieldKeyEvent := nil;
|
||||
FOnAfterUserAction := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.DestroyView;
|
||||
begin
|
||||
FTextfield := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.CreateTextField;
|
||||
begin
|
||||
CreateView;
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.doOnKeyEvent(const textfield : ICefTextfield;
|
||||
const event : TCefKeyEvent;
|
||||
var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnTextfieldKeyEvent) then
|
||||
FOnTextfieldKeyEvent(self, textfield, event, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.doOnAfterUserAction(const textfield: ICefTextfield);
|
||||
begin
|
||||
if assigned(FOnAfterUserAction) then
|
||||
FOnAfterUserAction(self, textfield);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.doCreateCustomView;
|
||||
var
|
||||
TempDelegate : ICefTextfieldDelegate;
|
||||
begin
|
||||
if (FTextfield = nil) then
|
||||
try
|
||||
TempDelegate := TCustomTextfieldDelegate.Create(self);
|
||||
FTextfield := TCefTextfieldRef.CreateTextField(TempDelegate);
|
||||
finally
|
||||
TempDelegate := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FTextfield <> nil);
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FTextfield as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetAsTextfield : ICefTextfield;
|
||||
begin
|
||||
Result := FTextfield;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetIsPasswordInput : boolean;
|
||||
begin
|
||||
Result := Initialized and FTextfield.IsPasswordInput;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetIsReadOnly : boolean;
|
||||
begin
|
||||
Result := Initialized and FTextfield.IsReadOnly;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetText : ustring;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetText
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetHasSelection : boolean;
|
||||
begin
|
||||
Result := Initialized and FTextfield.HasSelection;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetSelectedText : ustring;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.SelectedText
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetSelectedRange : TCefRange;
|
||||
var
|
||||
TempRange : TCefRange;
|
||||
begin
|
||||
if Initialized then
|
||||
TempRange := FTextfield.GetSelectedRange
|
||||
else
|
||||
begin
|
||||
TempRange.from := 0;
|
||||
TempRange.to_ := 0;
|
||||
end;
|
||||
|
||||
Result := TempRange;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetCursorPosition : NativeUInt;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetCursorPosition
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetTextColor : TCefColor;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetTextColor
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetSelectionTextColor : TCefColor;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetSelectionTextColor
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetSelectionBackgroundColor : TCefColor;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetSelectionBackgroundColor
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.GetPlaceholderText : ustring;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FTextfield.GetPlaceholderText
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetPasswordInput(password_input: boolean);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetPasswordInput(password_input);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetReadOnly(read_only: boolean);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetReadOnly(read_only);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetText(const text_: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetText(text_);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetTextColor(color: TCefColor);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetTextColor(color);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetSelectionTextColor(color: TCefColor);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetSelectionTextColor(color);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetSelectionBackgroundColor(color: TCefColor);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetSelectionBackgroundColor(color);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetPlaceholderText(const text_: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetPlaceholderText(text_);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.AppendText(const text_: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.AppendText(text_);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.InsertOrReplaceText(const text_: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.InsertOrReplaceText(text_);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SelectAll(reversed: boolean);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SelectAll(reversed);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.ClearSelection;
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.ClearSelection;
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SelectRange(const range: TCefRange);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SelectRange(range);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetFontList(const font_list: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetFontList(font_list);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.ApplyTextColor(color: TCefColor; const range: TCefRange);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.ApplyTextColor(color, range);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.ApplyTextStyle(style: TCefTextStyle; add: boolean; const range: TCefRange);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.ApplyTextStyle(style, add, range);
|
||||
end;
|
||||
|
||||
function TCEFTextfieldComponent.IsCommandEnabled(command_id: Integer): boolean;
|
||||
begin
|
||||
Result := Initialized and FTextfield.IsCommandEnabled(command_id);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.ExecuteCommand(command_id: Integer);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.ExecuteCommand(command_id);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.ClearEditHistory;
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.ClearEditHistory;
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetAccessibleName(const name_: ustring);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetAccessibleName(name_);
|
||||
end;
|
||||
|
||||
procedure TCEFTextfieldComponent.SetPlaceholderTextColor(color: TCefColor);
|
||||
begin
|
||||
if Initialized then
|
||||
FTextfield.SetPlaceholderTextColor(color);
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tceftextfieldcomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFTextfieldComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end.
|
@ -59,24 +59,63 @@ uses
|
||||
type
|
||||
TCefTextfieldDelegateRef = class(TCefViewDelegateRef, ICefTextfieldDelegate)
|
||||
protected
|
||||
function OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent): boolean;
|
||||
procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
procedure OnAfterUserAction(const textfield: ICefTextfield);
|
||||
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefTextfieldDelegate;
|
||||
end;
|
||||
|
||||
TCefTextfieldDelegateOwn = class(TCefViewDelegateOwn, ICefTextfieldDelegate)
|
||||
protected
|
||||
procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); virtual;
|
||||
procedure OnAfterUserAction(const textfield: ICefTextfield); virtual;
|
||||
|
||||
procedure InitializeCEFMethods; override;
|
||||
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
TCustomTextfieldDelegate = class(TCefTextfieldDelegateOwn)
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
// ICefTextfieldDelegate
|
||||
procedure OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean); override;
|
||||
procedure OnAfterUserAction(const textfield: ICefTextfield); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefTextfieldDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions;
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFTextfield;
|
||||
|
||||
function TCefTextfieldDelegateRef.OnKeyEvent(const textfield : ICefTextfield;
|
||||
const event : TCefKeyEvent): boolean;
|
||||
|
||||
// **************************************************************
|
||||
// ***************** TCefTextfieldDelegateRef *******************
|
||||
// **************************************************************
|
||||
|
||||
procedure TCefTextfieldDelegateRef.OnKeyEvent(const textfield : ICefTextfield;
|
||||
const event : TCefKeyEvent;
|
||||
var aResult : boolean);
|
||||
begin
|
||||
Result := (PCefTextfieldDelegate(FData)^.on_key_event(PCefTextfieldDelegate(FData),
|
||||
CefGetData(textfield),
|
||||
@event) <> 0);
|
||||
aResult := (PCefTextfieldDelegate(FData)^.on_key_event(PCefTextfieldDelegate(FData),
|
||||
CefGetData(textfield),
|
||||
@event) <> 0);
|
||||
end;
|
||||
|
||||
procedure TCefTextfieldDelegateRef.OnAfterUserAction(const textfield: ICefTextfield);
|
||||
@ -93,4 +132,183 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// ***************** TCefTextfieldDelegateOwn *******************
|
||||
// **************************************************************
|
||||
|
||||
function cef_textfield_delegate_on_key_event(self: PCefTextfieldDelegate; textfield: PCefTextfield; const event: PCefKeyEvent): Integer; stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
TempResult : boolean;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempResult := False;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefTextfieldDelegateOwn) then
|
||||
TCefTextfieldDelegateOwn(TempObject).OnKeyEvent(TCefTextfieldRef.UnWrap(textfield), event^, TempResult);
|
||||
|
||||
Result := ord(TempResult);
|
||||
end;
|
||||
|
||||
procedure cef_textfield_delegate_on_accelerator(self: PCefTextfieldDelegate; textfield: PCefTextfield); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefTextfieldDelegateOwn) then
|
||||
TCefTextfieldDelegateOwn(TempObject).OnAfterUserAction(TCefTextfieldRef.UnWrap(textfield));
|
||||
end;
|
||||
|
||||
constructor TCefTextfieldDelegateOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefTextfieldDelegate));
|
||||
|
||||
InitializeCEFMethods;
|
||||
end;
|
||||
|
||||
procedure TCefTextfieldDelegateOwn.InitializeCEFMethods;
|
||||
begin
|
||||
inherited InitializeCEFMethods;
|
||||
|
||||
with PCefTextfieldDelegate(FData)^ do
|
||||
begin
|
||||
on_after_user_action := {$IFDEF FPC}@{$ENDIF}cef_textfield_delegate_on_accelerator;
|
||||
on_key_event := {$IFDEF FPC}@{$ENDIF}cef_textfield_delegate_on_key_event;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCefTextfieldDelegateOwn.OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefTextfieldDelegateOwn.OnAfterUserAction(const textfield: ICefTextfield);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// ***************** TCustomTextfieldDelegate *******************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomTextfieldDelegate.Create(const events: ICefTextfieldDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnKeyEvent(const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnKeyEvent(textfield, event, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnKeyEvent', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTextfieldDelegate.OnAfterUserAction(const textfield: ICefTextfield);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefTextfieldDelegateEvents(FEvents).doOnAfterUserAction(textfield);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomTextfieldDelegate.OnAfterUserAction', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -2894,7 +2894,39 @@ type
|
||||
// *********************************
|
||||
// ************* Views *************
|
||||
// *********************************
|
||||
|
||||
//
|
||||
// (*) Has CEF creation function
|
||||
// (d) Has delegate
|
||||
//
|
||||
// ---------------- ----------------------
|
||||
// | TCefView (d) | -------> | TCefTextfield (*d) |
|
||||
// ---------------- | ----------------------
|
||||
// |
|
||||
// | ----------------------
|
||||
// |---> | TCefScrollView (*) |
|
||||
// | ----------------------
|
||||
// |
|
||||
// | ------------------ -------------------
|
||||
// |---> | TCefPanel (*d) | -------> | TCefWindow (*d) |
|
||||
// | ------------------ -------------------
|
||||
// |
|
||||
// | ------------------------
|
||||
// |---> | TCefBrowserView (*d) |
|
||||
// | ------------------------
|
||||
// |
|
||||
// | ------------------ ----------------------- -----------------------
|
||||
// |---> | TCefButton (d) | -------> | TCefLabelButton (*) | -------> | TCefMenuButton (*d) |
|
||||
// ------------------ ----------------------- -----------------------
|
||||
//
|
||||
//
|
||||
// -------------- -----------------
|
||||
// | TCefLayout | -------> | TCefBoxLayout |
|
||||
// -------------- | -----------------
|
||||
// |
|
||||
// | ------------------
|
||||
// |---> | TCefFillLayout |
|
||||
// ------------------
|
||||
//
|
||||
|
||||
// /include/capi/views/cef_display_capi.h (cef_display_t)
|
||||
TCefDisplay = record
|
||||
@ -3172,7 +3204,7 @@ type
|
||||
get_client_area_bounds_in_screen : function(self: PCefWindow): TCefRect; stdcall;
|
||||
set_draggable_regions : procedure(self: PCefWindow; regionsCount: NativeUInt; const regions: PCefDraggableRegionArray); stdcall;
|
||||
get_window_handle : function(self: PCefWindow): TCefWindowHandle; stdcall;
|
||||
send_key_press : procedure(self: PCefWindow; key_code: Integer; event_flags: uint32); stdcall;
|
||||
send_key_press : procedure(self: PCefWindow; key_code: Integer; event_flags: cardinal); stdcall;
|
||||
send_mouse_move : procedure(self: PCefWindow; screen_x, screen_y: Integer); stdcall;
|
||||
send_mouse_events : procedure(self: PCefWindow; button: TCefMouseButtonType; mouse_down, mouse_up: Integer); stdcall;
|
||||
set_accelerator : procedure(self: PCefWindow; command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed: Integer); stdcall;
|
||||
|
714
source/uCEFViewComponent.pas
Normal file
@ -0,0 +1,714 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFViewComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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;
|
||||
FOnFocus : TOnFocusEvent;
|
||||
FOnBlur : TOnBlurEvent;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
// 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;
|
||||
procedure doOnFocus(const view: ICefView); virtual;
|
||||
procedure doOnBlur(const view: ICefView); virtual;
|
||||
procedure doCreateCustomView; virtual;
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure BeforeDestruction; override;
|
||||
|
||||
function ToStringEx(include_children: boolean): ustring;
|
||||
function IsSame(const that: ICefView): boolean;
|
||||
procedure SizeToPreferredSize;
|
||||
procedure InvalidateLayout;
|
||||
procedure RequestFocus;
|
||||
|
||||
function ConvertPointToScreen(var point: TCefPoint): boolean;
|
||||
function ConvertPointFromScreen(var point: TCefPoint): boolean;
|
||||
function ConvertPointToWindow(var point: TCefPoint): boolean;
|
||||
function ConvertPointFromWindow(var point: TCefPoint): boolean;
|
||||
function ConvertPointToView(const view : ICefView; var point: TCefPoint): boolean;
|
||||
function ConvertPointFromView(const view : ICefView; var point: TCefPoint): boolean;
|
||||
|
||||
property Initialized : boolean read GetInitialized;
|
||||
property AsView : ICefView read GetAsView;
|
||||
property AsBrowserView : ICefBrowserView read GetAsBrowserView;
|
||||
property AsButton : ICefButton read GetAsButton;
|
||||
property AsPanel : ICefPanel read GetAsPanel;
|
||||
property AsScrollView : ICefScrollView read GetAsScrollView;
|
||||
property AsTextfield : ICefTextfield read GetAsTextfield;
|
||||
property ViewForID[id_: Integer] : ICefView read GetViewForID;
|
||||
property Valid : boolean read GetIsValid;
|
||||
property Attached : boolean read GetIsAttached;
|
||||
property Delegate : ICefViewDelegate read GetDelegate;
|
||||
property Window : ICefWindow read GetWindow;
|
||||
property ParentView : ICefView read GetParentView;
|
||||
property BoundsInScreen : TCefRect read GetBoundsInScreen;
|
||||
property PreferredSize : TCefSize read GetPreferredSize;
|
||||
property MinimumSize : TCefSize read GetMinimumSize;
|
||||
property MaximumSize : TCefSize read GetMaximumSize;
|
||||
property Visible : boolean read GetIsVisible write SetVisible;
|
||||
property Drawn : boolean read GetIsDrawn;
|
||||
property Enabled : boolean read GetIsEnabled write SetEnabled;
|
||||
property Focusable : boolean read GetIsFocusable write SetFocusable;
|
||||
property AccessibilityFocusable : boolean read GetIsAccessibilityFocusable;
|
||||
property BackgroundColor : TCefColor read GetBackgroundColor write SetBackgroundColor;
|
||||
property ID : integer read GetID write SetID;
|
||||
property GroupID : integer read GetGroupID write SetGroupID;
|
||||
property Bounds : TCefRect read GetBounds write SetBounds;
|
||||
property Size : TCefSize read GetSize write SetSize;
|
||||
property Position : TCefPoint read GetPosition write SetPosition;
|
||||
property TypeString : ustring read GetTypeString;
|
||||
property HeightForWidth[width: Integer] : Integer read GetHeightForWidth;
|
||||
|
||||
published
|
||||
property OnGetPreferredSize : TOnGetPreferredSizeEvent read FOnGetPreferredSize write FOnGetPreferredSize;
|
||||
property OnGetMinimumSize : TOnGetMinimumSizeEvent read FOnGetMinimumSize write FOnGetMinimumSize;
|
||||
property OnGetMaximumSize : TOnGetMaximumSizeEvent read FOnGetMaximumSize write FOnGetMaximumSize;
|
||||
property OnGetHeightForWidth : TOnGetHeightForWidthEvent read FOnGetHeightForWidth write FOnGetHeightForWidth;
|
||||
property OnParentViewChanged : TOnParentViewChangedEvent read FOnParentViewChanged write FOnParentViewChanged;
|
||||
property OnChildViewChanged : TOnChildViewChangedEvent read FOnChildViewChanged write FOnChildViewChanged;
|
||||
property OnFocus : TOnFocusEvent read FOnFocus write FOnFocus;
|
||||
property OnBlur : TOnBlurEvent read FOnBlur write FOnBlur;
|
||||
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
|
||||
uCEFViewDelegate, uCEFMiscFunctions, uCEFTask;
|
||||
|
||||
constructor TCEFViewComponent.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(aOwner);
|
||||
|
||||
Initialize;
|
||||
end;
|
||||
|
||||
procedure TCEFViewComponent.BeforeDestruction;
|
||||
begin
|
||||
DestroyView;
|
||||
|
||||
inherited BeforeDestruction;
|
||||
end;
|
||||
|
||||
procedure TCEFViewComponent.Initialize;
|
||||
begin
|
||||
FOnGetPreferredSize := nil;
|
||||
FOnGetMinimumSize := nil;
|
||||
FOnGetMaximumSize := nil;
|
||||
FOnGetHeightForWidth := nil;
|
||||
FOnParentViewChanged := nil;
|
||||
FOnChildViewChanged := nil;
|
||||
FOnFocus := nil;
|
||||
FOnBlur := nil;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
function TCEFViewComponent.GetBackgroundColor : TCefColor;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := AsView.GetBackgroundColor
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
procedure TCEFViewComponent.doCreateCustomView;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
end.
|
@ -88,6 +88,24 @@ type
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCustomViewDelegate = class(TCefViewDelegateOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefViewDelegateEvents); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -171,8 +189,8 @@ var
|
||||
TempSize : TCefSize;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempSize.width := 50;
|
||||
TempSize.height := 50;
|
||||
TempSize.width := 100;
|
||||
TempSize.height := 100;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then
|
||||
TCefViewDelegateOwn(TempObject).OnGetPreferredSize(TCefViewRef.UnWrap(view),
|
||||
@ -187,8 +205,8 @@ var
|
||||
TempSize : TCefSize;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempSize.width := 10;
|
||||
TempSize.height := 10;
|
||||
TempSize.width := 0;
|
||||
TempSize.height := 0;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then
|
||||
TCefViewDelegateOwn(TempObject).OnGetMinimumSize(TCefViewRef.UnWrap(view),
|
||||
@ -203,8 +221,8 @@ var
|
||||
TempSize : TCefSize;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
TempSize.width := 1000;
|
||||
TempSize.height := 1000;
|
||||
TempSize.width := 0;
|
||||
TempSize.height := 0;
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefViewDelegateOwn) then
|
||||
TCefViewDelegateOwn(TempObject).OnGetMaximumSize(TCefViewRef.UnWrap(view),
|
||||
@ -335,5 +353,112 @@ begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// ******************** TCustomViewDelegate *********************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomViewDelegate.Create(const events: ICefViewDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
destructor TCustomViewDelegate.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomViewDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefViewDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomViewDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
103
source/uCEFViewsFrameworkEvents.pas
Normal file
@ -0,0 +1,103 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFViewsFrameworkEvents;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFInterfaces;
|
||||
|
||||
type
|
||||
// ICefViewDelegate
|
||||
TOnGetPreferredSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object;
|
||||
TOnGetMinimumSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object;
|
||||
TOnGetMaximumSizeEvent = procedure(const Sender: TObject; const view: ICefView; var aResult : TCefSize) of object;
|
||||
TOnGetHeightForWidthEvent = procedure(const Sender: TObject; const view: ICefView; width: Integer; var aResult: Integer) of object;
|
||||
TOnParentViewChangedEvent = procedure(const Sender: TObject; const view: ICefView; added: boolean; const parent: ICefView) of object;
|
||||
TOnChildViewChangedEvent = procedure(const Sender: TObject; const view: ICefView; added: boolean; const child: ICefView) of object;
|
||||
TOnFocusEvent = procedure(const Sender: TObject; const view: ICefView) of object;
|
||||
TOnBlurEvent = procedure(const Sender: TObject; const view: ICefView) of object;
|
||||
|
||||
// ICefTextfieldDelegate
|
||||
TOnTextfieldKeyEventEvent = procedure(const Sender: TObject; const textfield: ICefTextfield; const event: TCefKeyEvent; var aResult : boolean) of object;
|
||||
TOnAfterUserActionEvent = procedure(const Sender: TObject; const textfield: ICefTextfield) of object;
|
||||
|
||||
// ICefPanelDelegate
|
||||
|
||||
// ICefBrowserViewDelegate
|
||||
TOnBrowserCreatedEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const browser: ICefBrowser) of object;
|
||||
TOnBrowserDestroyedEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const browser: ICefBrowser) of object;
|
||||
TOnGetDelegateForPopupBrowserViewEvent = procedure(const Sender: TObject; const browser_view: ICefBrowserView; const settings: TCefBrowserSettings; const client: ICefClient; is_devtools: boolean; var aResult : ICefBrowserViewDelegate) of object;
|
||||
TOnPopupBrowserViewCreatedEvent = procedure(const Sender: TObject; const browser_view, popup_browser_view: ICefBrowserView; is_devtools: boolean; var aResult : boolean) of object;
|
||||
|
||||
// ICefButtonDelegate
|
||||
TOnButtonPressedEvent = procedure(const Sender: TObject; const button: ICefButton) of object;
|
||||
TOnButtonStateChangedEvent = procedure(const Sender: TObject; const button: ICefButton) of object;
|
||||
|
||||
// ICefMenuButtonDelegate
|
||||
TOnMenuButtonPressedEvent = procedure(const Sender: TObject; const menu_button: ICefMenuButton; const screen_point: TCefPoint; const button_pressed_lock: ICefMenuButtonPressedLock) of object;
|
||||
|
||||
// ICefWindowDelegate
|
||||
TOnWindowCreatedEvent = procedure(const Sender: TObject; const window: ICefWindow) of object;
|
||||
TOnWindowDestroyedEvent = procedure(const Sender: TObject; const window: ICefWindow) of object;
|
||||
TOnGetParentWindowEvent = procedure(const Sender: TObject; const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow) of object;
|
||||
TOnIsFramelessEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object;
|
||||
TOnCanResizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object;
|
||||
TOnCanMaximizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object;
|
||||
TOnCanMinimizeEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object;
|
||||
TOnCanCloseEvent = procedure(const Sender: TObject; const window: ICefWindow; var aResult : boolean) of object;
|
||||
TOnAcceleratorEvent = procedure(const Sender: TObject; const window: ICefWindow; command_id: Integer; var aResult : boolean) of object;
|
||||
TOnWindowKeyEventEvent = procedure(const Sender: TObject; const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean) of object;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
@ -89,7 +89,7 @@ type
|
||||
function GetClientAreaBoundsInScreen : TCefRect;
|
||||
procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray);
|
||||
function GetWindowHandle : TCefWindowHandle;
|
||||
procedure SendKeyPress(key_code: Integer; event_flags: uint32);
|
||||
procedure SendKeyPress(key_code: Integer; event_flags: cardinal);
|
||||
procedure SendMouseMove(screen_x, screen_y: Integer);
|
||||
procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean);
|
||||
procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean);
|
||||
@ -264,7 +264,7 @@ begin
|
||||
Result := PCefWindow(FData)^.get_window_handle(PCefWindow(FData));
|
||||
end;
|
||||
|
||||
procedure TCefWindowRef.SendKeyPress(key_code: Integer; event_flags: uint32);
|
||||
procedure TCefWindowRef.SendKeyPress(key_code: Integer; event_flags: cardinal);
|
||||
begin
|
||||
PCefWindow(FData)^.send_key_press(PCefWindow(FData), key_code, event_flags);
|
||||
end;
|
||||
@ -317,8 +317,18 @@ begin
|
||||
end;
|
||||
|
||||
class function TCefWindowRef.CreateTopLevel(const delegate: ICefWindowDelegate): ICefWindow;
|
||||
var
|
||||
TempWindow : PCefWindow;
|
||||
begin
|
||||
UnWrap(cef_window_create_top_level(CefGetData(delegate)));
|
||||
Result := nil;
|
||||
|
||||
if (delegate <> nil) then
|
||||
begin
|
||||
TempWindow := cef_window_create_top_level(CefGetData(delegate));
|
||||
|
||||
if (TempWindow <> nil) then
|
||||
Result := Create(TempWindow) as ICefWindow;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
558
source/uCEFWindowComponent.pas
Normal file
@ -0,0 +1,558 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright � 2020 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFWindowComponent;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
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, uCEFPanelComponent;
|
||||
|
||||
type
|
||||
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
|
||||
TCEFWindowComponent = class(TCEFPanelComponent, ICefWindowDelegateEvents)
|
||||
protected
|
||||
FWindow : ICefWindow;
|
||||
FWindowDlg : ICefWindowDelegate;
|
||||
|
||||
// ICefWindowDelegateEvents
|
||||
FOnWindowCreated : TOnWindowCreatedEvent;
|
||||
FOnWindowDestroyed : TOnWindowDestroyedEvent;
|
||||
FOnGetParentWindow : TOnGetParentWindowEvent;
|
||||
FOnIsFrameless : TOnIsFramelessEvent;
|
||||
FOnCanResize : TOnCanResizeEvent;
|
||||
FOnCanMaximize : TOnCanMaximizeEvent;
|
||||
FOnCanMinimize : TOnCanMinimizeEvent;
|
||||
FOnCanClose : TOnCanCloseEvent;
|
||||
FOnAccelerator : TOnAcceleratorEvent;
|
||||
FOnKeyEvent : TOnWindowKeyEventEvent;
|
||||
|
||||
procedure DestroyView; override;
|
||||
procedure Initialize; override;
|
||||
|
||||
function GetInitialized : boolean; override;
|
||||
function GetAsView : ICefView; override;
|
||||
function GetAsPanel : ICefPanel; override;
|
||||
function GetAsWindow : ICefWindow; override;
|
||||
function GetIsClosed : boolean;
|
||||
function GetIsActive : boolean;
|
||||
function GetIsAlwaysOnTop : boolean;
|
||||
function GetIsMaximized : boolean;
|
||||
function GetIsMinimized : boolean;
|
||||
function GetIsFullscreen : boolean;
|
||||
function GetTitle : ustring;
|
||||
function GetWindowIcon : ICefImage;
|
||||
function GetWindowAppIcon : ICefImage;
|
||||
function GetDisplay : ICefDisplay;
|
||||
function GetClientAreaBoundsInScreen : TCefRect;
|
||||
function GetWindowHandle : TCefWindowHandle;
|
||||
|
||||
procedure SetAlwaysOnTop(on_top: boolean);
|
||||
procedure SetFullscreen(fullscreen: boolean);
|
||||
procedure SetTitle(const title_: ustring);
|
||||
procedure SetWindowIcon(const image: ICefImage);
|
||||
procedure SetWindowAppIcon(const image: ICefImage);
|
||||
|
||||
// ICefWindowDelegateEvents
|
||||
procedure doOnWindowCreated(const window_: ICefWindow);
|
||||
procedure doOnWindowDestroyed(const window_: ICefWindow);
|
||||
procedure doOnGetParentWindow(const window_: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow);
|
||||
procedure doOnIsFrameless(const window_: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanResize(const window_: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanMaximize(const window_: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanMinimize(const window_: ICefWindow; var aResult : boolean);
|
||||
procedure doOnCanClose(const window_: ICefWindow; var aResult : boolean);
|
||||
procedure doOnAccelerator(const window_: ICefWindow; command_id: Integer; var aResult : boolean);
|
||||
procedure doOnKeyEvent(const window_: ICefWindow; const event: TCefKeyEvent; var aResult : boolean);
|
||||
|
||||
// ICefViewDelegateEvents
|
||||
procedure doCreateCustomView; override;
|
||||
|
||||
public
|
||||
procedure CreateTopLevelWindow;
|
||||
procedure Show;
|
||||
procedure Hide;
|
||||
procedure CenterWindow(const size_: TCefSize);
|
||||
procedure Close;
|
||||
procedure Activate;
|
||||
procedure Deactivate;
|
||||
procedure BringToTop;
|
||||
procedure Maximize;
|
||||
procedure Minimize;
|
||||
procedure Restore;
|
||||
procedure ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition);
|
||||
procedure CancelMenu;
|
||||
procedure SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray);
|
||||
procedure SendKeyPress(key_code: Integer; event_flags: cardinal);
|
||||
procedure SendMouseMove(screen_x, screen_y: Integer);
|
||||
procedure SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean);
|
||||
procedure SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean);
|
||||
procedure RemoveAccelerator(command_id: Integer);
|
||||
procedure RemoveAllAccelerators;
|
||||
|
||||
property Title : ustring read GetTitle write SetTitle;
|
||||
property WindowIcon : ICefImage read GetWindowIcon write SetWindowIcon;
|
||||
property WindowAppIcon : ICefImage read GetWindowAppIcon write SetWindowAppIcon;
|
||||
property Display : ICefDisplay read GetDisplay;
|
||||
property ClientAreaBoundsInScreen : TCefRect read GetClientAreaBoundsInScreen;
|
||||
property WindowHandle : TCefWindowHandle read GetWindowHandle;
|
||||
property IsClosed : boolean read GetIsClosed;
|
||||
property IsActive : boolean read GetIsActive;
|
||||
property IsAlwaysOnTop : boolean read GetIsAlwaysOnTop write SetAlwaysOnTop;
|
||||
property IsFullscreen : boolean read GetIsFullscreen write SetFullscreen;
|
||||
property IsMaximized : boolean read GetIsMaximized;
|
||||
property IsMinimized : boolean read GetIsMinimized;
|
||||
|
||||
published
|
||||
property OnWindowCreated : TOnWindowCreatedEvent read FOnWindowCreated write FOnWindowCreated;
|
||||
property OnWindowDestroyed : TOnWindowDestroyedEvent read FOnWindowDestroyed write FOnWindowDestroyed;
|
||||
property OnGetParentWindow : TOnGetParentWindowEvent read FOnGetParentWindow write FOnGetParentWindow;
|
||||
property OnIsFrameless : TOnIsFramelessEvent read FOnIsFrameless write FOnIsFrameless;
|
||||
property OnCanResize : TOnCanResizeEvent read FOnCanResize write FOnCanResize;
|
||||
property OnCanMaximize : TOnCanMaximizeEvent read FOnCanMaximize write FOnCanMaximize;
|
||||
property OnCanMinimize : TOnCanMinimizeEvent read FOnCanMinimize write FOnCanMinimize;
|
||||
property OnCanClose : TOnCanCloseEvent read FOnCanClose write FOnCanClose;
|
||||
property OnAccelerator : TOnAcceleratorEvent read FOnAccelerator write FOnAccelerator;
|
||||
property OnKeyEvent : TOnWindowKeyEventEvent read FOnKeyEvent write FOnKeyEvent;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
{$ENDIF}
|
||||
|
||||
// *********************************************************
|
||||
// ********************** 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
|
||||
uCEFMiscFunctions, uCEFWindowDelegate, uCEFWindow, uCEFTask;
|
||||
|
||||
procedure TCEFWindowComponent.Initialize;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
FWindow := nil;
|
||||
FWindowDlg := nil;
|
||||
FOnWindowCreated := nil;
|
||||
FOnWindowDestroyed := nil;
|
||||
FOnGetParentWindow := nil;
|
||||
FOnIsFrameless := nil;
|
||||
FOnCanResize := nil;
|
||||
FOnCanMaximize := nil;
|
||||
FOnCanMinimize := nil;
|
||||
FOnCanClose := nil;
|
||||
FOnAccelerator := nil;
|
||||
FOnKeyEvent := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.CreateTopLevelWindow;
|
||||
begin
|
||||
CreateView;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doCreateCustomView;
|
||||
var
|
||||
TempWindow : ICefWindow;
|
||||
begin
|
||||
if (FWindow = nil) then
|
||||
begin
|
||||
if (FWindowDlg = nil) then
|
||||
FWindowDlg := TCustomWindowDelegate.Create(self);
|
||||
|
||||
TempWindow := TCefWindowRef.CreateTopLevel(FWindowDlg);
|
||||
|
||||
if (FWindow = nil) then FWindow := TempWindow;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.DestroyView;
|
||||
begin
|
||||
if (FWindowDlg <> nil) then
|
||||
begin
|
||||
FWindowDlg.DestroyOtherRefs;
|
||||
FWindowDlg := nil;
|
||||
end;
|
||||
|
||||
FWindow := nil;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetInitialized : boolean;
|
||||
begin
|
||||
Result := (FWindow <> nil);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetAsView : ICefView;
|
||||
begin
|
||||
Result := FWindow as ICefView;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetAsPanel : ICefPanel;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FWindow as ICefPanel
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetAsWindow : ICefWindow;
|
||||
begin
|
||||
Result := FWindow;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnWindowCreated(const window_: ICefWindow);
|
||||
begin
|
||||
if (FWindow = nil) then FWindow := window_;
|
||||
|
||||
if assigned(FOnWindowCreated) then
|
||||
FOnWindowCreated(self, window_);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnWindowDestroyed(const window_: ICefWindow);
|
||||
begin
|
||||
if assigned(FOnWindowDestroyed) then
|
||||
FOnWindowDestroyed(self, window_);
|
||||
|
||||
FWindow := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnGetParentWindow(const window_: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow);
|
||||
begin
|
||||
if assigned(FOnGetParentWindow) then
|
||||
FOnGetParentWindow(self, window_, is_menu, can_activate_menu, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnIsFrameless(const window_: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnIsFrameless) then
|
||||
FOnIsFrameless(self, window_, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnCanResize(const window_: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnCanResize) then
|
||||
FOnCanResize(self, window_, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnCanMaximize(const window_: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnCanMaximize) then
|
||||
FOnCanMaximize(self, window_, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnCanMinimize(const window_: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnCanMinimize) then
|
||||
FOnCanMinimize(self, window_, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnCanClose(const window_: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnCanClose) then
|
||||
FOnCanClose(self, window_, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnAccelerator(const window_: ICefWindow; command_id: Integer; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnAccelerator) then
|
||||
FOnAccelerator(self, window_, command_id, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.doOnKeyEvent(const window_: ICefWindow; const event: TCefKeyEvent; var aResult : boolean);
|
||||
begin
|
||||
if assigned(FOnKeyEvent) then
|
||||
FOnKeyEvent(self, window_, event, aResult);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Show;
|
||||
begin
|
||||
if Initialized then FWindow.Show;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Hide;
|
||||
begin
|
||||
if Initialized then FWindow.Hide;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.CenterWindow(const size_: TCefSize);
|
||||
begin
|
||||
if Initialized then FWindow.CenterWindow(size_);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Close;
|
||||
begin
|
||||
if Initialized then FWindow.Close;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsClosed : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsClosed;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Activate;
|
||||
begin
|
||||
if Initialized then FWindow.Activate;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Deactivate;
|
||||
begin
|
||||
if Initialized then FWindow.Deactivate;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsActive : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsActive;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.BringToTop;
|
||||
begin
|
||||
if Initialized then FWindow.BringToTop;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetAlwaysOnTop(on_top: boolean);
|
||||
begin
|
||||
if Initialized then FWindow.SetAlwaysOnTop(on_top);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsAlwaysOnTop : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsAlwaysOnTop;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Maximize;
|
||||
begin
|
||||
if Initialized then FWindow.Maximize;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Minimize;
|
||||
begin
|
||||
if Initialized then FWindow.Minimize;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.Restore;
|
||||
begin
|
||||
if Initialized then FWindow.Restore;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetFullscreen(fullscreen: boolean);
|
||||
begin
|
||||
if Initialized then FWindow.SetFullscreen(fullscreen);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsMaximized : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsMaximized;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsMinimized : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsMinimized;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetIsFullscreen : boolean;
|
||||
begin
|
||||
Result := Initialized and FWindow.IsFullscreen;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetTitle(const title_: ustring);
|
||||
begin
|
||||
if Initialized then FWindow.SetTitle(title_);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetTitle : ustring;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FWindow.GetTitle
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetWindowIcon(const image: ICefImage);
|
||||
begin
|
||||
if Initialized then FWindow.SetWindowIcon(image);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetWindowIcon : ICefImage;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FWindow.GetWindowIcon
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetWindowAppIcon(const image: ICefImage);
|
||||
begin
|
||||
if Initialized then FWindow.SetWindowAppIcon(image);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetWindowAppIcon : ICefImage;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FWindow.GetWindowAppIcon
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.ShowMenu(const menu_model: ICefMenuModel; const screen_point: TCefPoint; anchor_position : TCefMenuAnchorPosition);
|
||||
begin
|
||||
if Initialized then FWindow.ShowMenu(menu_model, screen_point, anchor_position);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.CancelMenu;
|
||||
begin
|
||||
if Initialized then FWindow.CancelMenu;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetDisplay : ICefDisplay;
|
||||
begin
|
||||
if Initialized then
|
||||
Result := FWindow.GetDisplay
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetClientAreaBoundsInScreen : TCefRect;
|
||||
var
|
||||
TempRect : TCefRect;
|
||||
begin
|
||||
if Initialized then
|
||||
TempRect := FWindow.GetClientAreaBoundsInScreen
|
||||
else
|
||||
begin
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := 0;
|
||||
TempRect.height := 0;
|
||||
end;
|
||||
|
||||
Result := TempRect;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetDraggableRegions(regionsCount: NativeUInt; const regions: PCefDraggableRegionArray);
|
||||
begin
|
||||
if Initialized then FWindow.SetDraggableRegions(regionsCount, regions);
|
||||
end;
|
||||
|
||||
function TCEFWindowComponent.GetWindowHandle : TCefWindowHandle;
|
||||
var
|
||||
TempHandle : TCefWindowHandle;
|
||||
begin
|
||||
InitializeWindowHandle(TempHandle);
|
||||
if Initialized then TempHandle := FWindow.GetWindowHandle;
|
||||
Result := TempHandle;
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SendKeyPress(key_code: Integer; event_flags: cardinal);
|
||||
begin
|
||||
if Initialized then FWindow.SendKeyPress(key_code, event_flags);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SendMouseMove(screen_x, screen_y: Integer);
|
||||
begin
|
||||
if Initialized then FWindow.SendMouseMove(screen_x, screen_y);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SendMouseEvents(button: TCefMouseButtonType; mouse_down, mouse_up: boolean);
|
||||
begin
|
||||
if Initialized then FWindow.SendMouseEvents(button, mouse_down, mouse_up);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.SetAccelerator(command_id, key_code : Integer; shift_pressed, ctrl_pressed, alt_pressed: boolean);
|
||||
begin
|
||||
if Initialized then FWindow.SetAccelerator(command_id, key_code, shift_pressed, ctrl_pressed, alt_pressed);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.RemoveAccelerator(command_id: Integer);
|
||||
begin
|
||||
if Initialized then FWindow.RemoveAccelerator(command_id);
|
||||
end;
|
||||
|
||||
procedure TCEFWindowComponent.RemoveAllAccelerators;
|
||||
begin
|
||||
if Initialized then FWindow.RemoveAllAccelerators;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tcefwindowcomponent.lrs}
|
||||
RegisterComponents('Chromium Views Framework', [TCEFWindowComponent]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -88,10 +88,41 @@ type
|
||||
procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); virtual;
|
||||
|
||||
procedure InitializeCEFMethods; override;
|
||||
|
||||
public
|
||||
constructor Create; override;
|
||||
end;
|
||||
|
||||
TCustomWindowDelegate = class(TCefWindowDelegateOwn)
|
||||
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;
|
||||
procedure OnFocus(const view: ICefView); override;
|
||||
procedure OnBlur(const view: ICefView); override;
|
||||
|
||||
// ICefWindowDelegate
|
||||
procedure OnWindowCreated(const window: ICefWindow); override;
|
||||
procedure OnWindowDestroyed(const window: ICefWindow); override;
|
||||
procedure OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow); override;
|
||||
procedure OnIsFrameless(const window: ICefWindow; var aResult : boolean); override;
|
||||
procedure OnCanResize(const window: ICefWindow; var aResult : boolean); override;
|
||||
procedure OnCanMaximize(const window: ICefWindow; var aResult : boolean); override;
|
||||
procedure OnCanMinimize(const window: ICefWindow; var aResult : boolean); override;
|
||||
procedure OnCanClose(const window: ICefWindow; var aResult : boolean); override;
|
||||
procedure OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean); override;
|
||||
procedure OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean); override;
|
||||
|
||||
public
|
||||
constructor Create(const events: ICefWindowDelegateEvents); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -404,5 +435,216 @@ begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// **************************************************************
|
||||
// ******************* TCustomWindowDelegate ********************
|
||||
// **************************************************************
|
||||
|
||||
constructor TCustomWindowDelegate.Create(const events: ICefWindowDelegateEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnGetPreferredSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnGetPreferredSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnGetPreferredSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnGetMinimumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnGetMinimumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnGetMinimumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnGetMaximumSize(const view: ICefView; var aResult : TCefSize);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnGetMaximumSize(view, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnGetMaximumSize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnGetHeightForWidth(const view: ICefView; width: Integer; var aResult: Integer);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnGetHeightForWidth(view, width, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnGetHeightForWidth', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnParentViewChanged(const view: ICefView; added: boolean; const parent: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnParentViewChanged(view, added, parent);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnParentViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnChildViewChanged(const view: ICefView; added: boolean; const child: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnChildViewChanged(view, added, child);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnChildViewChanged', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnFocus(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnFocus(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnFocus', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnBlur(const view: ICefView);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnBlur(view);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnBlur', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnWindowCreated(const window: ICefWindow);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnWindowCreated(window);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnWindowCreated', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnWindowDestroyed(const window: ICefWindow);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnWindowDestroyed(window);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnWindowDestroyed', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnGetParentWindow(const window: ICefWindow; var is_menu, can_activate_menu: boolean; var aResult : ICefWindow);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnGetParentWindow(window, is_menu, can_activate_menu, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnGetParentWindow', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnIsFrameless(const window: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnIsFrameless(window, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnIsFrameless', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnCanResize(const window: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnCanResize(window, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnCanResize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnCanMaximize(const window: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnCanMaximize(window, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnCanMaximize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnCanMinimize(const window: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnCanMinimize(window, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnCanMinimize', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnCanClose(const window: ICefWindow; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnCanClose(window, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnCanClose', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnAccelerator(const window: ICefWindow; command_id: Integer; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnAccelerator(window, command_id, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnAccelerator', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomWindowDelegate.OnKeyEvent(const window: ICefWindow; const event: TCefKeyEvent; var aResult : boolean);
|
||||
begin
|
||||
try
|
||||
if (FEvents <> nil) then
|
||||
ICefWindowDelegateEvents(FEvents).doOnKeyEvent(window, event, aResult);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCustomWindowDelegate.OnKeyEvent', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 129,
|
||||
"InternalVersion" : 130,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "81.3.1.0"
|
||||
}
|
||||
|