1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Added TBufferPanel.OnMouseEnter and TBufferPanel.OnMouseLeave on Lazarus

Fixed building in Windows
Issue #337 : First implementation. It's incomplete.
This commit is contained in:
Salvador Diaz Fau
2021-02-08 10:28:36 +01:00
parent a1f3e133ed
commit e45839bb90
17 changed files with 881 additions and 293 deletions

View File

@@ -25,13 +25,16 @@
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="2">
<RequiredPackages Count="3">
<Item1>
<PackageName Value="CEF4Delphi_Lazarus"/>
<PackageName Value="Printer4Lazarus"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
<PackageName Value="CEF4Delphi_Lazarus"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="3">
<Unit0>

View File

@@ -44,7 +44,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, uMiniBrowser
Forms, printer4lazarus, uMiniBrowser
{ you can add units after this },
uCEFApplication;

View File

@@ -3,15 +3,14 @@
<ProjectSession>
<Version Value="11"/>
<BuildModes Active="Default"/>
<Units Count="13">
<Units Count="48">
<Unit0>
<Filename Value="MiniBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<TopLine Value="26"/>
<CursorPos X="62" Y="52"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<UsageCount Value="33"/>
</Unit0>
<Unit1>
<Filename Value="uMiniBrowser.pas"/>
@@ -20,10 +19,15 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="168"/>
<CursorPos X="52" Y="196"/>
<FoldState Value=" TJmA1{32 pjZlg1@311]B8qW1JF"/>
<UsageCount Value="22"/>
<TopLine Value="780"/>
<CursorPos X="3" Y="782"/>
<FoldState Value=" TJnR1{3122{"/>
<UsageCount Value="33"/>
<Bookmarks Count="3">
<Item0 X="66" Y="1049" ID="1"/>
<Item1 Y="936" ID="9"/>
<Item2 X="12" Y="618" ID="8"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
@@ -33,7 +37,7 @@
<UnitName Value="Interfaces"/>
<EditorIndex Value="-1"/>
<CursorPos X="11" Y="9"/>
<UsageCount Value="22"/>
<UsageCount Value="33"/>
</Unit2>
<Unit3>
<Filename Value="uminibrowser.pas"/>
@@ -44,21 +48,21 @@
<WindowIndex Value="-1"/>
<TopLine Value="29"/>
<CursorPos X="45" Y="36"/>
<UsageCount Value="20"/>
<UsageCount Value="19"/>
</Unit3>
<Unit4>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/winapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="306"/>
<CursorPos Y="329"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit4>
<Unit5>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/application.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="420"/>
<CursorPos Y="439"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit5>
<Unit6>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/forms.pp"/>
@@ -66,84 +70,431 @@
<EditorIndex Value="-1"/>
<TopLine Value="1462"/>
<CursorPos X="25" Y="1499"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit6>
<Unit7>
<Filename Value="../../../source/uCEFChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="130"/>
<CursorPos X="3" Y="146"/>
<UsageCount Value="10"/>
<TopLine Value="183"/>
<CursorPos X="68" Y="201"/>
<UsageCount Value="9"/>
<Bookmarks Count="1">
<Item0 Y="198" ID="9"/>
</Bookmarks>
</Unit7>
<Unit8>
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="780"/>
<CursorPos X="70" Y="807"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="68" Y="793" ID="2"/>
</Bookmarks>
<TopLine Value="700"/>
<CursorPos X="77" Y="725"/>
<UsageCount Value="9"/>
</Unit8>
<Unit9>
<Filename Value="../../../source/uCEFChromiumCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1950"/>
<CursorPos X="71" Y="1975"/>
<UsageCount Value="10"/>
<Bookmarks Count="1">
<Item0 X="56" Y="1966" ID="1"/>
<TopLine Value="728"/>
<CursorPos X="32" Y="735"/>
<UsageCount Value="12"/>
<Bookmarks Count="5">
<Item0 X="7" Y="59" ID="3"/>
<Item1 X="35" Y="1230" ID="4"/>
<Item2 X="3" Y="2733" ID="8"/>
<Item3 Y="4621" ID="7"/>
<Item4 X="37" Y="6383" ID="6"/>
</Bookmarks>
</Unit9>
<Unit10>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gtk/gtkwidget.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="82"/>
<CursorPos X="9" Y="105"/>
<UsageCount Value="10"/>
<CursorPos X="20"/>
<UsageCount Value="9"/>
</Unit10>
<Unit11>
<Filename Value="../../../source/uCEFTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="1228"/>
<CursorPos X="53" Y="1251"/>
<UsageCount Value="10"/>
<TopLine Value="505"/>
<CursorPos X="9" Y="528"/>
<UsageCount Value="11"/>
</Unit11>
<Unit12>
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="220"/>
<UsageCount Value="10"/>
<EditorIndex Value="7"/>
<TopLine Value="545"/>
<CursorPos Y="570"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="../../../source/uCEFLibFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="316"/>
<CursorPos X="3" Y="356"/>
<UsageCount Value="10"/>
</Unit13>
<Unit14>
<Filename Value="/usr/share/lazarus/2.0.10/components/opengl/glgtkglxcontext.pas"/>
<UnitName Value="GLGtkGlxContext"/>
<EditorIndex Value="-1"/>
<CursorPos X="56" Y="24"/>
<UsageCount Value="10"/>
</Unit14>
<Unit15>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk2x11/include/gdkx.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="18"/>
<CursorPos X="10" Y="41"/>
<UsageCount Value="10"/>
</Unit15>
<Unit16>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk2x11/include/gdk2x11includes.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="5" Y="12"/>
<UsageCount Value="10"/>
</Unit16>
<Unit17>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk2x11/gdk2x.pas"/>
<EditorIndex Value="-1"/>
<CursorPos X="11" Y="16"/>
<UsageCount Value="10"/>
</Unit17>
<Unit18>
<Filename Value="../../../source/uCEFLinuxTypes.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="16"/>
<CursorPos X="42" Y="40"/>
<UsageCount Value="10"/>
</Unit18>
<Unit19>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk3/gtk3bindings/lazgtk3.pas"/>
<UnitName Value="LazGtk3"/>
<EditorIndex Value="2"/>
<TopLine Value="12147"/>
<CursorPos X="10" Y="12129"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="../../../source/uCEFLinuxFunctions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="40"/>
<CursorPos Y="73"/>
<UsageCount Value="10"/>
</Unit20>
<Unit21>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk1/src/gdk/gdkx.pp"/>
<EditorIndex Value="-1"/>
<CursorPos X="67" Y="15"/>
<UsageCount Value="10"/>
</Unit21>
<Unit22>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk1/src/gdk/gdkprivate.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<CursorPos X="6" Y="11"/>
<UsageCount Value="9"/>
</Unit22>
<Unit23>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtk1extra.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="276"/>
<CursorPos X="57" Y="279"/>
<UsageCount Value="9"/>
</Unit23>
<Unit24>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkwinapi.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="6852"/>
<CursorPos X="48" Y="6875"/>
<UsageCount Value="9"/>
</Unit24>
<Unit25>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtkproc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="763"/>
<CursorPos X="36" Y="779"/>
<UsageCount Value="9"/>
</Unit25>
<Unit26>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2proc.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="714"/>
<CursorPos X="18" Y="730"/>
<UsageCount Value="9"/>
</Unit26>
<Unit27>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk/gtk1extrah.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="36"/>
<CursorPos X="48" Y="59"/>
<UsageCount Value="9"/>
</Unit27>
<Unit28>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk2/src/gtk+/gdk/gdkdrawable.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="4" Y="10"/>
<UsageCount Value="9"/>
</Unit28>
<Unit29>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2trayicon.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="144"/>
<CursorPos X="54" Y="167"/>
<UsageCount Value="9"/>
</Unit29>
<Unit30>
<Filename Value="../../../source/uCEFLinkedWindowParent.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="146"/>
<UsageCount Value="9"/>
</Unit30>
<Unit31>
<Filename Value="../../../source/uCEFFMXChromium.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="171"/>
<CursorPos X="42" Y="191"/>
<UsageCount Value="9"/>
</Unit31>
<Unit32>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="-1"/>
<TopLine Value="2312"/>
<CursorPos X="14" Y="2333"/>
<UsageCount Value="9"/>
</Unit32>
<Unit33>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/include/wincontrol.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="7414"/>
<CursorPos X="3" Y="7435"/>
<UsageCount Value="9"/>
</Unit33>
<Unit34>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/x11/src/xlib.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="110"/>
<CursorPos X="4" Y="133"/>
<UsageCount Value="9"/>
</Unit34>
<Unit35>
<Filename Value="../../../source/uCEFTask.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="639"/>
<CursorPos Y="683"/>
<UsageCount Value="9"/>
</Unit35>
<Unit36>
<Filename Value="../../../source/uCEFInterfaces.pas"/>
<EditorIndex Value="5"/>
<TopLine Value="2274"/>
<CursorPos X="53" Y="2312"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit36>
<Unit37>
<Filename Value="../../../source/uCEFPrintHandler.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<UsageCount Value="12"/>
</Unit37>
<Unit38>
<Filename Value="../../../source/uCEFPrintDialogCallback.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="19"/>
<UsageCount Value="12"/>
</Unit38>
<Unit39>
<Filename Value="../../../source/uCEFPrintSettings.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="38"/>
<CursorPos X="63" Y="70"/>
<UsageCount Value="12"/>
</Unit39>
<Unit40>
<Filename Value="../../../source/uCEFPrintJobCallback.pas"/>
<EditorIndex Value="6"/>
<TopLine Value="22"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
<Filename Value="../../../source/uCEFPDFPrintOptions.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="58"/>
<CursorPos X="3" Y="60"/>
<UsageCount Value="11"/>
</Unit41>
<Unit42>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/printers.pas"/>
<UnitName Value="Printers"/>
<EditorIndex Value="1"/>
<TopLine Value="270"/>
<CursorPos X="23" Y="303"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit42>
<Unit43>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/graphics.pp"/>
<UnitName Value="Graphics"/>
<EditorIndex Value="-1"/>
<TopLine Value="940"/>
<CursorPos X="3" Y="966"/>
<UsageCount Value="10"/>
</Unit43>
<Unit44>
<Filename Value="../../../source/uCEFProcessMessage.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="10"/>
</Unit44>
<Unit45>
<Filename Value="/usr/share/lazarus/2.0.10/components/printers/printersdlgs.pp"/>
<UnitName Value="PrintersDlgs"/>
<EditorIndex Value="3"/>
<TopLine Value="90"/>
<CursorPos X="14" Y="128"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit45>
<Unit46>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<UnitName Value="Dialogs"/>
<EditorIndex Value="4"/>
<TopLine Value="936"/>
<CursorPos X="3" Y="961"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit46>
<Unit47>
<Filename Value="/usr/share/fpcsrc/3.2.0/packages/gtk1/src/glib/glib.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="641"/>
<CursorPos X="16" Y="668"/>
<UsageCount Value="10"/>
</Unit47>
</Units>
<OtherDefines Count="1">
<Define0 Value="UseCThreads"/>
</OtherDefines>
<JumpHistory Count="6" HistoryIndex="5">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="865" TopLine="829"/>
<Caret Line="932" Column="22" TopLine="909"/>
</Position1>
<Position2>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="158" Column="15" TopLine="137"/>
<Caret Line="935" Column="57" TopLine="909"/>
</Position2>
<Position3>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="863" Column="3" TopLine="829"/>
<Caret Line="59" Column="5" TopLine="33"/>
</Position3>
<Position4>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="849" Column="74" TopLine="829"/>
<Filename Value="/usr/share/lazarus/2.0.10/components/printers/printersdlgs.pp"/>
<Caret Line="114" Column="3" TopLine="82"/>
</Position4>
<Position5>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="222" Column="47" TopLine="210"/>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<Caret Line="506" Column="3" TopLine="492"/>
</Position5>
<Position6>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="352" TopLine="188"/>
<Caret Line="59" Column="5" TopLine="33"/>
</Position6>
<Position7>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="938" Column="50" TopLine="904"/>
</Position7>
<Position8>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="940" Column="82" TopLine="904"/>
</Position8>
<Position9>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="1037" TopLine="1001"/>
</Position9>
<Position10>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="945" Column="9" TopLine="919"/>
</Position10>
<Position11>
<Filename Value="/usr/share/lazarus/2.0.10/components/printers/printersdlgs.pp"/>
<Caret Line="128" Column="14" TopLine="102"/>
</Position11>
<Position12>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<Caret Line="506" Column="3" TopLine="486"/>
</Position12>
<Position13>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="945" Column="9" TopLine="919"/>
</Position13>
<Position14>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="1028" Column="25" TopLine="1008"/>
</Position14>
<Position15>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="927" Column="16" TopLine="904"/>
</Position15>
<Position16>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="1038" TopLine="1010"/>
</Position16>
<Position17>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="976" Column="57" TopLine="936"/>
</Position17>
<Position18>
<Filename Value="/usr/share/lazarus/2.0.10/components/printers/printersdlgs.pp"/>
<Caret Line="128" Column="14" TopLine="102"/>
</Position18>
<Position19>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<Caret Line="518" Column="25" TopLine="489"/>
</Position19>
<Position20>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/dialogs.pp"/>
<Caret Line="961" Column="3" TopLine="936"/>
</Position20>
<Position21>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="976" Column="57" TopLine="936"/>
</Position21>
<Position22>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="620" Column="7" TopLine="573"/>
</Position22>
<Position23>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="979" Column="54" TopLine="915"/>
</Position23>
<Position24>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="1089" Column="53" TopLine="1053"/>
</Position24>
<Position25>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="620" Column="48" TopLine="614"/>
</Position25>
<Position26>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="54" Column="84" TopLine="22"/>
</Position26>
<Position27>
<Filename Value="/usr/share/lazarus/2.0.10/lcl/printers.pas"/>
</Position27>
<Position28>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="54" Column="84" TopLine="22"/>
</Position28>
<Position29>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="624" TopLine="576"/>
</Position29>
<Position30>
<Filename Value="uMiniBrowser.pas"/>
<Caret Line="436" Column="74" TopLine="413"/>
</Position30>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>

View File

@@ -236,6 +236,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnAddressChange = Chromium1AddressChange
OnTitleChange = Chromium1TitleChange
OnStatusMessage = Chromium1StatusMessage
OnJsdialog = Chromium1Jsdialog
OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose
OnClose = Chromium1Close
@@ -270,12 +271,10 @@ object MiniBrowserFrm: TMiniBrowserFrm
end
object Print1: TMenuItem
Caption = 'Print'
Enabled = False
OnClick = Print1Click
end
object PrintinPDF1: TMenuItem
Caption = 'Print to PDF'
Enabled = False
OnClick = PrintinPDF1Click
end
object N3: TMenuItem
@@ -313,4 +312,10 @@ object MiniBrowserFrm: TMiniBrowserFrm
Left = 32
Top = 344
end
object PrintDialog1: TPrintDialog
FromPage = 1
ToPage = 1
Left = 32
Top = 416
end
end

View File

@@ -45,7 +45,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
Menus, ComCtrls, SyncObjs, LMessages,
Menus, ComCtrls, SyncObjs, LMessages, Printers, PrintersDlgs,
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes,
uCEFConstants, uCEFWinControl, uCEFChromiumEvents, uCEFLinkedWindowParent;
@@ -56,6 +56,7 @@ type
HideDevTools1: TMenuItem;
NavControlPnl: TPanel;
NavButtonPnl: TPanel;
PrintDialog1: TPrintDialog;
StatusBar1: TStatusBar;
URLEditPnl: TPanel;
BackBtn: TButton;
@@ -89,6 +90,7 @@ type
procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1BeforePluginLoad(Sender: TObject; const mimeType, pluginUrl: ustring; isMainFrame: boolean; const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo; var pluginPolicy: TCefPluginPolicy; var aResult: boolean);
procedure Chromium1GotFocus(Sender: TObject; const browser: ICefBrowser);
procedure Chromium1Jsdialog(Sender: TObject; const browser: ICefBrowser; const originUrl: ustring; dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring; const callback: ICefJsDialogCallback; out suppressMessage: Boolean; out Result: Boolean);
procedure Chromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
procedure Chromium1AddressChange(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring);
@@ -140,6 +142,13 @@ type
FBrowserStatusText : string;
FBrowserTitle : string;
FPrintJobCallback : ICefPrintJobCallback;
FPrintJobDocumentName : ustring;
FPrintJobPDFFilePath : ustring;
FPrintDialogCallback : ICefPrintDialogCallback;
FPrintDialogHasSelection : boolean;
procedure SetBrowserAddress(const aValue : string);
procedure SetBrowserIsLoading(aValue : boolean);
procedure SetBrowserCanGoBack(aValue : boolean);
@@ -174,6 +183,10 @@ type
procedure BrowserShowDevToolsMsg(Data: PtrInt);
procedure BrowserHideDevToolsMsg(Data: PtrInt);
procedure BrowserPrintPDFEndMsg(Data: PtrInt);
procedure BrowserShowPrintDlgMsg(Data: PtrInt);
procedure BrowserPrintJobStartedMsg(Data: PtrInt);
procedure BrowserPrintStartMsg(Data: PtrInt);
procedure BrowserPrintResetMsg(Data: PtrInt);
property BrowserAddress : string read GetBrowserAddress write SetBrowserAddress;
property BrowserIsLoading : boolean read GetBrowserIsLoading write SetBrowserIsLoading;
@@ -181,6 +194,12 @@ type
property BrowserCanGoForward : boolean read GetBrowserCanGoForward write SetBrowserCanGoForward;
property BrowserStatusText : string read GetBrowserStatusText write SetBrowserStatusText;
property BrowserTitle : string read GetBrowserTitle write SetBrowserTitle;
public
procedure HandlePrintStart(const browser: ICefBrowser);
procedure HandlePrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean);
procedure HandlePrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean);
procedure HandlePrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean);
procedure HandlePrintReset(const browser: ICefBrowser);
end;
var
@@ -193,7 +212,7 @@ implementation
{$R *.lfm}
uses
uCEFMiscFunctions, uCefClient, uCEFLinuxConstants;
uCEFMiscFunctions, uCefClient, uCEFLinuxConstants, uCEFPrintSettings;
const
CEF_UPDATEADDRESS = 1;
@@ -203,6 +222,10 @@ const
CEF_SHOWDEVTOOLS = 5;
CEF_HIDEDEVTOOLS = 6;
CEF_PDFPRINTEND = 7;
CEF_SHOWPRINTDIALOG = 8;
CEF_PRINTJOBSTARTED = 9;
CEF_PRINTSTART = 10;
CEF_PRINTRESET = 11;
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 1;
MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS = MENU_ID_USER_FIRST + 2;
@@ -213,13 +236,50 @@ const
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
procedure GlobalCEFApp_OnPrintStart(const browser: ICefBrowser);
begin
MiniBrowserFrm.HandlePrintStart(browser);
end;
procedure GlobalCEFApp_OnPrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean);
begin
MiniBrowserFrm.HandlePrintSettings(browser, settings, getDefaults);
end;
procedure GlobalCEFApp_OnPrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean);
begin
MiniBrowserFrm.HandlePrintDialog(browser, hasSelection, callback, aResult);
end;
procedure GlobalCEFApp_OnPrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean);
begin
MiniBrowserFrm.HandlePrintJob(browser, documentName, PDFFilePath, callback, aResult);
end;
procedure GlobalCEFApp_OnPrintReset(const browser: ICefBrowser);
begin
MiniBrowserFrm.HandlePrintReset(browser);
end;
procedure GlobalCEFApp_OnGetPDFPaperSize(deviceUnitsPerInch: Integer; var aResult : TCefSize);
begin
aResult.width := Printer.PaperSize.Width;
aResult.height := Printer.PaperSize.Height;
end;
procedure CreateGlobalCEFApp;
begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.cache := 'cache';
//GlobalCEFApp.LogFile := 'debug.log';
//GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
//GlobalCEFApp.EnablePrintPreview := True;
GlobalCEFApp.LogFile := 'debug.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
GlobalCEFApp.EnablePrintPreview := True;
GlobalCEFApp.OnPrintStart := @GlobalCEFApp_OnPrintStart;
GlobalCEFApp.OnPrintSettings := @GlobalCEFApp_OnPrintSettings;
GlobalCEFApp.OnPrintDialog := @GlobalCEFApp_OnPrintDialog;
GlobalCEFApp.OnPrintJob := @GlobalCEFApp_OnPrintJob;
GlobalCEFApp.OnPrintReset := @GlobalCEFApp_OnPrintReset;
GlobalCEFApp.OnGetPDFPaperSize := @GlobalCEFApp_OnGetPDFPaperSize;
end;
{Property setters and getters}
@@ -367,22 +427,16 @@ end;
procedure TMiniBrowserFrm.Print1Click(Sender: TObject);
begin
// TODO: Linux applications need to use the Printer Handler events in
// GlobalCEFApp before printing.
//Chromium1.Print;
Chromium1.Print;
end;
procedure TMiniBrowserFrm.PrintinPDF1Click(Sender: TObject);
begin
// TODO: Linux applications need to use the Printer Handler events in
// GlobalCEFApp before printing.
{
SaveDialog1.DefaultExt := 'pdf';
SaveDialog1.Filter := 'PDF files (*.pdf)|*.PDF';
if SaveDialog1.Execute and (length(SaveDialog1.FileName) > 0) then
Chromium1.PrintToPDF(SaveDialog1.FileName, Chromium1.DocumentURL, Chromium1.DocumentURL);
}
end;
procedure TMiniBrowserFrm.ShowDevTools1Click(Sender: TObject);
@@ -482,6 +536,9 @@ begin
FBrowserStatusText := '';
FBrowserTitle := '';
FPrintDialogCallback := nil;
FPrintJobCallback := nil;
FBrowserCS := TCriticalSection.Create;
// The MultiBrowserMode store all the browser references in TChromium.
@@ -503,6 +560,9 @@ end;
procedure TMiniBrowserFrm.FormDestroy(Sender: TObject);
begin
FPrintDialogCallback := nil;
FPrintJobCallback := nil;
FBrowserCS.Free;
end;
{%Endregion}
@@ -549,10 +609,20 @@ end;
{%Region}
procedure TMiniBrowserFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFLinkedWindowParent1.Handle, CEFLinkedWindowParent1.BoundsRect)) and
not(Chromium1.Initialized) then
Timer1.Enabled := True;
if Chromium1.Initialized then
begin
if (FPrintJobCallback <> nil) and not(Printer.Printing) then
begin
FPrintJobCallback.Cont();
FPrintJobCallback := nil;
end;
end
else
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFLinkedWindowParent1.Handle, CEFLinkedWindowParent1.BoundsRect)) then
Timer1.Enabled := True;
end;
end;
{%Endregion}
@@ -756,6 +826,20 @@ procedure TMiniBrowserFrm.Chromium1GotFocus(Sender: TObject;
begin
CEFLinkedWindowParent1.SetFocus;
end;
procedure TMiniBrowserFrm.Chromium1Jsdialog(Sender: TObject;
const browser: ICefBrowser; const originUrl: ustring;
dialogType: TCefJsDialogType; const messageText, defaultPromptText: ustring;
const callback: ICefJsDialogCallback; out suppressMessage: Boolean; out
Result: Boolean);
begin
// We skip JS dialogs to avoid a crash due to the CEF issue #3087
// https://bitbucket.org/chromiumembedded/cef/issues/3087/linux-multi-threaded-message-loop-not
// Even with this workaround the application may have issues if a JS dialog is suppressed.
suppressMessage := True;
Result := False;
end;
{%Endregion}
{Custom form messages}
@@ -839,6 +923,72 @@ begin
Caption := BrowserTitle;
end;
procedure TMiniBrowserFrm.BrowserShowPrintDlgMsg(Data: PtrInt);
var
TempSettings : ICefPrintSettings;
TempRanges : TCefRangeArray;
TempSize : TCefSize;
TempArea : TCefRect;
begin
if (FPrintDialogCallback = nil) then exit;
try
if PrintDialog1.Execute then
begin
TempSettings := TCefPrintSettingsRef.New();
if (PrintDialog1.PrintRange = TPrintRange.prPageNums) then
begin
SetLength(TempRanges, 1);
TempRanges[0].from := PrintDialog1.FromPage;
TempRanges[0].to_ := PrintDialog1.ToPage;
end
else
SetLength(TempRanges, 0);
TempSettings.SetPageRanges(TempRanges);
TempSettings.SetSelectionOnly(PrintDialog1.PrintRange = TPrintRange.prSelection);
TempSettings.DeviceName := Printer.PrinterName;
TempSettings.Dpi := Printer.XDPI;
TempSize.width := Printer.PaperSize.Width;
TempSize.height := Printer.PaperSize.Height;
TempArea.x := TPrinterCanvas(Printer.Canvas).LeftMargin;
TempArea.y := TPrinterCanvas(Printer.Canvas).TopMargin;
TempArea.width := TPrinterCanvas(Printer.Canvas).PageWidth;
TempArea.height := TPrinterCanvas(Printer.Canvas).PageHeight;
TempSettings.SetOrientation(Printer.Orientation in [TPrinterOrientation.poLandscape, TPrinterOrientation.poReverseLandscape]);
TempSettings.SetPrinterPrintableArea(@TempSize, @TempArea, Printer.Orientation = TPrinterOrientation.poReverseLandscape);
FPrintDialogCallback.Cont(TempSettings);
end
else
FPrintDialogCallback.Cancel;
finally
TempSettings := nil;
FPrintDialogCallback := nil;
end;
end;
procedure TMiniBrowserFrm.BrowserPrintJobStartedMsg(Data: PtrInt);
begin
StatusBar1.Panels[0].Text := 'Print job started';
Timer1.Enabled := True;
end;
procedure TMiniBrowserFrm.BrowserPrintStartMsg(Data: PtrInt);
begin
StatusBar1.Panels[0].Text := 'Print start';
end;
procedure TMiniBrowserFrm.BrowserPrintResetMsg(Data: PtrInt);
begin
StatusBar1.Panels[0].Text := 'Print reset';
end;
procedure TMiniBrowserFrm.SendCompMessage(aMsg : cardinal; Data: PtrInt);
begin
case aMsg of
@@ -851,6 +1001,10 @@ begin
CEF_SHOWDEVTOOLS : Application.QueueAsyncCall(@BrowserShowDevToolsMsg, Data);
CEF_HIDEDEVTOOLS : Application.QueueAsyncCall(@BrowserHideDevToolsMsg, Data);
CEF_PDFPRINTEND : Application.QueueAsyncCall(@BrowserPrintPDFEndMsg, Data);
CEF_SHOWPRINTDIALOG : Application.QueueAsyncCall(@BrowserShowPrintDlgMsg, Data);
CEF_PRINTJOBSTARTED : Application.QueueAsyncCall(@BrowserPrintJobStartedMsg, Data);
CEF_PRINTSTART : Application.QueueAsyncCall(@BrowserPrintStartMsg, Data);
CEF_PRINTRESET : Application.QueueAsyncCall(@BrowserPrintResetMsg, Data);
end;
end;
{%Endregion}
@@ -877,4 +1031,73 @@ begin
end;
{%Endregion}
{Printing procedures}
{%Region}
procedure TMiniBrowserFrm.HandlePrintStart(const browser: ICefBrowser);
begin
if (browser <> nil) and Chromium1.IsSameBrowser(browser) then
SendCompMessage(CEF_PRINTSTART);
end;
procedure TMiniBrowserFrm.HandlePrintSettings(const browser: ICefBrowser; const settings: ICefPrintSettings; getDefaults: boolean);
var
TempSize : TCefSize;
TempArea : TCefRect;
begin
if (settings <> nil) and (browser <> nil) and settings.IsValid and not(settings.IsReadOnly) and Chromium1.IsSameBrowser(browser) then
begin
// if getDefaults then ...
TempSize.width := Printer.PaperSize.Width;
TempSize.height := Printer.PaperSize.Height;
TempArea.x := TPrinterCanvas(Printer.Canvas).LeftMargin;
TempArea.y := TPrinterCanvas(Printer.Canvas).TopMargin;
TempArea.width := TPrinterCanvas(Printer.Canvas).PageWidth;
TempArea.height := TPrinterCanvas(Printer.Canvas).PageHeight;
settings.DeviceName := Printer.PrinterName;
settings.Dpi := Printer.XDPI;
settings.SetOrientation(Printer.Orientation in [TPrinterOrientation.poLandscape, TPrinterOrientation.poReverseLandscape]);
settings.SetPrinterPrintableArea(@TempSize, @TempArea, Printer.Orientation = TPrinterOrientation.poReverseLandscape);
end;
end;
procedure TMiniBrowserFrm.HandlePrintDialog(const browser: ICefBrowser; hasSelection: boolean; const callback: ICefPrintDialogCallback; var aResult : boolean);
begin
if (browser <> nil) and (callback <> nil) and Chromium1.IsSameBrowser(browser) then
begin
FPrintDialogCallback := callback;
FPrintDialogHasSelection := hasSelection;
aResult := True;
SendCompMessage(CEF_SHOWPRINTDIALOG);
end
else
aResult := False;
end;
procedure TMiniBrowserFrm.HandlePrintJob(const browser: ICefBrowser; const documentName, PDFFilePath: ustring; const callback: ICefPrintJobCallback; var aResult : boolean);
begin
if (browser <> nil) and (callback <> nil) and Chromium1.IsSameBrowser(browser) then
begin
FPrintJobCallback := callback;
FPrintJobDocumentName := documentName;
FPrintJobPDFFilePath := PDFFilePath;
aResult := True;
SendCompMessage(CEF_PRINTJOBSTARTED);
end
else
aResult := False;
end;
procedure TMiniBrowserFrm.HandlePrintReset(const browser: ICefBrowser);
begin
if (browser <> nil) and Chromium1.IsSameBrowser(browser) then
SendCompMessage(CEF_PRINTRESET);
end;
{%Endregion}
end.