2017-01-27 16:37:51 +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
|
|
|
|
|
//
|
2019-01-08 19:15:25 +01:00
|
|
|
|
// Copyright <20> 2019 Salvador Diaz Fau. All rights reserved.
|
2017-01-27 16:37:51 +01:00
|
|
|
|
//
|
|
|
|
|
// ************************************************************************
|
|
|
|
|
// ************ 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 uCEFMenuModel;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
{$IFDEF FPC}
|
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
2018-11-22 15:02:21 +01:00
|
|
|
|
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
|
|
|
|
{$MINENUMSIZE 4}
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
|
{$I cef.inc}
|
|
|
|
|
|
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;
|
|
|
|
|
function GetCount: Integer;
|
|
|
|
|
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;
|
|
|
|
|
function InsertSeparatorAt(index: Integer): Boolean;
|
|
|
|
|
function InsertItemAt(index, commandId: Integer; const text: ustring): Boolean;
|
|
|
|
|
function InsertCheckItemAt(index, commandId: Integer; const text: ustring): Boolean;
|
|
|
|
|
function InsertRadioItemAt(index, commandId: Integer; const text: ustring; groupId: Integer): Boolean;
|
|
|
|
|
function InsertSubMenuAt(index, commandId: Integer; const text: ustring): ICefMenuModel;
|
|
|
|
|
function Remove(commandId: Integer): Boolean;
|
|
|
|
|
function RemoveAt(index: Integer): Boolean;
|
|
|
|
|
function GetIndexOf(commandId: Integer): Integer;
|
|
|
|
|
function GetCommandIdAt(index: Integer): Integer;
|
|
|
|
|
function SetCommandIdAt(index, commandId: Integer): Boolean;
|
|
|
|
|
function GetLabel(commandId: Integer): ustring;
|
|
|
|
|
function GetLabelAt(index: Integer): ustring;
|
|
|
|
|
function SetLabel(commandId: Integer; const text: ustring): Boolean;
|
|
|
|
|
function SetLabelAt(index: Integer; const text: ustring): Boolean;
|
|
|
|
|
function GetType(commandId: Integer): TCefMenuItemType;
|
|
|
|
|
function GetTypeAt(index: Integer): TCefMenuItemType;
|
|
|
|
|
function GetGroupId(commandId: Integer): Integer;
|
|
|
|
|
function GetGroupIdAt(index: Integer): Integer;
|
|
|
|
|
function SetGroupId(commandId, groupId: Integer): Boolean;
|
|
|
|
|
function SetGroupIdAt(index, groupId: Integer): Boolean;
|
|
|
|
|
function GetSubMenu(commandId: Integer): ICefMenuModel;
|
|
|
|
|
function GetSubMenuAt(index: Integer): ICefMenuModel;
|
|
|
|
|
function IsVisible(commandId: Integer): Boolean;
|
|
|
|
|
function isVisibleAt(index: Integer): Boolean;
|
|
|
|
|
function SetVisible(commandId: Integer; visible: Boolean): Boolean;
|
|
|
|
|
function SetVisibleAt(index: Integer; visible: Boolean): Boolean;
|
|
|
|
|
function IsEnabled(commandId: Integer): Boolean;
|
|
|
|
|
function IsEnabledAt(index: Integer): Boolean;
|
|
|
|
|
function SetEnabled(commandId: Integer; enabled: Boolean): Boolean;
|
|
|
|
|
function SetEnabledAt(index: Integer; enabled: Boolean): Boolean;
|
|
|
|
|
function IsChecked(commandId: Integer): Boolean;
|
|
|
|
|
function IsCheckedAt(index: Integer): Boolean;
|
|
|
|
|
function setChecked(commandId: Integer; checked: Boolean): Boolean;
|
|
|
|
|
function setCheckedAt(index: Integer; checked: Boolean): Boolean;
|
|
|
|
|
function HasAccelerator(commandId: Integer): Boolean;
|
|
|
|
|
function HasAcceleratorAt(index: Integer): Boolean;
|
|
|
|
|
function SetAccelerator(commandId, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
|
|
|
|
function SetAcceleratorAt(index, keyCode: Integer; shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
|
|
|
|
function RemoveAccelerator(commandId: Integer): Boolean;
|
|
|
|
|
function RemoveAcceleratorAt(index: Integer): Boolean;
|
|
|
|
|
function GetAccelerator(commandId: Integer; out keyCode: Integer; out shiftPressed, ctrlPressed, altPressed: Boolean): Boolean;
|
|
|
|
|
function GetAcceleratorAt(index: Integer; 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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.GetAcceleratorAt(index: 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_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;
|
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
|
function TCefMenuModelRef.GetCommandIdAt(index: Integer): Integer;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetCount: Integer;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetGroupIdAt(index: Integer): Integer;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetLabelAt(index: Integer): ustring;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetSubMenuAt(index: Integer): ICefMenuModel;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.GetTypeAt(index: Integer): TCefMenuItemType;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.HasAcceleratorAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.InsertCheckItemAt(index, 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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.InsertItemAt(index, 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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.InsertRadioItemAt(index, 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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.InsertSeparatorAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.InsertSubMenuAt(index, 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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.IsCheckedAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.IsEnabledAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.isVisibleAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.RemoveAcceleratorAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.RemoveAt(index: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.SetAcceleratorAt(index, 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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.setCheckedAt(index: 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_at(PCefMenuModel(FData), index, Ord(checked)) <> 0;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetCommandIdAt(index, commandId: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.SetEnabledAt(index: 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_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;
|
|
|
|
|
|
|
|
|
|
function TCefMenuModelRef.SetGroupIdAt(index, groupId: Integer): Boolean;
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.SetLabelAt(index: 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_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;
|
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
|
function TCefMenuModelRef.SetVisibleAt(index: 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_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.
|