CEF4Delphi/source/uCEFContextMenuParams.pas

222 lines
7.2 KiB
ObjectPascal
Raw Normal View History

2017-01-27 17:29:37 +01:00
// ************************************************************************
// ***************************** 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 <20> 2017 Salvador D<>az 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 uCEFContextMenuParams;
{$IFNDEF CPUX64}
{$ALIGN ON}
{$MINENUMSIZE 4}
{$ENDIF}
2017-02-05 20:56:46 +01:00
{$I cef.inc}
2017-01-27 17:29:37 +01:00
interface
uses
2017-02-05 20:56:46 +01:00
{$IFDEF DELPHI16_UP}
2017-01-27 17:29:37 +01:00
System.Classes,
2017-02-05 20:56:46 +01:00
{$ELSE}
Classes,
{$ENDIF}
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
2017-01-27 17:29:37 +01:00
type
TCefContextMenuParamsRef = class(TCefBaseRefCountedRef, ICefContextMenuParams)
2017-01-27 17:29:37 +01: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;
function IsPepperMenu: Boolean;
public
class function UnWrap(data: Pointer): ICefContextMenuParams;
end;
implementation
uses
uCEFMiscFunctions, uCEFLibFunctions;
function TCefContextMenuParamsRef.GetDictionarySuggestions(
const suggestions: TStringList): Boolean;
var
list: TCefStringList;
i: Integer;
str: TCefString;
begin
list := cef_string_list_alloc;
try
Result := PCefContextMenuParams(FData).get_dictionary_suggestions(PCefContextMenuParams(FData), list) <> 0;
FillChar(str, SizeOf(str), 0);
for i := 0 to cef_string_list_size(list) - 1 do
begin
FillChar(str, SizeOf(str), 0);
cef_string_list_value(list, i, @str);
suggestions.Add(CefStringClearAndGet(str));
end;
finally
cef_string_list_free(list);
end;
end;
function TCefContextMenuParamsRef.GetEditStateFlags: TCefContextMenuEditStateFlags;
begin
Byte(Result) := PCefContextMenuParams(FData).get_edit_state_flags(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.GetFrameCharset: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_frame_charset(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetFrameUrl: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_frame_url(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetLinkUrl: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_link_url(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetMediaStateFlags: TCefContextMenuMediaStateFlags;
begin
Word(Result) := PCefContextMenuParams(FData).get_media_state_flags(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.GetMediaType: TCefContextMenuMediaType;
begin
Result := PCefContextMenuParams(FData).get_media_type(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.GetMisspelledWord: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_misspelled_word(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetTitleText: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_title_text(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetPageUrl: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_page_url(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetSelectionText: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_selection_text(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetSourceUrl: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_source_url(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetTypeFlags: TCefContextMenuTypeFlags;
begin
Byte(Result) := PCefContextMenuParams(FData).get_type_flags(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.GetUnfilteredLinkUrl: ustring;
begin
Result := CefStringFreeAndGet(PCefContextMenuParams(FData).get_unfiltered_link_url(PCefContextMenuParams(FData)));
end;
function TCefContextMenuParamsRef.GetXCoord: Integer;
begin
Result := PCefContextMenuParams(FData).get_xcoord(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.GetYCoord: Integer;
begin
Result := PCefContextMenuParams(FData).get_ycoord(PCefContextMenuParams(FData));
end;
function TCefContextMenuParamsRef.IsCustomMenu: Boolean;
begin
Result := PCefContextMenuParams(FData).is_custom_menu(PCefContextMenuParams(FData)) <> 0;
end;
function TCefContextMenuParamsRef.IsEditable: Boolean;
begin
Result := PCefContextMenuParams(FData).is_editable(PCefContextMenuParams(FData)) <> 0;
end;
function TCefContextMenuParamsRef.IsPepperMenu: Boolean;
begin
Result := PCefContextMenuParams(FData).is_pepper_menu(PCefContextMenuParams(FData)) <> 0;
end;
function TCefContextMenuParamsRef.IsSpellCheckEnabled: Boolean;
begin
Result := PCefContextMenuParams(FData).is_spell_check_enabled(PCefContextMenuParams(FData)) <> 0;
end;
function TCefContextMenuParamsRef.HasImageContents: Boolean;
begin
Result := PCefContextMenuParams(FData).has_image_contents(PCefContextMenuParams(FData)) <> 0;
end;
class function TCefContextMenuParamsRef.UnWrap(
data: Pointer): ICefContextMenuParams;
begin
if data <> nil then
Result := Create(data) as ICefContextMenuParams else
Result := nil;
end;
end.