mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Rename Components
This commit is contained in:
parent
0abb2732de
commit
eec00d7da7
@ -48,7 +48,7 @@ uses
|
||||
SysUtils, Messages, Forms, Controls,
|
||||
Dialogs, ExtCtrls, StdCtrls, LMessages,
|
||||
uCEFTypes, uCEFInterfaces,
|
||||
uCEFWorkScheduler, uCEFLazarusBrowserWindow, Classes;
|
||||
uCEFWorkScheduler, uCEFBrowserWindow, Classes;
|
||||
|
||||
type
|
||||
|
||||
@ -58,7 +58,7 @@ type
|
||||
AddressEdt: TComboBox;
|
||||
GoBtn: TButton;
|
||||
AddressPnl: TPanel;
|
||||
LazarusBrowserWindow1: TLazarusBrowserWindow;
|
||||
LazarusBrowserWindow1: TBrowserWindow;
|
||||
|
||||
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: Boolean; var Result: Boolean);
|
||||
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
|
@ -61,7 +61,7 @@ object Form1: TForm1
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
end
|
||||
object LazarusBrowserWindow1: TLazarusBrowserWindow
|
||||
object LazarusBrowserWindow1: TBrowserWindow
|
||||
Left = 0
|
||||
Height = 566
|
||||
Top = 23
|
||||
|
@ -48,7 +48,7 @@ uses
|
||||
SysUtils, Messages, Forms, Controls,
|
||||
Dialogs, ExtCtrls, StdCtrls, LMessages, Menus,
|
||||
uCEFTypes, uCEFInterfaces, uHelperProcessDom,
|
||||
uCEFWorkScheduler, uCEFLazarusBrowserWindow, uCEFProcessMessage, Classes;
|
||||
uCEFWorkScheduler, uCEFBrowserWindow, uCEFProcessMessage, Classes;
|
||||
|
||||
type
|
||||
|
||||
@ -58,7 +58,7 @@ type
|
||||
AddressEdt: TComboBox;
|
||||
GoBtn: TButton;
|
||||
AddressPnl: TPanel;
|
||||
LazarusBrowserWindow1: TLazarusBrowserWindow;
|
||||
LazarusBrowserWindow1: TBrowserWindow;
|
||||
mDomHere: TMenuItem;
|
||||
|
||||
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: Boolean; var Result: Boolean);
|
||||
|
@ -48,7 +48,7 @@ uses
|
||||
SysUtils, Messages, Forms, Controls,
|
||||
Dialogs, ExtCtrls, StdCtrls, LMessages, Buttons,
|
||||
uCEFTypes, uCEFInterfaces,
|
||||
uCEFWorkScheduler, uCEFLazarusBrowserWindow, Classes;
|
||||
uCEFWorkScheduler, uCEFBrowserWindow, Classes;
|
||||
|
||||
type
|
||||
|
||||
@ -98,7 +98,7 @@ type
|
||||
procedure MaybeTerminateApp(Sender: TObject);
|
||||
procedure MaybeCloseApp(Sender: TObject);
|
||||
protected
|
||||
FBrowserLeft, FBrowserRight: TLazarusBrowserWindow;
|
||||
FBrowserLeft, FBrowserRight: TBrowserWindow;
|
||||
FClosingBrowsers: TList;
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
@ -150,7 +150,7 @@ uses
|
||||
|
||||
procedure TForm1.OpenBtnLeftClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserLeft := TLazarusBrowserWindow.Create(Self);
|
||||
FBrowserLeft := TBrowserWindow.Create(Self);
|
||||
FBrowserLeft.Chromium.OnBeforePopup := @Chromium1BeforePopup;
|
||||
FBrowserLeft.Chromium.OnOpenUrlFromTab := @Chromium1OpenUrlFromTab;
|
||||
FBrowserLeft.OnBrowserCreated := @LeftBrowserCreated;
|
||||
@ -191,7 +191,7 @@ end;
|
||||
|
||||
procedure TForm1.OpenBtnRightClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserRight := TLazarusBrowserWindow.Create(Self);
|
||||
FBrowserRight := TBrowserWindow.Create(Self);
|
||||
FBrowserRight.Chromium.OnBeforePopup := @Chromium1BeforePopup;
|
||||
FBrowserRight.Chromium.OnOpenUrlFromTab := @Chromium1OpenUrlFromTab;
|
||||
FBrowserRight.OnBrowserCreated := @RightBrowserCreated;
|
||||
|
@ -47,8 +47,8 @@ uses
|
||||
uCEFLazarusCocoa, // required for Cocoa
|
||||
SysUtils, Messages, Forms, Controls, Dialogs, ExtCtrls, StdCtrls, LMessages,
|
||||
Menus, Graphics, uCEFTypes, uCEFInterfaces, uHelperProcessDom,
|
||||
uCEFWorkScheduler, uCEFLazarusBrowserWindow, uCEFProcessMessage,
|
||||
uCEFLazarusOsrBrowserWindow, Classes;
|
||||
uCEFWorkScheduler, uCEFBrowserWindow, uCEFProcessMessage,
|
||||
uCEFOsrBrowserWindow, Classes;
|
||||
|
||||
type
|
||||
|
||||
@ -58,7 +58,7 @@ type
|
||||
AddressEdt: TComboBox;
|
||||
GoBtn: TButton;
|
||||
AddressPnl: TPanel;
|
||||
LazarusOsrBrowserWindow1: TLazarusOsrBrowserWindow;
|
||||
LazarusOsrBrowserWindow1: TOsrBrowserWindow;
|
||||
mDomHere: TMenuItem;
|
||||
MenuItem1: TMenuItem;
|
||||
PopupMenu1: TPopupMenu;
|
||||
|
@ -833,21 +833,21 @@
|
||||
</Item198>
|
||||
<Item199>
|
||||
<Filename Value="..\source\uceflazaruscocoa.pas"/>
|
||||
<UnitName Value="uceflazaruscocoa"/>
|
||||
<UnitName Value="uCEFLazarusCocoa"/>
|
||||
</Item199>
|
||||
<Item200>
|
||||
<Filename Value="..\source\uceflazarusbrowserwindow.pas"/>
|
||||
<Filename Value="..\source\uCEFBrowserWindow.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uceflazarusbrowserwindow"/>
|
||||
<UnitName Value="uCEFBrowserWindow"/>
|
||||
</Item200>
|
||||
<Item201>
|
||||
<Filename Value="..\source\uCEFLazApplication.pas"/>
|
||||
<UnitName Value="uCEFLazApplication"/>
|
||||
</Item201>
|
||||
<Item202>
|
||||
<Filename Value="..\source\uCEFLazarusOsrBrowserWindow.pas"/>
|
||||
<Filename Value="..\source\uCEFOsrBrowserWindow.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFLazarusOsrBrowserWindow"/>
|
||||
<UnitName Value="uCEFOsrBrowserWindow"/>
|
||||
</Item202>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
|
@ -66,7 +66,7 @@ uses
|
||||
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
|
||||
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
|
||||
uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa,
|
||||
uCEFLazarusBrowserWindow, uCEFLazApplication, uCEFLazarusOsrBrowserWindow,
|
||||
uCEFBrowserWindow, uCEFLazApplication, uCEFOsrBrowserWindow,
|
||||
LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
@ -90,9 +90,8 @@ begin
|
||||
RegisterUnit('uCEFPanelComponent', @uCEFPanelComponent.Register);
|
||||
RegisterUnit('uCEFScrollViewComponent', @uCEFScrollViewComponent.Register);
|
||||
RegisterUnit('uCEFTextfieldComponent', @uCEFTextfieldComponent.Register);
|
||||
RegisterUnit('uCEFLazarusBrowserWindow', @uCEFLazarusBrowserWindow.Register);
|
||||
RegisterUnit('uCEFLazarusOsrBrowserWindow',
|
||||
@uCEFLazarusOsrBrowserWindow.Register);
|
||||
RegisterUnit('uCEFBrowserWindow', @uCEFBrowserWindow.Register);
|
||||
RegisterUnit('uCEFOsrBrowserWindow', @uCEFOsrBrowserWindow.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
38
source/res/tosrbrowserwindow.lrs
Normal file
38
source/res/tosrbrowserwindow.lrs
Normal file
@ -0,0 +1,38 @@
|
||||
LazarusResources.Add('tlazarusbrowserwindow','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175
|
||||
+#0#0#0#9'pHYs'#0#0#13#215#0#0#13#215#1'B('#155'x'#0#0#0#7'tIME'#7#226#5#11#10
|
||||
+#31#18#187#205#226'X'#0#0#3#10'IDAT8'#203#173#149'Ml'#27'U'#16#199'g'#158'7'
|
||||
+#222#197'Qk'#183'IIBl#'#156'JM'#12'V'#137#168#16'E *8Qn'#17' '#142#168#226
|
||||
+#200#181#189'p'#228#128#212'['#213#3'\'#171#194#165'= TQ'#129'P'#131#26#138
|
||||
+'d'#167#20'PE'#212'H'#9'_'#18'i'#226#218#241'G'#214'~'#187#222'}3'#195'a#w'
|
||||
+#243'Q)'#144#206'i5o'#222'_3'#191#153'y'#139'"'#2#143#195','#215'u'#23#23#23
|
||||
+#247#169'R,'#22#161'\.'#19#145#236#195#136#168'\.+"RJ'#237''''#29#165#20#17
|
||||
+#237'I'#162'g'#246#192#232'Q'#7'k.\-'#223#191#241#253'M'#1#4#128#4#192#169
|
||||
+#215'_}'#231#197#241#177#131#143#22'b'#230'm'#222'Oo5'#191#190'v'#205'NZ'#153
|
||||
+'L'#26#5#1#128#133'ggg'#175'_'#15#222#255#224#204#187#147#187'4Z'#1#128#136
|
||||
+'p'#204'.'#220'l^'#186#252#133#149't'#208'Jv'#180#239'j'#175#165#187#237#142
|
||||
+'6'#146#224'D'#242#147#243#23#206']Y'#142#199'G'#3#180#153'Q'#127#154'j'#30
|
||||
+#206#207#223'N$'#157#182#246#200#176#31#154#227#133#209#3#169#228'j'#203#183
|
||||
+#5#6#149#12#165#7#239#222#254'a'#253#244'3'#135#156#205'+'#136#184')'#20'e'
|
||||
+#20'y'#231#254#30'('#30'+'#212'j'#235'n'#167'{4w'#248#243#143#222'^m'#19#139
|
||||
+'d3'#214#221#127#186':'#228#148'm'#245#180'k'#148'b'#14#251']'#3#0'+R!'#162
|
||||
+#200'['#249'y!?>'#246#236'sS_~'#245#237#220#197'3'#31'_Y'#178#7#20'"z~xvfb'
|
||||
+#249#129#7#28#218#142#179#244#231#253'L'#225'p'#31#144#136#168#168#180'X'#193
|
||||
+'@l'#242#217#209#247'N'#191#242#203#239#27#141#166#214':'#208#186#215'r{'#183
|
||||
+'~'#171#167#146#9'f'#16#129'-P'#153'w)'#141'X'#136#152#133#166'&'''#218#186
|
||||
+'Wk{'#134#24#17'Z:'#232#6#6#128#1#0#1#12#131'!V'#24'+'#173#159'Q$'#20#132#20
|
||||
+#24#177'mY'#217#8'_'#155#28'Zu'#189#7']'#31#1#12'K'#169#144#209#1'#'#2#3#244
|
||||
+#136'@'#152#5#250#211'cE*}F'''#166#167#23#238'-'#140#28'9d)u'#227#158#251#217
|
||||
+#135'/|sgMD'#222'x~'#196'0'#136#0' 4'#154#237'\6K'#180#209#135#205#204#219#25
|
||||
+#189'<'#214#233't}'#207'7'#134#184#222#9#175#222'i'#13#13#165#237#212#224#210
|
||||
+#154'oH'#16' 4'#208#236#132#25#232'lc'#180'} '#135#147#193'K'''#166'W'#170'u'
|
||||
+#207#15'{'#129#17#162#229#170'n'#235#224#216'S'#131'!'#177#14#229#143#149'Zv'
|
||||
+'|'#212#134'`'#247#129#140'o'#201'['#185#134#147'(}'#247#227#175#169''''#236
|
||||
+'t'#250'`h'#248#228#241#225#182'G'#213'zk'#221#13#158#206#231'rV3'#190'T'#15
|
||||
+#187#22'g'#20#217#169#145'F'#241#205#137#185'j'#166'2'#255#211#147#233#129
|
||||
+#191'V'#209#13'h'#234'h'#225#228#145#214#1#171#190'5v'#171#208#206#189#29#182
|
||||
+'{3'#249#234'L>'#23#243'U'#1'`G <d'#244'x'#222#236' '#8#148'R'#142#227#252'o'
|
||||
+#9'D'#212'Zc'#163#209#168'T*'#158#231#25'c'#254#235#31#5#17#17#209'q'#156'R'
|
||||
+#169#132#241#203';I'#237#229#193#142'>'#254#5'Ixq'#26'FW'#221'b'#0#0#0#0'IEN'
|
||||
+'D'#174'B`'#130
|
||||
]);
|
@ -35,7 +35,7 @@
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLazarusBrowserWindow;
|
||||
unit uCEFBrowserWindow;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$i cef.inc}
|
||||
@ -57,14 +57,26 @@ type
|
||||
only close once that event was finished.
|
||||
*)
|
||||
|
||||
{ TLazChromium }
|
||||
{ TEmbeddedChromium
|
||||
|
||||
TLazChromium = class(TChromium)
|
||||
1) TEmbeddedChromium keeps track of the browser while it is created.
|
||||
This allows for CloseBrowser to function, even if the Browser object is not
|
||||
yet known.
|
||||
Also calls to "LoadUrl" are cached until the browser object is created.
|
||||
|
||||
2) TEmbeddedChromium adds InternalEvents that can be hooked by the
|
||||
component that owns the TEmbeddedChromium.
|
||||
This means the default published events are available to the end user.
|
||||
Published events that should not be available are hidden via THiddenPropertyEditor
|
||||
* Hidden event properties must not be assigned by any end user code. *
|
||||
}
|
||||
|
||||
TEmbeddedChromium = class(TChromium)
|
||||
private type
|
||||
TLazChromiumState = (csNoBrowser, csCreatingBrowser, csHasBrowser, csClosingBrowser, csCloseAfterCreate);
|
||||
TChromiumBrowserState = (csNoBrowser, csCreatingBrowser, csHasBrowser, csClosingBrowser, csCloseAfterCreate);
|
||||
private
|
||||
FInternalOnGotFocus: TOnGotFocus;
|
||||
FState : TLazChromiumState;
|
||||
FState : TChromiumBrowserState;
|
||||
FInternalOnBrowserClosed : TNotifyEvent;
|
||||
FInternalOnBrowserCreated : TNotifyEvent;
|
||||
|
||||
@ -108,7 +120,8 @@ type
|
||||
property HasBrowser: Boolean read GetHasBrowser; // Includes browser in creation
|
||||
property IsClosing : Boolean read GetIsClosing;
|
||||
|
||||
(* - Events to be called in main thread
|
||||
(* - Events for use by the Owning component ONLY
|
||||
- Events are called in main thread
|
||||
- OnBrowserCreated: the parent event may be called when procedure Initialized is still false.
|
||||
- OnBrowserCreated: may not be called, if the CloseBrowser has already been called
|
||||
*)
|
||||
@ -117,7 +130,7 @@ type
|
||||
property InternalOnGotFocus : TOnGotFocus read FInternalOnGotFocus write FInternalOnGotFocus;
|
||||
end;
|
||||
|
||||
TLazarusBrowserWindow = class;
|
||||
TBrowserWindow = class;
|
||||
|
||||
{ TChromiumWrapper }
|
||||
|
||||
@ -125,9 +138,9 @@ type
|
||||
protected type
|
||||
TWrapperState = (wsNone, wsWaitingForClose, wsSentCloseEventAfterWait, wsDestroyAfterWait);
|
||||
protected
|
||||
FChromium : TLazChromium;
|
||||
FChromium : TEmbeddedChromium;
|
||||
FWrapperState : TWrapperState;
|
||||
FBrowserWindow : TLazarusBrowserWindow;
|
||||
FBrowserWindow : TBrowserWindow;
|
||||
|
||||
procedure DoOnAfterCreated(Sender: TObject);
|
||||
procedure DoOnBeforeClose(Sender: TObject);
|
||||
@ -139,7 +152,7 @@ type
|
||||
|
||||
procedure MaybeDestroy;
|
||||
public
|
||||
constructor Create(AOwner: TLazarusBrowserWindow); reintroduce;
|
||||
constructor Create(AOwner: TBrowserWindow); reintroduce;
|
||||
destructor Destroy; override;
|
||||
|
||||
function CreateBrowser: boolean;
|
||||
@ -147,23 +160,64 @@ type
|
||||
procedure CloseBrowser(aForceClose: boolean);
|
||||
function IsClosed: boolean;
|
||||
(* WaitForBrowserClosed calls ProcessMessages.
|
||||
It therefore is possible that the TLazarusBrowserWindow will be destroyed
|
||||
It therefore is possible that the TBrowserWindow will be destroyed
|
||||
when this method returns.
|
||||
It is the callers responsibility to take any necessary precaution.
|
||||
*)
|
||||
procedure WaitForBrowserClosed;
|
||||
|
||||
published
|
||||
property Chromium: TLazChromium read FChromium;
|
||||
property Chromium: TEmbeddedChromium read FChromium;
|
||||
end;
|
||||
|
||||
{ TLazarusBrowserWindow }
|
||||
{ TBrowserWindow
|
||||
|
||||
(* On MacOs TLazarusBrowserWindow must wait for OnBrowserClosed before it can
|
||||
be destroyed or before its handle can be closed
|
||||
*)
|
||||
A simple "drop on the Form" component for an full embedded browser.
|
||||
|
||||
TLazarusBrowserWindow = class(TCEFLinkedWinControlBase)
|
||||
The component handles most events required by CEF.
|
||||
The only additions needed to be made by the User in their code are:
|
||||
|
||||
* Implement TForm.OnCloseQuery
|
||||
CEF must be able to destroy the browser, before the main form is closed.
|
||||
(That is while the Form still has a Handle, and the event loop is still
|
||||
running)
|
||||
It is adviced to do the same for any other form (other than the main form).
|
||||
|
||||
TForm.OnCloseQuery should call (for each TBrowserWindow)
|
||||
TBrowserWindow.CloseBrowser(True);
|
||||
The Form can be allowed to close by setting (checking for all BrowserWindows)
|
||||
CanClose := BrowserWindow.IsClosed;
|
||||
|
||||
On Windows and Linux it is also possible to Destroy the TBrowserWindow.
|
||||
This will wait for the browser to close, and after that the form can be closed.
|
||||
- However, this must be done in OnCloseQuery (or before).
|
||||
- Once TForm.Destroy is called, it is to late. By that time the event loop
|
||||
no longer runs.
|
||||
|
||||
*** IMPORTANT: (MacOS) ***
|
||||
On MacOs CloseBrowser() must be called, and the *event* must be awaited.
|
||||
Neither destroying the component, nor waiting with App.ProcessMessages will
|
||||
work.
|
||||
On MacOS, CEF will not finish until the OnCloseQuery event returned to the
|
||||
main event loop. (Hence ProcessMessage does not work).
|
||||
The same is true for any action taken in OnClick or other event.
|
||||
CEF always waits for any event to return to the main event loop.
|
||||
See also the BrowserWindowEX example how that affect modal forms.
|
||||
|
||||
* Implement TBrowserWindow.OnBrowserClosed
|
||||
If TForm.OnCloseQuery called CloseBrowser, this callback can be used to
|
||||
call Form.Close again (the callback should check if the browser was
|
||||
closed by OnCloseQuery.
|
||||
|
||||
* On Windows:
|
||||
handle the WM_ENTERMENULOOP and WM_EXITMENULOOP, as shown in examples
|
||||
|
||||
* Optional prevent pop-up windows by implementing
|
||||
Chromium.BeforePopup
|
||||
Chromium.OpenUrlFromTab
|
||||
}
|
||||
|
||||
TBrowserWindow = class(TCEFLinkedWinControlBase)
|
||||
private
|
||||
FChromiumWrapper : TChromiumWrapper;
|
||||
|
||||
@ -173,7 +227,7 @@ type
|
||||
|
||||
procedure DoCreateBrowser(Sender: TObject);
|
||||
procedure DoCreateBrowserAfterContext(Sender: TObject);
|
||||
function GetLazChromium: TLazChromium;
|
||||
function GetEmbeddedChromium: TEmbeddedChromium;
|
||||
protected
|
||||
function GetChromium: TChromium; override;
|
||||
procedure DestroyHandle; override;
|
||||
@ -195,10 +249,10 @@ type
|
||||
procedure LoadURL(aURL: ustring);
|
||||
|
||||
published
|
||||
property Chromium: TLazChromium read GetLazChromium;
|
||||
property Chromium: TEmbeddedChromium read GetEmbeddedChromium;
|
||||
|
||||
property OnBrowserCreated : TNotifyEvent read FOnBrowserCreated write FOnBrowserCreated;
|
||||
(* OnBrowserClosed will not be called, if the TLazarusBrowserWindow is
|
||||
(* OnBrowserClosed will not be called, if the TBrowserWindow is
|
||||
destroyed/destroying before the browser is closed.
|
||||
*)
|
||||
property OnBrowserClosed : TNotifyEvent read FOnBrowserClosed write FOnBrowserClosed;
|
||||
@ -210,24 +264,24 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
{ TLazChromium }
|
||||
{ TEmbeddedChromium }
|
||||
|
||||
function TLazChromium.GetIsClosing: Boolean;
|
||||
function TEmbeddedChromium.GetIsClosing: Boolean;
|
||||
begin
|
||||
Result := FState in [csCloseAfterCreate, csClosingBrowser];
|
||||
end;
|
||||
|
||||
procedure TLazChromium.SetInternalOnClose(AValue: TOnClose);
|
||||
procedure TEmbeddedChromium.SetInternalOnClose(AValue: TOnClose);
|
||||
begin
|
||||
inherited OnClose := AValue;
|
||||
end;
|
||||
|
||||
function TLazChromium.GetHasBrowser: boolean;
|
||||
function TEmbeddedChromium.GetHasBrowser: boolean;
|
||||
begin
|
||||
Result := (FState <> csNoBrowser) or (inherited GetHasBrowser);
|
||||
end;
|
||||
|
||||
procedure TLazChromium.doOnBeforeClose(const ABrowser: ICefBrowser);
|
||||
procedure TEmbeddedChromium.doOnBeforeClose(const ABrowser: ICefBrowser);
|
||||
begin
|
||||
inherited doOnBeforeClose(ABrowser);
|
||||
|
||||
@ -235,7 +289,7 @@ begin
|
||||
Application.QueueAsyncCall(@DoOnClosed, 0);
|
||||
end;
|
||||
|
||||
procedure TLazChromium.doOnAfterCreated(const ABrowser: ICefBrowser);
|
||||
procedure TEmbeddedChromium.doOnAfterCreated(const ABrowser: ICefBrowser);
|
||||
begin
|
||||
inherited doOnAfterCreated(ABrowser);
|
||||
(* We may still be in Chromium.CreateBrowserSync
|
||||
@ -245,20 +299,20 @@ begin
|
||||
Application.QueueAsyncCall(@DoCreated, 0);
|
||||
end;
|
||||
|
||||
procedure TLazChromium.doOnGotFocus(const Abrowser: ICefBrowser);
|
||||
procedure TEmbeddedChromium.doOnGotFocus(const Abrowser: ICefBrowser);
|
||||
begin
|
||||
inherited doOnGotFocus(Abrowser);
|
||||
if Assigned(FInternalOnGotFocus) then
|
||||
FInternalOnGotFocus(Self, Abrowser);
|
||||
end;
|
||||
|
||||
function TLazChromium.MustCreateFocusHandler: boolean;
|
||||
function TEmbeddedChromium.MustCreateFocusHandler: boolean;
|
||||
begin
|
||||
Result := assigned(FInternalOnGotFocus) or
|
||||
inherited MustCreateFocusHandler;
|
||||
end;
|
||||
|
||||
procedure TLazChromium.DoCreated(Data: PtrInt);
|
||||
procedure TEmbeddedChromium.DoCreated(Data: PtrInt);
|
||||
var
|
||||
u, f: ustring;
|
||||
begin
|
||||
@ -282,25 +336,25 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazChromium.DoOnClosed(Data: PtrInt);
|
||||
procedure TEmbeddedChromium.DoOnClosed(Data: PtrInt);
|
||||
begin
|
||||
if (FInternalOnBrowserClosed <> nil) then
|
||||
FInternalOnBrowserClosed(Self);
|
||||
end;
|
||||
|
||||
constructor TLazChromium.Create(AOwner: TComponent);
|
||||
constructor TEmbeddedChromium.Create(AOwner: TComponent);
|
||||
begin
|
||||
FState := csNoBrowser;
|
||||
inherited Create(AOwner);
|
||||
end;
|
||||
|
||||
destructor TLazChromium.Destroy;
|
||||
destructor TEmbeddedChromium.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
Application.RemoveAsyncCalls(Self);
|
||||
end;
|
||||
|
||||
function TLazChromium.CreateBrowser(const aBrowserParent: TWinControl;
|
||||
function TEmbeddedChromium.CreateBrowser(const aBrowserParent: TWinControl;
|
||||
const aWindowName: ustring; const aContext: ICefRequestContext;
|
||||
const aExtraInfo: ICefDictionaryValue): boolean;
|
||||
begin
|
||||
@ -311,7 +365,7 @@ begin
|
||||
DoCreated(0);
|
||||
end;
|
||||
|
||||
function TLazChromium.CreateBrowser(aParentHandle: TCefWindowHandle;
|
||||
function TEmbeddedChromium.CreateBrowser(aParentHandle: TCefWindowHandle;
|
||||
aParentRect: TRect; const aWindowName: ustring;
|
||||
const aContext: ICefRequestContext; const aExtraInfo: ICefDictionaryValue): boolean;
|
||||
begin
|
||||
@ -322,7 +376,7 @@ begin
|
||||
DoCreated(0);
|
||||
end;
|
||||
|
||||
procedure TLazChromium.CreateBrowser(const aWindowName: ustring);
|
||||
procedure TEmbeddedChromium.CreateBrowser(const aWindowName: ustring);
|
||||
begin
|
||||
FState := csCreatingBrowser;
|
||||
inherited CreateBrowser(aWindowName);
|
||||
@ -330,7 +384,7 @@ begin
|
||||
DoCreated(0);
|
||||
end;
|
||||
|
||||
function TLazChromium.CreateBrowser(const aURL: ustring;
|
||||
function TEmbeddedChromium.CreateBrowser(const aURL: ustring;
|
||||
const aBrowserViewComp: TCEFBrowserViewComponent;
|
||||
const aContext: ICefRequestContext; const aExtraInfo: ICefDictionaryValue
|
||||
): boolean;
|
||||
@ -341,7 +395,7 @@ begin
|
||||
DoCreated(0);
|
||||
end;
|
||||
|
||||
procedure TLazChromium.CloseBrowser(aForceClose: boolean);
|
||||
procedure TEmbeddedChromium.CloseBrowser(aForceClose: boolean);
|
||||
begin
|
||||
if FState = csCreatingBrowser then begin
|
||||
FState := csCloseAfterCreate;
|
||||
@ -355,7 +409,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazChromium.LoadURL(const aURL: ustring; const aFrameName: ustring);
|
||||
procedure TEmbeddedChromium.LoadURL(const aURL: ustring; const aFrameName: ustring);
|
||||
begin
|
||||
FLoadUrl := '';
|
||||
FFrameName := '';
|
||||
@ -420,12 +474,12 @@ begin
|
||||
Destroy;
|
||||
end;
|
||||
|
||||
constructor TChromiumWrapper.Create(AOwner: TLazarusBrowserWindow);
|
||||
constructor TChromiumWrapper.Create(AOwner: TBrowserWindow);
|
||||
begin
|
||||
FBrowserWindow := AOwner;
|
||||
FWrapperState := wsNone;
|
||||
|
||||
FChromium := TLazChromium.Create(nil);
|
||||
FChromium := TEmbeddedChromium.Create(nil);
|
||||
if not(csDesigning in AOwner.ComponentState) then
|
||||
begin
|
||||
FChromium.OnClose := {$IFDEF FPC}@{$ENDIF}BrowserThread_OnClose;
|
||||
@ -498,9 +552,9 @@ begin
|
||||
FWrapperState := wsNone;
|
||||
end;
|
||||
|
||||
{ TLazarusBrowserWindow }
|
||||
{ TBrowserWindow }
|
||||
|
||||
procedure TLazarusBrowserWindow.DoCreateBrowser(Sender: TObject);
|
||||
procedure TBrowserWindow.DoCreateBrowser(Sender: TObject);
|
||||
begin
|
||||
if FTimer <> nil then
|
||||
FTimer.Enabled := False;
|
||||
@ -531,7 +585,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject);
|
||||
procedure TBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject);
|
||||
begin
|
||||
{$IFnDEF WINDOWS}
|
||||
FTimer := TTimer.Create(Self);
|
||||
@ -543,17 +597,17 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TLazarusBrowserWindow.GetLazChromium: TLazChromium;
|
||||
function TBrowserWindow.GetEmbeddedChromium: TEmbeddedChromium;
|
||||
begin
|
||||
Result := FChromiumWrapper.Chromium;
|
||||
end;
|
||||
|
||||
function TLazarusBrowserWindow.GetChromium: TChromium;
|
||||
function TBrowserWindow.GetChromium: TChromium;
|
||||
begin
|
||||
Result := FChromiumWrapper.FChromium;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.CreateHandle;
|
||||
procedure TBrowserWindow.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
if not (csDesigning in ComponentState) then begin
|
||||
@ -568,7 +622,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DestroyHandle;
|
||||
procedure TBrowserWindow.DestroyHandle;
|
||||
begin
|
||||
if FTimer <> nil then
|
||||
FreeAndNil(FTimer);
|
||||
@ -590,7 +644,7 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.RealizeBounds;
|
||||
procedure TBrowserWindow.RealizeBounds;
|
||||
begin
|
||||
inherited RealizeBounds;
|
||||
|
||||
@ -598,20 +652,20 @@ begin
|
||||
Chromium.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoEnter;
|
||||
procedure TBrowserWindow.DoEnter;
|
||||
begin
|
||||
inherited DoEnter;
|
||||
If not(csDesigning in ComponentState) then Chromium.SetFocus(True);
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoExit;
|
||||
procedure TBrowserWindow.DoExit;
|
||||
begin
|
||||
inherited DoExit;
|
||||
if not(csDesigning in ComponentState) then
|
||||
Chromium.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoOnCreated;
|
||||
procedure TBrowserWindow.DoOnCreated;
|
||||
begin
|
||||
{$IFDEF FPC}{$IFDEF LINUX}
|
||||
Chromium.UpdateXWindowVisibility(Visible);
|
||||
@ -621,7 +675,7 @@ begin
|
||||
FOnBrowserCreated(Self);
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoOnClosed(Data: PtrInt);
|
||||
procedure TBrowserWindow.DoOnClosed(Data: PtrInt);
|
||||
begin
|
||||
if (not(csDestroying in ComponentState)) and
|
||||
Assigned(FOnBrowserClosed)
|
||||
@ -629,40 +683,40 @@ begin
|
||||
FOnBrowserClosed(Self);
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.DoOnFocus(Data: PtrInt);
|
||||
procedure TBrowserWindow.DoOnFocus(Data: PtrInt);
|
||||
begin
|
||||
SetFocus;
|
||||
end;
|
||||
|
||||
constructor TLazarusBrowserWindow.Create(AOwner: TComponent);
|
||||
constructor TBrowserWindow.Create(AOwner: TComponent);
|
||||
begin
|
||||
FChromiumWrapper := TChromiumWrapper.Create(Self);
|
||||
inherited Create(AOwner);
|
||||
end;
|
||||
|
||||
destructor TLazarusBrowserWindow.Destroy;
|
||||
destructor TBrowserWindow.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
FChromiumWrapper.MaybeDestroy;
|
||||
Application.RemoveAsyncCalls(Self);
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.CloseBrowser(aForceClose: boolean);
|
||||
procedure TBrowserWindow.CloseBrowser(aForceClose: boolean);
|
||||
begin
|
||||
FChromiumWrapper.CloseBrowser(aForceClose);
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.WaitForBrowserClosed;
|
||||
procedure TBrowserWindow.WaitForBrowserClosed;
|
||||
begin
|
||||
FChromiumWrapper.WaitForBrowserClosed;
|
||||
end;
|
||||
|
||||
function TLazarusBrowserWindow.IsClosed: boolean;
|
||||
function TBrowserWindow.IsClosed: boolean;
|
||||
begin
|
||||
Result := FChromiumWrapper.IsClosed;
|
||||
end;
|
||||
|
||||
procedure TLazarusBrowserWindow.LoadURL(aURL: ustring);
|
||||
procedure TBrowserWindow.LoadURL(aURL: ustring);
|
||||
begin
|
||||
FChromiumWrapper.LoadURL(aURL);
|
||||
end;
|
||||
@ -671,10 +725,10 @@ end;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
{$I res/tlazarusbrowserwindow.lrs}
|
||||
RegisterComponents('Chromium', [TLazarusBrowserWindow]);
|
||||
RegisterPropertyEditor(ClassTypeInfo(TLazChromium), nil,'',TClassPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnClose), TLazChromium, 'OnClose', THiddenPropertyEditor);
|
||||
{$I res/TBrowserWindow.lrs}
|
||||
RegisterComponents('Chromium', [TBrowserWindow]);
|
||||
RegisterPropertyEditor(ClassTypeInfo(TEmbeddedChromium), nil,'',TClassPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedChromium, 'OnClose', THiddenPropertyEditor);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
*)
|
||||
|
||||
unit uCEFLazarusOsrBrowserWindow;
|
||||
unit uCEFOsrBrowserWindow;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$i cef.inc}
|
||||
@ -52,15 +52,17 @@ unit uCEFLazarusOsrBrowserWindow;
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DARWIN} // $IFDEF MACOSX
|
||||
uCEFLazarusCocoa,
|
||||
{$ENDIF}
|
||||
{$IFDEF FPC}
|
||||
LResources, PropEdits,
|
||||
{$ENDIF}
|
||||
uCEFApplication, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium,
|
||||
uCEFLinkedWinControlBase, uCEFLazApplication, uCEFBufferPanel,
|
||||
uCEFLazarusBrowserWindow, uCEFBitmapBitBuffer, uCEFMiscFunctions,
|
||||
uCEFBrowserWindow, uCEFBitmapBitBuffer, uCEFMiscFunctions,
|
||||
uCEFConstants, uCEFChromiumEvents, Forms, ExtCtrls, LCLType, Graphics,
|
||||
Controls, syncobjs, LazLogger, Classes, sysutils, math;
|
||||
Controls, syncobjs, Classes, sysutils, math;
|
||||
|
||||
type
|
||||
|
||||
@ -77,13 +79,31 @@ type
|
||||
//TBrowserKeyPressEvent = procedure(Sender: TObject; var Key: char; var AHandled: Boolean) of Object;
|
||||
TBrowserUTF8KeyPressEvent = procedure(Sender: TObject; var UTF8Key: TUTF8Char; var AHandled: Boolean) of Object;
|
||||
|
||||
(* TEmbeddedOsrChromium
|
||||
|
||||
TLazOsrChromium = class(TLazChromium)
|
||||
Hides (THiddenPropertyEditor) any published event that is used by TOsrBrowserWindow
|
||||
* Hidden events must also not be used by user code *
|
||||
*)
|
||||
|
||||
TEmbeddedOsrChromium = class(TEmbeddedChromium)
|
||||
end;
|
||||
|
||||
{ TLazarusOsrBrowserWindow }
|
||||
{ TOsrBrowserWindow - Off-Screen-Rendering
|
||||
|
||||
TLazarusOsrBrowserWindow = class(TBufferPanel)
|
||||
A simple "drop on the Form" component for an full embedded browser.
|
||||
|
||||
See notes an TBrowserWindow for requirements in user code.
|
||||
Further:
|
||||
- Some keystrokes may not be sent to KeyDown/KeyPress by the LCL.
|
||||
They may be available as WM_SYSKEYDOWN/UP message on the containing Form.
|
||||
|
||||
|
||||
This component is still experimental.
|
||||
- On MacOS Keyboard support is not complete
|
||||
|
||||
}
|
||||
|
||||
TOsrBrowserWindow = class(TBufferPanel)
|
||||
private
|
||||
FPopUpBitmap : TBitmap;
|
||||
FPopUpRect : TRect;
|
||||
@ -136,7 +156,7 @@ type
|
||||
AHeight: Integer);
|
||||
|
||||
private
|
||||
FChromium : TLazOsrChromium;
|
||||
FChromium : TEmbeddedOsrChromium;
|
||||
|
||||
FOnBrowserClosed : TNotifyEvent;
|
||||
FOnBrowserCreated : TNotifyEvent;
|
||||
@ -151,7 +171,7 @@ type
|
||||
procedure DoCreateBrowserAfterContext(Sender: TObject);
|
||||
|
||||
protected
|
||||
function GetChromium: TLazOsrChromium;
|
||||
function GetChromium: TEmbeddedOsrChromium;
|
||||
function getModifiers(Shift: TShiftState): TCefEventFlags;
|
||||
function getKeyModifiers(Shift: TShiftState): TCefEventFlags;
|
||||
function GetButton(Button: TMouseButton): TCefMouseButtonType;
|
||||
@ -193,11 +213,16 @@ type
|
||||
procedure LoadURL(aURL: ustring);
|
||||
//
|
||||
published
|
||||
property Chromium : TLazOsrChromium read GetChromium;
|
||||
property Chromium : TEmbeddedOsrChromium read GetChromium;
|
||||
|
||||
property OnBrowserCreated : TNotifyEvent read FOnBrowserCreated write FOnBrowserCreated;
|
||||
property OnBrowserClosed : TNotifyEvent read FOnBrowserClosed write FOnBrowserClosed;
|
||||
|
||||
(* Mouse/Key events
|
||||
The below events can be used to see mouse/key input before it is sent to CEF.
|
||||
All events have a "AHandled" parameter, which can be used to prevent the event
|
||||
from being sent to CEF.
|
||||
*)
|
||||
property OnMouseDown: TBrowserMouseEvent read FOnMouseDown write FOnMouseDown;
|
||||
property OnMouseUp: TBrowserMouseEvent read FOnMouseUp write FOnMouseUp;
|
||||
property OnMouseMove: TBrowserMouseMoveEvent read FOnMouseMove write FOnMouseMove;
|
||||
@ -214,14 +239,14 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
{ TLazarusOsrBrowserWindow }
|
||||
{ TOsrBrowserWindow }
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.AsyncInvalidate(Data: PtrInt);
|
||||
procedure TOsrBrowserWindow.AsyncInvalidate(Data: PtrInt);
|
||||
begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.AsyncResize(Data: PtrInt);
|
||||
procedure TOsrBrowserWindow.AsyncResize(Data: PtrInt);
|
||||
begin
|
||||
try
|
||||
FResizeCS.Acquire;
|
||||
@ -241,12 +266,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.SyncIMERangeChanged;
|
||||
procedure TOsrBrowserWindow.SyncIMERangeChanged;
|
||||
begin
|
||||
ChangeCompositionRange(FSelectedRange, FDeviceBounds);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumBeforePopup(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumBeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
@ -258,7 +283,7 @@ begin
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumPopupShow(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumPopupShow(Sender: TObject;
|
||||
const browser: ICefBrowser; AShow: Boolean);
|
||||
begin
|
||||
if aShow then
|
||||
@ -272,7 +297,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumPopupSize(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumPopupSize(Sender: TObject;
|
||||
const browser: ICefBrowser; const rect: PCefRect);
|
||||
begin
|
||||
LogicalToDevice(rect^, ScreenScale);
|
||||
@ -283,7 +308,7 @@ begin
|
||||
FPopUpRect.Bottom := rect^.y + rect^.height - 1;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumTooltip(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumTooltip(Sender: TObject;
|
||||
const browser: ICefBrowser; var AText: ustring; out Result: Boolean);
|
||||
begin
|
||||
hint := aText;
|
||||
@ -291,7 +316,7 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumIMECompositionRangeChanged(
|
||||
procedure TOsrBrowserWindow.DoGetChromiumIMECompositionRangeChanged(
|
||||
Sender: TObject; const browser: ICefBrowser; const selected_range: PCefRange;
|
||||
character_boundsCount: NativeUInt; const character_bounds: PCefRect);
|
||||
var
|
||||
@ -334,7 +359,7 @@ begin
|
||||
TThread.Synchronize(nil, @SyncIMERangeChanged);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumCursorChange(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumCursorChange(Sender: TObject;
|
||||
const browser: ICefBrowser; cursor_: TCefCursorHandle;
|
||||
cursorType: TCefCursorType; const customCursorInfo: PCefCursorInfo;
|
||||
var aResult: boolean);
|
||||
@ -343,7 +368,7 @@ begin
|
||||
aResult := True;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumGetScreenInfo(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumGetScreenInfo(Sender: TObject;
|
||||
const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out
|
||||
Result: Boolean);
|
||||
var
|
||||
@ -366,7 +391,7 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumGetScreenPoint(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumGetScreenPoint(Sender: TObject;
|
||||
const browser: ICefBrowser; viewX, viewY: Integer; var screenX,
|
||||
screenY: Integer; out Result: Boolean);
|
||||
var
|
||||
@ -382,7 +407,7 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoGetChromiumViewRect(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoGetChromiumViewRect(Sender: TObject;
|
||||
const browser: ICefBrowser; var rect: TCefRect);
|
||||
var
|
||||
TempScale : single;
|
||||
@ -394,7 +419,7 @@ begin
|
||||
rect.height := DeviceToLogical(Height, TempScale);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoChromiumPaint(Sender: TObject;
|
||||
procedure TOsrBrowserWindow.DoChromiumPaint(Sender: TObject;
|
||||
const browser: ICefBrowser; kind: TCefPaintElementType;
|
||||
dirtyRectsCount: NativeUInt; const dirtyRects: PCefRectArray;
|
||||
const ABuffer: Pointer; AWidth, AHeight: Integer);
|
||||
@ -530,12 +555,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.GetChromium: TLazOsrChromium;
|
||||
function TOsrBrowserWindow.GetChromium: TEmbeddedOsrChromium;
|
||||
begin
|
||||
Result := FChromium;
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.getModifiers(Shift: TShiftState
|
||||
function TOsrBrowserWindow.getModifiers(Shift: TShiftState
|
||||
): TCefEventFlags;
|
||||
begin
|
||||
Result := EVENTFLAG_NONE;
|
||||
@ -549,7 +574,7 @@ begin
|
||||
if (ssMiddle in Shift) then Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON;
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.getKeyModifiers(Shift: TShiftState): TCefEventFlags;
|
||||
function TOsrBrowserWindow.getKeyModifiers(Shift: TShiftState): TCefEventFlags;
|
||||
begin
|
||||
Result := EVENTFLAG_NONE;
|
||||
|
||||
@ -561,7 +586,7 @@ begin
|
||||
if (ssCaps in Shift) then Result := Result or EVENTFLAG_CAPS_LOCK_ON;
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.GetButton(Button: TMouseButton
|
||||
function TOsrBrowserWindow.GetButton(Button: TMouseButton
|
||||
): TCefMouseButtonType;
|
||||
begin
|
||||
case Button of
|
||||
@ -571,12 +596,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject);
|
||||
procedure TOsrBrowserWindow.DoCreateBrowserAfterContext(Sender: TObject);
|
||||
begin
|
||||
FChromium.CreateBrowser(nil);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.CreateHandle;
|
||||
procedure TOsrBrowserWindow.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
if not (csDesigning in ComponentState) then begin
|
||||
@ -587,7 +612,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DestroyHandle;
|
||||
procedure TOsrBrowserWindow.DestroyHandle;
|
||||
begin
|
||||
if (GlobalCEFApp = nil) or
|
||||
(not FChromium.HasBrowser) or
|
||||
@ -601,32 +626,32 @@ begin
|
||||
inherited DestroyHandle;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.RealizeBounds;
|
||||
procedure TOsrBrowserWindow.RealizeBounds;
|
||||
begin
|
||||
inherited RealizeBounds;
|
||||
Chromium.NotifyMoveOrResizeStarted;
|
||||
AsyncResize(0);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoEnter;
|
||||
procedure TOsrBrowserWindow.DoEnter;
|
||||
begin
|
||||
inherited DoEnter;
|
||||
Chromium.SendFocusEvent(True);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoExit;
|
||||
procedure TOsrBrowserWindow.DoExit;
|
||||
begin
|
||||
inherited DoExit;
|
||||
Chromium.SendFocusEvent(False);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.Click;
|
||||
procedure TOsrBrowserWindow.Click;
|
||||
begin
|
||||
inherited Click;
|
||||
SetFocus;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.MouseDown(Button: TMouseButton;
|
||||
procedure TOsrBrowserWindow.MouseDown(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
@ -654,7 +679,7 @@ begin
|
||||
Chromium.SendMouseClickEvent(@TempEvent, GetButton(Button), False, LastClickCount);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.MouseUp(Button: TMouseButton;
|
||||
procedure TOsrBrowserWindow.MouseUp(Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
@ -680,7 +705,7 @@ begin
|
||||
Chromium.SendMouseClickEvent(@TempEvent, GetButton(Button), True, LastClickCount);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
procedure TOsrBrowserWindow.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
IsHandled: Boolean;
|
||||
@ -699,7 +724,7 @@ begin
|
||||
Chromium.SendMouseMoveEvent(@TempEvent, False);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.MouseEnter;
|
||||
procedure TOsrBrowserWindow.MouseEnter;
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempPoint : TPoint;
|
||||
@ -714,7 +739,7 @@ begin
|
||||
Chromium.SendMouseMoveEvent(@TempEvent, False);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.MouseLeave;
|
||||
procedure TOsrBrowserWindow.MouseLeave;
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempPoint : TPoint;
|
||||
@ -735,7 +760,7 @@ begin
|
||||
Chromium.SendMouseMoveEvent(@TempEvent, True);
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.DoMouseWheel(Shift: TShiftState;
|
||||
function TOsrBrowserWindow.DoMouseWheel(Shift: TShiftState;
|
||||
WheelDelta: Integer; MousePos: TPoint): Boolean;
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
@ -760,7 +785,7 @@ begin
|
||||
Chromium.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
procedure TOsrBrowserWindow.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
IsHandled: Boolean;
|
||||
@ -797,7 +822,7 @@ begin
|
||||
inherited KeyDown(Key, Shift);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
||||
procedure TOsrBrowserWindow.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
TempString : UnicodeString;
|
||||
@ -838,7 +863,7 @@ begin
|
||||
inherited UTF8KeyPress(UTF8Key);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.KeyUp(var Key: Word; Shift: TShiftState);
|
||||
procedure TOsrBrowserWindow.KeyUp(var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
IsHandled: Boolean;
|
||||
@ -869,20 +894,20 @@ begin
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TLazarusOsrBrowserWindow.DoOnIMECancelComposition;
|
||||
procedure TOsrBrowserWindow.DoOnIMECancelComposition;
|
||||
begin
|
||||
inherited DoOnIMECancelComposition;
|
||||
Chromium.IMECancelComposition;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoOnIMECommitText(const aText: ustring;
|
||||
procedure TOsrBrowserWindow.DoOnIMECommitText(const aText: ustring;
|
||||
const replacement_range: PCefRange; relative_cursor_pos: integer);
|
||||
begin
|
||||
inherited DoOnIMECommitText(aText, replacement_range, relative_cursor_pos);
|
||||
Chromium.IMECommitText(aText, replacement_range, relative_cursor_pos);;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoOnIMESetComposition(const aText: ustring;
|
||||
procedure TOsrBrowserWindow.DoOnIMESetComposition(const aText: ustring;
|
||||
const underlines: TCefCompositionUnderlineDynArray; const replacement_range,
|
||||
selection_range: TCefRange);
|
||||
begin
|
||||
@ -891,20 +916,20 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.CaptureChanged;
|
||||
procedure TOsrBrowserWindow.CaptureChanged;
|
||||
begin
|
||||
inherited CaptureChanged;
|
||||
|
||||
if (Chromium <> nil) then Chromium.SendCaptureLostEvent;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoOnCreated(Sender: TObject);
|
||||
procedure TOsrBrowserWindow.DoOnCreated(Sender: TObject);
|
||||
begin
|
||||
if Assigned(FOnBrowserCreated) then
|
||||
FOnBrowserCreated(Self);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.DoOnClosed(Sender: TObject);
|
||||
procedure TOsrBrowserWindow.DoOnClosed(Sender: TObject);
|
||||
begin
|
||||
if (not(csDestroying in ComponentState)) and
|
||||
Assigned(FOnBrowserClosed)
|
||||
@ -912,7 +937,7 @@ begin
|
||||
FOnBrowserClosed(Self);
|
||||
end;
|
||||
|
||||
constructor TLazarusOsrBrowserWindow.Create(AOwner: TComponent);
|
||||
constructor TOsrBrowserWindow.Create(AOwner: TComponent);
|
||||
begin
|
||||
FResizeCS := TCriticalSection.Create;
|
||||
|
||||
@ -920,7 +945,7 @@ begin
|
||||
FSelectedRange.from := 0;
|
||||
FSelectedRange.to_ := 0;
|
||||
|
||||
FChromium := TLazOsrChromium.Create(Self);
|
||||
FChromium := TEmbeddedOsrChromium.Create(Self);
|
||||
FChromium.InternalOnBrowserClosed := {$IFDEF FPC}@{$ENDIF}DoOnClosed;
|
||||
FChromium.InternalOnBrowserCreated := {$IFDEF FPC}@{$ENDIF}DoOnCreated;
|
||||
|
||||
@ -939,7 +964,7 @@ begin
|
||||
CopyOriginalBuffer := true;
|
||||
end;
|
||||
|
||||
destructor TLazarusOsrBrowserWindow.Destroy;
|
||||
destructor TOsrBrowserWindow.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
FreeAndNil(FResizeCS);
|
||||
@ -950,12 +975,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.CloseBrowser(aForceClose: boolean);
|
||||
procedure TOsrBrowserWindow.CloseBrowser(aForceClose: boolean);
|
||||
begin
|
||||
FChromium.CloseBrowser(aForceClose);
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.WaitForBrowserClosed;
|
||||
procedure TOsrBrowserWindow.WaitForBrowserClosed;
|
||||
begin
|
||||
if not FChromium.HasBrowser then
|
||||
exit;
|
||||
@ -971,12 +996,12 @@ begin
|
||||
// TODO : sent closed?
|
||||
end;
|
||||
|
||||
function TLazarusOsrBrowserWindow.IsClosed: boolean;
|
||||
function TOsrBrowserWindow.IsClosed: boolean;
|
||||
begin
|
||||
Result := not FChromium.HasBrowser;
|
||||
end;
|
||||
|
||||
procedure TLazarusOsrBrowserWindow.LoadURL(aURL: ustring);
|
||||
procedure TOsrBrowserWindow.LoadURL(aURL: ustring);
|
||||
begin
|
||||
FChromium.LoadURL(aURL);
|
||||
end;
|
||||
@ -985,19 +1010,19 @@ end;
|
||||
{$IFDEF FPC}
|
||||
procedure Register;
|
||||
begin
|
||||
// {$I res/tlazarusosrbrowserwindow.lrs}
|
||||
RegisterComponents('Chromium', [TLazarusOsrBrowserWindow]);
|
||||
RegisterPropertyEditor(TypeInfo(TOnClose), TLazOsrChromium,'OnClose',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPaint), TLazOsrChromium,'OnPaint',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetViewRect), TLazOsrChromium,'OnGetViewRect',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnCursorChange), TLazOsrChromium,'OnCursorChange',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetScreenPoint), TLazOsrChromium,'OnGetScreenPoint',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetScreenInfo), TLazOsrChromium,'OnGetScreenInfo',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPopupShow), TLazOsrChromium,'OnPopupShow',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPopupSize), TLazOsrChromium,'OnPopupSize',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnTooltip), TLazOsrChromium,'OnTooltip',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnBeforePopup), TLazOsrChromium,'OnBeforePopup',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnIMECompositionRangeChanged), TLazOsrChromium,'OnIMECompositionRangeChanged',THiddenPropertyEditor);
|
||||
{$I res/TOsrBrowserWindow.lrs}
|
||||
RegisterComponents('Chromium', [TOsrBrowserWindow]);
|
||||
RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedOsrChromium,'OnClose',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPaint), TEmbeddedOsrChromium,'OnPaint',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetViewRect), TEmbeddedOsrChromium,'OnGetViewRect',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnCursorChange), TEmbeddedOsrChromium,'OnCursorChange',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetScreenPoint), TEmbeddedOsrChromium,'OnGetScreenPoint',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnGetScreenInfo), TEmbeddedOsrChromium,'OnGetScreenInfo',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPopupShow), TEmbeddedOsrChromium,'OnPopupShow',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnPopupSize), TEmbeddedOsrChromium,'OnPopupSize',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnTooltip), TEmbeddedOsrChromium,'OnTooltip',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnBeforePopup), TEmbeddedOsrChromium,'OnBeforePopup',THiddenPropertyEditor);
|
||||
RegisterPropertyEditor(TypeInfo(TOnIMECompositionRangeChanged), TEmbeddedOsrChromium,'OnIMECompositionRangeChanged',THiddenPropertyEditor);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user