2017-01-27 18:29:37 +02:00
|
|
|
unit uCEFContextMenuParams;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 21:56:46 +02:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 19:56:41 +02:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 18:29:37 +02:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-02-05 21:56:46 +02:00
|
|
|
{$IFDEF DELPHI16_UP}
|
2018-02-26 19:40:51 +02:00
|
|
|
System.Classes, System.SysUtils,
|
2017-02-05 21:56:46 +02:00
|
|
|
{$ELSE}
|
2018-02-26 19:40:51 +02:00
|
|
|
Classes, SysUtils,
|
2017-02-05 21:56:46 +02:00
|
|
|
{$ENDIF}
|
2017-03-16 20:09:42 +02:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 18:29:37 +02:00
|
|
|
|
|
|
|
type
|
2017-03-16 20:09:42 +02:00
|
|
|
TCefContextMenuParamsRef = class(TCefBaseRefCountedRef, ICefContextMenuParams)
|
2017-01-27 18:29:37 +02:00
|
|
|
protected
|
|
|
|
function GetXCoord: Integer;
|
|
|
|
function GetYCoord: Integer;
|
|
|
|
function GetTypeFlags: TCefContextMenuTypeFlags;
|
|
|
|
function GetLinkUrl: ustring;
|
|
|
|
function GetUnfilteredLinkUrl: ustring;
|
|
|
|
function GetSourceUrl: ustring;
|
|
|
|
function HasImageContents: Boolean;
|
|
|
|
function GetTitleText: ustring;
|
|
|
|
function GetPageUrl: ustring;
|
|
|
|
function GetFrameUrl: ustring;
|
|
|
|
function GetFrameCharset: ustring;
|
|
|
|
function GetMediaType: TCefContextMenuMediaType;
|
|
|
|
function GetMediaStateFlags: TCefContextMenuMediaStateFlags;
|
|
|
|
function GetSelectionText: ustring;
|
|
|
|
function GetMisspelledWord: ustring;
|
|
|
|
function GetDictionarySuggestions(const suggestions: TStringList): Boolean;
|
|
|
|
function IsEditable: Boolean;
|
|
|
|
function IsSpellCheckEnabled: Boolean;
|
|
|
|
function GetEditStateFlags: TCefContextMenuEditStateFlags;
|
|
|
|
function IsCustomMenu: Boolean;
|
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefContextMenuParams;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-03-29 20:02:04 +02:00
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFStringList;
|
2017-01-27 18:29:37 +02:00
|
|
|
|
|
|
|
|
2018-02-26 19:40:51 +02:00
|
|
|
function TCefContextMenuParamsRef.GetDictionarySuggestions(const suggestions : TStringList): Boolean;
|
2017-01-27 18:29:37 +02:00
|
|
|
var
|
2018-03-29 20:02:04 +02:00
|
|
|
TempSL : ICefStringList;
|
2017-01-27 18:29:37 +02:00
|
|
|
begin
|
2018-02-26 19:40:51 +02:00
|
|
|
Result := False;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
if (suggestions <> nil) then
|
|
|
|
begin
|
|
|
|
TempSL := TCefStringListOwn.Create;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
if (PCefContextMenuParams(FData)^.get_dictionary_suggestions(PCefContextMenuParams(FData), TempSL.Handle) <> 0) then
|
2018-02-26 19:40:51 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
TempSL.CopyToStrings(suggestions);
|
|
|
|
Result := True;
|
2018-02-26 19:40:51 +02:00
|
|
|
end;
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetEditStateFlags: TCefContextMenuEditStateFlags;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_edit_state_flags(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetFrameCharset: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_frame_charset(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetFrameUrl: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_frame_url(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetLinkUrl: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_link_url(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetMediaStateFlags: TCefContextMenuMediaStateFlags;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_media_state_flags(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetMediaType: TCefContextMenuMediaType;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_media_type(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetMisspelledWord: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_misspelled_word(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetTitleText: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_title_text(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetPageUrl: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_page_url(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetSelectionText: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_selection_text(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetSourceUrl: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_source_url(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetTypeFlags: TCefContextMenuTypeFlags;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_type_flags(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetUnfilteredLinkUrl: ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefContextMenuParams(FData)^.get_unfiltered_link_url(PCefContextMenuParams(FData)));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetXCoord: Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_xcoord(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.GetYCoord: Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.get_ycoord(PCefContextMenuParams(FData));
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.IsCustomMenu: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.is_custom_menu(PCefContextMenuParams(FData)) <> 0;
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.IsEditable: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.is_editable(PCefContextMenuParams(FData)) <> 0;
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.IsSpellCheckEnabled: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.is_spell_check_enabled(PCefContextMenuParams(FData)) <> 0;
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefContextMenuParamsRef.HasImageContents: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefContextMenuParams(FData)^.has_image_contents(PCefContextMenuParams(FData)) <> 0;
|
2017-01-27 18:29:37 +02:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
class function TCefContextMenuParamsRef.UnWrap(data: Pointer): ICefContextMenuParams;
|
2017-01-27 18:29:37 +02:00
|
|
|
begin
|
2018-03-29 20:02:04 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefContextMenuParams
|
|
|
|
else
|
2017-01-27 18:29:37 +02:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|