2017-01-27 16:37:51 +01:00
|
|
|
unit uCEFMenuModel;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 19:09:42 +01:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
TCefMenuModelRef = class(TCefBaseRefCountedRef, ICefMenuModel)
|
2017-01-27 16:37:51 +01:00
|
|
|
protected
|
2017-03-16 19:09:42 +01:00
|
|
|
function IsSubMenu: Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function Clear: Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetCount: NativeUInt;
|
2017-01-27 16:37:51 +01:00
|
|
|
function AddSeparator: Boolean;
|
|
|
|
function AddItem(commandId: Integer; const text: ustring): Boolean;
|
|
|
|
function AddCheckItem(commandId: Integer; const text: ustring): Boolean;
|
|
|
|
function AddRadioItem(commandId: Integer; const text: ustring; groupId: Integer): Boolean;
|
|
|
|
function AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel;
|
2022-09-04 19:18:07 +02:00
|
|
|
function InsertSeparatorAt(index: NativeUInt): Boolean;
|
|
|
|
function InsertItemAt(index: NativeUInt; commandId: Integer; const text: ustring): Boolean;
|
|
|
|
function InsertCheckItemAt(index: NativeUInt; commandId: Integer; const text: ustring): Boolean;
|
|
|
|
function InsertRadioItemAt(index: NativeUInt; commandId: Integer; const text: ustring; groupId: Integer): Boolean;
|
|
|
|
function InsertSubMenuAt(index: NativeUInt; commandId: Integer; const text: ustring): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
function Remove(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function RemoveAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetIndexOf(commandId: Integer): Integer;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetCommandIdAt(index: NativeUInt): Integer;
|
|
|
|
function SetCommandIdAt(index: NativeUInt; commandId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetLabel(commandId: Integer): ustring;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetLabelAt(index: NativeUInt): ustring;
|
2017-01-27 16:37:51 +01:00
|
|
|
function SetLabel(commandId: Integer; const text: ustring): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function SetLabelAt(index: NativeUInt; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetType(commandId: Integer): TCefMenuItemType;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetTypeAt(index: NativeUInt): TCefMenuItemType;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetGroupId(commandId: Integer): Integer;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetGroupIdAt(index: NativeUInt): Integer;
|
2017-01-27 16:37:51 +01:00
|
|
|
function SetGroupId(commandId, groupId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function SetGroupIdAt(index: NativeUInt; groupId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetSubMenu(commandId: Integer): ICefMenuModel;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetSubMenuAt(index: NativeUInt): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
function IsVisible(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function isVisibleAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function SetVisible(commandId: Integer; visible: Boolean): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function SetVisibleAt(index: NativeUInt; visible: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function IsEnabled(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function IsEnabledAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function SetEnabled(commandId: Integer; enabled: Boolean): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function SetEnabledAt(index: NativeUInt; enabled: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function IsChecked(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function IsCheckedAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function setChecked(commandId: Integer; checked: Boolean): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function setCheckedAt(index: NativeUInt; checked: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function HasAccelerator(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function HasAcceleratorAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function SetAcceleratorAt(index: NativeUInt; keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function RemoveAccelerator(commandId: Integer): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function RemoveAcceleratorAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
function GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2022-09-04 19:18:07 +02:00
|
|
|
function GetAcceleratorAt(index: NativeUInt; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-03-16 19:09:42 +01:00
|
|
|
function SetColor(commandId: Integer; colorType: TCefMenuColorType; color: TCefColor): Boolean;
|
|
|
|
function SetColorAt(index: Integer; colorType: TCefMenuColorType; color: TCefColor): Boolean;
|
|
|
|
function GetColor(commandId: Integer; colorType: TCefMenuColorType; out color: TCefColor): Boolean;
|
|
|
|
function GetColorAt(index: Integer; colorType: TCefMenuColorType; out color: TCefColor): Boolean;
|
|
|
|
function SetFontList(commandId: Integer; const fontList: ustring): Boolean;
|
|
|
|
function SetFontListAt(index: Integer; const fontList: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefMenuModel;
|
|
|
|
class function New(const delegate: ICefMenuModelDelegate): ICefMenuModel;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions;
|
|
|
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.AddCheckItem(commandId: Integer; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.add_check_item(PCefMenuModel(FData), commandId, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.AddItem(commandId: Integer; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.add_item(PCefMenuModel(FData), commandId, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.AddRadioItem(commandId: Integer; const text: ustring; groupId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.add_radio_item(PCefMenuModel(FData), commandId, @TempText, groupId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.AddSeparator: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.add_separator(PCefMenuModel(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.AddSubMenu(commandId: Integer; const text: ustring): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData)^.add_sub_menu(PCefMenuModel(FData), commandId, @TempText));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2017-03-16 19:09:42 +01:00
|
|
|
function TCefMenuModelRef.IsSubMenu: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_sub_menu(PCefMenuModel(FData)) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
function TCefMenuModelRef.Clear: Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.clear(PCefMenuModel(FData)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempShift, TempCtrl, TempAlt : Integer;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_accelerator(PCefMenuModel(FData), commandId, @keyCode, @TempShift, @TempCtrl, @TempAlt) <> 0;
|
|
|
|
shiftPressed := TempShift <> 0;
|
|
|
|
ctrlPressed := TempCtrl <> 0;
|
|
|
|
altPressed := TempAlt <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetAcceleratorAt(index: NativeUInt; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempShift, TempCtrl, TempAlt : Integer;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_accelerator_at(PCefMenuModel(FData), index, @keyCode, @TempShift, @TempCtrl, @TempAlt) <> 0;
|
|
|
|
shiftPressed := TempShift <> 0;
|
|
|
|
ctrlPressed := TempCtrl <> 0;
|
|
|
|
altPressed := TempAlt <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2017-03-16 19:09:42 +01:00
|
|
|
function TCefMenuModelRef.SetColor(commandId: Integer; colorType: TCefMenuColorType; color: TCefColor): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_color(PCefMenuModel(FData), commandId, colorType, color) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetColorAt(index: Integer; colorType: TCefMenuColorType; color: TCefColor): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_color_at(PCefMenuModel(FData), index, colorType, color) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetColor(commandId: Integer; colorType: TCefMenuColorType; out color: TCefColor): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_color(PCefMenuModel(FData), commandId, colorType, @color) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetColorAt(index: Integer; colorType: TCefMenuColorType; out color: TCefColor): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_color_at(PCefMenuModel(FData), index, colorType, @color) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetFontList(commandId: Integer; const fontList: ustring): Boolean;
|
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempList : TCefString;
|
2017-03-16 19:09:42 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempList := CefString(fontList);
|
|
|
|
Result := PCefMenuModel(FData)^.set_font_list(PCefMenuModel(FData), commandId, @TempList) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetFontListAt(index: Integer; const fontList: ustring): Boolean;
|
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempList : TCefString;
|
2017-03-16 19:09:42 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempList := CefString(fontList);
|
|
|
|
Result := PCefMenuModel(FData)^.set_font_list_at(PCefMenuModel(FData), index, @TempList) <> 0;
|
2017-03-16 19:09:42 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetCommandIdAt(index: NativeUInt): Integer;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_command_id_at(PCefMenuModel(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetCount: NativeUInt;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_count(PCefMenuModel(FData));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetGroupId(commandId: Integer): Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_group_id(PCefMenuModel(FData), commandId);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetGroupIdAt(index: NativeUInt): Integer;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_group_id(PCefMenuModel(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetIndexOf(commandId: Integer): Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_index_of(PCefMenuModel(FData), commandId);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetLabel(commandId: Integer): ustring;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefMenuModel(FData)^.get_label(PCefMenuModel(FData), commandId));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetLabelAt(index: NativeUInt): ustring;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := CefStringFreeAndGet(PCefMenuModel(FData)^.get_label_at(PCefMenuModel(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetSubMenu(commandId: Integer): ICefMenuModel;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData)^.get_sub_menu(PCefMenuModel(FData), commandId));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetSubMenuAt(index: NativeUInt): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData)^.get_sub_menu_at(PCefMenuModel(FData), index));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetType(commandId: Integer): TCefMenuItemType;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_type(PCefMenuModel(FData), commandId);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.GetTypeAt(index: NativeUInt): TCefMenuItemType;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.get_type_at(PCefMenuModel(FData), index);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.HasAccelerator(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.has_accelerator(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.HasAcceleratorAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.has_accelerator_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.InsertCheckItemAt(index: NativeUInt; commandId: Integer; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.insert_check_item_at(PCefMenuModel(FData), index, commandId, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.InsertItemAt(index: NativeUInt; commandId: Integer; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.insert_item_at(PCefMenuModel(FData), index, commandId, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.InsertRadioItemAt(index: NativeUInt; commandId: Integer; const text: ustring; groupId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.insert_radio_item_at(PCefMenuModel(FData), index, commandId, @TempText, groupId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.InsertSeparatorAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.insert_separator_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.InsertSubMenuAt(index: NativeUInt; commandId: Integer; const text: ustring): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := TCefMenuModelRef.UnWrap(PCefMenuModel(FData)^.insert_sub_menu_at( PCefMenuModel(FData), index, commandId, @TempText));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.IsChecked(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_checked(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.IsCheckedAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_checked_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.IsEnabled(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_enabled(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.IsEnabledAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_enabled_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.IsVisible(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_visible(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.isVisibleAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.is_visible_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
class function TCefMenuModelRef.New(const delegate: ICefMenuModelDelegate): ICefMenuModel;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
|
|
|
Result := UnWrap(cef_menu_model_create(CefGetData(delegate)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.Remove(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.remove(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.RemoveAccelerator(commandId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.remove_accelerator(PCefMenuModel(FData), commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.RemoveAcceleratorAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.remove_accelerator_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.RemoveAt(index: NativeUInt): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.remove_at(PCefMenuModel(FData), index) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_accelerator(PCefMenuModel(FData), commandId, keyCode,
|
|
|
|
Ord(shiftPressed), Ord(ctrlPressed), Ord(altPressed)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetAcceleratorAt(index: NativeUInt; keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_accelerator_at(PCefMenuModel(FData), index, keyCode,
|
|
|
|
Ord(shiftPressed), Ord(ctrlPressed), Ord(altPressed)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.setChecked(commandId: Integer; checked: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_checked(PCefMenuModel(FData), commandId, Ord(checked)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.setCheckedAt(index: NativeUInt; checked: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_checked_at(PCefMenuModel(FData), index, Ord(checked)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetCommandIdAt(index: NativeUInt; commandId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_command_id_at(PCefMenuModel(FData), index, commandId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.SetEnabled(commandId: Integer; enabled: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_enabled(PCefMenuModel(FData), commandId, Ord(enabled)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetEnabledAt(index: NativeUInt; enabled: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_enabled_at(PCefMenuModel(FData), index, Ord(enabled)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetGroupId(commandId, groupId: Integer): Boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_group_id(PCefMenuModel(FData), commandId, groupId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetGroupIdAt(index: NativeUInt; groupId: Integer): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_group_id_at(PCefMenuModel(FData), index, groupId) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.SetLabel(commandId: Integer; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.set_label(PCefMenuModel(FData), commandId, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetLabelAt(index: NativeUInt; const text: ustring): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
TempText := CefString(text);
|
|
|
|
Result := PCefMenuModel(FData)^.set_label_at(PCefMenuModel(FData), index, @TempText) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
function TCefMenuModelRef.SetVisible(commandId: Integer; visible: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_visible(PCefMenuModel(FData), commandId, Ord(visible)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2022-09-04 19:18:07 +02:00
|
|
|
function TCefMenuModelRef.SetVisibleAt(index: NativeUInt; visible: Boolean): Boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefMenuModel(FData)^.set_visible_at(PCefMenuModel(FData), index, Ord(visible)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefMenuModelRef.UnWrap(data: Pointer): ICefMenuModel;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefMenuModel
|
|
|
|
else
|
2017-01-27 16:37:51 +01:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|