CEF4Delphi/source/uCEFResourceBundle.pas
salvadordf ca8bc9dff4 Added cef4delphi.chm help file
Added the PDS file to extract the HTML Help files using PasDoc
Added more XML documentation
Fixed some XML errors.
Removed the license copy from the pas units.
Updated the LICENSE.md file
2023-08-09 19:38:57 +02:00

67 lines
2.1 KiB
ObjectPascal

unit uCEFResourceBundle;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
{$I cef.inc}
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
{$MINENUMSIZE 4}
interface
uses
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
type
TCefResourceBundleRef = class(TCefBaseRefCountedRef, ICefResourceBundle)
protected
function GetLocalizedString(stringId: Integer): ustring;
function GetDataResource(resourceId: Integer): ICefBinaryValue;
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor): ICefBinaryValue;
public
class function UnWrap(data: Pointer): ICefResourceBundle;
class function Global: ICefResourceBundle;
end;
implementation
uses
uCEFMiscFunctions, uCEFLibFunctions, uCEFBinaryValue;
function TCefResourceBundleRef.GetDataResource(resourceId: Integer): ICefBinaryValue;
begin
Result := TCefBinaryValueRef.UnWrap(PCefResourceBundle(FData)^.get_data_resource(PCefResourceBundle(FData),
resourceId));
end;
function TCefResourceBundleRef.GetDataResourceForScale(resourceId : Integer;
scaleFactor : TCefScaleFactor): ICefBinaryValue;
begin
Result := TCefBinaryValueRef.UnWrap(PCefResourceBundle(FData)^.get_data_resource_for_scale(PCefResourceBundle(FData),
resourceId,
scaleFactor));
end;
function TCefResourceBundleRef.GetLocalizedString(stringId: Integer): ustring;
begin
Result := CefStringFreeAndGet(PCefResourceBundle(FData)^.get_localized_string(PCefResourceBundle(FData), stringId));
end;
class function TCefResourceBundleRef.Global: ICefResourceBundle;
begin
Result := UnWrap(cef_resource_bundle_get_global());
end;
class function TCefResourceBundleRef.UnWrap(data: Pointer): ICefResourceBundle;
begin
if (data <> nil) then
Result := Create(data) as ICefResourceBundle
else
Result := nil;
end;
end.